use of org.apache.ignite.ml.math.primitives.matrix.Matrix in project ignite by apache.
the class BlasTest method testGemmSparseDenseDense.
/**
* Tests 'gemm' operation for sparse matrix A, dense matrix B and dense matrix C.
*/
@Test
public void testGemmSparseDenseDense() {
// C := alpha * A * B + beta * C
double alpha = 1.0;
SparseMatrix a = (SparseMatrix) new SparseMatrix(2, 2).assign(new double[][] { { 10.0, 11.0 }, { 0.0, 1.0 } });
DenseMatrix b = new DenseMatrix(new double[][] { { 1.0, 0.3 }, { 0.0, 1.0 } });
double beta = 0.0;
DenseMatrix c = new DenseMatrix(new double[][] { { 1.0, 2.0 }, { 2.0, 3.0 } });
// .times(alpha).plus(c.times(beta));
Matrix exp = a.times(b);
Blas.gemm(alpha, a, b, beta, c);
Assert.assertTrue(Arrays.equals(exp.getStorage().data(), c.getStorage().data()));
}
Aggregations