public void testThreeSparse() { int K = 60; int N = thousandconstant; SparseMatrixLil A = SparseMatrixLil.rand(N, K); SparseMatrixLil B = SparseMatrixLil.rand(K, N); // System.out.println(A.toDense()); Timer timer = new Timer(); SparseMatrixLil C = B.mmul(A); timer.printTimeCheckMilliseconds(); SparseMatrixLil C1 = B.mmul(A); timer.printTimeCheckMilliseconds(); SparseMatrixLil C2 = B.mmul(A); timer.printTimeCheckMilliseconds(); DenseMatrix CDense = B.toDense().mmul(A.toDense()); timer.printTimeCheckMilliseconds("for dense"); assertTrue(C.equals(CDense)); K = 400; N = thousandconstant; A = SparseMatrixLil.rand(N, K); B = SparseMatrixLil.rand(K, N); // System.out.println(A.toDense()); timer = new Timer(); C = B.mmul(A); timer.printTimeCheckMilliseconds(); C1 = B.mmul(A); timer.printTimeCheckMilliseconds(); C2 = B.mmul(A); timer.printTimeCheckMilliseconds(); CDense = B.toDense().mmul(A.toDense()); timer.printTimeCheckMilliseconds("for dense"); assertTrue(C.equals(CDense)); }
public void testOneSparse() { SparseMatrixLil A = SparseMatrixLil.rand(3, 3).t(); System.out.println(A); SparseMatrixLil B = SparseMatrixLil.rand(3, 3); System.out.println(B); SparseMatrixLil C = A.mmul(B); System.out.println(C); DenseMatrix CDense = A.toDense().mmul(B.toDense()); System.out.println(CDense); assertTrue(C.equals(CDense)); }
public void testSparseDenseMmul() { int K = 60; int N = thousandconstant; SparseMatrixLil A = SparseMatrixLil.rand(K, N); DenseMatrix B = DenseMatrix.rand(N, K); Timer timer = new Timer(); DenseMatrix C = A.mmul(B); timer.printTimeCheckMilliseconds(); DenseMatrix C2 = A.toDense().mmul(B); assertTrue(C.equals(C2)); }