// Permutation matrix:
// 1.000 0.000 0.000
// 0.000 0.000 1.000
// 0.000 1.000 0.000
DenseLU dlu = DenseLU.factorize(m);
// check that m = L . U
Matrix lTimesU = new DenseMatrix(3, 3);
dlu.getL().mult(dlu.getU(), lTimesU);
int[] pivots = dlu.getPivots();
for (MatrixEntry entry : m) {
int row = entry.row();
int col = entry.column();
double val = entry.get();
double valLU = pivots[row] * lTimesU.get(row, col);
assert val == valLU : "Row " + row + ", Col " + col
+ " wasn't equal! " + val + " " + valLU;
}
Matrix lu = dlu.getLU();
// m == lu
for (MatrixEntry entry : m) {
int row = entry.row();
int col = entry.column();
double val = entry.get();