}
/** test matrices values */
public void testMatricesValues2() {
LUDecomposition lu =
new LUDecompositionImpl(MatrixUtils.createRealMatrix(luData));
RealMatrix lRef = MatrixUtils.createRealMatrix(new double[][] {
{ 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 },
{ 1.0 / 3.0, 0.0, 1.0 }
});
RealMatrix uRef = MatrixUtils.createRealMatrix(new double[][] {
{ 6.0, 9.0, 8.0 },
{ 0.0, 5.0, 7.0 },
{ 0.0, 0.0, 1.0 / 3.0 }
});
RealMatrix pRef = MatrixUtils.createRealMatrix(new double[][] {
{ 0.0, 0.0, 1.0 },
{ 0.0, 1.0, 0.0 },
{ 1.0, 0.0, 0.0 }
});
int[] pivotRef = { 2, 1, 0 };
// check values against known references
RealMatrix l = lu.getL();
assertEquals(0, l.subtract(lRef).getNorm(), 1.0e-13);
RealMatrix u = lu.getU();
assertEquals(0, u.subtract(uRef).getNorm(), 1.0e-13);
RealMatrix p = lu.getP();
assertEquals(0, p.subtract(pRef).getNorm(), 1.0e-13);
int[] pivot = lu.getPivot();
for (int i = 0; i < pivotRef.length; ++i) {
assertEquals(pivotRef[i], pivot[i]);
}
// check the same cached instance is returned the second time
assertTrue(l == lu.getL());
assertTrue(u == lu.getU());
assertTrue(p == lu.getP());
}