package org.mwg.ml.common;

import org.junit.Assert;
import org.junit.Test;
import org.mwg.ml.common.matrix.Matrix;
import org.mwg.ml.common.matrix.MatrixEngine;
import org.mwg.ml.common.matrix.TransposeType;
import org.mwg.ml.common.matrix.blassolver.BlasMatrixEngine;

/**
 * Created by assaad on 03/06/16.
 */
public class MultiplyTest {




    @Test
    public void MatrixMult() {
        InternalManualMult(new BlasMatrixEngine());
    }

    public Matrix manualMultpily(Matrix matA, Matrix matB) {
        Matrix matC = new Matrix(null, matA.rows(), matB.columns());

        for (int i = 0; i < matA.rows(); i++) {
            for (int j = 0; j < matB.columns(); j++) {
                for (int k = 0; k < matA.columns(); k++) {
                    matC.add(i, j, matA.get(i, k) * matB.get(k, j));
                }
            }
        }

        return matC;

    }


    public void InternalManualMult(MatrixEngine engine) {
        //Test matrix mult
        int r = 50;
        int o = 40;
        int p = 20;
        Matrix matA = Matrix.random(r, o, 0, 100);
        Matrix matB = Matrix.random(o, p, 0, 100);


        Matrix result = engine.multiplyTransposeAlphaBeta(TransposeType.NOTRANSPOSE,1,matA,TransposeType.NOTRANSPOSE,1,matB);
        Matrix matD = manualMultpily(matA, matB);

        double eps = 1e-7;

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < p; j++) {
                Assert.assertTrue(Math.abs(result.get(i, j) - matD.get(i, j)) < eps);
            }
        }
    }
}

@@ -262,16 +262,77 @@
 xEngine;
+%0Aimport org.mwg.ml.common.matrix.jamasolver.JamaMatrixEngine;
 %0A%0A/**%0A *
@@ -435,16 +435,20 @@
 trixMult
+Blas
 () %7B%0A   
@@ -496,23 +496,132 @@
 ine());%0A
-
     %7D%0A%0A
+    @Test%0A    public void MatrixMultJama() %7B%0A        InternalManualMult(new JamaMatrixEngine());%0A    %7D%0A    %0A%0A
     publ

Multiply test