Examples of AMatrix


Examples of mikera.matrixx.AMatrix

   
    assertTrue(mmt.isSameShape(m));
  }
 
  @Test public void testBigZeros() {
    AMatrix m=ZeroMatrix.create(2000000, 2000000);
    m=m.sparseClone();
    assertTrue("Not fully sparse:" +m.getClass(), m.isFullyMutable());
    m.set(3,4,7.0);
 
    assertEquals(1,m.nonZeroCount());
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

 
    assertEquals(1,m.nonZeroCount());
  }
 
  @Test public void testBigIdentity() {
    AMatrix m=IdentityMatrix.create(2000000);
    m=m.sparse();
   
    assertEquals(m,m.innerProduct(m));
    assertEquals(m.rowCount(),m.nonZeroCount());
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

  public void testDecompose() {
//    TEST: 1
    double[][] dataA = {{5, 2, 3}, {1.5, -2, 8}, {-3, 4.7, -0.5}};
    Matrix A = Matrix.create(dataA);
    LUPResult ans = AltLU.decompose(A);
    AMatrix L = ans.getL();
    AMatrix U = ans.getU();
    AMatrix P = ans.getP();
   
    double[][] exceptDataL = {{1, 0, 0}, {-0.6, 1, 0}, {0.3, -0.44068, 1}};
    double[][] exceptDataU = {{5, 2, 3}, {0, 5.9, 1.3}, {0, 0, 7.67288}};
    double[][] exceptDataP = {{1, 0, 0}, {0, 0, 1}, {0, 1, 0}};
    Matrix exceptL = Matrix.create(exceptDataL);
    Matrix exceptU = Matrix.create(exceptDataU);
    Matrix exceptP = Matrix.create(exceptDataP);
    assertArrayEquals(L.getElements(), exceptL.data, 1e-5);
    assertArrayEquals(U.getElements(), exceptU.data, 1e-5);
    assertArrayEquals(P.getElements(), exceptP.data, 1e-5);
    assertTrue(Math.abs(-226.350 - ans.computeDeterminant()) < 1e-3);
   
//    TEST: 2
    dataA = new double[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    Matrix B = Matrix.create(dataA);
    ans = AltLU.decompose(B);
    L = ans.getL();
    U = ans.getU();
    P = ans.getP();
 
    exceptDataL = new double[][]{{1, 0, 0}, {0.142857, 1, 0}, {0.571429, 0.5, 1}};
    exceptDataU = new double[][]{{7, 8, 9}, {0, 0.857143, 1.714286}, {0, 0, 0}};
    exceptDataP = new double[][]{{0, 1, 0}, {0, 0, 1}, {1, 0, 0}};
    exceptL = Matrix.create(exceptDataL);
    exceptU = Matrix.create(exceptDataU);
    exceptP = Matrix.create(exceptDataP);
    assertArrayEquals(L.getElements(), exceptL.data, 1e-5);
    assertArrayEquals(U.getElements(), exceptU.data, 1e-5);
    assertArrayEquals(P.getElements(), exceptP.data, 1e-5);
    assertTrue(Math.abs(0 - ans.computeDeterminant()) < 1e-3);
     
//    AMatrix LU=L.innerProduct(U);
//    AMatrix PA=P.innerProduct(A);
// TODO: apprears to be broken? Needs fixing
View Full Code Here

Examples of mikera.matrixx.AMatrix

//    }
//  }

  @Test
  public void testRandomDecompose() {
    AMatrix a=Matrixx.createRandomMatrix(4, 4);
    ILUPResult r=SimpleLUP.decompose(a);
   
    AMatrix lu=r.getL().innerProduct(r.getU());
    AMatrix pa=r.getP().innerProduct(a);
   
    if(!lu.epsilonEquals(pa)) {
      fail("L="+r.getL()+"\n"+"U="+r.getU()+"\n"+"LU="+lu+"\n"+"PA="+pa+"\n");
    }
  }
View Full Code Here

Examples of mikera.matrixx.AMatrix

      assertNotNull(result);

      // not singular
      assertFalse(Math.abs(result.computeDeterminant() - 0) < 1e-8);

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

      assertTrue(octLower.epsilonEquals(L,1e-5));
      assertTrue(octUpper.epsilonEquals(U,1e-5));

//      DenseMatrix64F A_found = P.mult(L).mult(U).getMatrix();
View Full Code Here

Examples of mikera.matrixx.AMatrix

          assertNotNull(result);

       // not singular
          assertFalse(Math.abs(result.computeDeterminant() - 0) < 1e-8);

          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, Multiplications.multiply(L, U));
          assertTrue(A_found.epsilonEquals(A,1e-8));
      }
View Full Code Here

Examples of mikera.matrixx.AMatrix

      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());
View Full Code Here

Examples of mikera.matrixx.AMatrix

      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

Examples of mikera.matrixx.AMatrix

      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

Examples of mikera.matrixx.AMatrix

    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 } });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.