Package mikera.matrixx

Examples of mikera.matrixx.Matrix


      }
  }

  @Test
  public void zeroMatrix() {
      Matrix A = Matrix.create(3,3);

      LUPResult result =AltLU.decompose(A);
      assertNotNull(result);

   // not singular
      assertEquals(0.0, result.computeDeterminant(), 1e-8);

      AMatrix L = result.getL();
      AMatrix U = result.getU();

//      CommonOps.mult(L,U,A_found);
      Matrix A_found = Multiplications.multiply(L, U);     

      assertFalse(A_found.hasUncountable());
      assertTrue(A_found.epsilonEquals(A,1e-8));
  }
View Full Code Here


      assertTrue(A_found.epsilonEquals(A,1e-8));
  }

  @Test
  public void testSingular(){
      Matrix A = Matrix.create(new double[][] {{1, 2, 3},{ 2, 4, 6},{ 4, 4, 0}});

      LUPResult result = AltLU.decompose(A);
      assertNotNull(result);
   // singular
      assertEquals(0.0, result.computeDeterminant(), 1e-10);
View Full Code Here

    public void testRandomMatrices() {

        for( int i = 0; i < 10; i++ ) {
            for( int N = 2;  N <= 10; N++ ) {
                for( int tall = 0; tall <= 2; tall++ ) {
                    Matrix A = Matrix.createRandom(N+tall,N);
                   
                    IBidiagonalResult ans = BidiagonalRow.decompose(A);
                    assertNotNull(ans);
                    checkGeneric(A, ans);
                   
                    IBidiagonalResult ansCompact = BidiagonalRow.decompose(A, true);
                    assertNotNull(ansCompact);
                    checkGenericCompact(A, ansCompact);
                }
                for( int wide = 1; wide <= 2; wide++ ) {
                    Matrix A = Matrix.createRandom(N,N+wide);
                   
                    IBidiagonalResult ans = BidiagonalRow.decompose(A);
                    assertNotNull(ans);
                    checkGeneric(A, ans);
                   
View Full Code Here

        }
    }

    @Test
    public void testIdentity() {
        Matrix A = Matrix.createIdentity(5);

        IBidiagonalResult ans = BidiagonalRow.decompose(A);
        assertNotNull(ans);
        checkGeneric(A, ans);
       
View Full Code Here

       
    }

    @Test
    public void testZero() {
        Matrix A = Matrix.create(5,5);

        IBidiagonalResult ans = BidiagonalRow.decompose(A);
        assertNotNull(ans);
        checkGeneric(A, ans);
       
View Full Code Here

     * Checks to see if the decomposition will reconstruct the original input matrix
     */
    protected void checkGeneric(Matrix a,
                                IBidiagonalResult ans) {
        // check the full version
      Matrix U = ans.getU().toMatrix();
      Matrix B = ans.getB().toMatrix();
        Matrix V = ans.getV().toMatrix();
       
        Matrix foundA = Multiplications.multiply(U, Multiplications.multiply(B, V.getTransposeCopy().toMatrix()));

        assertTrue(a.epsilonEquals(foundA, 1e-8));
    }
View Full Code Here

        assertTrue(a.epsilonEquals(foundA, 1e-8));
    }
   
    protected void checkGenericCompact(Matrix a, IBidiagonalResult ans) {
        // now test compact
        Matrix U = ans.getU().toMatrix();
        Matrix B = ans.getB().toMatrix();
        Matrix V = ans.getV().toMatrix();

//        U.print();
//        V.print();
//        B.print();

        Matrix foundA = Multiplications.multiply(U, Multiplications.multiply(B, V.getTransposeCopy().toMatrix()));

        assertTrue(a.epsilonEquals(foundA,1e-8));
    }
View Full Code Here

      assertEquals(0.0, result.computeDeterminant(), 1e-10);
  }

  @Test
  public void testNearlySingular(){
      Matrix A = Matrix.create(new double[][] {{1, 2, 3},{ 2, 4, 6.1},{ 4, 4, 0}});

      LUPResult result = AltLU.decompose(A);
      assertNotNull(result);
   // singular
      assertNotEquals(0.0, result.computeDeterminant(), 1e-10);
View Full Code Here

      assertNotEquals(0.0, result.computeDeterminant(), 1e-10);
  }

  @Test
  public void testFat() {
      Matrix A = Matrix.create(new double[][] {{1, 2, 3},{2, 4, 6.1}});

      LUPResult result = AltLU.decompose(A);
      assertNotNull(result);

      AMatrix L = result.getL();
      AMatrix U = result.getU();
      AMatrix P = result.getP();

//      DenseMatrix64F A_found = P.mult(L).mult(U).getMatrix();
      Matrix A_found = Multiplications.multiply(P, Multiplications.multiply(L, U));

      assertTrue(A_found.epsilonEquals(A,1e-8));
  }
View Full Code Here

      assertTrue(A_found.epsilonEquals(A,1e-8));
  }

  @Test
  public void testTall() {
      Matrix A = Matrix.create(new double[][] {{1, 2}, {3, 2}, {4, 6.1}});

      LUPResult result = AltLU.decompose(A);
      assertNotNull(result);

      AMatrix L = result.getL();
      AMatrix U = result.getU();
      AMatrix P = result.getP();

//      DenseMatrix64F A_found = P.transpose().mult(L).mult(U).getMatrix();
      Matrix A_found = Multiplications.multiply(P.getTranspose(), Multiplications.multiply(L, U));

      assertTrue(A_found.epsilonEquals(A,1e-8));
  }
View Full Code Here

TOP

Related Classes of mikera.matrixx.Matrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.