@Test
public void testDecompose() {
double[][] dataA = { { 0, 3, 1 }, { 0, 4, -2 }, { 2, 1, 1 } };
Matrix A = Matrix.create(dataA);
HouseholderQR alg = new HouseholderQR(false);
IQRResult result = alg.decompose(A);
AMatrix Q = result.getQ();
AMatrix R = result.getR();
Matrix expectQ = Matrix.create(new double[][] { { 0, -0.6, 0.8 },
{ 0, -0.8, -0.6 }, { -1, 0, 0 } });
Matrix expectR = Matrix.create(new double[][] { { -2, -1, -1 },
{ 0, -5, 1 }, { 0, 0, 2 } });
assertEquals(Q, expectQ);
assertEquals(R, expectR);
A = Matrix.create(dataA);
alg = new HouseholderQR(true);
result = alg.decompose(A);
Q = result.getQ();
R = result.getR();
assertEquals(Q, expectQ);
assertEquals(R, expectR);