Package mikera.matrixx

Examples of mikera.matrixx.AMatrix


        assertTrue(Vector.of(-1.35294117647,1.05882352941,0.11764705882).epsilonEquals(x, 1e-8));
    }
   
    @Test
    public void testSolveSquareMatrix() {
        AMatrix m= Matrix.create(new double[][] {{1,2,2},{1,4,1},{5,9,2}});
       
        AMatrix x = Linear.solveLeastSquares(m, Matrix.create(new double[][]{{1},{3},{3}}));
        assertArrayEquals(new double[] {-1.35294117647,1.05882352941,0.11764705882},x.asDoubleArray(), 1e-8);
    }
View Full Code Here


        assertArrayEquals(new double[] {-1.35294117647,1.05882352941,0.11764705882},x.asDoubleArray(), 1e-8);
    }
   
    @Test(expected=IllegalArgumentException.class)
    public void testSolveSquareMatrixRectangular() {
        AMatrix m= Matrix.create(new double[][] {{1,2},{1,4},{5,9}});
       
        AVector x = Linear.solve(m, Vector.of(1,3,3));
        assertTrue(Vector.of(-1.35294117647,1.05882352941,0.11764705882).epsilonEquals(x, 1e-8));
    }
View Full Code Here

        assertTrue(Vector.of(-1.35294117647,1.05882352941,0.11764705882).epsilonEquals(x, 1e-8));
    }

  @Test
  public void testSolveSquareMatrixSingular() {
    AMatrix m= Matrix.create(new double[][] {{1,2,3},{4,5,6},{7,8,9}});
   
    assertNull(Linear.solve(m, Vector.of(1,3,3)));
  }
View Full Code Here

        M.set(SSIZE-1, SSIZE-1, M.get(SSIZE-1, SSIZE-1) + 3.14159);
    assertFalse(M.equals(D));
        D.set(SSIZE-1, SSIZE-1, D.get(SSIZE-1, SSIZE-1) + 3.14159);
    assertTrue(M.equals(D));

        AMatrix N = M.getTranspose();
        AMatrix Dt = D.getTranspose();
    assertTrue(N.equals(Dt));
        N.set(SSIZE-1, SSIZE-1, N.get(SSIZE-1, SSIZE-1) + 3.14159);
    assertFalse(N.equals(Dt));
        Dt.addAt(SSIZE-1, SSIZE-1, 3.14159);        // also test addAt
    assertTrue(N.equals(Dt));
  }
View Full Code Here

    assertEquals(JoinedMultiVector.class, Vectorz.join(Matrixx.createIdentityMatrix(4).getSlices()).getClass());
    assertEquals(ZeroVector.class, Vectorz.join(ZeroMatrix.create(3, 4).getSlices()).getClass());
  }
 
  @Test public void testMatrixRowJoining() {
    AMatrix m=Matrixx.createRandomMatrix(5, 5);
    AMatrix sm=m.subMatrix(1,3,0,5);
    List<AVector> slices=sm.getSlices();
    AVector jr=Vectorz.join(slices);
    assertEquals(ArraySubVector.class, jr.getClass());
  }
View Full Code Here

public class TestQR {
 
  @Test
  public void testQR() {
    AMatrix a = Matrixx.createRandomMatrix(3, 3);
   
    IQRResult result = QR.decompose(a);
    validateQR(a,result);
  }
View Full Code Here

//    validateQR(a,result);
//  }
 
  @Test
  public void testZero() {
    AMatrix a = ZeroMatrix.create(4, 4);
    IQRResult result = QR.decompose(a);
    assertTrue(result.getQ().isIdentity());
    assertTrue(result.getR().isZero());
  }
View Full Code Here

    assertTrue(result.getR().isZero());
  }
 
  @Test
  public void testIdentity() {
    AMatrix a = IdentityMatrix.create(4);
    IQRResult result = QR.decompose(a);
    validateQR(a,result);
  }
View Full Code Here

    validateQR(a,result);
  }
 
  @Test
  public void testBig() {
    AMatrix a = Matrix.createRandom(30, 30);
    IQRResult result = QR.decompose(a);
    validateQR(a, result);
  }
View Full Code Here

    validateQR(a, result);
  }
 
  @Test
  public void testTall() {
    AMatrix a = Matrix.createRandom(5, 3);
    IQRResult result = QR.decompose(a);
    validateQR(a, result);
  }
View Full Code Here

TOP

Related Classes of mikera.matrixx.AMatrix

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.