}
/** test matrices values */
public void testMatricesValues1() {
SingularValueDecomposition svd =
new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare));
RealMatrix uRef = MatrixUtils.createRealMatrix(new double[][] {
{ 3.0 / 5.0, -4.0 / 5.0 },
{ 4.0 / 5.0, 3.0 / 5.0 }
});
RealMatrix sRef = MatrixUtils.createRealMatrix(new double[][] {
{ 3.0, 0.0 },
{ 0.0, 1.0 }
});
RealMatrix vRef = MatrixUtils.createRealMatrix(new double[][] {
{ 4.0 / 5.0, 3.0 / 5.0 },
{ 3.0 / 5.0, -4.0 / 5.0 }
});
// check values against known references
RealMatrix u = svd.getU();
assertEquals(0, u.subtract(uRef).getNorm(), normTolerance);
RealMatrix s = svd.getS();
assertEquals(0, s.subtract(sRef).getNorm(), normTolerance);
RealMatrix v = svd.getV();
assertEquals(0, v.subtract(vRef).getNorm(), normTolerance);
// check the same cached instance is returned the second time
assertTrue(u == svd.getU());
assertTrue(s == svd.getS());
assertTrue(v == svd.getV());
}