package Misc; import java.util.Scanner; /* * Wikipedia link : https://en.wikipedia.org/wiki/Invertible_matrix * * Here we use gauss elimination method to find the inverse of a given matrix. * To understand gauss elimination method to find inverse of a matrix: https://www.sangakoo.com/en/unit/inverse-matrix-method-of-gaussian-elimination * * We can also find the inverse of a matrix */ public class InverseOfMatrix { public static void main(String argv[]) { Scanner input = new Scanner(System.in); System.out.println("Enter the matrix size (Square matrix only): "); int n = input.nextInt(); double a[][]= new double[n][n]; System.out.println("Enter the elements of matrix: "); for(int i=0; i=0; --j) { x[j][i] = b[index[j]][i]; for (int k=j+1; k c1) c1 = c0; } c[i] = c1; } // Search the pivoting element from each column int k = 0; for (int j=0; j pi1) { pi1 = pi0; k = i; } } // Interchange rows according to the pivoting order int itmp = index[j]; index[j] = index[k]; index[k] = itmp; for (int i=j+1; i