Package mikera.matrixx.decompose

Examples of mikera.matrixx.decompose.ISVDResult


   * @param A The input matrix
   * @param threshold Tolerance used to determine if a singular value is singular.
   * @return The matrix's rank
   */
  public static int compute(AMatrix A, double threshold) {
    ISVDResult ans = SVD.decompose(A, true);
    int rank = 0;
    AVector singularValues = ans.getSingularValues();
    int n=singularValues.length();
    for(int i=0; i<n; i++) {
      if( singularValues.unsafeGet(i) >= threshold)
        rank++;
    }
View Full Code Here


  public void testRankUsingResult() {
//    Test 1
    Matrix A = Matrix.create(new double[][] {{1, 2, 3},
        {4, 5, 6},
        {7, 8, 9}});
    ISVDResult result = SVD.decompose(A);
    assertEquals(Rank.compute(result),2);
//    Test 2
    Matrix B = Matrix.create(new double[][] {{1, 2, 3, 4},
        {4, 5, 6, 7},
        {7, 8, 9, 10}});
View Full Code Here

  public void testRankWithThresholdUsingResult() {
//    Test 1
    Matrix A = Matrix.create(new double[][] {{1, 2, 3},
                            {4, 5, 6},
                          {7, 8, 9}});
    ISVDResult result = SVD.decompose(A);
    assertEquals(Rank.compute(result, 10e-20),3);
//    Test 2
    Matrix B = Matrix.create(new double[][] {{1, 2, 3, 4},
                         {4, 5, 6, 7},
                         {7, 8, 9, 10}});
View Full Code Here

  }
 
  @Test public void testSVD() {
   
    AMatrix a=Matrixx.createRandomMatrix(5, 3);
    ISVDResult ms=ThinSVD.decompose(a);
   
    AMatrix u=ms.getU();
    AMatrix s=ms.getS();
    AMatrix v=ms.getV();
   
    // we are testing that A = USV*
    AMatrix usvt=u.innerProduct(s.innerProduct(v.getTranspose()));
    //assertEquals(a,usvt);
    assertTrue(usvt.epsilonEquals(a));
View Full Code Here

TOP

Related Classes of mikera.matrixx.decompose.ISVDResult

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.