package test;

import org.junit.Test;
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 = 1000;
        int[] dimA = {r, r};
        boolean rand = true;
        double eps = 1e-7;

        NativeArray2D matA = new NativeArray2D(dimA[0], dimA[1]);
        MatrixOperations.initMatrice(matA, rand);
        JavaBlas java = new JavaBlas();
        JavaBlas java = new JavaBlas();

        SimpleMatrix ejmlmatA = new SimpleMatrix(dimA[0], dimA[1]);
        MatrixOperations.copyMatrix(matA, ejmlmatA);

        long timestart, timeend;

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

@@ -25,20 +25,90 @@
 g.junit.
-Test
+Assert;%0Aimport org.junit.Test;%0Aimport org.kevoree.modeling.blas.NetlibBlas
 ;%0Aimport
@@ -566,17 +566,17 @@
 int r = 
-1
+3
 000;%0A   
@@ -648,19 +648,17 @@
 uble eps
- = 
+=
 1e-7;%0A%0A 
@@ -785,32 +785,36 @@
    JavaBlas java
+blas
  = new JavaBlas(
@@ -828,32 +828,42 @@
     
-JavaBlas java
+NetlibBlas nativeblas
  = new 
-Java
+Netlib
 Blas
@@ -867,24 +867,25 @@
 las();%0A%0A
+%0A
         
 SimpleMa
@@ -880,130 +880,152 @@
     
-SimpleMatrix ejmlmatA = new SimpleMatrix(dimA%5B0%5D, dimA%5B1%5D);%0A        MatrixOperations.copyMatrix(matA, ejmlmatA
+long timestart, timeend;%0A%0A        timestart=System.currentTimeMillis();%0A        KArray2D res= MatrixOperations.invert(matA,nativeblas
 );%0A
-%0A
         
 long
@@ -1020,39 +1020,148 @@
         
-long timestart, timeend
+timeend=System.currentTimeMillis();%0A        System.out.println(%22Netlib blas invert %22 + ((double) (timeend - timestart)) / 1000+%22 s%22)
 ;%0A%0A     
@@ -1223,16 +1223,17 @@
 ay2D res
+J
  = Matri
@@ -1261,16 +1261,20 @@
 tA, java
+blas
 );%0A     
@@ -1342,17 +1342,17 @@
 rintln(%22
-j
+J
 ava blas
@@ -1402,18 +1402,282 @@
 ) / 1000
-);
++%22 s%22);%0A%0A        assert res != null;%0A        assert resJ != null;%0A        for (int i = 0; i %3C matA.rows(); i++) %7B%0A            for (int j = 0; j %3C matA.columns(); j++) %7B%0A                Assert.assertEquals(res.get(i, j), resJ.get(i, j), eps);%0A            %7D%0A        %7D%0A
 %0A    %7D%0A%7D

update Matrix invert test