// inverse.java find inverse of |A| into |AI|, |A|*|AI|=|I| // |A| unmodified for possible reuse or testing public strictfp class inverse { public inverse(final double A[][], double AI[][]) { int n = A.length; int row[] = new int[n]; int col[] = new int[n]; double temp[] = new double[n]; int hold , I_pivot , J_pivot; double pivot, abs_pivot; if(A[0].length!=n || AI.length!=n || AI[0].length!=n) { System.out.println("Error in inverse, inconsistent array sizes."); } for(int i=0; i abs_pivot) { I_pivot = i ; J_pivot = j ; pivot = AI[row[i]][col[j]] ; } } } if(Math.abs(pivot) < 1.0E-15) { System.out.println("Matrix is singular !"); return; } hold = row[k]; row[k]= row[I_pivot]; row[I_pivot] = hold ; hold = col[k]; col[k]= col[J_pivot]; col[J_pivot] = hold ; // reduce about pivot AI[row[k]][col[k]] = 1.0 / pivot ; for(int j=0; j