/** * Helper method converts P into a pivot matrix that can pre-multiply * L*U. * * @return an identity matrix with the appropriate row swaps to * re-generate the original matrix A when P * L * U is calculated. */ public Matrix getPivotMatrix() { SparseMatrix pivot = new SparseMatrix(L.getNumRows(), L.getNumRows()); pivot.identity(); for (int i = 0; i < P.size(); ++i) { if (P.get(i) != i) { Vector tmp = pivot.getRow(i); pivot.setRow(i, pivot.getRow(P.get(i))); pivot.setRow(P.get(i), tmp); } } return pivot; }
/** * Helper method converts P into a pivot matrix that can pre-multiply * L*U. * * @return an identity matrix with the appropriate row swaps to * re-generate the original matrix A when P * L * U is calculated. */ public Matrix getPivotMatrix() { SparseMatrix pivot = new SparseMatrix(L.getNumRows(), L.getNumRows()); pivot.identity(); for (int i = 0; i < P.size(); ++i) { if (P.get(i) != i) { Vector tmp = pivot.getRow(i); pivot.setRow(i, pivot.getRow(P.get(i))); pivot.setRow(P.get(i), tmp); } } return pivot; }
/** * Helper method converts P into a pivot matrix that can pre-multiply * L*U. * * @return an identity matrix with the appropriate row swaps to * re-generate the original matrix A when P * L * U is calculated. */ public Matrix getPivotMatrix() { SparseMatrix pivot = new SparseMatrix(L.getNumRows(), L.getNumRows()); pivot.identity(); for (int i = 0; i < P.size(); ++i) { if (P.get(i) != i) { Vector tmp = pivot.getRow(i); pivot.setRow(i, pivot.getRow(P.get(i))); pivot.setRow(P.get(i), tmp); } } return pivot; }