Ejemplo n.º 1
0
  @Test
  public void testQR() {

    AMatrix a = Matrixx.createRandomMatrix(5, 4);
    AMatrix[] ms = QR.decompose(a);

    AMatrix q = ms[0];
    AMatrix r = ms[1];

    // we are testing that A = QR
    assertTrue(q.innerProduct(r).epsilonEquals(a));

    // check properties of Q - should be orthogonal
    assertTrue(q.hasOrthonormalColumns());
    // assertTrue(q.isSquare()); // TODO: should be square??

    // check properties of R - should be upper triangular
    assertTrue(r.isUpperTriangular());
  }