/** test A = USVt */ @Test public void testAEqualUSVt() { checkAEqualUSVt(new DenseMatrix(testSquare)); checkAEqualUSVt(new DenseMatrix(testNonSquare)); checkAEqualUSVt(new DenseMatrix(testNonSquare).transpose()); }
/** test that U is orthogonal */ @Test public void testUOrthogonal() { checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testSquare)).getU()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare)).getU()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare).transpose()).getU()); }
/** test that V is orthogonal */ @Test public void testVOrthogonal() { checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testSquare)).getV()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare)).getV()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare).transpose()).getV()); }
/** test A = USVt */ @Test public void testAEqualUSVt() { checkAEqualUSVt(new DenseMatrix(testSquare)); checkAEqualUSVt(new DenseMatrix(testNonSquare)); checkAEqualUSVt(new DenseMatrix(testNonSquare).transpose()); }
/** test that U is orthogonal */ @Test public void testUOrthogonal() { checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testSquare)).getU()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare)).getU()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare).transpose()).getU()); }
/** test that V is orthogonal */ @Test public void testVOrthogonal() { checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testSquare)).getV()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare)).getV()); checkOrthogonal(new SingularValueDecomposition(new DenseMatrix(testNonSquare).transpose()).getV()); }
@Test public void testGivensQR() throws Exception { // DenseMatrix m = new DenseMatrix(dims<<2,dims); Matrix m = new DenseMatrix(3, 3); m.assign(new DoubleFunction() { private final Random rnd = RandomUtils.getRandom(); @Override public double apply(double arg0) { return rnd.nextDouble() * SCALE; } }); m.setQuick(0, 0, 1); m.setQuick(0, 1, 2); m.setQuick(0, 2, 3); m.setQuick(1, 0, 4); m.setQuick(1, 1, 5); m.setQuick(1, 2, 6); m.setQuick(2, 0, 7); m.setQuick(2, 1, 8); m.setQuick(2, 2, 9); GivensThinSolver qrSolver = new GivensThinSolver(m.rowSize(), m.columnSize()); qrSolver.solve(m); Matrix qtm = new DenseMatrix(qrSolver.getThinQtTilde()); assertOrthonormality(qtm.transpose(), false, SVD_EPSILON); Matrix aClone = new DenseMatrix(qrSolver.getThinQtTilde()).transpose() .times(qrSolver.getRTilde()); System.out.println("aclone : " + aClone); }