package test;

import org.junit.Assert;
import org.junit.Test;
import org.kevoree.modeling.blas.NetlibBlas;
import org.kevoree.modeling.blas.NetlibJavaBlas;
import org.kevoree.modeling.util.maths.matrix.SimpleMatrix;
import org.kevoree.modeling.util.maths.structure.KArray2D;
import org.kevoree.modeling.util.maths.structure.blas.impl.JavaBlas;
import org.kevoree.modeling.util.maths.structure.impl.NativeArray2D;
import org.kevoree.modeling.util.maths.structure.matrix.MatrixOperations;

/**
 * Created by assaad on 03/09/15.
 */
public class MatrixInvertTest {
    @Test
    public void invertMatrix() {
        int r = 3000;
        int[] dimA = {r, r};
        boolean rand = true;
        double eps=1e-7;

        NativeArray2D matA = new NativeArray2D(dimA[0], dimA[1]);
        MatrixOperations.initMatrice(matA, rand);
        JavaBlas javablas = new JavaBlas();
        NetlibBlas nativeblas = new NetlibBlas();
        NetlibJavaBlas netlibJavaBlas = new NetlibJavaBlas();


        long timestart, timeend;

        timestart=System.currentTimeMillis();
        KArray2D res= MatrixOperations.invert(matA,nativeblas);
        timeend=System.currentTimeMillis();
        System.out.println("Netlib blas invert " + ((double) (timeend - timestart)) / 1000+" s");

        timestart = System.currentTimeMillis();
        KArray2D resJ = MatrixOperations.invert(matA, javablas);
        timeend = System.currentTimeMillis();
        System.out.println("Java blas invert " + ((double) (timeend - timestart)) / 1000+" s");

        timestart = System.currentTimeMillis();
        KArray2D resnJ = MatrixOperations.invert(matA, netlibJavaBlas);
        timeend = System.currentTimeMillis();
        System.out.println("Netlib Java blas invert " + ((double) (timeend - timestart)) / 1000+" s");

        assert res != null;
        assert resJ != null;
        for (int i = 0; i < matA.rows(); i++) {
            for (int j = 0; j < matA.columns(); j++) {
                Assert.assertEquals(res.get(i, j), resJ.get(i, j), eps);
            }
        }

    }
}

@@ -978,16 +978,137 @@
 las();%0A%0A
+        SimpleMatrix ejmlmatA = new SimpleMatrix(dimA%5B0%5D,dimA%5B1%5D);%0A        MatrixOperations.copyMatrix(matA, ejmlmatA);%0A%0A
 %0A       
@@ -1575,24 +1575,28 @@
 intln(%22Java 
+Src 
 blas invert 
@@ -1852,21 +1852,257 @@
 lib Java
- blas
+Class blas invert %22 + ((double) (timeend - timestart)) / 1000+%22 s%22);%0A%0A        timestart=System.currentTimeMillis();%0A        SimpleMatrix resEjml= ejmlmatA.invert();%0A        timeend=System.currentTimeMillis();%0A        System.out.println(%22Ejml
  invert 

Update matrix test