Exemple #1
0
 public void testElements() {
   DenseMatrix A = rand(5, 8);
   DenseMatrix B = rand(5, 8);
   assertTrue(zeros(5, 8).equals(A.sub(A)));
   assertTrue(A.equals(A.add(A).div(2)));
   assertTrue(ones(5, 8).equals(A.div(A)));
   assertTrue(A.equals(A.mul(A).div(A)));
   assertTrue(A.neg().abs().equals(A));
   assertTrue(A.neg().add(A).equals(zeros(5, 8)));
 }
Exemple #2
0
 public void testfullpivhouseholderqrsolve() {
   int K = thousandconstant;
   DenseMatrix A = rand(K, K / 2);
   DenseMatrix B = rand(K, K / 3);
   Timer timer = new Timer();
   DenseMatrix X = A.fullPivHouseholderQRSolve(B);
   timer.printTimeCheckMilliseconds();
   DenseMatrix AX = A.mmul(X);
   double diff = AX.sub(B).abs().sum().s();
   assertTrue(diff < 0.01 * K * K / 3);
 }