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());
  }
Ejemplo n.º 2
0
  @Test
  public void testSVD() {

    AMatrix a = Matrixx.createRandomMatrix(5, 3);
    AMatrix[] ms = ThinSVD.decompose(a);

    AMatrix u = ms[0];
    AMatrix s = ms[1];
    AMatrix v = ms[2];

    // we are testing that A = USV*
    AMatrix usvt = u.innerProduct(s.innerProduct(v.getTranspose()));
    // assertEquals(a,usvt);
    assertTrue(usvt.epsilonEquals(a));

    assertTrue(v.isOrthogonal());
    assertTrue(s.isRectangularDiagonal());
    assertTrue(u.hasOrthonormalColumns());
  }
Ejemplo n.º 3
0
 public void propagateGround() {
   DoubleMatrix _densitynext = DoubleMatrix.zeros(trueStatesGround.getRows(), 1);
   trueStatesGroundPrior = trueStatesGround.dup();
   _densitynext = AMatrix.mmul(trueStatesGroundPrior);
   trueStatesGround = _densitynext.dup();
 }