summaryrefslogtreecommitdiff
path: root/modules/sparse/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/sparse/tests')
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_10126.dia.ref23
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_10126.tst27
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_10271.dia.ref22
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_10271.tst25
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_11612.dia.ref106
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_11612.tst128
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_11618.dia.ref30
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_11618.tst32
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_2003.dia.ref35
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_2003.tst41
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_2277.dia.ref26
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_2277.tst32
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_2430.dia.ref18
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_2430.tst25
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_3006.dia.ref26
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_3006.tst32
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_3025.dia.ref18
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_3025.tst24
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_3263.dia.ref27
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_3263.tst41
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_4654.dia.ref18
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_4654.tst22
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_4783.dia.ref27
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_4783.tst33
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_490.dia.ref18
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_490.tst23
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6401.dia.ref31
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6401.tst39
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6412.dia.ref19
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6412.tst22
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6427.dia.ref15
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6427.tst18
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6827.dia.ref30
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_6827.tst36
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_8511.dia.ref20
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_8511.tst23
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_9780.dia.ref23
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_9780.tst26
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_9999.dia.ref19
-rwxr-xr-xmodules/sparse/tests/nonreg_tests/bug_9999.tst21
-rwxr-xr-xmodules/sparse/tests/unit_tests/adj2sp.dia.ref57
-rwxr-xr-xmodules/sparse/tests/unit_tests/adj2sp.tst59
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad.dia.ref349
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad.tst368
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_function.dia.ref68
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_function.tst76
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_list.dia.ref103
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_list.tst76
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_numerical.dia.ref108
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_numerical.tst116
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_sparse.dia.ref65
-rwxr-xr-xmodules/sparse/tests/unit_tests/conjgrad_sparse.tst73
-rwxr-xr-xmodules/sparse/tests/unit_tests/lsparse.dia.ref382
-rwxr-xr-xmodules/sparse/tests/unit_tests/lsparse.tst391
-rwxr-xr-xmodules/sparse/tests/unit_tests/ordmmd.dia.ref21
-rwxr-xr-xmodules/sparse/tests/unit_tests/ordmmd.tst24
-rwxr-xr-xmodules/sparse/tests/unit_tests/qmr.dia.ref645
-rwxr-xr-xmodules/sparse/tests/unit_tests/qmr.tst772
-rwxr-xr-xmodules/sparse/tests/unit_tests/sp2adj.dia.ref65
-rwxr-xr-xmodules/sparse/tests/unit_tests/sp2adj.tst67
-rwxr-xr-xmodules/sparse/tests/unit_tests/sparse-insert.dia.ref22
-rwxr-xr-xmodules/sparse/tests/unit_tests/sparse-insert.tst27
-rwxr-xr-xmodules/sparse/tests/unit_tests/sparse.dia.ref779
-rwxr-xr-xmodules/sparse/tests/unit_tests/sparse.tst782
-rwxr-xr-xmodules/sparse/tests/unit_tests/sparseBool.dia.ref92
-rwxr-xr-xmodules/sparse/tests/unit_tests/sparseBool.tst92
-rwxr-xr-xmodules/sparse/tests/unit_tests/spisp.dia.ref37
-rwxr-xr-xmodules/sparse/tests/unit_tests/spisp.tst51
-rwxr-xr-xmodules/sparse/tests/unit_tests/sprand.dia.ref90
-rwxr-xr-xmodules/sparse/tests/unit_tests/sprand.tst103
-rwxr-xr-xmodules/sparse/tests/unit_tests/spzeros.dia.ref18
-rwxr-xr-xmodules/sparse/tests/unit_tests/spzeros.tst25
72 files changed, 7224 insertions, 0 deletions
diff --git a/modules/sparse/tests/nonreg_tests/bug_10126.dia.ref b/modules/sparse/tests/nonreg_tests/bug_10126.dia.ref
new file mode 100755
index 000000000..346c29248
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_10126.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 10126 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10126
+//
+// <-- Short Description -->
+// sparse matrix insertion was failing (segfault and/or wrong results)
+A=sprand(5,5,1);
+A(7,1)=1; //A is correctly reshaped and the insertion is ok
+B=full(A);
+assert_checkequal(B(7,1),1);
+assert_checkequal(size(A),[7,5]);
+A(10,1)=2; // Was either doing a segfault or producing a bad result
+B=full(A);
+assert_checkequal(B(10,1),2);
+assert_checkequal(size(A),[10,5]);
diff --git a/modules/sparse/tests/nonreg_tests/bug_10126.tst b/modules/sparse/tests/nonreg_tests/bug_10126.tst
new file mode 100755
index 000000000..1e537de2f
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_10126.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 10126 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10126
+//
+// <-- Short Description -->
+// sparse matrix insertion was failing (segfault and/or wrong results)
+
+A=sprand(5,5,1);
+A(7,1)=1; //A is correctly reshaped and the insertion is ok
+B=full(A);
+assert_checkequal(B(7,1),1);
+assert_checkequal(size(A),[7,5]);
+
+A(10,1)=2; // Was either doing a segfault or producing a bad result
+B=full(A);
+assert_checkequal(B(10,1),2);
+assert_checkequal(size(A),[10,5]); \ No newline at end of file
diff --git a/modules/sparse/tests/nonreg_tests/bug_10271.dia.ref b/modules/sparse/tests/nonreg_tests/bug_10271.dia.ref
new file mode 100755
index 000000000..281722f19
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_10271.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10271 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10271
+//
+// <-- Short Description -->
+// ordmmd now checks the consistency of the third input argument with the
+// input matrix defined by the two first input arguments.
+A = ReadHBSparse(SCI+"/modules/umfpack/examples/ex14.rua");
+[xadj, iadj, val] = sp2adj(A);
+n = floor(size(A, "r")/2);
+refMsg = msprintf(_(" The provided ""n"" does not correspond to the matrix defined by xadj and iadj"));
+assert_checkerror("[perm, invp, nofsub] = ordmmd(xadj, iadj, n);", refMsg);
diff --git a/modules/sparse/tests/nonreg_tests/bug_10271.tst b/modules/sparse/tests/nonreg_tests/bug_10271.tst
new file mode 100755
index 000000000..375ccf963
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_10271.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10271 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10271
+//
+// <-- Short Description -->
+// ordmmd now checks the consistency of the third input argument with the
+// input matrix defined by the two first input arguments.
+
+A = ReadHBSparse(SCI+"/modules/umfpack/examples/ex14.rua");
+
+[xadj, iadj, val] = sp2adj(A);
+n = floor(size(A, "r")/2);
+
+refMsg = msprintf(_(" The provided ""n"" does not correspond to the matrix defined by xadj and iadj"));
+assert_checkerror("[perm, invp, nofsub] = ordmmd(xadj, iadj, n);", refMsg);
diff --git a/modules/sparse/tests/nonreg_tests/bug_11612.dia.ref b/modules/sparse/tests/nonreg_tests/bug_11612.dia.ref
new file mode 100755
index 000000000..78dc6bafb
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_11612.dia.ref
@@ -0,0 +1,106 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 11612 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11612
+//
+// <-- Short Description -->
+// index of the max value of a negative sparse was wrong
+a = -1 * rand(3,2);
+a(2) = 0;
+A = sparse(a);
+[m, i] = max(a);
+[m1, i1] = max(A);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(a');
+[m1, i1] = max(A');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(a(:));
+[m1, i1] = max(A(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(a(:)');
+[m1, i1] = max(A(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+a = [-3 -4;0 -1;-5 -6];
+A = sparse(a);
+[m, i] = max(a);
+[m1, i1] = max(A);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(a');
+[m1, i1] = max(A');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(a(:));
+[m1, i1] = max(A(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(a(:)');
+[m1, i1] = max(A(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+b = [-5 0;-1 -6];
+B = sparse(b);
+[m, i] = max(b);
+[m1, i1] = max(B);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(b');
+[m1, i1] = max(B');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(b(:));
+[m1, i1] = max(B(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(b(:)');
+[m1, i1] = max(B(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+s = rand(3,2);
+s(2) = 0;
+S = sparse(s);
+[m, i] = min(s);
+[m1, i1] = min(S);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = min(s');
+[m1, i1] = min(S');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = min(s(:));
+[m1, i1] = min(S(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = min(s(:)');
+[m1, i1] = min(S(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+v = [1 4;7 6];
+V = sparse(v);
+[m, i] = max(v);
+[m1, i1] = max(V);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(v');
+[m1, i1] = max(V');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(v(:));
+[m1, i1] = max(V(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+[m, i] = max(v(:)');
+[m1, i1] = max(V(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
diff --git a/modules/sparse/tests/nonreg_tests/bug_11612.tst b/modules/sparse/tests/nonreg_tests/bug_11612.tst
new file mode 100755
index 000000000..6cc03a727
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_11612.tst
@@ -0,0 +1,128 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 11612 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11612
+//
+// <-- Short Description -->
+// index of the max value of a negative sparse was wrong
+
+a = -1 * rand(3,2);
+a(2) = 0;
+A = sparse(a);
+[m, i] = max(a);
+[m1, i1] = max(A);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(a');
+[m1, i1] = max(A');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(a(:));
+[m1, i1] = max(A(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(a(:)');
+[m1, i1] = max(A(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+a = [-3 -4;0 -1;-5 -6];
+A = sparse(a);
+[m, i] = max(a);
+[m1, i1] = max(A);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(a');
+[m1, i1] = max(A');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(a(:));
+[m1, i1] = max(A(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(a(:)');
+[m1, i1] = max(A(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+b = [-5 0;-1 -6];
+B = sparse(b);
+[m, i] = max(b);
+[m1, i1] = max(B);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(b');
+[m1, i1] = max(B');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(b(:));
+[m1, i1] = max(B(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(b(:)');
+[m1, i1] = max(B(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+s = rand(3,2);
+s(2) = 0;
+S = sparse(s);
+[m, i] = min(s);
+[m1, i1] = min(S);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = min(s');
+[m1, i1] = min(S');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = min(s(:));
+[m1, i1] = min(S(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = min(s(:)');
+[m1, i1] = min(S(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+v = [1 4;7 6];
+V = sparse(v);
+[m, i] = max(v);
+[m1, i1] = max(V);
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(v');
+[m1, i1] = max(V');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(v(:));
+[m1, i1] = max(V(:));
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
+
+[m, i] = max(v(:)');
+[m1, i1] = max(V(:)');
+assert_checkequal(m1,m);
+assert_checkequal(i1,i);
diff --git a/modules/sparse/tests/nonreg_tests/bug_11618.dia.ref b/modules/sparse/tests/nonreg_tests/bug_11618.dia.ref
new file mode 100755
index 000000000..ceffb94f2
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_11618.dia.ref
@@ -0,0 +1,30 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 11618 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11618
+//
+// <-- Short Description -->
+// if A is a complex sparse matrix, A(:) returned wrong values
+A = [0 %i;1 2]
+ A =
+
+ 0 i
+ 1. 2.
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
+A = [1 0; 3 %i];
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
+A = [%i 3; 0 1];
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
+A = [1 %i;%i 0];
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
diff --git a/modules/sparse/tests/nonreg_tests/bug_11618.tst b/modules/sparse/tests/nonreg_tests/bug_11618.tst
new file mode 100755
index 000000000..a0858286f
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_11618.tst
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 11618 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11618
+//
+// <-- Short Description -->
+// if A is a complex sparse matrix, A(:) returned wrong values
+
+A = [0 %i;1 2]
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
+
+A = [1 0; 3 %i];
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
+
+A = [%i 3; 0 1];
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
+
+A = [1 %i;%i 0];
+A1 = sparse(A);
+assert_checkequal(full(A1(:)), A(:));
diff --git a/modules/sparse/tests/nonreg_tests/bug_2003.dia.ref b/modules/sparse/tests/nonreg_tests/bug_2003.dia.ref
new file mode 100755
index 000000000..38fa22af0
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_2003.dia.ref
@@ -0,0 +1,35 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 2003 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2003
+//
+// <-- Short Description -->
+//lusolve crashes scilab when handle has been freed
+a=[0.2,0.6,0.6,0.2,0.3;
+0.8,0.8,0.7,0.2,0.9;
+0,0.7,0.7,0.2,0.2;
+0.3,0.9,0.2,0.9,0.3;
+0.7,0.1,0.5,0.7,0.4];
+b=[0.3;0.6;0.5;0.3;0.6];
+A=sparse(a);
+[h,rk]=lufact(A);
+x=lusolve(h,b);
+if norm(a*x-b)>1d-10 then bugmes();quit;end
+[P,L,U,Q]=luget(h);
+if norm(P*L*U*Q-A)>1d-10 then bugmes();quit;end
+ludel(h)
+if execstr('x=lusolve(h,b);','errcatch')<>247 then bugmes();quit;end
+if execstr('ludel(h);','errcatch')<>247 then bugmes();quit;end
+if execstr('[P,L,U,Q]=luget(h);','errcatch')<>247 then bugmes();quit;end
+//try to allocate a lot of handles
+for k=1:20
+ [h1,rk]=lufact(A);
+end
+x=lusolve(h1,b);
+if norm(a*x-b)>1d-10 then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_2003.tst b/modules/sparse/tests/nonreg_tests/bug_2003.tst
new file mode 100755
index 000000000..550d760e2
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_2003.tst
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 2003 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2003
+//
+// <-- Short Description -->
+//lusolve crashes scilab when handle has been freed
+
+a=[0.2,0.6,0.6,0.2,0.3;
+0.8,0.8,0.7,0.2,0.9;
+0,0.7,0.7,0.2,0.2;
+0.3,0.9,0.2,0.9,0.3;
+0.7,0.1,0.5,0.7,0.4];
+b=[0.3;0.6;0.5;0.3;0.6];
+A=sparse(a);
+[h,rk]=lufact(A);
+x=lusolve(h,b);
+if norm(a*x-b)>1d-10 then pause,end
+[P,L,U,Q]=luget(h);
+if norm(P*L*U*Q-A)>1d-10 then pause,end
+ludel(h)
+if execstr('x=lusolve(h,b);','errcatch')<>247 then pause,end
+if execstr('ludel(h);','errcatch')<>247 then pause,end
+if execstr('[P,L,U,Q]=luget(h);','errcatch')<>247 then pause,end
+
+//try to allocate a lot of handles
+for k=1:20
+ [h1,rk]=lufact(A);
+end
+
+x=lusolve(h1,b);
+if norm(a*x-b)>1d-10 then pause,end
diff --git a/modules/sparse/tests/nonreg_tests/bug_2277.dia.ref b/modules/sparse/tests/nonreg_tests/bug_2277.dia.ref
new file mode 100755
index 000000000..a3bc13099
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_2277.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 2277 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2277
+//
+// <-- Short Description -->
+// Scilab has a bug with the SPARSE command. When the "values vector" in the
+// row/column representation is COMPLEX the routine fails to build the sparse
+// matrix correctly. This seems to occur always when the first AND third entry of
+// this vector are zero.
+// The other bug is that when other elements are zero (not the third, the fifth for
+// example) they are still stored in the sparse representation.
+// This is very problematic for people doing finite element calculations with scilab!
+ij = [1,3;1,7;3,3;4,4;5,3;6,10;7,1;7,9;8,10;9,6;9,7;9,9;10,10] ;
+v = [1 0 0 4:13]'*%i;
+A = sparse(ij,v,[10 10]);
+[ij2,v2,mn] = spget(A);
+if or(v2<>[1 4:13]'*%i) then bugmes();quit;end
+ij(2:3,:) = [];
+if or(ij<>ij2) then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_2277.tst b/modules/sparse/tests/nonreg_tests/bug_2277.tst
new file mode 100755
index 000000000..8f639a004
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_2277.tst
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 2277 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2277
+//
+// <-- Short Description -->
+// Scilab has a bug with the SPARSE command. When the "values vector" in the
+// row/column representation is COMPLEX the routine fails to build the sparse
+// matrix correctly. This seems to occur always when the first AND third entry of
+// this vector are zero.
+// The other bug is that when other elements are zero (not the third, the fifth for
+// example) they are still stored in the sparse representation.
+// This is very problematic for people doing finite element calculations with scilab!
+
+ij = [1,3;1,7;3,3;4,4;5,3;6,10;7,1;7,9;8,10;9,6;9,7;9,9;10,10] ;
+v = [1 0 0 4:13]'*%i;
+A = sparse(ij,v,[10 10]);
+[ij2,v2,mn] = spget(A);
+
+if or(v2<>[1 4:13]'*%i) then pause,end
+
+ij(2:3,:) = [];
+if or(ij<>ij2) then pause,end
diff --git a/modules/sparse/tests/nonreg_tests/bug_2430.dia.ref b/modules/sparse/tests/nonreg_tests/bug_2430.dia.ref
new file mode 100755
index 000000000..f9f71c7bd
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_2430.dia.ref
@@ -0,0 +1,18 @@
+// <-- Non-regression test for bug 2430 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2430
+//
+// <-- Short Description -->
+// Wrong results when solving linear systems when the matrix
+// is sparse and 1x1, and rhs is compatible and sparse.
+// In the example below, M\b and full(M)\b give a wrong result,
+// whereas M\full(b) and full(M)\full(b) are ok.
+//
+// Strangely, when the size of b is less than 10, then all
+// cases give the correct answer !
+// Scilab Project - Serge Steer
+// Copyright INRIA 2007
+// Date : June 2007
+b = sparse(1:16);
+if or(abs(full(2\b)-2\full(b)) >= 100*%eps) then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_2430.tst b/modules/sparse/tests/nonreg_tests/bug_2430.tst
new file mode 100755
index 000000000..dfd1a35ab
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_2430.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 2430 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2430
+//
+// <-- Short Description -->
+// Wrong results when solving linear systems when the matrix
+// is sparse and 1x1, and rhs is compatible and sparse.
+// In the example below, M\b and full(M)\b give a wrong result,
+// whereas M\full(b) and full(M)\full(b) are ok.
+//
+// Strangely, when the size of b is less than 10, then all
+// cases give the correct answer !
+
+b = sparse(1:16);
+if or(abs(full(2\b)-2\full(b)) >= 100*%eps) then pause,end
diff --git a/modules/sparse/tests/nonreg_tests/bug_3006.dia.ref b/modules/sparse/tests/nonreg_tests/bug_3006.dia.ref
new file mode 100755
index 000000000..9f5f2b5c8
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_3006.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3006 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3006
+//
+// <-- Short Description -->
+// submatrix assignment impossible when the matrix is indexed with a boolean array of falses
+a=sparse([1 2;3 4]);a_ref=a;
+a(1,[%f %f])=[];
+if or(a<>a_ref) then bugmes();quit;end
+a([%f %f],1)=[];
+if or(a<>a_ref) then bugmes();quit;end
+a([%f %f],[%f %f])=[];
+if or(a<>a_ref) then bugmes();quit;end
+a(1,$:1)=[];
+if or(a<>a_ref) then bugmes();quit;end
+a($:1,1)=[];
+if or(a<>a_ref) then bugmes();quit;end
+a($:1,$:1)=[];
+if or(a<>a_ref) then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_3006.tst b/modules/sparse/tests/nonreg_tests/bug_3006.tst
new file mode 100755
index 000000000..47a74071c
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_3006.tst
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 3006 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3006
+//
+// <-- Short Description -->
+// submatrix assignment impossible when the matrix is indexed with a boolean array of falses
+
+a=sparse([1 2;3 4]);a_ref=a;
+
+a(1,[%f %f])=[];
+if or(a<>a_ref) then pause,end
+a([%f %f],1)=[];
+if or(a<>a_ref) then pause,end
+a([%f %f],[%f %f])=[];
+if or(a<>a_ref) then pause,end
+
+a(1,$:1)=[];
+if or(a<>a_ref) then pause,end
+a($:1,1)=[];
+if or(a<>a_ref) then pause,end
+a($:1,$:1)=[];
+if or(a<>a_ref) then pause,end
diff --git a/modules/sparse/tests/nonreg_tests/bug_3025.dia.ref b/modules/sparse/tests/nonreg_tests/bug_3025.dia.ref
new file mode 100755
index 000000000..6112f97a2
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_3025.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 2277 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2277
+//
+// <-- Short Description -->
+//lusolve produces erroneous results with Scilab5 (it was ok on Scilab4)
+A=sparse([2,2;2,4;3,3;3,7;4,2;4,4;6,6;6,8;7,3;7,7;8,6;8,8],..
+ [-1;1;-1;1;1;-1;-1;1;1;-1;1;-1],[10,10]) ;
+[ptr,rkA]=lufact(A);
+x=lusolve(ptr,zeros(10,1));ludel(ptr);
+if norm(A*x)>1d-14 then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_3025.tst b/modules/sparse/tests/nonreg_tests/bug_3025.tst
new file mode 100755
index 000000000..2581230c9
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_3025.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 2277 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2277
+//
+// <-- Short Description -->
+//lusolve produces erroneous results with Scilab5 (it was ok on Scilab4)
+
+A=sparse([2,2;2,4;3,3;3,7;4,2;4,4;6,6;6,8;7,3;7,7;8,6;8,8],..
+ [-1;1;-1;1;1;-1;-1;1;1;-1;1;-1],[10,10]) ;
+[ptr,rkA]=lufact(A);
+x=lusolve(ptr,zeros(10,1));ludel(ptr);
+if norm(A*x)>1d-14 then pause,end
+
+
diff --git a/modules/sparse/tests/nonreg_tests/bug_3263.dia.ref b/modules/sparse/tests/nonreg_tests/bug_3263.dia.ref
new file mode 100755
index 000000000..c8b12ceff
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_3263.dia.ref
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3263 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3263
+//
+// <-- Short Description -->
+// ludel(h) fails @ rev. 25935
+a=[0.2,0.6,0.6,0.2,0.3;
+0.8,0.8,0.7,0.2,0.9;
+0,0.7,0.7,0.2,0.2;
+0.3,0.9,0.2,0.9,0.3;
+0.7,0.1,0.5,0.7,0.4];
+b=[0.3;0.6;0.5;0.3;0.6];
+A=sparse(a);
+[h,rk]=lufact(A);
+x=lusolve(h,b);
+if norm(a*x-b)>1d-10 then bugmes();quit;end
+[P,L,U,Q]=luget(h);
+if norm(P*L*U*Q-A)>1d-10 then bugmes();quit;end
+ierr = execstr('ludel(h);','errcatch');
+if ierr <> 0 then bugmes();quit;end;
diff --git a/modules/sparse/tests/nonreg_tests/bug_3263.tst b/modules/sparse/tests/nonreg_tests/bug_3263.tst
new file mode 100755
index 000000000..ea020d0d7
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_3263.tst
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 3263 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3263
+//
+// <-- Short Description -->
+// ludel(h) fails @ rev. 25935
+
+
+a=[0.2,0.6,0.6,0.2,0.3;
+0.8,0.8,0.7,0.2,0.9;
+0,0.7,0.7,0.2,0.2;
+0.3,0.9,0.2,0.9,0.3;
+0.7,0.1,0.5,0.7,0.4];
+
+b=[0.3;0.6;0.5;0.3;0.6];
+
+A=sparse(a);
+
+[h,rk]=lufact(A);
+
+x=lusolve(h,b);
+
+if norm(a*x-b)>1d-10 then pause,end
+
+[P,L,U,Q]=luget(h);
+
+if norm(P*L*U*Q-A)>1d-10 then pause,end
+
+ierr = execstr('ludel(h);','errcatch');
+if ierr <> 0 then pause,end;
+
diff --git a/modules/sparse/tests/nonreg_tests/bug_4654.dia.ref b/modules/sparse/tests/nonreg_tests/bug_4654.dia.ref
new file mode 100755
index 000000000..8aec8ff16
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_4654.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Yann COLLETTE <yann.collette@scilab.fr>
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 4654 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4654
+//
+// <-- Short Description -->
+// max of an empty sparse matrix makes Scilab hangs
+[v, ij] = max(sprand(50,50,0));
+assert_checkequal(v, 0);
+assert_checkequal(ij, [1 1]);
diff --git a/modules/sparse/tests/nonreg_tests/bug_4654.tst b/modules/sparse/tests/nonreg_tests/bug_4654.tst
new file mode 100755
index 000000000..4e29bd8fa
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_4654.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Yann COLLETTE <yann.collette@scilab.fr>
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 4654 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4654
+//
+// <-- Short Description -->
+// max of an empty sparse matrix makes Scilab hangs
+
+[v, ij] = max(sprand(50,50,0));
+
+assert_checkequal(v, 0);
+assert_checkequal(ij, [1 1]);
diff --git a/modules/sparse/tests/nonreg_tests/bug_4783.dia.ref b/modules/sparse/tests/nonreg_tests/bug_4783.dia.ref
new file mode 100755
index 000000000..30ca1d1c7
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_4783.dia.ref
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 4783 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4783
+//
+// <-- Short Description -->
+// comparison between sparse complex matrix and a full one is wrong when the sparse matrix contains a full zero row.
+C=sparse([1 1+2*%i;0 0]);
+D=full(C);
+if ~and(full(D==C)) then bugmes();quit;end
+if or(full(D<>C)) then bugmes();quit;end
+if ~and(full(C==D)) then bugmes();quit;end
+if or(full(C<>D)) then bugmes();quit;end
+//real case = OK
+C=sparse([1 2;0 0]);
+D=full(C);
+if ~and(full(D==C)) then bugmes();quit;end
+if or(full(D<>C)) then bugmes();quit;end
+if ~and(full(C==D)) then bugmes();quit;end
+if or(full(C<>D)) then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_4783.tst b/modules/sparse/tests/nonreg_tests/bug_4783.tst
new file mode 100755
index 000000000..84df9609a
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_4783.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 4783 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4783
+//
+// <-- Short Description -->
+// comparison between sparse complex matrix and a full one is wrong when the sparse matrix contains a full zero row.
+
+C=sparse([1 1+2*%i;0 0]);
+D=full(C);
+if ~and(full(D==C)) then pause,end
+if or(full(D<>C)) then pause,end
+if ~and(full(C==D)) then pause,end
+if or(full(C<>D)) then pause,end
+
+
+//real case = OK
+C=sparse([1 2;0 0]);
+D=full(C);
+if ~and(full(D==C)) then pause,end
+if or(full(D<>C)) then pause,end
+if ~and(full(C==D)) then pause,end
+if or(full(C<>D)) then pause,end
+
diff --git a/modules/sparse/tests/nonreg_tests/bug_490.dia.ref b/modules/sparse/tests/nonreg_tests/bug_490.dia.ref
new file mode 100755
index 000000000..3d9259a59
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_490.dia.ref
@@ -0,0 +1,18 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Sylvestre LEDRU <sylvestre.ledru@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// ============================================================================
+// <-- Non-regression test for bug 490 -->
+// Please note that it is store under the request feature of Scilab
+//
+// <-- Bugzilla URL -->
+// http://requestzilla.scilab.org/show_bug.cgi?id=490
+//
+// <-- Short Description -->
+// Wrong size detection in sparse matrix
+toto = spzeros(2^16, 2^16);
+toto(1, 8) =toto(1, 8)+5;
+toto(1, 8) =toto(1, 8)+5;
+if toto(1, 8) == []; then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_490.tst b/modules/sparse/tests/nonreg_tests/bug_490.tst
new file mode 100755
index 000000000..c7e1ceb53
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_490.tst
@@ -0,0 +1,23 @@
+// ============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Sylvestre LEDRU <sylvestre.ledru@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// ============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 490 -->
+// Please note that it is store under the request feature of Scilab
+//
+// <-- Bugzilla URL -->
+// http://requestzilla.scilab.org/show_bug.cgi?id=490
+//
+// <-- Short Description -->
+// Wrong size detection in sparse matrix
+
+toto = spzeros(2^16, 2^16);
+toto(1, 8) =toto(1, 8)+5;
+toto(1, 8) =toto(1, 8)+5;
+if toto(1, 8) == []; then pause, end
+
diff --git a/modules/sparse/tests/nonreg_tests/bug_6401.dia.ref b/modules/sparse/tests/nonreg_tests/bug_6401.dia.ref
new file mode 100755
index 000000000..86d5a69d1
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6401.dia.ref
@@ -0,0 +1,31 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 6401 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6401
+//
+// <-- Short Description -->
+// chfact() returned a error
+a = [1,0,0;
+0,1,0;
+0,0,1];
+aa = sparse(a);
+ierr = execstr('chfact(aa)','errcatch');
+if ierr <> 0 then bugmes();quit;end
+xadj= [ 1. ; 1. ; 1. ; 1. ];
+adjncy = [];
+neqns = 3. ;
+ierr = execstr('[perm,invp,nofsub]=ordmmd(xadj,adjncy,neqns)','errcatch');
+if ierr <> 0 then bugmes();quit;end
+refperm = [ 3. ; 2. ; 1. ];
+refinvp = [ 3. ; 2. ; 1. ];
+refnofsub = 0;
+if refperm <> perm then bugmes();quit;end
+if refinvp <> invp then bugmes();quit;end
+if refnofsub <> nofsub then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_6401.tst b/modules/sparse/tests/nonreg_tests/bug_6401.tst
new file mode 100755
index 000000000..147dcdf78
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6401.tst
@@ -0,0 +1,39 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 6401 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6401
+//
+// <-- Short Description -->
+// chfact() returned a error
+
+a = [1,0,0;
+0,1,0;
+0,0,1];
+
+aa = sparse(a);
+ierr = execstr('chfact(aa)','errcatch');
+if ierr <> 0 then pause,end
+
+xadj= [ 1. ; 1. ; 1. ; 1. ];
+adjncy = [];
+neqns = 3. ;
+ierr = execstr('[perm,invp,nofsub]=ordmmd(xadj,adjncy,neqns)','errcatch');
+if ierr <> 0 then pause,end
+
+refperm = [ 3. ; 2. ; 1. ];
+refinvp = [ 3. ; 2. ; 1. ];
+refnofsub = 0;
+if refperm <> perm then pause,end
+if refinvp <> invp then pause,end
+if refnofsub <> nofsub then pause,end
+
+
diff --git a/modules/sparse/tests/nonreg_tests/bug_6412.dia.ref b/modules/sparse/tests/nonreg_tests/bug_6412.dia.ref
new file mode 100755
index 000000000..8650bc25d
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6412.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Yann COLLETTE <yann.collette@scilab.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 6412 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6412
+//
+// <-- Short Description -->
+// the function sp2adj was not working
+A = sprand(100,50,.05);
+[xadj,adjncy,anz]= sp2adj(A);
+[n,m]=size(A);
+p = adj2sp(xadj,adjncy,anz,[n,m]);
+if norm(A-p)~=0 then bugmes();quit;end
diff --git a/modules/sparse/tests/nonreg_tests/bug_6412.tst b/modules/sparse/tests/nonreg_tests/bug_6412.tst
new file mode 100755
index 000000000..341151f51
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6412.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Yann COLLETTE <yann.collette@scilab.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 6412 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6412
+//
+// <-- Short Description -->
+// the function sp2adj was not working
+
+A = sprand(100,50,.05);
+[xadj,adjncy,anz]= sp2adj(A);
+[n,m]=size(A);
+p = adj2sp(xadj,adjncy,anz,[n,m]);
+if norm(A-p)~=0 then pause, end
diff --git a/modules/sparse/tests/nonreg_tests/bug_6427.dia.ref b/modules/sparse/tests/nonreg_tests/bug_6427.dia.ref
new file mode 100755
index 000000000..f339a1018
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6427.dia.ref
@@ -0,0 +1,15 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 6427 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6427
+//
+// <-- Short Description -->
+// full([%T %F]) returns an error
+assert_checkequal(full([%T %F]), [%T %F]);
diff --git a/modules/sparse/tests/nonreg_tests/bug_6427.tst b/modules/sparse/tests/nonreg_tests/bug_6427.tst
new file mode 100755
index 000000000..40581fa8f
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6427.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 6427 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6427
+//
+// <-- Short Description -->
+// full([%T %F]) returns an error
+
+assert_checkequal(full([%T %F]), [%T %F]);
diff --git a/modules/sparse/tests/nonreg_tests/bug_6827.dia.ref b/modules/sparse/tests/nonreg_tests/bug_6827.dia.ref
new file mode 100755
index 000000000..8b8a94e9c
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6827.dia.ref
@@ -0,0 +1,30 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Yann COLLETTE <yann.collette@scilab.org>
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 6827 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6827
+//
+// <-- Short Description -->
+// the function spchol was returning a wrong error message if X is complex
+X=[3., 0., 0., 2., 0., 0., 2., 0., 2., 0., 0. ; ...
+ 0., 5., 4., 0., 0., 0., 0., 0., 0., 0., 0. ; ...
+ 0., 4., 5., 0., 0., 0., 0., 0., 0., 0., 0. ; ...
+ 2., 0., 0., 3., 0., 0., 2., 0., 2., 0., 0. ; ...
+ 0., 0., 0., 0. , 5., 0., 0., 0., 0., 0., 4. ; ...
+ 0., 0., 0., 0., 0., 4., 0., 3., 0., 3., 0. ; ...
+ 2., 0., 0., 2., 0., 0., 3., 0., 2., 0., 0. ; ...
+ 0., 0., 0., 0., 0., 3., 0., 4., 0., 3., 0. ; ...
+ 2., 0., 0., 2., 0., 0., 2., 0., 3., 0., 0. ; ...
+ 0., 0., 0., 0., 0., 3., 0., 3., 0., 4., 0. ; ...
+ 0., 0., 0., 0., 4., 0., 0., 0., 0., 0., 5.];
+X(1,1) = X(1,1) + %i;
+X = sparse(X);
+msgerr = msprintf(gettext("Wrong type for argument #%d: Real matrix expected.\n"), 1);
+assert_checkerror('[R,P] = spchol(X);', msgerr);
diff --git a/modules/sparse/tests/nonreg_tests/bug_6827.tst b/modules/sparse/tests/nonreg_tests/bug_6827.tst
new file mode 100755
index 000000000..815765d34
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_6827.tst
@@ -0,0 +1,36 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Yann COLLETTE <yann.collette@scilab.org>
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 6827 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6827
+//
+// <-- Short Description -->
+// the function spchol was returning a wrong error message if X is complex
+
+X=[3., 0., 0., 2., 0., 0., 2., 0., 2., 0., 0. ; ...
+ 0., 5., 4., 0., 0., 0., 0., 0., 0., 0., 0. ; ...
+ 0., 4., 5., 0., 0., 0., 0., 0., 0., 0., 0. ; ...
+ 2., 0., 0., 3., 0., 0., 2., 0., 2., 0., 0. ; ...
+ 0., 0., 0., 0. , 5., 0., 0., 0., 0., 0., 4. ; ...
+ 0., 0., 0., 0., 0., 4., 0., 3., 0., 3., 0. ; ...
+ 2., 0., 0., 2., 0., 0., 3., 0., 2., 0., 0. ; ...
+ 0., 0., 0., 0., 0., 3., 0., 4., 0., 3., 0. ; ...
+ 2., 0., 0., 2., 0., 0., 2., 0., 3., 0., 0. ; ...
+ 0., 0., 0., 0., 0., 3., 0., 3., 0., 4., 0. ; ...
+ 0., 0., 0., 0., 4., 0., 0., 0., 0., 0., 5.];
+
+X(1,1) = X(1,1) + %i;
+X = sparse(X);
+
+msgerr = msprintf(gettext("Wrong type for argument #%d: Real matrix expected.\n"), 1);
+assert_checkerror('[R,P] = spchol(X);', msgerr);
+
diff --git a/modules/sparse/tests/nonreg_tests/bug_8511.dia.ref b/modules/sparse/tests/nonreg_tests/bug_8511.dia.ref
new file mode 100755
index 000000000..1c040989c
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_8511.dia.ref
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 8511 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8511
+//
+// <-- Short Description -->
+// sprand uses rand and grand functions, and internal state of the random number
+// generator is changed
+grand("setsd",0);
+state1=rand("seed");
+A = sprand(5,5,.05);
+state2=rand("seed");
+assert_checkequal(state1,state2);
diff --git a/modules/sparse/tests/nonreg_tests/bug_8511.tst b/modules/sparse/tests/nonreg_tests/bug_8511.tst
new file mode 100755
index 000000000..9d95384c7
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_8511.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 8511 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8511
+//
+// <-- Short Description -->
+// sprand uses rand and grand functions, and internal state of the random number
+// generator is changed
+
+grand("setsd",0);
+state1=rand("seed");
+A = sprand(5,5,.05);
+state2=rand("seed");
+assert_checkequal(state1,state2);
diff --git a/modules/sparse/tests/nonreg_tests/bug_9780.dia.ref b/modules/sparse/tests/nonreg_tests/bug_9780.dia.ref
new file mode 100755
index 000000000..dfcc47937
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_9780.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 9780 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9780
+//
+// <-- Short Description -->
+// gmres does not run with complex systems
+n_eqns=3;
+tol=1.e-6;
+rstr=n_eqns;
+maxi=5000;
+M=eye(n_eqns,n_eqns)+%i*eye(n_eqns,n_eqns);
+x0=zeros(n_eqns,1);
+A=rand(n_eqns,n_eqns)+%i*rand(n_eqns,n_eqns);
+b=rand(n_eqns,1);
+assert_checktrue(execstr("gmres(A,b,rstr,tol,maxi,M,x0)-[0.4336542-0.8855630*%i;-0.9532019+0.9207990*%i;0.5351043-0.3759549*%i]","errcatch") == 0);
diff --git a/modules/sparse/tests/nonreg_tests/bug_9780.tst b/modules/sparse/tests/nonreg_tests/bug_9780.tst
new file mode 100755
index 000000000..c5fc6499e
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_9780.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 9780 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9780
+//
+// <-- Short Description -->
+// gmres does not run with complex systems
+
+n_eqns=3;
+tol=1.e-6;
+rstr=n_eqns;
+maxi=5000;
+M=eye(n_eqns,n_eqns)+%i*eye(n_eqns,n_eqns);
+x0=zeros(n_eqns,1);
+A=rand(n_eqns,n_eqns)+%i*rand(n_eqns,n_eqns);
+b=rand(n_eqns,1);
+assert_checktrue(execstr("gmres(A,b,rstr,tol,maxi,M,x0)-[0.4336542-0.8855630*%i;-0.9532019+0.9207990*%i;0.5351043-0.3759549*%i]","errcatch") == 0);
diff --git a/modules/sparse/tests/nonreg_tests/bug_9999.dia.ref b/modules/sparse/tests/nonreg_tests/bug_9999.dia.ref
new file mode 100755
index 000000000..01c9e5c24
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_9999.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9999 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9999
+//
+// <-- Short Description -->
+// The sparse() and ^ operators mix could fail.
+A=[1 2 ; 3 4];
+res = sparse(A)^0 == sparse(A^0);
+assert_checkequal(res, sparse([%t %t ; %t %t]));
diff --git a/modules/sparse/tests/nonreg_tests/bug_9999.tst b/modules/sparse/tests/nonreg_tests/bug_9999.tst
new file mode 100755
index 000000000..fcf095460
--- /dev/null
+++ b/modules/sparse/tests/nonreg_tests/bug_9999.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9999 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9999
+//
+// <-- Short Description -->
+// The sparse() and ^ operators mix could fail.
+
+A=[1 2 ; 3 4];
+res = sparse(A)^0 == sparse(A^0);
+
+assert_checkequal(res, sparse([%t %t ; %t %t]));
diff --git a/modules/sparse/tests/unit_tests/adj2sp.dia.ref b/modules/sparse/tests/unit_tests/adj2sp.dia.ref
new file mode 100755
index 000000000..f386117a3
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/adj2sp.dia.ref
@@ -0,0 +1,57 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// Check the adjacency representation of a simple matrix
+xadj = [1 3 4 7 9 11]';
+iadj = [3 5 3 1 2 4 3 5 1 4]';
+v = [1 2 3 4 5 6 7 8 9 10]';
+B=adj2sp(xadj,iadj,v);
+A = [
+0 0 4 0 9
+0 0 5 0 0
+1 3 0 7 0
+0 0 6 0 10
+2 0 0 8 0
+];
+C=sparse(A);
+assert_checkequal ( and(B==C) , %t );
+//
+// Check the adjacency representation of a simple matrix
+xadj = [1 2 3 4 5 5 6 6 7 8 9]';
+iadj = [2 5 2 3 1 2 7 6]';
+v = [3 7 5 3 6 5 2 3]';
+C=adj2sp(xadj,iadj,v);
+A = [
+0 0 0 0 0 6 0 0 0 0
+3 0 5 0 0 0 0 5 0 0
+0 0 0 3 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0
+0 7 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3
+0 0 0 0 0 0 0 0 2 0
+];
+B=sparse(A);
+assert_checkequal ( and(B==C) , %t );
+//
+// Test the C=adj2sp(xadj,iadj,v,mn) calling sequence
+xadj = [1 2 3 4 5 5 6 6 7 8 9]';
+iadj = [2 5 2 3 1 2 7 6]';
+v = [3 7 5 3 6 5 2 3]';
+mn=[7 10];
+C=adj2sp(xadj,iadj,v,mn);
+A = [
+0 0 0 0 0 6 0 0 0 0
+3 0 5 0 0 0 0 5 0 0
+0 0 0 3 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0
+0 7 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3
+0 0 0 0 0 0 0 0 2 0
+];
+B=sparse(A);
+assert_checkequal ( and(B==C) , %t );
diff --git a/modules/sparse/tests/unit_tests/adj2sp.tst b/modules/sparse/tests/unit_tests/adj2sp.tst
new file mode 100755
index 000000000..0961dec16
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/adj2sp.tst
@@ -0,0 +1,59 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+
+//
+// Check the adjacency representation of a simple matrix
+xadj = [1 3 4 7 9 11]';
+iadj = [3 5 3 1 2 4 3 5 1 4]';
+v = [1 2 3 4 5 6 7 8 9 10]';
+B=adj2sp(xadj,iadj,v);
+A = [
+0 0 4 0 9
+0 0 5 0 0
+1 3 0 7 0
+0 0 6 0 10
+2 0 0 8 0
+];
+C=sparse(A);
+assert_checkequal ( and(B==C) , %t );
+//
+// Check the adjacency representation of a simple matrix
+xadj = [1 2 3 4 5 5 6 6 7 8 9]';
+iadj = [2 5 2 3 1 2 7 6]';
+v = [3 7 5 3 6 5 2 3]';
+C=adj2sp(xadj,iadj,v);
+A = [
+0 0 0 0 0 6 0 0 0 0
+3 0 5 0 0 0 0 5 0 0
+0 0 0 3 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0
+0 7 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3
+0 0 0 0 0 0 0 0 2 0
+];
+B=sparse(A);
+assert_checkequal ( and(B==C) , %t );
+//
+// Test the C=adj2sp(xadj,iadj,v,mn) calling sequence
+xadj = [1 2 3 4 5 5 6 6 7 8 9]';
+iadj = [2 5 2 3 1 2 7 6]';
+v = [3 7 5 3 6 5 2 3]';
+mn=[7 10];
+C=adj2sp(xadj,iadj,v,mn);
+A = [
+0 0 0 0 0 6 0 0 0 0
+3 0 5 0 0 0 0 5 0 0
+0 0 0 3 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0
+0 7 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3
+0 0 0 0 0 0 0 0 2 0
+];
+B=sparse(A);
+assert_checkequal ( and(B==C) , %t );
+
diff --git a/modules/sparse/tests/unit_tests/conjgrad.dia.ref b/modules/sparse/tests/unit_tests/conjgrad.dia.ref
new file mode 100755
index 000000000..6708187f6
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad.dia.ref
@@ -0,0 +1,349 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//-------------------------------------------------------
+// PCG
+// Test with 2 input arguments and all output arguments
+A = [10 1; 1 10];
+b = [11; 11];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg");
+xexpected = [1; 1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+A2 = [100 1; 1 10];
+b2 = [101; 11];
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="pcg", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="pcg", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+A3 = [100 1; 1 0.0101];
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="pcg", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "pcg", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+b3 = [0; 0];
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "pcg");
+xexpected2 = [0; 0];
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+A4 = [
+1. 0.5000000000000001110223 0.3333333333333334258519 0.2500000000000000555112 0.2000000000000000666134
+0.4999999999999982236432 0.3333333333333319825620 0.2499999999999988897770 0.1999999999999990951682 0.1666666666666659080143
+0.3333333333333320380731 0.2499999999999990563104 0.1999999999999992617017 0.1666666666666660745477 0.1428571428571423496123
+0.2499999999999990285549 0.1999999999999993449684 0.1666666666666661855700 0.1428571428571424883902 0.1249999999999996808109
+0.1999999999999991506794 0.1666666666666660745477 0.1428571428571424328791 0.1249999999999996669331 0.11111111111111082739
+];
+b4 = ones(5, 1);
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "pcg", %M=M, tol=%eps, maxIter=3);
+expected = [
+5
+-120
+630
+-1120
+630 ];
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+C = [
+1. 0.5000000000000001110223 0.3333333333333334258519 0.2500000000000000555112 0.2000000000000000666134
+0. 0.288675134594810367528 0.2886751345948112557060 0.2598076211353305131624 0.2309401076758494653074
+0. 0. 0.0745355992499937836104 0.1118033988749897594817 0.1277753129999876502421
+0. 0. 0. 0.0188982236504644136865 0.0377964473009222076683
+0. 0. 0. 0. 0.0047619047619250291087
+];
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "pcg", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Well-conditionned problem
+A5 = [ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b5 = ones(10, 1);
+[x, fail, err, iter, res] = conjgrad(A5, b5, "pcg", 1d-12, 10);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+//-------------------------------------------------------
+// CGS
+// Test with 2 input arguments and all output arguments
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs");
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="cgs", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="cgs", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="cgs", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "cgs", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "cgs");
+xexpected2 = [0; 0];
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "cgs", %M=M, tol=%eps, maxIter=3);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "cgs", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+// Well-conditionned problem with a nonsymmetric matrix (top-right element)
+A5 = [ 94 0 0 0 0 28 0 0 32 20
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+[x, fail, err, iter, res] = conjgrad(A5, b5, "cgs", 1d-12, 15);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 11 );
+//-------------------------------------------------------
+// BICG
+// Test with 2 input arguments and all output arguments
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg");
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicg", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicg", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="bicg", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "bicg", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "bicg");
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicg", %M=M, tol=%eps, maxIter=3);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicg", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 8 );
+// Well-conditionned problem with a nonsymmetric matrix (top-right element)
+[x, fail, err, iter, res] = conjgrad(A5, b5, "bicg", 1d-12, 15);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+//-------------------------------------------------------
+// BICGSTAB
+// Test with 2 input arguments and all output arguments
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab");
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicgstab", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicgstab", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="bicgstab", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "bicgstab", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "bicgstab");
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicgstab", %M=M, tol=%eps, maxIter=3);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 1 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicgstab", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 9 );
+// Well-conditionned problem with a nonsymmetric matrix (top-right element)
+[x, fail, err, iter, res] = conjgrad(A5, b5, "bicgstab", 1d-12, 15);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+//-------------------------------------------------------
+// Error checks
+refMsg = msprintf(_("%s: Wrong number of input arguments: %d to %d expected.\n"),"conjgrad",2,7);
+assert_checkerror("conjgrad(A);", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d.\n"),"conjgrad",1);
+assert_checkerror("conjgrad(""string"", b);", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Square matrix expected.\n"),"conjgrad",1);
+assert_checkerror("conjgrad(ones(5, 4), b);", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"),"conjgrad",2);
+assert_checkerror("conjgrad(A, ""string"");", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Column vector expected.\n"),"conjgrad",2);
+assert_checkerror("conjgrad(A, A);", refMsg);
+refMsg = msprintf(_("%s: Wrong size for input argument #%d: Same size as input argument #%d expected.\n"),"conjgrad",2,1);
+assert_checkerror("conjgrad(A, b4);", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Single String expected.\n"),"conjgrad",3);
+assert_checkerror("conjgrad(A, b, 1d-12, 15);", refMsg);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: %s, %s, %s or %s expected.\n"),"conjgrad",3,"pcg","cgs","bicg","bicgstab");
+assert_checkerror("conjgrad(A, b, ""gmres"", 1d-12, 15);", refMsg);
diff --git a/modules/sparse/tests/unit_tests/conjgrad.tst b/modules/sparse/tests/unit_tests/conjgrad.tst
new file mode 100755
index 000000000..6039e2a36
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad.tst
@@ -0,0 +1,368 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+
+//-------------------------------------------------------
+// PCG
+
+// Test with 2 input arguments and all output arguments
+A = [10 1; 1 10];
+b = [11; 11];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg");
+xexpected = [1; 1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "pcg", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+A2 = [100 1; 1 10];
+b2 = [101; 11];
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="pcg", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="pcg", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+A3 = [100 1; 1 0.0101];
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="pcg", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "pcg", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+b3 = [0; 0];
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "pcg");
+xexpected2 = [0; 0];
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+A4 = [
+1. 0.5000000000000001110223 0.3333333333333334258519 0.2500000000000000555112 0.2000000000000000666134
+0.4999999999999982236432 0.3333333333333319825620 0.2499999999999988897770 0.1999999999999990951682 0.1666666666666659080143
+0.3333333333333320380731 0.2499999999999990563104 0.1999999999999992617017 0.1666666666666660745477 0.1428571428571423496123
+0.2499999999999990285549 0.1999999999999993449684 0.1666666666666661855700 0.1428571428571424883902 0.1249999999999996808109
+0.1999999999999991506794 0.1666666666666660745477 0.1428571428571424328791 0.1249999999999996669331 0.11111111111111082739
+];
+b4 = ones(5, 1);
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "pcg", %M=M, tol=%eps, maxIter=3);
+expected = [
+5
+-120
+630
+-1120
+630 ];
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+C = [
+1. 0.5000000000000001110223 0.3333333333333334258519 0.2500000000000000555112 0.2000000000000000666134
+0. 0.288675134594810367528 0.2886751345948112557060 0.2598076211353305131624 0.2309401076758494653074
+0. 0. 0.0745355992499937836104 0.1118033988749897594817 0.1277753129999876502421
+0. 0. 0. 0.0188982236504644136865 0.0377964473009222076683
+0. 0. 0. 0. 0.0047619047619250291087
+];
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "pcg", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Well-conditionned problem
+A5 = [ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b5 = ones(10, 1);
+[x, fail, err, iter, res] = conjgrad(A5, b5, "pcg", 1d-12, 10);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+
+//-------------------------------------------------------
+// CGS
+
+// Test with 2 input arguments and all output arguments
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs");
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "cgs", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="cgs", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="cgs", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="cgs", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "cgs", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "cgs");
+xexpected2 = [0; 0];
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "cgs", %M=M, tol=%eps, maxIter=3);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "cgs", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+// Well-conditionned problem with a nonsymmetric matrix (top-right element)
+A5 = [ 94 0 0 0 0 28 0 0 32 20
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+[x, fail, err, iter, res] = conjgrad(A5, b5, "cgs", 1d-12, 15);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 11 );
+
+//-------------------------------------------------------
+// BICG
+
+// Test with 2 input arguments and all output arguments
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg");
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicg", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicg", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicg", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="bicg", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "bicg", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "bicg");
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicg", %M=M, tol=%eps, maxIter=3);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 2 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicg", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 8 );
+// Well-conditionned problem with a nonsymmetric matrix (top-right element)
+[x, fail, err, iter, res] = conjgrad(A5, b5, "bicg", 1d-12, 15);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+
+//-------------------------------------------------------
+// BICGSTAB
+
+// Test with 2 input arguments and all output arguments
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab");
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// Test with 3 input arguments and all output arguments
+tol = 100*%eps;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checktrue ( err <= tol);
+// Test with 4 input arguments and all output arguments
+maxit = 10;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit);
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// Test with 5 input arguments and all output arguments
+M1 = [1 0; 0 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit, M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 6 input arguments and all output arguments
+M2 = M1;
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit, M1, M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with 7 input arguments and all output arguments
+x0 = [1; 1];
+[xcomputed, flag, err, iter, res] = conjgrad(A, b, "bicgstab", tol, maxit, M1, M2, x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test with non-positional input parameters so that 0 iteration can happen
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicgstab", maxIter=0);
+assert_checkequal ( iter , 0 );
+// Test with non-positional input parameters so that 1 iteration is sufficient
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, method="bicgstab", tol=0.1);
+assert_checkequal ( iter , 1 );
+// Test with non-positional input parameters so that pre-conditionning is necessary
+M = A3;
+[xcomputed, flag, err, iter, res] = conjgrad(A3, b2, method="bicgstab", tol, maxit,%M=M, maxIter=5, tol=%eps);
+assert_checkequal ( flag , 0 );
+// Test with non-positional input parameters so that good initialization generates 0 iterations
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b2, "bicgstab", x0=[1;1]);
+assert_checkequal ( iter , 0 );
+// Test the special case where b = 0
+[xcomputed, flag, err, iter, res] = conjgrad(A2, b3, "bicgstab");
+assert_checkalmostequal ( xcomputed , xexpected2 , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// Try a hard case where preconditionning is necessary
+// This is the Hilbert 5x5 matrix : A = 1/(testmatrix("hilb",5))
+M = A4;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicgstab", %M=M, tol=%eps, maxIter=3);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 1 );
+// Try a difficult case where preconditionning is necessary
+// Use two pre-conditionning matrices.
+// This is the Cholesky factorization of the matrix A : C = chol(A)
+M1 = C';
+M2 = C;
+[xcomputed, flag, err, iter, res] = conjgrad(A4, b4, "bicgstab", %M=M1, %M2=M2, tol=%eps, maxIter=10);
+assert_checkalmostequal ( xcomputed , expected, 1.e8*%eps );
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 9 );
+// Well-conditionned problem with a nonsymmetric matrix (top-right element)
+[x, fail, err, iter, res] = conjgrad(A5, b5, "bicgstab", 1d-12, 15);
+assert_checkequal ( flag , 0 );
+assert_checkequal ( iter , 10 );
+
+
+
+//-------------------------------------------------------
+// Error checks
+
+refMsg = msprintf(_("%s: Wrong number of input arguments: %d to %d expected.\n"),"conjgrad",2,7);
+assert_checkerror("conjgrad(A);", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type for input argument #%d.\n"),"conjgrad",1);
+assert_checkerror("conjgrad(""string"", b);", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Square matrix expected.\n"),"conjgrad",1);
+assert_checkerror("conjgrad(ones(5, 4), b);", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"),"conjgrad",2);
+assert_checkerror("conjgrad(A, ""string"");", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Column vector expected.\n"),"conjgrad",2);
+assert_checkerror("conjgrad(A, A);", refMsg);
+
+refMsg = msprintf(_("%s: Wrong size for input argument #%d: Same size as input argument #%d expected.\n"),"conjgrad",2,1);
+assert_checkerror("conjgrad(A, b4);", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Single String expected.\n"),"conjgrad",3);
+assert_checkerror("conjgrad(A, b, 1d-12, 15);", refMsg);
+
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: %s, %s, %s or %s expected.\n"),"conjgrad",3,"pcg","cgs","bicg","bicgstab");
+assert_checkerror("conjgrad(A, b, ""gmres"", 1d-12, 15);", refMsg);
diff --git a/modules/sparse/tests/unit_tests/conjgrad_function.dia.ref b/modules/sparse/tests/unit_tests/conjgrad_function.dia.ref
new file mode 100755
index 000000000..518691729
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_function.dia.ref
@@ -0,0 +1,68 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//------------------------------------------------------------------
+// PCG
+// Numerical tests
+// Case where A is given as a function computing the right-hand side
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+function y=Afunction(x)
+ mymatrix=[ 94 0 0 0 0 28 0 0 32 0
+ 0 59 13 5 0 0 0 10 0 0
+ 0 13 72 34 2 0 0 0 0 65
+ 0 5 34 114 0 0 0 0 0 55
+ 0 0 2 0 70 0 28 32 12 0
+ 28 0 0 0 0 87 20 0 33 0
+ 0 0 0 0 28 20 71 39 0 0
+ 0 10 0 0 32 0 39 46 8 0
+ 32 0 0 0 12 33 0 8 82 11
+ 0 0 65 55 0 0 0 0 11 100];
+ y=mymatrix*x
+endfunction
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// CGS
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>11 then bugmes();quit;end
+if err > 100**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// BICG
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// BICGSTAB
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"bicgstab");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10000**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>8 then bugmes();quit;end
+if err > 1000**3*%eps then bugmes();quit;end
diff --git a/modules/sparse/tests/unit_tests/conjgrad_function.tst b/modules/sparse/tests/unit_tests/conjgrad_function.tst
new file mode 100755
index 000000000..d6dadd462
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_function.tst
@@ -0,0 +1,76 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+
+//------------------------------------------------------------------
+// PCG
+
+// Numerical tests
+// Case where A is given as a function computing the right-hand side
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+function y=Afunction(x)
+ mymatrix=[ 94 0 0 0 0 28 0 0 32 0
+ 0 59 13 5 0 0 0 10 0 0
+ 0 13 72 34 2 0 0 0 0 65
+ 0 5 34 114 0 0 0 0 0 55
+ 0 0 2 0 70 0 28 32 12 0
+ 28 0 0 0 0 87 20 0 33 0
+ 0 0 0 0 28 20 71 39 0 0
+ 0 10 0 0 32 0 39 46 8 0
+ 32 0 0 0 12 33 0 8 82 11
+ 0 0 65 55 0 0 0 0 11 100];
+ y=mymatrix*x
+endfunction
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// CGS
+
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>11 then pause,end
+if err > 100**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// BICG
+
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// BICGSTAB
+
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(Afunction,b,"bicgstab");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10000**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>8 then pause,end
+if err > 1000**3*%eps then pause,end
diff --git a/modules/sparse/tests/unit_tests/conjgrad_list.dia.ref b/modules/sparse/tests/unit_tests/conjgrad_list.dia.ref
new file mode 100755
index 000000000..ac27aa75e
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_list.dia.ref
@@ -0,0 +1,103 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//------------------------------------------------------------------
+// PCG
+// Numerical tests
+// Case where A is given as a function computing the right-hand side
+mymatrix=[ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+function y=Atimesx(x,mymatrix)
+ y=mymatrix*x
+endfunction
+// With the default 10 iterations, the algorithm performs well
+Alist = list(Atimesx,mymatrix)
+ Alist =
+
+
+ Alist(1)
+
+[y]=function(x,mymatrix)
+
+ Alist(2)
+
+
+ column 1 to 9
+
+ 94. 0. 0. 0. 0. 28. 0. 0. 32.
+ 0. 59. 13. 5. 0. 0. 0. 10. 0.
+ 0. 13. 72. 34. 2. 0. 0. 0. 0.
+ 0. 5. 34. 114. 0. 0. 0. 0. 0.
+ 0. 0. 2. 0. 70. 0. 28. 32. 12.
+ 28. 0. 0. 0. 0. 87. 20. 0. 33.
+ 0. 0. 0. 0. 28. 20. 71. 39. 0.
+ 0. 10. 0. 0. 32. 0. 39. 46. 8.
+ 32. 0. 0. 0. 12. 33. 0. 8. 82.
+ 0. 0. 65. 55. 0. 0. 0. 0. 11.
+
+ column 10
+
+ 0.
+ 0.
+ 65.
+ 55.
+ 0.
+ 0.
+ 0.
+ 0.
+ 11.
+ 100.
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// CGS
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>11 then bugmes();quit;end
+if err > 100**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// BICG
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// BICGSTAB
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"bicgstab");
+if norm(xcomputed-xexpected)>10000**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>8 then bugmes();quit;end
+if err > 1000**3*%eps then bugmes();quit;end
diff --git a/modules/sparse/tests/unit_tests/conjgrad_list.tst b/modules/sparse/tests/unit_tests/conjgrad_list.tst
new file mode 100755
index 000000000..e1c1af719
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_list.tst
@@ -0,0 +1,76 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+
+//------------------------------------------------------------------
+// PCG
+
+// Numerical tests
+// Case where A is given as a function computing the right-hand side
+mymatrix=[ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+function y=Atimesx(x,mymatrix)
+ y=mymatrix*x
+endfunction
+// With the default 10 iterations, the algorithm performs well
+Alist = list(Atimesx,mymatrix)
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// CGS
+
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>11 then pause,end
+if err > 100**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// BICG
+
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// BICGSTAB
+
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(Alist,b,"bicgstab");
+if norm(xcomputed-xexpected)>10000**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>8 then pause,end
+if err > 1000**3*%eps then pause,end
diff --git a/modules/sparse/tests/unit_tests/conjgrad_numerical.dia.ref b/modules/sparse/tests/unit_tests/conjgrad_numerical.dia.ref
new file mode 100755
index 000000000..bacd6d08d
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_numerical.dia.ref
@@ -0,0 +1,108 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//------------------------------------------------------------------
+// PCG
+// Numerical tests
+//Well conditionned problem
+A=[ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+// With a tolerance of 1.e-3, there are 5 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"pcg",tol);
+if fail<>0 then bugmes();quit;end
+if iter>10 then bugmes();quit;end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"pcg",tol,maxIter);
+if fail<>1 then bugmes();quit;end
+if iter<>maxIter then bugmes();quit;end
+//------------------------------------------------------------------
+// CGS
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>11 then bugmes();quit;end
+if err > 100**3*%eps then bugmes();quit;end
+// With a tolerance of 1.e-3, there are 3 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"cgs",tol);
+if fail<>0 then bugmes();quit;end
+if iter>10 then bugmes();quit;end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"cgs",tol,maxIter);
+if fail<>1 then bugmes();quit;end
+if iter<>maxIter then bugmes();quit;end
+//------------------------------------------------------------------
+// BICG
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+// With a tolerance of 1.e-3, there are 5 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicg",tol);
+if fail<>0 then bugmes();quit;end
+if iter>10 then bugmes();quit;end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicg",tol,maxIter);
+if fail<>1 then bugmes();quit;end
+if iter<>maxIter then bugmes();quit;end
+//------------------------------------------------------------------
+// BICGSTAB
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicgstab");
+if norm(xcomputed-xexpected)>10000**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>8 then bugmes();quit;end
+if err > 1000**3*%eps then bugmes();quit;end
+// With a tolerance of 1.e-3, there are 3 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicgstab",tol);
+if fail<>0 then bugmes();quit;end
+if iter>10 then bugmes();quit;end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicgstab",tol,maxIter);
+if fail<>1 then bugmes();quit;end
+if iter<>maxIter then bugmes();quit;end
diff --git a/modules/sparse/tests/unit_tests/conjgrad_numerical.tst b/modules/sparse/tests/unit_tests/conjgrad_numerical.tst
new file mode 100755
index 000000000..a1e93135d
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_numerical.tst
@@ -0,0 +1,116 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+
+//------------------------------------------------------------------
+// PCG
+
+// Numerical tests
+//Well conditionned problem
+A=[ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+// With a tolerance of 1.e-3, there are 5 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"pcg",tol);
+if fail<>0 then pause,end
+if iter>10 then pause,end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"pcg",tol,maxIter);
+if fail<>1 then pause,end
+if iter<>maxIter then pause,end
+
+//------------------------------------------------------------------
+// CGS
+
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>11 then pause,end
+if err > 100**3*%eps then pause,end
+// With a tolerance of 1.e-3, there are 3 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"cgs",tol);
+if fail<>0 then pause,end
+if iter>10 then pause,end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"cgs",tol,maxIter);
+if fail<>1 then pause,end
+if iter<>maxIter then pause,end
+
+//------------------------------------------------------------------
+// BICG
+
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+// With a tolerance of 1.e-3, there are 5 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicg",tol);
+if fail<>0 then pause,end
+if iter>10 then pause,end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicg",tol,maxIter);
+if fail<>1 then pause,end
+if iter<>maxIter then pause,end
+
+//------------------------------------------------------------------
+// BICGSTAB
+
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicgstab");
+if norm(xcomputed-xexpected)>10000**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>8 then pause,end
+if err > 1000**3*%eps then pause,end
+// With a tolerance of 1.e-3, there are 3 iterations and the status is "success"
+tol=1.d-3;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicgstab",tol);
+if fail<>0 then pause,end
+if iter>10 then pause,end
+// With a tolerance of %eps but only 5 iterations allowed, the status is "fail"
+tol=%eps;
+maxIter = 5;
+[xcomputed, fail, err, iter, res]=conjgrad(A,b,"bicgstab",tol,maxIter);
+if fail<>1 then pause,end
+if iter<>maxIter then pause,end
diff --git a/modules/sparse/tests/unit_tests/conjgrad_sparse.dia.ref b/modules/sparse/tests/unit_tests/conjgrad_sparse.dia.ref
new file mode 100755
index 000000000..491bc2407
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_sparse.dia.ref
@@ -0,0 +1,65 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//------------------------------------------------------------------
+// PCG
+// Numerical tests
+// Case where A is sparse
+A=[ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+Asparse = sparse(A);
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// CGS
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>11 then bugmes();quit;end
+if err > 100**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// BICG
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>10 then bugmes();quit;end
+if err > 10**3*%eps then bugmes();quit;end
+//------------------------------------------------------------------
+// BICGSTAB
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"bicgstab");
+if norm(xcomputed-xexpected)>10000**3*%eps then bugmes();quit;end
+if fail<>0 then bugmes();quit;end
+if iter<>8 then bugmes();quit;end
+if err > 1000**3*%eps then bugmes();quit;end
diff --git a/modules/sparse/tests/unit_tests/conjgrad_sparse.tst b/modules/sparse/tests/unit_tests/conjgrad_sparse.tst
new file mode 100755
index 000000000..dfe585baa
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/conjgrad_sparse.tst
@@ -0,0 +1,73 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added cgs, bicg and bicgstab
+// Copyright (C) 2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+
+//------------------------------------------------------------------
+// PCG
+
+// Numerical tests
+// Case where A is sparse
+A=[ 94 0 0 0 0 28 0 0 32 0
+0 59 13 5 0 0 0 10 0 0
+0 13 72 34 2 0 0 0 0 65
+0 5 34 114 0 0 0 0 0 55
+0 0 2 0 70 0 28 32 12 0
+28 0 0 0 0 87 20 0 33 0
+0 0 0 0 28 20 71 39 0 0
+0 10 0 0 32 0 39 46 8 0
+32 0 0 0 12 33 0 8 82 11
+0 0 65 55 0 0 0 0 11 100];
+b = [154.
+87.
+186.
+208.
+144.
+168.
+158.
+135.
+178.
+231.];
+Asparse = sparse(A);
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"pcg");
+xexpected=ones(10,1);
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// CGS
+
+// CGS needs 11 iterations to converge
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"cgs",maxIter=11);
+if norm(xcomputed-xexpected)>100**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>11 then pause,end
+if err > 100**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// BICG
+
+// With the default 10 iterations, the algorithm performs well
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"bicg");
+if norm(xcomputed-xexpected)>10**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>10 then pause,end
+if err > 10**3*%eps then pause,end
+
+//------------------------------------------------------------------
+// BICGSTAB
+
+// BICGSTAB only needs 8 iterations to converge to the required tol, but is less accurate on arrival.
+[xcomputed, fail, err, iter, res]=conjgrad(Asparse,b,"bicgstab");
+if norm(xcomputed-xexpected)>10000**3*%eps then pause,end
+if fail<>0 then pause,end
+if iter<>8 then pause,end
+if err > 1000**3*%eps then pause,end
diff --git a/modules/sparse/tests/unit_tests/lsparse.dia.ref b/modules/sparse/tests/unit_tests/lsparse.dia.ref
new file mode 100755
index 000000000..2947beae8
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/lsparse.dia.ref
@@ -0,0 +1,382 @@
+// Copyright INRIA
+mode(5)
+lines(0)
+zer=sparse([],[],[6,6]);
+//
+//
+//-------------------------------------------------------------
+//test des primitives sparse, full
+//-------------------------------------------------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[5 6]);B=full(b);
+if or(full(a<>0)<>(A<>0)) then bugmes();quit;end
+if or(full(b<>0)<>(B<>0)) then bugmes();quit;end
+if or(full(b>0)<>(B>0)) then bugmes();quit;end
+if or(full(b<0)<>(B<0)) then bugmes();quit;end
+if or(full(a>100)<>(A>100)) then bugmes();quit;end
+if sparse(B>0)<>(b>0) then bugmes();quit;end
+if sparse(B<0)<>(b<0) then bugmes();quit;end
+//-------------------------------------------------------------
+//test de la primitives spget
+//-------------------------------------------------------------
+//-----------------------------------------------
+// | and & tests
+//-----------------------------------------------
+// -- sparse sparse
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if (a|b)<>(A|B) then bugmes();quit;end
+if (a&b)<>(A&B) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|b)<>(A|B) then bugmes();quit;end
+if (a&b)<>(A&B) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+if (a|b)<>(A|B) then bugmes();quit;end
+if (a&b)<>(A&B) then bugmes();quit;end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|b)<>(A|B) then bugmes();quit;end
+if (a&b)<>(A&B) then bugmes();quit;end
+// -- sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if (a|B)<>(A|B) then bugmes();quit;end
+if (a&B)<>(A&B) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|B)<>(A|B) then bugmes();quit;end
+if (a&B)<>(A&B) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+if (a|B)<>(A|B) then bugmes();quit;end
+if (a&B)<>(A&B) then bugmes();quit;end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|B)<>(A|B) then bugmes();quit;end
+if (a&B)<>(A&B) then bugmes();quit;end
+// -- full sparse
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if (A|b)<>(A|B) then bugmes();quit;end
+if (A&b)<>(A&B) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (A|b)<>(A|B) then bugmes();quit;end
+if (A&b)<>(A&B) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+if (A|b)<>(A|B) then bugmes();quit;end
+if (A&b)<>(A&B) then bugmes();quit;end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (A|b)<>(A|B) then bugmes();quit;end
+if (A&b)<>(A&B) then bugmes();quit;end
+// ----------------------------------------------------------
+// test de la transposition
+//-----------------------------------------------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if or(full(a')<>full(a)') then bugmes();quit;end
+if or(full(b')<>full(b)') then bugmes();quit;end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if or(full(a')<>full(a)') then bugmes();quit;end
+if or(full(b')<>full(b)') then bugmes();quit;end
+// ----------------------------------------------------------
+// test des concatenation
+//-----------------------------------------------------------
+// sparse sparse
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if or(full([a])<>A) then bugmes();quit;end
+if or(full([a b])<>[A B]) then bugmes();quit;end
+if or(full([a;b])<>[A;B]) then bugmes();quit;end
+if or(full([a []])<>A) then bugmes();quit;end
+if or(full([a;[]])<>A) then bugmes();quit;end
+// sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if or(full([a B])<>[A B]) then bugmes();quit;end
+if or(full([a;B])<>[A;B]) then bugmes();quit;end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if or(full([a B])<>[A B]) then bugmes();quit;end
+if or(full([a;B])<>[A;B]) then bugmes();quit;end
+// full sparse
+if or(full([A b])<>[A B]) then bugmes();quit;end
+if or(full([A;b])<>[A;B]) then bugmes();quit;end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if or(full([A b])<>[A B]) then bugmes();quit;end
+if or(full([B;b])<>[A;B]) then bugmes();quit;end
+// ----------------------------------------------------------
+// test des extractions
+//-----------------------------------------------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;af=full(a);
+if or(full(a(1,3))<>af(1,3)) then bugmes();quit;end
+if or(full(a(1,4))<>af(1,4)) then bugmes();quit;end
+if or(full(a(1,:))<>af(1,:)) then bugmes();quit;end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);v=v<>0;vf=full(v);
+if or(full(v(:))<>vf(:)) then bugmes();quit;end
+if or(full(v(3:4))<>vf(3:4)) then bugmes();quit;end
+if or(full(v([1 5]))<>vf([1 5])) then bugmes();quit;end
+if or(full(v([4 3]))<>vf([4 3])) then bugmes();quit;end
+if or(full(v([4 4]))<>vf([4 4])) then bugmes();quit;end
+if or(full(v([1 1]))<>vf([1 1])) then bugmes();quit;end
+v=v';vf=vf';
+if or(full(v(:))<>vf(:)) then bugmes();quit;end
+if or(full(v(3:4))<>vf(3:4)) then bugmes();quit;end
+if or(full(v([1 5]))<>vf([1 5])) then bugmes();quit;end
+if or(full(v([4 3]))<>vf([4 3])) then bugmes();quit;end
+if or(full(v([4 4]))<>vf([4 4])) then bugmes();quit;end
+if or(full(v([1 1]))<>vf([1 1])) then bugmes();quit;end
+// full line insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;af=full(a);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);vt=vt<>0;
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6])<>0;
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6])<>0;
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+// insert zero vector
+vt=sparse([],[],[1,6])<>0;
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);b=b<>0;
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);b=b<>0;
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);v=v<>0;
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);b=b<>0;
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);b=b<>0;
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+b=sparse([1 2;1 3;3 3],-(1:3),[3,3]);b=b<>0;
+a1=a;a1(1,1)=sparse(%t);A=full(a);A(1,1)=%t;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,6)=sparse(%t);A=full(a);A(1,6)=%t;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,8)=sparse(%t);A=full(a);A(1,8)=%t;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+//sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+vt=[%t %f %t %t %t %t];
+// full line insertion
+//----------------------
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t];
+a1=a;a1([1 3],:)=b;A=full(a);A([1 3],:)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=b;A=full(a);A([3 1],:)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t;%t %f %t %f %t %t];
+a1=a;a1([1 3 1],:)=b;A=full(a);A([1 3 1],:)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+v=[%t %f %t %t %t %t]';
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);A(:,3)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);A(:,7)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);A(:,8)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t]';
+a1=a;a1(:,[1 3])=b;A=full(a);A(:,[1 3])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);A(:,[3 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t;%f %t %t %t %t %f]';
+a1=a;a1(:,[1 3 1])=b;A=full(a);A(:,[1 3 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+b=[%t %t %f;%f %t %f;%t %t %t];
+a1=a;a1(1,1)=%t;A=full(a);A(1,1)=%t;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,6)=%t;A=full(a);A(1,6)=%t;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,8)=%t;A=full(a);A(1,8)=%t;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+// vector insertion
+v=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);v=v<>0;
+v1=v;v1(1)=%f;V=full(v);V(1)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=%t;V=full(v);V(2)=%t;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=%f;V=full(v);V(8)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=[%t;%t;%f];V=full(v);V([1 2 8])=[%t;%t;%f];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then bugmes();quit;end
+v1=v;v1(1)=sparse(%f);V=full(v);V(1)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=sparse(%f);V=full(v);V(2)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=sparse(%f);V=full(v);V(8)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=sparse([%f;%t;%f]);V=full(v);V([1 2 8])=[%f;%t;%f];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 1])=sparse([%f;%f;%f]);V=full(v);V([1 2 1])=[%f;%f;%f];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then bugmes();quit;end
+v1=v;v1(:)=(sparse([2 1],44,[6 1])<>0);V=full(v);V(:)=[%f;%t;%f;%f;%f;%f];
+if or(full(v1)<>V) then bugmes();quit;end
+v=v';
+v1=v;v1(1)=%f;V=full(v);V(1)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=%f;V=full(v);V(2)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=%f;V=full(v);V(8)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=[%t %f %f];V=full(v);V([1 2 8])=[%t %f %f];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(1)=sparse(%f);V=full(v);V(1)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=sparse(%f);V=full(v);V(2)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=sparse(%f);V=full(v);V(8)=%f;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=sparse([%f %t %f]);V=full(v);V([1 2 8])=[%f %t %f];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 1])=sparse([%f %f %f]);V=full(v);V([1 2 1])=[%f %f %f];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(:)=(sparse([1 2],44,[1,6]))<>0;V=full(v);V(:)=[%f %t %f %f %f %f];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(1)=[];V=full(v);V(1)=[];
+if or(full(v1)<>V) then bugmes();quit;end
+//test des comparaisons
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6])<>0;
+b=sparse([1 6;1 2;6 5],[10;-1;-1],[6 6])<>0;;
+if full(a==a)<>full(a)==full(a) then bugmes();quit;end
+if full(a<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a==full(a))<>full(a)==full(a) then bugmes();quit;end
+if full(a<>full(a))<>(full(a)<>full(a)) then bugmes();quit;end
+if full(full(a)==a)<>full(a)==full(a) then bugmes();quit;end
+if full(full(a)<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+a=sparse([1 1;3 1;6 1],[10 11 12],[6 1])<>0;
+if full(a==a)<>full(a)==full(a) then bugmes();quit;end
+if full(a<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a==full(a))<>full(a)==full(a) then bugmes();quit;end
+if full(a<>full(a))<>(full(a)<>full(a)) then bugmes();quit;end
+if full(full(a)==a)<>full(a)==full(a) then bugmes();quit;end
+if full(full(a)<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+a=a';
+if full(a==a)<>full(a)==full(a) then bugmes();quit;end
+if full(a<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a==full(a))<>full(a)==full(a) then bugmes();quit;end
+if full(a<>full(a))<>(full(a)<>full(a)) then bugmes();quit;end
+if full(full(a)==a)<>full(a)==full(a) then bugmes();quit;end
+if full(full(a)<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6])<>0;
+b=sparse([1 6;1 2;5 5],[10;-1;-1],[5 6])<>0;
+if a==b<>%f then bugmes();quit;end
+if a<>b<>%t then bugmes();quit;end
diff --git a/modules/sparse/tests/unit_tests/lsparse.tst b/modules/sparse/tests/unit_tests/lsparse.tst
new file mode 100755
index 000000000..7f1dfcfea
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/lsparse.tst
@@ -0,0 +1,391 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+mode(5)
+lines(0)
+zer=sparse([],[],[6,6]);
+//
+//
+//-------------------------------------------------------------
+//test des primitives sparse, full
+//-------------------------------------------------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[5 6]);B=full(b);
+if or(full(a<>0)<>(A<>0)) then pause,end
+if or(full(b<>0)<>(B<>0)) then pause,end
+if or(full(b>0)<>(B>0)) then pause,end
+if or(full(b<0)<>(B<0)) then pause,end
+if or(full(a>100)<>(A>100)) then pause,end
+if sparse(B>0)<>(b>0) then pause,end
+if sparse(B<0)<>(b<0) then pause,end
+//-------------------------------------------------------------
+//test de la primitives spget
+//-------------------------------------------------------------
+//-----------------------------------------------
+// | and & tests
+//-----------------------------------------------
+// -- sparse sparse
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if (a|b)<>(A|B) then pause,end
+if (a&b)<>(A&B) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|b)<>(A|B) then pause,end
+if (a&b)<>(A&B) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+if (a|b)<>(A|B) then pause,end
+if (a&b)<>(A&B) then pause,end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|b)<>(A|B) then pause,end
+if (a&b)<>(A&B) then pause,end
+// -- sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if (a|B)<>(A|B) then pause,end
+if (a&B)<>(A&B) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|B)<>(A|B) then pause,end
+if (a&B)<>(A&B) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+if (a|B)<>(A|B) then pause,end
+if (a&B)<>(A&B) then pause,end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (a|B)<>(A|B) then pause,end
+if (a&B)<>(A&B) then pause,end
+// -- full sparse
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if (A|b)<>(A|B) then pause,end
+if (A&b)<>(A&B) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (A|b)<>(A|B) then pause,end
+if (A&b)<>(A&B) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+if (A|b)<>(A|B) then pause,end
+if (A&b)<>(A&B) then pause,end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if (A|b)<>(A|B) then pause,end
+if (A&b)<>(A&B) then pause,end
+// ----------------------------------------------------------
+// test de la transposition
+//-----------------------------------------------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if or(full(a')<>full(a)') then pause,end
+if or(full(b')<>full(b)') then pause,end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if or(full(a')<>full(a)') then pause,end
+if or(full(b')<>full(b)') then pause,end
+// ----------------------------------------------------------
+// test des concatenation
+//-----------------------------------------------------------
+// sparse sparse
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if or(full([a])<>A) then pause,end
+if or(full([a b])<>[A B]) then pause,end
+if or(full([a;b])<>[A;B]) then pause,end
+if or(full([a []])<>A) then pause,end
+if or(full([a;[]])<>A) then pause,end
+// sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;A=full(a);
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b<>0;B=full(b);
+if or(full([a B])<>[A B]) then pause,end
+if or(full([a;B])<>[A;B]) then pause,end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if or(full([a B])<>[A B]) then pause,end
+if or(full([a;B])<>[A;B]) then pause,end
+// full sparse
+if or(full([A b])<>[A B]) then pause,end
+if or(full([A;b])<>[A;B]) then pause,end
+b=sparse([1 6;1 2;5 5],[-1;-1;-1],[6 6]);b=b>0;B=full(b);
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a>100;A=full(a);
+if or(full([A b])<>[A B]) then pause,end
+if or(full([B;b])<>[A;B]) then pause,end
+// ----------------------------------------------------------
+// test des extractions
+//-----------------------------------------------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;af=full(a);
+if or(full(a(1,3))<>af(1,3)) then pause,end
+if or(full(a(1,4))<>af(1,4)) then pause,end
+if or(full(a(1,:))<>af(1,:)) then pause,end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);v=v<>0;vf=full(v);
+if or(full(v(:))<>vf(:)) then pause,end
+if or(full(v(3:4))<>vf(3:4)) then pause,end
+if or(full(v([1 5]))<>vf([1 5])) then pause,end
+if or(full(v([4 3]))<>vf([4 3])) then pause,end
+if or(full(v([4 4]))<>vf([4 4])) then pause,end
+if or(full(v([1 1]))<>vf([1 1])) then pause,end
+v=v';vf=vf';
+if or(full(v(:))<>vf(:)) then pause,end
+if or(full(v(3:4))<>vf(3:4)) then pause,end
+if or(full(v([1 5]))<>vf([1 5])) then pause,end
+if or(full(v([4 3]))<>vf([4 3])) then pause,end
+if or(full(v([4 4]))<>vf([4 4])) then pause,end
+if or(full(v([1 1]))<>vf([1 1])) then pause,end
+// full line insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;af=full(a);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);vt=vt<>0;
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6])<>0;
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6])<>0;
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+// insert zero vector
+vt=sparse([],[],[1,6])<>0;
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);b=b<>0;
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);b=b<>0;
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);v=v<>0;
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);b=b<>0;
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);b=b<>0;
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then pause,end
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+b=sparse([1 2;1 3;3 3],-(1:3),[3,3]);b=b<>0;
+a1=a;a1(1,1)=sparse(%t);A=full(a);A(1,1)=%t;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,6)=sparse(%t);A=full(a);A(1,6)=%t;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,8)=sparse(%t);A=full(a);A(1,8)=%t;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=full(b);
+if or(full(a1)<>A) then pause,end
+//sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+vt=[%t %f %t %t %t %t];
+// full line insertion
+//----------------------
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
+if or(full(a1)<>A) then pause,end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t];
+a1=a;a1([1 3],:)=b;A=full(a);A([1 3],:)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=b;A=full(a);A([3 1],:)=b;
+if or(full(a1)<>A) then pause,end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t;%t %f %t %f %t %t];
+a1=a;a1([1 3 1],:)=b;A=full(a);A([1 3 1],:)=b;
+if or(full(a1)<>A) then pause,end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+v=[%t %f %t %t %t %t]';
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);A(:,3)=v;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);A(:,7)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);A(:,8)=v;
+if or(full(a1)<>A) then pause,end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t]';
+a1=a;a1(:,[1 3])=b;A=full(a);A(:,[1 3])=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);A(:,[3 1])=b;
+if or(full(a1)<>A) then pause,end
+b=[%t %f %t %t %t %t;%f %f %t %t %f %t;%f %t %t %t %t %f]';
+a1=a;a1(:,[1 3 1])=b;A=full(a);A(:,[1 3 1])=b;
+if or(full(a1)<>A) then pause,end
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);a=a<>0;
+b=[%t %t %f;%f %t %f;%t %t %t];
+a1=a;a1(1,1)=%t;A=full(a);A(1,1)=%t;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,6)=%t;A=full(a);A(1,6)=%t;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,8)=%t;A=full(a);A(1,8)=%t;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=b;
+if or(full(a1)<>A) then pause,end
+// vector insertion
+v=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);v=v<>0;
+v1=v;v1(1)=%f;V=full(v);V(1)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=%t;V=full(v);V(2)=%t;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=%f;V=full(v);V(8)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=[%t;%t;%f];V=full(v);V([1 2 8])=[%t;%t;%f];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then pause,end
+v1=v;v1(1)=sparse(%f);V=full(v);V(1)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=sparse(%f);V=full(v);V(2)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=sparse(%f);V=full(v);V(8)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=sparse([%f;%t;%f]);V=full(v);V([1 2 8])=[%f;%t;%f];
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 1])=sparse([%f;%f;%f]);V=full(v);V([1 2 1])=[%f;%f;%f];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then pause,end
+v1=v;v1(:)=(sparse([2 1],44,[6 1])<>0);V=full(v);V(:)=[%f;%t;%f;%f;%f;%f];
+if or(full(v1)<>V) then pause,end
+v=v';
+v1=v;v1(1)=%f;V=full(v);V(1)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=%f;V=full(v);V(2)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=%f;V=full(v);V(8)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=[%t %f %f];V=full(v);V([1 2 8])=[%t %f %f];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(1)=sparse(%f);V=full(v);V(1)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=sparse(%f);V=full(v);V(2)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=sparse(%f);V=full(v);V(8)=%f;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=sparse([%f %t %f]);V=full(v);V([1 2 8])=[%f %t %f];
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 1])=sparse([%f %f %f]);V=full(v);V([1 2 1])=[%f %f %f];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(:)=(sparse([1 2],44,[1,6]))<>0;V=full(v);V(:)=[%f %t %f %f %f %f];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(1)=[];V=full(v);V(1)=[];
+if or(full(v1)<>V) then pause,end
+//test des comparaisons
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6])<>0;
+b=sparse([1 6;1 2;6 5],[10;-1;-1],[6 6])<>0;;
+if full(a==a)<>full(a)==full(a) then pause,end
+if full(a<>a)<>(full(a)<>full(a)) then pause,end
+if full(a==full(a))<>full(a)==full(a) then pause,end
+if full(a<>full(a))<>(full(a)<>full(a)) then pause,end
+if full(full(a)==a)<>full(a)==full(a) then pause,end
+if full(full(a)<>a)<>(full(a)<>full(a)) then pause,end
+a=sparse([1 1;3 1;6 1],[10 11 12],[6 1])<>0;
+if full(a==a)<>full(a)==full(a) then pause,end
+if full(a<>a)<>(full(a)<>full(a)) then pause,end
+if full(a==full(a))<>full(a)==full(a) then pause,end
+if full(a<>full(a))<>(full(a)<>full(a)) then pause,end
+if full(full(a)==a)<>full(a)==full(a) then pause,end
+if full(full(a)<>a)<>(full(a)<>full(a)) then pause,end
+a=a';
+if full(a==a)<>full(a)==full(a) then pause,end
+if full(a<>a)<>(full(a)<>full(a)) then pause,end
+if full(a==full(a))<>full(a)==full(a) then pause,end
+if full(a<>full(a))<>(full(a)<>full(a)) then pause,end
+if full(full(a)==a)<>full(a)==full(a) then pause,end
+if full(full(a)<>a)<>(full(a)<>full(a)) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6])<>0;
+b=sparse([1 6;1 2;5 5],[10;-1;-1],[5 6])<>0;
+if a==b<>%f then pause,end
+if a<>b<>%t then pause,end
+
diff --git a/modules/sparse/tests/unit_tests/ordmmd.dia.ref b/modules/sparse/tests/unit_tests/ordmmd.dia.ref
new file mode 100755
index 000000000..a49b2d395
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/ordmmd.dia.ref
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+A = [
+4. 1. 2. 0.5 2.
+1. 0.5 0. 0. 0.
+2. 0. 3. 0. 0.
+0.5 0. 0. 5/8 0.
+2. 0. 0. 0. 16.
+];
+A = sparse(A);
+[xadj,iadj,val]=sp2adj(A);
+n = size(A,"r");
+[perm,invp,nofsub]=ordmmd(xadj,iadj,n);
+assert_checkequal(perm,[5;4;3;2;1]);
+assert_checkequal(invp,[5;4;3;2;1]);
+assert_checkequal(nofsub,8);
diff --git a/modules/sparse/tests/unit_tests/ordmmd.tst b/modules/sparse/tests/unit_tests/ordmmd.tst
new file mode 100755
index 000000000..6c90c3d45
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/ordmmd.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+
+
+
+A = [
+4. 1. 2. 0.5 2.
+1. 0.5 0. 0. 0.
+2. 0. 3. 0. 0.
+0.5 0. 0. 5/8 0.
+2. 0. 0. 0. 16.
+];
+A = sparse(A);
+[xadj,iadj,val]=sp2adj(A);
+n = size(A,"r");
+[perm,invp,nofsub]=ordmmd(xadj,iadj,n);
+assert_checkequal(perm,[5;4;3;2;1]);
+assert_checkequal(invp,[5;4;3;2;1]);
+assert_checkequal(nofsub,8);
diff --git a/modules/sparse/tests/unit_tests/qmr.dia.ref b/modules/sparse/tests/unit_tests/qmr.dia.ref
new file mode 100755
index 000000000..e2c564039
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/qmr.dia.ref
@@ -0,0 +1,645 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 Scilab Enterprises Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// unit tests for qmr() function
+// =============================================================================
+warning('off')
+// ----------------
+// If A is a matrix
+// ----------------
+// 1. Interface
+// ============
+assert_checkerror( "qmr()", "%s: Wrong number of input arguments: At least %d expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr(1)", "%s: Wrong number of input arguments: At least %d expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr([1 2;3 4])", "%s: Wrong number of input arguments: At least %d expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr([1 2;3 4;5 6],[1;1;1])", "%s: Wrong size for input argument #%d: Square matrix expected.\n", 10000, "qmr", 1);
+assert_checkerror( "qmr([1 2;3 4;5 6],[1 1 1])", "%s: Wrong size for input argument #%d: Square matrix expected.\n", 10000, "qmr", 1);
+assert_checkerror( "qmr([1 2;3 4],[1 1])", "%s: Wrong size for input argument #%d: Column vector expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr([%t %t;%t %t],[1;1])", "%s: Wrong type for input argument #%d : A real or complex matrix or a sparse matrix or a function expected.\n", 10000, "qmr", 1);
+assert_checkerror( "qmr([],[])", "%s: Wrong size for input argument #%d: Column vector expected.\n", 10000, "qmr", 2);
+// 2. Test with 2 input arguments and all output arguments
+// =======================================================
+assert_checkfalse(execstr("qmr([10 1;1 10],""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse column vector expected.\n"), "qmr", 2);
+assert_checkerror("qmr([10 1;1 10],""t"")", refMsg);
+A=[10,1;1,10];
+b=[11;11];
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// 3. Test with 3 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+assert_checkfalse(execstr("qmr(A, b,""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse column vector expected.\n"), "qmr", 3);
+assert_checkerror("qmr(A, b,""t"")", refMsg);
+x0=[0.5;0.5];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 4. Test with 4 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+assert_checkfalse(execstr("qmr(A, b, x0, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse, square matrix or a function expected.\n"), "qmr", 4);
+assert_checkerror("qmr(A, b, x0, ""t"")", refMsg);
+M1=[1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+// 5.Test with 5 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+assert_checkfalse(execstr("qmr(A, b, x0, M1, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse, square matrix or a function expected.\n"), "qmr", 5);
+assert_checkerror("qmr(A, b, x0, M1, ""t"")", refMsg);
+M2=[1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 6.Test with 6 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+x0 = [0.5;0.5];
+M1=[1,0;0,1];
+M2=[1,0;0,1];
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: Scalar expected.\n"), "qmr", 6);
+assert_checkerror("qmr(A, b, x0, M1, M2, ""t"")", refMsg);
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, %i)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar expected.\n"), "qmr", 6);
+assert_checkerror("qmr(A, b, x0, M1, M2, %i)", refMsg);
+maxit = 10;
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,M2,maxit);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 7.Test with 7 input arguments and all output arguments
+// =======================================================
+A=[10,1;1,10];
+b=[11;11];
+tol = 100*%eps;
+maxit = 10;
+M1=[1,0;0,1];
+M2=[1,0;0,1];
+x0=[0.5;0.5];
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, maxit, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: Scalar expected.\n"), "qmr", 7);
+assert_checkerror("qmr(A, b, x0, M1, M2, maxit, ""t"")", refMsg);
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, maxit, %i)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar expected.\n"), "qmr", 7);
+assert_checkerror("qmr(A, b, x0, M1, M2, maxit, %i)", refMsg);
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,M2,maxit,tol);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 8. Test with non-positionnal input parameters so that good initialization generates 0 iterations
+// =================================================================================================
+A=[100,1;1,10.];
+b=[101;11];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0=[0.5;0.5]);
+assert_checkequal ( iter , 2 );
+// 9. Test the special case where b=0
+// ====================================
+A=[100,1;1,10.];
+b=[0;0];
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0;0];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+// 10. A is a sparse matrix
+// =========================
+A = sparse([10 1;1 10]);
+b = ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0.0909091;0.0909091];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+// 11. A is a complex full matrix
+// =========================
+A = [10 1;1 10] + %i * [1 10;10 1];
+b = ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0.0454545-0.0454545*%i;0.0454545-0.0454545*%i];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+// 12. A is a complex sparse matrix
+// =========================
+A = sparse([10 1;1 10] + %i * [1 10;10 1]);
+b = ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0.0454545-0.0454545*%i;0.0454545-0.0454545*%i];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+// 13. b is a complex column vector
+// =========================
+A = [10 1;1 10];
+b = %i * ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=%i .* [0.0909091;0.0909091];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+// 14. b is a complex sparse column vector
+// =========================
+A = [10 1;1 10];
+b = sparse(%i * ones(2,1));
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=%i .* [0.0909091;0.0909091];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+// 15. x0 is complex column vector
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=%i.*[0.5;0.5];
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 16. x0 is sparse column vector
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=sparse([0.5;0.5]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 17. x0 is complex sparse column vector
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=sparse(%i .* [0.5;0.5]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 18. M1 is complex matrix
+// ========================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=%i .* [1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 19. M1 is sparse matrix
+// =======================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=sparse([1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 20. M1 is complex sparse matrix
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=sparse(%i .* [1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 21. M2 is complex matrix
+// ========================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+M2=%i .* [1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1, M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 22. M2 is sparse matrix
+// =======================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+M2=sparse([1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1, M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 23. M2 is complex sparse matrix
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+M2=sparse(%i .* [1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1, M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// --------------------
+// If A is a function
+// -------------------
+// 1. Interface
+// =============
+function y = func_A(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+assert_checkfalse(execstr("qmr(func_A)","errcatch") == 0);
+lasterror(execstr("10000","errcatch") == 0);
+// 2. Test with 2 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+xexpected=[1;1];
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+assert_checkfalse(execstr("qmr(funcA_notransp, b)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A transpose of the function %s expected.\n"), "qmr", 2, "A");
+assert_checkerror("qmr(funcA_notransp, b)", refMsg);
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+// 3. Test with 3 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0=[0.01;0.05];
+xexpected=[1;1];
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 4. Test with 4 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0 = [0.01;0.5];
+M1=[1,0;0,1];
+xexpected=[1;1];
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 5 Test with 5 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0 = [0.01;0.5];
+M1=[1,0;0,1];
+M2=[1,0;0,1];
+xexpected=[1;1];
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1,M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1,M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 6 Test with 6 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0 = [0.01;0.05];
+M1=[1,0;0,1];
+M2 = eye(2,2);
+maxit = 10;
+xexpected=[1;1];
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1,M2,maxit);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1,M2,maxit);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// 7 Test with 7 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+tol = 100*%eps;
+maxit = 10;
+M1=[1,0;0,1];
+M2 = eye(2,2);
+x0=[0.01;0.05];
+xexpected=[1;1];
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1,M2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1,M2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test : A is a matrix, M1 is a function, M2 is a matrix (default)
+// ===============================================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+xexpected=[1;1];
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,funM1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+assert_checkfalse(execstr("qmr(A, b, x0, functionM1)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong prototype of input argument #%d: If M1 is function, use the header M1(x,t) instead M1(x).\n"), "qmr", 4);
+assert_checkerror("qmr(A, b, x0, functionM1)", refMsg);
+assert_checkfalse(execstr("qmr(A, b, x0, functionM1, 1)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A transpose of the function expected.\n"), "qmr", 5);
+assert_checkerror("qmr(A, b, x0, functionM1, 1)", refMsg);
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,functionM1,functionM1t);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test : A is a matrix, M1 is a function, M2 is a matrix
+// ======================================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+M2 = eye(2,2);
+maxit = 10;
+tol = 100*%eps;
+xexpected=[1;1];
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,funM1,M2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,functionM1,functionM1t,M2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test : A is a matrix, M1 is a matrix, M2 is a function
+// ======================================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+M1 = eye(2,2);
+maxit = 10;
+tol = 100*%eps;
+xexpected=[1;1];
+function y = funM2(x,t)
+ M2 = eye(2,2);
+ if (t=="notransp") then
+ y = M2*x;
+ elseif (t=="transp") then
+ y = M2'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = functionM2(x)
+ M2 = eye(2,2);
+ y = M2*x;
+endfunction
+function y = functionM2t(x)
+ M2 = eye(2,2);
+ y = M2'*x;
+endfunction
+assert_checkfalse(execstr("qmr(A, b, x0, M1, functionM2)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong prototype of input argument #%d: If M2 is function, use the header M2(x,t) instead M2(x).\n"), "qmr", 5);
+assert_checkerror("qmr(A, b, x0, M1, functionM2)", refMsg);
+assert_checkfalse(execstr("qmr(A, b, x0, M2, functionM2, 1)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A transpose of the function expected.\n"), "qmr", 6);
+assert_checkerror("qmr(A, b, x0, M1, functionM2, 1)", refMsg);
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test : A is a matrix, M1 and M2 are functions
+// ==============================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+maxit = 10;
+tol = 100*%eps;
+xexpected=[1;1];
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+function y = funM2(x,t)
+ M2 = eye(2,2);
+ if (t=="notransp") then
+ y = M2*x;
+ elseif (t=="transp") then
+ y = M2'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,funM1,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+function y = functionM2(x)
+ M2 = eye(2,2);
+ y = M2*x;
+endfunction
+function y = functionM2t(x)
+ M2 = eye(2,2);
+ y = M2'*x;
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,functionM1,functionM1t,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+// Test : A, M1 and M2 are functions
+// ==================================
+b = [11;11];
+x0 = [0.01;0.05];
+maxit = 10;
+tol = 100*%eps;
+function y = funA(x,t)
+ A = [10 1;1 10];
+ if (t=="notransp") then
+ y = A*x;
+ elseif (t=="transp") then
+ y = A'*x;
+ end
+endfunction
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+function y = funM2(x,t)
+ M2 = eye(2,2);
+ if (t=="notransp") then
+ y = M2*x;
+ elseif (t=="transp") then
+ y = M2'*x;
+ end
+endfunction
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,funM1,funM2,maxit,tol);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = functionA(x)
+ A = [10 1;1 10];
+ y = A*x;
+endfunction
+function y = functionAt(x)
+ A = [10 1;1 10];
+ y = A'*x;
+endfunction
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+function y = functionM2(x)
+ M2 = eye(2,2);
+ y = M2*x;
+endfunction
+function y = functionM2t(x)
+ M2 = eye(2,2);
+ y = M2'*x;
+endfunction
+xexpected=[1;1];
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,functionM1,functionM1t,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,functionM1,functionM1t,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,funM1,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,funM1,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,funM1,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,functionM1,functionM1t,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,functionM1,functionM1t,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
diff --git a/modules/sparse/tests/unit_tests/qmr.tst b/modules/sparse/tests/unit_tests/qmr.tst
new file mode 100755
index 000000000..4c3364dac
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/qmr.tst
@@ -0,0 +1,772 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 Scilab Enterprises Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+
+// unit tests for qmr() function
+// =============================================================================
+warning('off')
+
+// ----------------
+// If A is a matrix
+// ----------------
+
+// 1. Interface
+// ============
+assert_checkerror( "qmr()", "%s: Wrong number of input arguments: At least %d expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr(1)", "%s: Wrong number of input arguments: At least %d expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr([1 2;3 4])", "%s: Wrong number of input arguments: At least %d expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr([1 2;3 4;5 6],[1;1;1])", "%s: Wrong size for input argument #%d: Square matrix expected.\n", 10000, "qmr", 1);
+assert_checkerror( "qmr([1 2;3 4;5 6],[1 1 1])", "%s: Wrong size for input argument #%d: Square matrix expected.\n", 10000, "qmr", 1);
+assert_checkerror( "qmr([1 2;3 4],[1 1])", "%s: Wrong size for input argument #%d: Column vector expected.\n", 10000, "qmr", 2);
+assert_checkerror( "qmr([%t %t;%t %t],[1;1])", "%s: Wrong type for input argument #%d : A real or complex matrix or a sparse matrix or a function expected.\n", 10000, "qmr", 1);
+assert_checkerror( "qmr([],[])", "%s: Wrong size for input argument #%d: Column vector expected.\n", 10000, "qmr", 2);
+
+// 2. Test with 2 input arguments and all output arguments
+// =======================================================
+assert_checkfalse(execstr("qmr([10 1;1 10],""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse column vector expected.\n"), "qmr", 2);
+assert_checkerror("qmr([10 1;1 10],""t"")", refMsg);
+
+A=[10,1;1,10];
+b=[11;11];
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+
+// 3. Test with 3 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+assert_checkfalse(execstr("qmr(A, b,""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse column vector expected.\n"), "qmr", 3);
+assert_checkerror("qmr(A, b,""t"")", refMsg);
+
+x0=[0.5;0.5];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 4. Test with 4 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+
+assert_checkfalse(execstr("qmr(A, b, x0, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse, square matrix or a function expected.\n"), "qmr", 4);
+assert_checkerror("qmr(A, b, x0, ""t"")", refMsg);
+
+M1=[1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed,xexpected,%eps);
+
+// 5.Test with 5 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+
+assert_checkfalse(execstr("qmr(A, b, x0, M1, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real or complex, full or sparse, square matrix or a function expected.\n"), "qmr", 5);
+assert_checkerror("qmr(A, b, x0, M1, ""t"")", refMsg);
+
+M2=[1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 6.Test with 6 input arguments and all output arguments
+// ======================================================
+A=[10,1;1,10];
+b=[11;11];
+x0 = [0.5;0.5];
+M1=[1,0;0,1];
+M2=[1,0;0,1];
+
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: Scalar expected.\n"), "qmr", 6);
+assert_checkerror("qmr(A, b, x0, M1, M2, ""t"")", refMsg);
+
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, %i)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar expected.\n"), "qmr", 6);
+assert_checkerror("qmr(A, b, x0, M1, M2, %i)", refMsg);
+
+maxit = 10;
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,M2,maxit);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 7.Test with 7 input arguments and all output arguments
+// =======================================================
+A=[10,1;1,10];
+b=[11;11];
+tol = 100*%eps;
+maxit = 10;
+M1=[1,0;0,1];
+M2=[1,0;0,1];
+x0=[0.5;0.5];
+
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, maxit, ""t"")" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: Scalar expected.\n"), "qmr", 7);
+assert_checkerror("qmr(A, b, x0, M1, M2, maxit, ""t"")", refMsg);
+
+assert_checkfalse(execstr("qmr(A, b, x0, M1, M2, maxit, %i)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar expected.\n"), "qmr", 7);
+assert_checkerror("qmr(A, b, x0, M1, M2, maxit, %i)", refMsg);
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,M2,maxit,tol);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 8. Test with non-positionnal input parameters so that good initialization generates 0 iterations
+// =================================================================================================
+A=[100,1;1,10.];
+b=[101;11];
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0=[0.5;0.5]);
+assert_checkequal ( iter , 2 );
+
+// 9. Test the special case where b=0
+// ====================================
+A=[100,1;1,10.];
+b=[0;0];
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0;0];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0 );
+assert_checktrue ( err <= %eps );
+assert_checkequal ( iter , 0 );
+
+// 10. A is a sparse matrix
+// =========================
+A = sparse([10 1;1 10]);
+b = ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0.0909091;0.0909091];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+
+// 11. A is a complex full matrix
+// =========================
+A = [10 1;1 10] + %i * [1 10;10 1];
+b = ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0.0454545-0.0454545*%i;0.0454545-0.0454545*%i];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+
+// 12. A is a complex sparse matrix
+// =========================
+A = sparse([10 1;1 10] + %i * [1 10;10 1]);
+b = ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=[0.0454545-0.0454545*%i;0.0454545-0.0454545*%i];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+
+// 13. b is a complex column vector
+// =========================
+A = [10 1;1 10];
+b = %i * ones(2,1);
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=%i .* [0.0909091;0.0909091];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+
+// 14. b is a complex sparse column vector
+// =========================
+A = [10 1;1 10];
+b = sparse(%i * ones(2,1));
+[xcomputed, flag, err, iter, res]=qmr(A,b);
+xexpected=%i .* [0.0909091;0.0909091];
+assert_checkalmostequal ( xcomputed , xexpected , 1e-1);
+assert_checkequal ( flag , 0);
+assert_checkalmostequal ( err , 1.110d-16, 1e-1);
+assert_checkequal ( iter, 1);
+
+// 15. x0 is complex column vector
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=%i.*[0.5;0.5];
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 16. x0 is sparse column vector
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=sparse([0.5;0.5]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 17. x0 is complex sparse column vector
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=sparse(%i .* [0.5;0.5]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 18. M1 is complex matrix
+// ========================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=%i .* [1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 19. M1 is sparse matrix
+// =======================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=sparse([1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 20. M1 is complex sparse matrix
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=sparse(%i .* [1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 21. M2 is complex matrix
+// ========================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+M2=%i .* [1,0;0,1];
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1, M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 22. M2 is sparse matrix
+// =======================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+M2=sparse([1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1, M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 23. M2 is complex sparse matrix
+// ===============================
+A=[10,1;1,10];
+b=[11;11];
+x0=[0.5;0.5];
+M1=[1,0;0,1];
+M2=sparse(%i .* [1,0;0,1]);
+[xcomputed, flag, err, iter, res]=qmr(A,b, x0, M1, M2);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+
+// --------------------
+// If A is a function
+// -------------------
+
+// 1. Interface
+// =============
+function y = func_A(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+assert_checkfalse(execstr("qmr(func_A)","errcatch") == 0);
+lasterror(execstr("10000","errcatch") == 0);
+
+// 2. Test with 2 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+xexpected=[1;1];
+
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+
+assert_checkfalse(execstr("qmr(funcA_notransp, b)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A transpose of the function %s expected.\n"), "qmr", 2, "A");
+assert_checkerror("qmr(funcA_notransp, b)", refMsg);
+
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+assert_checkequal ( flag , 0);
+assert_checkequal ( err , 0);
+assert_checkequal ( iter, 1);
+
+// 3. Test with 3 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0=[0.01;0.05];
+xexpected=[1;1];
+
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+
+
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 4. Test with 4 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0 = [0.01;0.5];
+M1=[1,0;0,1];
+xexpected=[1;1];
+
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 5 Test with 5 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0 = [0.01;0.5];
+M1=[1,0;0,1];
+M2=[1,0;0,1];
+xexpected=[1;1];
+
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1,M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1,M2);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 6 Test with 6 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+x0 = [0.01;0.05];
+M1=[1,0;0,1];
+M2 = eye(2,2);
+maxit = 10;
+xexpected=[1;1];
+
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1,M2,maxit);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1,M2,maxit);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// 7 Test with 7 input arguments and all output arguments
+// =======================================================
+b = [11;11];
+tol = 100*%eps;
+maxit = 10;
+M1=[1,0;0,1];
+M2 = eye(2,2);
+x0=[0.01;0.05];
+xexpected=[1;1];
+
+function y = func_qmr(x,t)
+ Amat = [10,1;1,10];
+ if (t == 'notransp') then
+ y = Amat*x;
+ elseif (t == 'transp') then
+ y = Amat'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(func_qmr,b,x0,M1,M2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = funcA_notransp(x)
+ Amat = [10,1;1,10];
+ y = Amat*x;
+endfunction
+
+function y = funcA_transp(x)
+ Amat = [10,1;1,10];
+ y = Amat'*x;
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(funcA_notransp,funcA_transp,b,x0,M1,M2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// Test : A is a matrix, M1 is a function, M2 is a matrix (default)
+// ===============================================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+xexpected=[1;1];
+
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,funM1);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+
+assert_checkfalse(execstr("qmr(A, b, x0, functionM1)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong prototype of input argument #%d: If M1 is function, use the header M1(x,t) instead M1(x).\n"), "qmr", 4);
+assert_checkerror("qmr(A, b, x0, functionM1)", refMsg);
+
+assert_checkfalse(execstr("qmr(A, b, x0, functionM1, 1)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A transpose of the function expected.\n"), "qmr", 5);
+assert_checkerror("qmr(A, b, x0, functionM1, 1)", refMsg);
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,functionM1,functionM1t);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// Test : A is a matrix, M1 is a function, M2 is a matrix
+// ======================================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+M2 = eye(2,2);
+maxit = 10;
+tol = 100*%eps;
+xexpected=[1;1];
+
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,funM1,M2,maxit,tol);
+
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,functionM1,functionM1t,M2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// Test : A is a matrix, M1 is a matrix, M2 is a function
+// ======================================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+M1 = eye(2,2);
+maxit = 10;
+tol = 100*%eps;
+xexpected=[1;1];
+
+function y = funM2(x,t)
+ M2 = eye(2,2);
+ if (t=="notransp") then
+ y = M2*x;
+ elseif (t=="transp") then
+ y = M2'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = functionM2(x)
+ M2 = eye(2,2);
+ y = M2*x;
+endfunction
+
+function y = functionM2t(x)
+ M2 = eye(2,2);
+ y = M2'*x;
+endfunction
+
+assert_checkfalse(execstr("qmr(A, b, x0, M1, functionM2)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong prototype of input argument #%d: If M2 is function, use the header M2(x,t) instead M2(x).\n"), "qmr", 5);
+assert_checkerror("qmr(A, b, x0, M1, functionM2)", refMsg);
+
+assert_checkfalse(execstr("qmr(A, b, x0, M2, functionM2, 1)" ,"errcatch") == 0);
+refMsg = msprintf(gettext("%s: Wrong type for input argument #%d: A transpose of the function expected.\n"), "qmr", 6);
+assert_checkerror("qmr(A, b, x0, M1, functionM2, 1)", refMsg);
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,M1,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// Test : A is a matrix, M1 and M2 are functions
+// ==============================================
+A = [10 1;1 10];
+b = [11;11];
+x0 = [0.01;0.05];
+maxit = 10;
+tol = 100*%eps;
+xexpected=[1;1];
+
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+
+function y = funM2(x,t)
+ M2 = eye(2,2);
+ if (t=="notransp") then
+ y = M2*x;
+ elseif (t=="transp") then
+ y = M2'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,funM1,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+
+function y = functionM2(x)
+ M2 = eye(2,2);
+ y = M2*x;
+endfunction
+
+function y = functionM2t(x)
+ M2 = eye(2,2);
+ y = M2'*x;
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(A,b,x0,functionM1,functionM1t,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+// Test : A, M1 and M2 are functions
+// ==================================
+b = [11;11];
+x0 = [0.01;0.05];
+maxit = 10;
+tol = 100*%eps;
+
+function y = funA(x,t)
+ A = [10 1;1 10];
+ if (t=="notransp") then
+ y = A*x;
+ elseif (t=="transp") then
+ y = A'*x;
+ end
+endfunction
+
+function y = funM1(x,t)
+ M1 = eye(2,2);
+ if (t=="notransp") then
+ y = M1*x;
+ elseif (t=="transp") then
+ y = M1'*x;
+ end
+endfunction
+
+function y = funM2(x,t)
+ M2 = eye(2,2);
+ if (t=="notransp") then
+ y = M2*x;
+ elseif (t=="transp") then
+ y = M2'*x;
+ end
+endfunction
+
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,funM1,funM2,maxit,tol);
+xexpected=[1;1];
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+function y = functionA(x)
+ A = [10 1;1 10];
+ y = A*x;
+endfunction
+
+function y = functionAt(x)
+ A = [10 1;1 10];
+ y = A'*x;
+endfunction
+
+function y = functionM1(x)
+ M1 = eye(2,2);
+ y = M1*x;
+endfunction
+
+function y = functionM1t(x)
+ M1 = eye(2,2);
+ y = M1'*x;
+endfunction
+
+function y = functionM2(x)
+ M2 = eye(2,2);
+ y = M2*x;
+endfunction
+
+function y = functionM2t(x)
+ M2 = eye(2,2);
+ y = M2'*x;
+endfunction
+
+xexpected=[1;1];
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,functionM1,functionM1t,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,functionM1,functionM1t,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,funM1,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,funM1,functionM2,functionM2t,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,funM1,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+[xcomputed, flag, err, iter, res]=qmr(functionA,functionAt,b,x0,functionM1,functionM1t,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
+
+[xcomputed, flag, err, iter, res]=qmr(funA,b,x0,functionM1,functionM1t,funM2,maxit,tol);
+assert_checkalmostequal ( xcomputed , xexpected , %eps);
diff --git a/modules/sparse/tests/unit_tests/sp2adj.dia.ref b/modules/sparse/tests/unit_tests/sp2adj.dia.ref
new file mode 100755
index 000000000..c0c2ec7af
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sp2adj.dia.ref
@@ -0,0 +1,65 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// Check the adjacency representation of a simple matrix
+A = [
+0 0 4 0 9
+0 0 5 0 0
+1 3 0 7 0
+0 0 6 0 10
+2 0 0 8 0
+];
+B=sparse(A);
+mn=size(B);
+[xadj,iadj,v]=sp2adj(B);
+m = max(iadj);
+n = size(xadj,"*")-1;
+assert_checkequal ( mn(1) , m );
+assert_checkequal ( mn(2) , n );
+expected_xadj = [1 3 4 7 9 11]';
+expected_iadj = [3 5 3 1 2 4 3 5 1 4]';
+expected_v = [1 2 3 4 5 6 7 8 9 10]';
+assert_checkequal ( and(expected_xadj == xadj) , %t );
+assert_checkequal ( and(expected_iadj == iadj) , %t );
+assert_checkequal ( and(expected_v == v) , %t );
+// j is the column index
+for j = 1 : size(xadj,"*")-1
+ irows = iadj(xadj(j):xadj(j+1)-1);
+ vcolj = v(xadj(j):xadj(j+1)-1);
+end
+//
+// Check the adjacency representation of a simple matrix
+A = [
+0 0 0 0 0 6 0 0 0 0
+3 0 5 0 0 0 0 5 0 0
+0 0 0 3 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0
+0 7 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3
+0 0 0 0 0 0 0 0 2 0
+];
+B=sparse(A);
+mn=size(B);
+[xadj,iadj,v]=sp2adj(B);
+m = max(iadj);
+n = size(xadj,"*")-1;
+assert_checkequal ( mn(1) , m );
+assert_checkequal ( mn(2) , n );
+expected_xadj = [1 2 3 4 5 5 6 6 7 8 9]';
+expected_iadj = [2 5 2 3 1 2 7 6]';
+expected_v = [3 7 5 3 6 5 2 3]';
+assert_checkequal ( and(expected_xadj == xadj) , %t );
+assert_checkequal ( and(expected_iadj == iadj) , %t );
+assert_checkequal ( and(expected_v == v) , %t );
+//
+// Check that sp2adj matches adj2sp
+A = sprand(100,50,.05);
+[xadj,iadj,v]= sp2adj(A);
+[n,m]=size(A);
+p = adj2sp(xadj,iadj,v,[n,m]);
+assert_checkequal ( and(A-p==0) , %t );
diff --git a/modules/sparse/tests/unit_tests/sp2adj.tst b/modules/sparse/tests/unit_tests/sp2adj.tst
new file mode 100755
index 000000000..8d641ceac
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sp2adj.tst
@@ -0,0 +1,67 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+
+//
+// Check the adjacency representation of a simple matrix
+A = [
+0 0 4 0 9
+0 0 5 0 0
+1 3 0 7 0
+0 0 6 0 10
+2 0 0 8 0
+];
+B=sparse(A);
+mn=size(B);
+[xadj,iadj,v]=sp2adj(B);
+m = max(iadj);
+n = size(xadj,"*")-1;
+assert_checkequal ( mn(1) , m );
+assert_checkequal ( mn(2) , n );
+expected_xadj = [1 3 4 7 9 11]';
+expected_iadj = [3 5 3 1 2 4 3 5 1 4]';
+expected_v = [1 2 3 4 5 6 7 8 9 10]';
+assert_checkequal ( and(expected_xadj == xadj) , %t );
+assert_checkequal ( and(expected_iadj == iadj) , %t );
+assert_checkequal ( and(expected_v == v) , %t );
+// j is the column index
+for j = 1 : size(xadj,"*")-1
+ irows = iadj(xadj(j):xadj(j+1)-1);
+ vcolj = v(xadj(j):xadj(j+1)-1);
+end
+//
+// Check the adjacency representation of a simple matrix
+A = [
+0 0 0 0 0 6 0 0 0 0
+3 0 5 0 0 0 0 5 0 0
+0 0 0 3 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0
+0 7 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 3
+0 0 0 0 0 0 0 0 2 0
+];
+B=sparse(A);
+mn=size(B);
+[xadj,iadj,v]=sp2adj(B);
+m = max(iadj);
+n = size(xadj,"*")-1;
+assert_checkequal ( mn(1) , m );
+assert_checkequal ( mn(2) , n );
+expected_xadj = [1 2 3 4 5 5 6 6 7 8 9]';
+expected_iadj = [2 5 2 3 1 2 7 6]';
+expected_v = [3 7 5 3 6 5 2 3]';
+assert_checkequal ( and(expected_xadj == xadj) , %t );
+assert_checkequal ( and(expected_iadj == iadj) , %t );
+assert_checkequal ( and(expected_v == v) , %t );
+//
+// Check that sp2adj matches adj2sp
+A = sprand(100,50,.05);
+[xadj,iadj,v]= sp2adj(A);
+[n,m]=size(A);
+p = adj2sp(xadj,iadj,v,[n,m]);
+assert_checkequal ( and(A-p==0) , %t );
+
diff --git a/modules/sparse/tests/unit_tests/sparse-insert.dia.ref b/modules/sparse/tests/unit_tests/sparse-insert.dia.ref
new file mode 100755
index 000000000..1dda488f3
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sparse-insert.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - S/E - Antoine Elias
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+a1=a;
+a1(1,:)=vt;
+assert_checkequal(vt, a1(1,:));
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+a1=a;
+b=-[1 2 3;4 5 6;7 8 9];
+a1(1:3,1:3)=b;
+assert_checkequal(a1(1:3,1:3), sparse(b));
+a = sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],[%t,%t,%t,%t,%t,%t,%t,%t,%t],[6 6]);
+vt = sparse([1 2;1 3;1 4;1 6],[%f,%f;%f,%f],[1,6]);
+a1=a;
+a1(1,:)=vt;
+assert_checkequal(a1(1,:), vt);
diff --git a/modules/sparse/tests/unit_tests/sparse-insert.tst b/modules/sparse/tests/unit_tests/sparse-insert.tst
new file mode 100755
index 000000000..d0c9e79e1
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sparse-insert.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - S/E - Antoine Elias
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+a1=a;
+a1(1,:)=vt;
+assert_checkequal(vt, a1(1,:));
+
+
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+a1=a;
+b=-[1 2 3;4 5 6;7 8 9];
+a1(1:3,1:3)=b;
+assert_checkequal(a1(1:3,1:3), sparse(b));
+
+a = sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],[%t,%t,%t,%t,%t,%t,%t,%t,%t],[6 6]);
+vt = sparse([1 2;1 3;1 4;1 6],[%f,%f;%f,%f],[1,6]);
+a1=a;
+a1(1,:)=vt;
+assert_checkequal(a1(1,:), vt);
diff --git a/modules/sparse/tests/unit_tests/sparse.dia.ref b/modules/sparse/tests/unit_tests/sparse.dia.ref
new file mode 100755
index 000000000..525798652
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sparse.dia.ref
@@ -0,0 +1,779 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+mode(5)
+lines(0)
+ij=[1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6];
+v=[1;2;3;4;5;6;7;8;9];
+ij1=[1 6;1 2;6 5];
+v1=[-1;-1;-1];
+vc=v+%i*(21:29)';
+v1c=v1+%i*[0;0.3;-1.2];
+zer=sparse([],[],[6,6]);
+//
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;6 5],[-1;-1;-1],[6 6]);
+ma=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9),[6 6]);
+mb=sparse([1 6;1 2;6 5],-[-1;-1;-1],[6 6]);
+ac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
+bc=sparse([1 6;1 2;6 5],[-1;-1;-1]+%i*[0;0.3;-1.2],[6 6]);
+mac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9)-%i*(21:29),[6 6]);
+mbc=sparse([1 6;1 2;6 5],[1;1;1]+%i*[0;-0.3;1.2],[6 6]);
+//
+if %t then
+//-------------------------------------------------------------
+//test des primitives sparse, full
+//--------------------------------------------------------------
+// -- for real matrix
+if or(full(sparse(0.3))<>0.3) then bugmes();quit;end
+v=0*ones(1,3);v(3)=5;v(1)=1;
+if or(full(sparse([1 1;1 3],[1 5]))<>v) then bugmes();quit;end
+v=0*ones(1,300);v(300)=5;v(1)=1;
+if or(full(sparse([1 1;1 300],[1 5]))<>v) then bugmes();quit;end
+v=0*ones(3,1);v(3)=5;v(1)=1;
+if or(full(sparse([1 1;3 1],[1 5]))<>v) then bugmes();quit;end
+v=0*ones(300,1);v(300)=5;v(1)=1;
+if or(full(sparse([1 1;300 1],[1 5]))<>v) then bugmes();quit;end
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+a=[0,0,3,0,2,1;;5,0,0,4,0,0;0,0,0,0,0,0;0,0,7,6,0,0;8,0,0,0,0,0;0,0,0,0,0,9];
+if or(full(sp)<>a) then bugmes();quit;end
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[8 6]);a(8,6)=0;
+if or(full(sp)<>a) then bugmes();quit;end
+if or(full(sparse([],[],[4 10]))<>0*ones(4,10)) then bugmes();quit;end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+a=[0;10;11;12;0;13];
+if or(full(v)<>a) then bugmes();quit;end
+v=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+a=[0,10,11,12,0,13];
+if or(full(v)<>a) then bugmes();quit;end
+// -- for complex matrix
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
+a=[0,0,3+%i*23,0,2+%i*22,1+%i*21
+ 5+%i*25,0,0,4+%i*24,0,0
+ 0,0,0,0,0,0
+ 0,0,7+%i*27,6+%i*26,0,0
+ 8+%i*28,0,0,0,0,0
+ 0,0,0,0,0,9+%i*29];
+if or(full(sp)<>a) then bugmes();quit;end
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[8 6]);
+a(8,6)=0;
+if or(full(sp)<>a) then bugmes();quit;end
+v=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
+a=[0;10-%i*3;11;12+%i*5;0;13+%i*0.5];
+if or(full(v)<>a) then bugmes();quit;end
+v=sparse([1 2;1 3;1 4;1 6],[10-3*%i;11;12+5*%i;13+0.5*%i],[1,6]);
+a=[0,10-%i*3,11,12+%i*5,0,13+%i*0.5];
+if or(full(v)<>a) then bugmes();quit;end
+//-------------------------------------------------------------
+//test de la primitives spget
+//--------------------------------------------------------------
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+[ij,v]=spget(sp);
+if or(ij<>[1,3;1,5;1,6;2,1;2,4;4,3;4,4;5,1;6,6])|or(v<>[3;2;1;5;4;7;6;8;9]) then bugmes();quit;end
+zer=sparse([],[],[6,6]);[ij,v]=spget(zer);
+if ij<>[]|v<>[] then bugmes();quit;end
+//-----------------------------------------------
+// addition and subtraction tests
+//-----------------------------------------------
+// -- real real
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;6 5],[-1;-1;-1],[6 6]);
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+ma=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9),[6 6]);
+mb=sparse([1 6;1 2;6 5],-[-1;-1;-1],[6 6]);
+zer=sparse([],[],[6,6]);
+ac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
+bc=sparse([1 6;1 2;6 5],[-1;-1;-1]+%i*[0;0.3;-1.2],[6 6]);
+vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
+vct=sparse([1 2;1 3;1 4;1 6],[10-3*%i;11;12+5*%i;13+0.5*%i],[1,6]);
+mac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9)-%i*(21:29),[6 6]);
+mbc=sparse([1 6;1 2;6 5],[1;1;1]+%i*[0;-0.3;1.2],[6 6]);
+if or(full(v+sparse([],[],[6,1]))<>full(v)) then bugmes();quit;end
+if or(full(sparse([],[],[6,1])+v)<>full(v)) then bugmes();quit;end
+if or(full(v+v)<>full(v)+full(v)) then bugmes();quit;end
+if or(full(v-v)<>full(v)-full(v)) then bugmes();quit;end
+if or(full(vt+sparse([],[],[1,6]))<>full(vt)) then bugmes();quit;end
+if or(full(vt+vt)<>full(vt)+full(vt)) then bugmes();quit;end
+if or(full(vt-vt)<>full(vt)-full(vt)) then bugmes();quit;end
+if or(full(zer+zer)<>0*ones(6,6)) then bugmes();quit;end
+if or(full(a+a)<>full(a)+full(a)) then bugmes();quit;end
+if or(full(b+b)<>full(b)+full(b)) then bugmes();quit;end
+if or(full(a+zer)<>full(a)) then bugmes();quit;end
+if or(full(zer+a)<>full(a)) then bugmes();quit;end
+if or(full(b+a)<>full(b)+full(a)) then bugmes();quit;end
+if or(full(a+b)<>full(b)+full(a)) then bugmes();quit;end
+if or(full(a+ma)<>full(a)+full(ma)) then bugmes();quit;end
+if or(full(a-a)<>full(a)-full(a)) then bugmes();quit;end
+if or(full(a-ma)<>full(a)-full(ma)) then bugmes();quit;end
+if or(full(b-mb)<>full(b)-full(mb)) then bugmes();quit;end
+if or(full(a-zer)<>full(a)) then bugmes();quit;end
+if or(full(zer-a)<>-full(a)) then bugmes();quit;end
+if or(full(a-mb)<>full(a)-full(mb)) then bugmes();quit;end
+// -- real complex
+if or(full(sparse([],[],[6,1])+vc)<>full(vc)) then bugmes();quit;end
+if or(full(v+vc)<>full(v)+full(vc)) then bugmes();quit;end
+if or(full(v-vc)<>full(v)-full(vc)) then bugmes();quit;end
+if or(full(vt+vct)<>full(vt)+full(vct)) then bugmes();quit;end
+if or(full(vt-vct)<>full(vt)-full(vct)) then bugmes();quit;end
+if or(full(a+ac)<>full(a)+full(ac)) then bugmes();quit;end
+if or(full(b+bc)<>full(b)+full(bc)) then bugmes();quit;end
+if or(full(a+bc)<>full(a)+full(bc)) then bugmes();quit;end
+if or(full(zer+ac)<>full(zer)+full(ac)) then bugmes();quit;end
+if or(full(b+ac)<>full(b)+full(ac)) then bugmes();quit;end
+if or(full(a-ac)<>full(a)-full(ac)) then bugmes();quit;end
+if or(full(b-bc)<>full(b)-full(bc)) then bugmes();quit;end
+if or(full(a-bc)<>full(a)-full(bc)) then bugmes();quit;end
+if or(full(zer-ac)<>full(zer)-full(ac)) then bugmes();quit;end
+if or(full(b-ac)<>full(b)-full(ac)) then bugmes();quit;end
+// -- complex real
+if or(full(vc+v)<>full(vc)+full(v)) then bugmes();quit;end
+if or(full(vc-v)<>full(vc)-full(v)) then bugmes();quit;end
+if or(full(vct+vt)<>full(vct)+full(vt)) then bugmes();quit;end
+if or(full(vct-vt)<>full(vct)-full(vt)) then bugmes();quit;end
+if or(full(ac+a)<>full(ac)+full(a)) then bugmes();quit;end
+if or(full(bc+b)<>full(bc)+full(b)) then bugmes();quit;end
+if or(full(ac+b)<>full(ac)+full(b)) then bugmes();quit;end
+if or(full(ac+zer)<>full(zer)+full(ac)) then bugmes();quit;end
+if or(full(bc+a)<>full(bc)+full(a)) then bugmes();quit;end
+if or(full(ac-a)<>full(ac)-full(a)) then bugmes();quit;end
+if or(full(bc-b)<>full(bc)-full(b)) then bugmes();quit;end
+if or(full(ac-b)<>full(ac)-full(b)) then bugmes();quit;end
+if or(full(ac-zer)<>-full(zer)+full(ac)) then bugmes();quit;end
+if or(full(bc-a)<>full(bc)-full(a)) then bugmes();quit;end
+// -- complex complex
+if or(full(vc+vc)<>full(vc)+full(vc)) then bugmes();quit;end
+if or(full(vc-vc)<>full(vc)-full(vc)) then bugmes();quit;end
+if or(full(vct+vct)<>full(vct)+full(vct)) then bugmes();quit;end
+if or(full(vct-vct)<>full(vct)-full(vct)) then bugmes();quit;end
+if or(full(ac+ac)<>full(ac)+full(ac)) then bugmes();quit;end
+if or(full(bc+bc)<>full(bc)+full(bc)) then bugmes();quit;end
+if or(full(ac+bc)<>full(ac)+full(bc)) then bugmes();quit;end
+if or(full(bc+ac)<>full(bc)+full(ac)) then bugmes();quit;end
+if or(full(ac-ac)<>full(zer)) then bugmes();quit;end
+if or(full(bc-bc)<>full(zer)) then bugmes();quit;end
+if or(full(ac-bc)<>full(ac)-full(bc)) then bugmes();quit;end
+if or(full(bc-ac)<>full(bc)-full(ac)) then bugmes();quit;end
+// sparse full and full sparse operation (soft coded apoerations)
+if or(full(a+1)<>full(a)+1) then bugmes();quit;end
+if or(full(1+a)<>full(a)+1) then bugmes();quit;end
+if or(full(a+ones(6,6))<>full(a)+ones(6,6)) then bugmes();quit;end
+if or(full(ones(6,6)+a)<>full(a)+ones(6,6)) then bugmes();quit;end
+if or(full(a+2*eye())<>full(a)+2*eye()) then bugmes();quit;end
+if or(full(2*eye()+a)<>full(a)+2*eye()) then bugmes();quit;end
+if or(full(a-1)<>full(a)-1) then bugmes();quit;end
+if or(full(1-a)<>1-full(a)) then bugmes();quit;end
+if or(full(a-ones(6,6))<>full(a)-ones(6,6)) then bugmes();quit;end
+if or(full(ones(6,6)-a)<>ones(6,6)-full(a)) then bugmes();quit;end
+if or(full(a-2*eye())<>full(a)-2*eye()) then bugmes();quit;end
+if or(full(2*eye()-a)<>2*eye()-full(a)) then bugmes();quit;end
+if or(full(ac+1)<>full(ac)+1) then bugmes();quit;end
+if or(full(1+ac)<>full(ac)+1) then bugmes();quit;end
+if or(full(ac+ones(6,6))<>full(ac)+ones(6,6)) then bugmes();quit;end
+if or(full(ones(6,6)+ac)<>full(ac)+ones(6,6)) then bugmes();quit;end
+if or(full(ac+2*eye())<>full(ac)+2*eye()) then bugmes();quit;end
+if or(full(2*eye()+ac)<>full(ac)+2*eye()) then bugmes();quit;end
+if or(full(ac-1)<>full(ac)-1) then bugmes();quit;end
+if or(full(1-ac)<>1-full(ac)) then bugmes();quit;end
+if or(full(ac-ones(6,6))<>full(ac)-ones(6,6)) then bugmes();quit;end
+if or(full(ones(6,6)-ac)<>ones(6,6)-full(ac)) then bugmes();quit;end
+if or(full(ac-2*eye())<>full(ac)-2*eye()) then bugmes();quit;end
+if or(full(2*eye()-ac)<>2*eye()-full(ac)) then bugmes();quit;end
+if or(full(ac+full(bc))<>full(ac)+full(bc)) then bugmes();quit;end
+if or(full(ac-full(bc))<>full(ac)-full(bc)) then bugmes();quit;end
+if or(full(full(ac)+full(bc))<>full(ac)+full(bc)) then bugmes();quit;end
+end
+if %t then
+//-----------------------------------------------
+// multiplication tests
+//-----------------------------------------------
+// real x real
+// sparse scalar , saclar sparse
+if or(full(a*2)<>full(a)*2) then bugmes();quit;end
+if or(full(2*a)<>full(a)*2) then bugmes();quit;end
+if a*[]<>[] then bugmes();quit;end
+if []*a<>[] then bugmes();quit;end
+c=rand(6,6);
+if norm(a*c-full(a)*c) >100*%eps then bugmes();quit;end
+if norm(c*a-c*full(a)) >100*%eps then bugmes();quit;end
+// sparse sparse
+if or(full(zer*zer)<>full(zer)) then bugmes();quit;end
+if or(full(a*zer)<>full(zer)) then bugmes();quit;end
+if or(full(zer*a)<>full(zer)) then bugmes();quit;end
+if norm(full(a*a)-full(a)*full(a),1)>100*%eps then bugmes();quit;end
+if norm(full(b*b)-full(b)*full(b),1)>100*%eps then bugmes();quit;end
+if norm(full(a*b)-full(a)*full(b),1)>100*%eps then bugmes();quit;end
+if norm(full(b*a)-full(b)*full(a),1)>100*%eps then bugmes();quit;end
+// complex x real real x complex
+// sparse scalar , scalar sparse
+if or(full(ac*2)<>full(ac)*2) then bugmes();quit;end
+if or(full(2*ac)<>full(ac)*2) then bugmes();quit;end
+if norm(full((2+%i)*a)-(2+%i)*full(a),1) >100*%eps then bugmes();quit;end
+if norm(full(a*(2+%i))-(2+%i)*full(a),1) >100*%eps then bugmes();quit;end
+if ac*[]<>[] then bugmes();quit;end
+if []*ac<>[] then bugmes();quit;end
+c=rand(6,6);
+cc=c+rand(6,6)*%i;
+if norm(ac*c-full(ac)*c) >100*%eps then bugmes();quit;end
+if norm(cc*a-cc*full(a)) >100*%eps then bugmes();quit;end
+// sparse sparse
+if or(full(ac*zer)<>full(zer)) then bugmes();quit;end
+if or(full(zer*ac)<>full(zer)) then bugmes();quit;end
+if norm(full(ac*a)-full(ac)*full(a),1)>100*%eps then bugmes();quit;end
+if norm(full(bc*b)-full(bc)*full(b),1)>100*%eps then bugmes();quit;end
+if norm(full(a*bc)-full(a)*full(bc),1)>100*%eps then bugmes();quit;end
+if norm(full(b*ac)-full(b)*full(ac),1)>100*%eps then bugmes();quit;end
+// // complex x complex
+if norm(ac*cc-full(ac)*cc) >100*%eps then bugmes();quit;end
+if norm(cc*ac-cc*full(ac)) >100*%eps then bugmes();quit;end
+// sparse sparse
+if norm(full(ac*ac)-full(ac)*full(ac),1)>100*%eps then bugmes();quit;end
+if norm(full(bc*bc)-full(bc)*full(bc),1)>100*%eps then bugmes();quit;end
+if norm(full(bc*ac)-full(bc)*full(ac),1)>100*%eps then bugmes();quit;end
+//----------------------------------------------------------
+// element wise multiplication tests
+//----------------------------------------------------------
+if or(full(ac.*2)<>full(ac)*2) then bugmes();quit;end
+if or(full((2).*ac)<>full(ac)*2) then bugmes();quit;end
+if a.*[]<>[] then bugmes();quit;end
+if [].*a<>[] then bugmes();quit;end
+c=rand(6,6);
+//if norm(a*c-full(a)*c) >100*%eps then bugmes();quit;end
+//if norm(c*a-c*full(a)) >100*%eps then bugmes();quit;end
+// sparse sparse
+if or(full(zer.*zer)<>full(zer)) then bugmes();quit;end
+if or(full(a.*zer)<>full(zer)) then bugmes();quit;end
+if or(full(zer.*a)<>full(zer)) then bugmes();quit;end
+if norm(full(a.*a)-full(a).*full(a),1)>100*%eps then bugmes();quit;end
+if norm(full(b.*b)-full(b).*full(b),1)>100*%eps then bugmes();quit;end
+if norm(full(a.*b)-full(a).*full(b),1)>100*%eps then bugmes();quit;end
+if norm(full(b.*a)-full(b).*full(a),1)>100*%eps then bugmes();quit;end
+// complex x real real x complex
+// sparse scalar , scalar sparse
+if norm(full((2+%i).*a)-(2+%i).*full(a),1) >100*%eps then bugmes();quit;end
+if norm(full(a.*(2+%i))-(2+%i).*full(a),1) >100*%eps then bugmes();quit;end
+if ac.*[]<>[] then bugmes();quit;end
+if [].*ac<>[] then bugmes();quit;end
+c=rand(6,6);
+cc=c+rand(6,6)*%i;
+if norm(full(ac.*c)-full(ac).*c) >100*%eps then bugmes();quit;end
+if norm(full(cc.*a)-cc.*full(a)) >100*%eps then bugmes();quit;end
+// sparse sparse
+if or(full(ac.*zer)<>full(zer)) then bugmes();quit;end
+if or(full(zer.*ac)<>full(zer)) then bugmes();quit;end
+if norm(full(ac.*a)-full(ac).*full(a),1)>100*%eps then bugmes();quit;end
+if norm(full(bc.*b)-full(bc).*full(b),1)>100*%eps then bugmes();quit;end
+if norm(full(a.*bc)-full(a).*full(bc),1)>100*%eps then bugmes();quit;end
+if norm(full(b.*ac)-full(b).*full(ac),1)>100*%eps then bugmes();quit;end
+// // complex x complex
+if norm(ac.*cc-full(ac).*cc) >100*%eps then bugmes();quit;end
+if norm(cc.*ac-cc.*full(ac)) >100*%eps then bugmes();quit;end
+// sparse sparse
+if norm(full(ac.*ac)-full(ac).*full(ac),1)>100*%eps then bugmes();quit;end
+if norm(full(bc.*bc)-full(bc).*full(bc),1)>100*%eps then bugmes();quit;end
+if norm(full(bc.*ac)-full(bc).*full(ac),1)>100*%eps then bugmes();quit;end
+// ----------------------------------------------------------
+// test de la transposition
+//-----------------------------------------------------------
+if or(full(a')<>full(a)') then bugmes();quit;end
+if or(full(ac')<>full(ac)') then bugmes();quit;end
+if or(full(zer')<>full(zer)' ) then bugmes();quit;end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+if or(full(v')<>full(v)') then bugmes();quit;end
+if or(full((v')')<>full(v)) then bugmes();quit;end
+vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
+if or(full(vc')<>full(vc)') then bugmes();quit;end
+if or(full((vc')')<>full(vc)) then bugmes();quit;end
+// ----------------------------------------------------------
+// test des concatenation
+//-----------------------------------------------------------
+if or(full([a])<>full(a)) then bugmes();quit;end
+if or(full([a b])<>[full(a) full(b)]) then bugmes();quit;end
+if or(full([a;b])<>[full(a);full(b)]) then bugmes();quit;end
+if or(full([a []])<>full(a)) then bugmes();quit;end
+if or(full([a;[]])<>full(a)) then bugmes();quit;end
+if or(full([a zer])<>[full(a) full(zer)]) then bugmes();quit;end
+if or(full([zer;b])<>[full(zer);full(b)]) then bugmes();quit;end
+if or(full([ac])<>full(ac)) then bugmes();quit;end
+if or(full([ac b])<>[full(ac) full(b)]) then bugmes();quit;end
+if or(full([ac;b])<>[full(ac);full(b)]) then bugmes();quit;end
+if or(full([ac []])<>full(ac)) then bugmes();quit;end
+if or(full([ac;[]])<>full(ac)) then bugmes();quit;end
+if or(full([a bc])<>[full(a) full(bc)]) then bugmes();quit;end
+if or(full([a;bc])<>[full(a);full(bc)]) then bugmes();quit;end
+if or(full([ac bc])<>[full(ac) full(bc)]) then bugmes();quit;end
+if or(full([ac;bc])<>[full(ac);full(bc)]) then bugmes();quit;end
+// ----------------------------------------------------------
+// test des extractions
+//-----------------------------------------------------------
+af=full(a);
+if or(full(a(1,3))<>af(1,3)) then bugmes();quit;end
+if or(full(a(1,4))<>af(1,4)) then bugmes();quit;end
+if or(full(a(1,:))<>af(1,:)) then bugmes();quit;end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);vf=full(v);
+if or(full(v(:))<>vf(:)) then bugmes();quit;end
+if or(full(v(3:4))<>vf(3:4)) then bugmes();quit;end
+if or(full(v([1 5]))<>vf([1 5])) then bugmes();quit;end
+if or(full(v([4 3]))<>vf([4 3])) then bugmes();quit;end
+if or(full(v([4 4]))<>vf([4 4])) then bugmes();quit;end
+if or(full(v([1 1]))<>vf([1 1])) then bugmes();quit;end
+v=v';vf=vf';
+if or(full(v(:))<>vf(:)) then bugmes();quit;end
+if or(full(v(3:4))<>vf(3:4)) then bugmes();quit;end
+if or(full(v([1 5]))<>vf([1 5])) then bugmes();quit;end
+if or(full(v([4 3]))<>vf([4 3])) then bugmes();quit;end
+if or(full(v([4 4]))<>vf([4 4])) then bugmes();quit;end
+if or(full(v([1 1]))<>vf([1 1])) then bugmes();quit;end
+acff=full(ac);
+if or(full(ac(1,3))<>acff(1,3)) then bugmes();quit;end
+if or(full(ac(1,4))<>acff(1,4)) then bugmes();quit;end
+if or(full(ac(1,:))<>acff(1,:)) then bugmes();quit;end
+vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);vcf=full(vc);
+if or(full(vc(:))<>vcf(:)) then bugmes();quit;end
+if or(full(vc(3:4))<>vcf(3:4)) then bugmes();quit;end
+if or(full(vc([1 5]))<>vcf([1 5])) then bugmes();quit;end
+if or(full(vc([4 3]))<>vcf([4 3])) then bugmes();quit;end
+if or(full(vc([4 4]))<>vcf([4 4])) then bugmes();quit;end
+if or(full(vc([1 1]))<>vcf([1 1])) then bugmes();quit;end
+vc=vc';vcf=vcf';
+if or(full(vc(:))<>vcf(:)) then bugmes();quit;end
+if or(full(vc(3:4))<>vcf(3:4)) then bugmes();quit;end
+if or(full(vc([1 5]))<>vcf([1 5])) then bugmes();quit;end
+if or(full(vc([4 3]))<>vcf([4 3])) then bugmes();quit;end
+if or(full(vc([4 4]))<>vcf([4 4])) then bugmes();quit;end
+if or(full(vc([1 1]))<>vcf([1 1])) then bugmes();quit;end
+// ----------------------------------------------------------
+// test des insertions
+//-----------------------------------------------------------
+end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+// full line insertion
+//----------------------
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([1 3],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([3 1],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);Vt=full(vt);A([1 3 1],:)=[Vt;2*Vt;3*Vt];
+if or(full(a1)<>A) then bugmes();quit;end
+// insert zero vector
+vt=sparse([],[],[1,6]);
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([1 3],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([3 1],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);Vt=full(vt);A([1 3 1],:)=[Vt;2*Vt;3*Vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a=sparse([],[],[6,6]);
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+// insert zero vector
+vt=sparse([],[],[1,6]);
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then bugmes();quit;end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+v=sparse([],[],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([],[],[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([],[],[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a=sparse([],[],[6,6]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+v=sparse([],[],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+v=sparse([],[],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([],[],[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+b=sparse([],[],[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then bugmes();quit;end
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 2;1 3;3 3],-(1:3),[3,3]);
+a1=a;a1(1,1)=sparse(30);A=full(a);A(1,1)=30;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,6)=sparse(30);A=full(a);A(1,6)=30;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,8)=sparse(30);A=full(a);A(1,8)=30;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=full(b);
+if or(full(a1)<>A) then bugmes();quit;end
+//sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+vt=11:16;
+// full line insertion
+//----------------------
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);A([1 3],:)=[vt;2*vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);A([3 1],:)=[vt;2*vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);A([1 3 1],:)=[vt;2*vt;3*vt];
+if or(full(a1)<>A) then bugmes();quit;end
+a=sparse([],[],[6,6]);
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[1:6;11:16];
+a1=a;a1([1 3],:)=b;A=full(a);A([1 3],:)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 1],:)=b;A=full(a);A([3 1],:)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[1:6;11:16;21:26];
+a1=a;a1([1 3 1],:)=b;A=full(a);A([1 3 1],:)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+v=(1:6)';
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,3)=v;A=full(a);A(:,3)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+//
+a1=a;a1(:,7)=v;A=full(a);A(:,7)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,8)=v;A=full(a);A(:,8)=v;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[(1:6)' (11:16)'];
+a1=a;a1(:,[1 3])=b;A=full(a);A(:,[1 3])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(:,[3 1])=b;A=full(a);A(:,[3 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+b=[(1:6)' (11:16)' (21:26)'];
+a1=a;a1(:,[1 3 1])=b;A=full(a);A(:,[1 3 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+//********
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=-[1 2 3;4 5 6;7 8 9];
+a1=a;a1(1,1)=30;A=full(a);A(1,1)=30;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,6)=30;A=full(a);A(1,6)=30;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1,8)=30;A=full(a);A(1,8)=30;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=b;
+if or(full(a1)<>A) then bugmes();quit;end
+// vector insertion
+v=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);
+v1=v;v1(1)=33;V=full(v);V(1)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=33;V=full(v);V(2)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=33;V=full(v);V(8)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=[5;10;33];V=full(v);V([1 2 8])=[5;10;33];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then bugmes();quit;end
+v1=v;v1(1)=sparse(33);V=full(v);V(1)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=sparse(33);V=full(v);V(2)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=sparse(33);V=full(v);V(8)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=sparse([5;10;33]);V=full(v);V([1 2 8])=[5;10;33];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 1])=sparse([5;10;33]);V=full(v);V([1 2 1])=[5;10;33];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then bugmes();quit;end
+v1=v;v1(:)=sparse([2 1],44,[6 1]);V=full(v);V(:)=[0;44;0;0;0;0];
+if or(full(v1)<>V) then bugmes();quit;end
+v=v';
+v1=v;v1(1)=33;V=full(v);V(1)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=33;V=full(v);V(2)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=33;V=full(v);V(8)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=[5 10 33];V=full(v);V([1 2 8])=[5 10 33];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(1)=sparse(33);V=full(v);V(1)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(2)=sparse(33);V=full(v);V(2)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(8)=sparse(33);V=full(v);V(8)=33;
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 8])=sparse([5 10 33]);V=full(v);V([1 2 8])=[5 10 33];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1([1 2 1])=sparse([5 10 33]);V=full(v);V([1 2 1])=[5 10 33];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(:)=sparse([1 2],44,[1,6]);V=full(v);V(:)=[0 44 0 0 0 0];
+if or(full(v1)<>V) then bugmes();quit;end
+v1=v;v1(1)=[];V=full(v);V(1)=[];
+if or(full(v1)<>V) then bugmes();quit;end
+//test des comparaisons
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;6 5],[10;-1;-1],[6 6]);
+if full(a==a)<>full(a)==full(a) then bugmes();quit;end
+if full(a<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a>sparse(5))<>(full(a)>5) then bugmes();quit;end
+if full(sparse(5)>a)<>(5>full(a)) then bugmes();quit;end
+if full(b>a)<>(full(b)>full(a)) then bugmes();quit;end
+if full(a==full(a))<>full(a)==full(a) then bugmes();quit;end
+if full(a<>full(a))<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a>5)<>(full(a)>5) then bugmes();quit;end
+if full(5>a)<>(5>full(a)) then bugmes();quit;end
+if full(b>full(a))<>(full(b)>full(a)) then bugmes();quit;end
+if full(full(a)==a)<>full(a)==full(a) then bugmes();quit;end
+if full(full(a)<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(full(a)>sparse(5))<>(full(a)>5) then bugmes();quit;end
+if full(full(b)>a)<>(full(b)>full(a)) then bugmes();quit;end
+a=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);
+if full(a==a)<>full(a)==full(a) then bugmes();quit;end
+if full(a<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a>sparse(5))<>(full(a)>5) then bugmes();quit;end
+if full(sparse(5)>a)<>(5>full(a)) then bugmes();quit;end
+if full(a==full(a))<>full(a)==full(a) then bugmes();quit;end
+if full(a<>full(a))<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a>5)<>(full(a)>5) then bugmes();quit;end
+if full(5>a)<>(5>full(a)) then bugmes();quit;end
+if full(full(a)==a)<>full(a)==full(a) then bugmes();quit;end
+if full(full(a)<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(full(a)>sparse(5))<>(full(a)>5) then bugmes();quit;end
+a=a';
+if full(a==a)<>full(a)==full(a) then bugmes();quit;end
+if full(a<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a>sparse(5))<>(full(a)>5) then bugmes();quit;end
+if full(sparse(5)>a)<>(5>full(a)) then bugmes();quit;end
+if full(a==full(a))<>full(a)==full(a) then bugmes();quit;end
+if full(a<>full(a))<>(full(a)<>full(a)) then bugmes();quit;end
+if full(a>5)<>(full(a)>5) then bugmes();quit;end
+if full(5>a)<>(5>full(a)) then bugmes();quit;end
+if full(full(a)==a)<>full(a)==full(a) then bugmes();quit;end
+if full(full(a)<>a)<>(full(a)<>full(a)) then bugmes();quit;end
+if full(full(a)>sparse(5))<>(full(a)>5) then bugmes();quit;end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;5 5],[10;-1;-1],[5 6]);
+if a==b<>%f then bugmes();quit;end
+if a<>b<>%t then bugmes();quit;end
+a=sparse([%f %t %f %t]);
+b=sparse([%t %f %t %f]);
+assert_checkequal(~a, b);
diff --git a/modules/sparse/tests/unit_tests/sparse.tst b/modules/sparse/tests/unit_tests/sparse.tst
new file mode 100755
index 000000000..ddd6f2911
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sparse.tst
@@ -0,0 +1,782 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+mode(5)
+lines(0)
+ij=[1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6];
+v=[1;2;3;4;5;6;7;8;9];
+ij1=[1 6;1 2;6 5];
+v1=[-1;-1;-1];
+vc=v+%i*(21:29)';
+v1c=v1+%i*[0;0.3;-1.2];
+zer=sparse([],[],[6,6]);
+//
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;6 5],[-1;-1;-1],[6 6]);
+ma=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9),[6 6]);
+mb=sparse([1 6;1 2;6 5],-[-1;-1;-1],[6 6]);
+ac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
+bc=sparse([1 6;1 2;6 5],[-1;-1;-1]+%i*[0;0.3;-1.2],[6 6]);
+mac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9)-%i*(21:29),[6 6]);
+mbc=sparse([1 6;1 2;6 5],[1;1;1]+%i*[0;-0.3;1.2],[6 6]);
+//
+if %t then
+//-------------------------------------------------------------
+//test des primitives sparse, full
+//--------------------------------------------------------------
+// -- for real matrix
+if or(full(sparse(0.3))<>0.3) then pause,end
+v=0*ones(1,3);v(3)=5;v(1)=1;
+if or(full(sparse([1 1;1 3],[1 5]))<>v) then pause,end
+v=0*ones(1,300);v(300)=5;v(1)=1;
+if or(full(sparse([1 1;1 300],[1 5]))<>v) then pause,end
+v=0*ones(3,1);v(3)=5;v(1)=1;
+if or(full(sparse([1 1;3 1],[1 5]))<>v) then pause,end
+v=0*ones(300,1);v(300)=5;v(1)=1;
+if or(full(sparse([1 1;300 1],[1 5]))<>v) then pause,end
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+a=[0,0,3,0,2,1;;5,0,0,4,0,0;0,0,0,0,0,0;0,0,7,6,0,0;8,0,0,0,0,0;0,0,0,0,0,9];
+if or(full(sp)<>a) then pause,end
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[8 6]);a(8,6)=0;
+if or(full(sp)<>a) then pause,end
+if or(full(sparse([],[],[4 10]))<>0*ones(4,10)) then pause,end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+a=[0;10;11;12;0;13];
+if or(full(v)<>a) then pause,end
+v=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+a=[0,10,11,12,0,13];
+if or(full(v)<>a) then pause,end
+// -- for complex matrix
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
+a=[0,0,3+%i*23,0,2+%i*22,1+%i*21
+ 5+%i*25,0,0,4+%i*24,0,0
+ 0,0,0,0,0,0
+ 0,0,7+%i*27,6+%i*26,0,0
+ 8+%i*28,0,0,0,0,0
+ 0,0,0,0,0,9+%i*29];
+if or(full(sp)<>a) then pause,end
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[8 6]);
+a(8,6)=0;
+if or(full(sp)<>a) then pause,end
+v=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
+a=[0;10-%i*3;11;12+%i*5;0;13+%i*0.5];
+if or(full(v)<>a) then pause,end
+v=sparse([1 2;1 3;1 4;1 6],[10-3*%i;11;12+5*%i;13+0.5*%i],[1,6]);
+a=[0,10-%i*3,11,12+%i*5,0,13+%i*0.5];
+if or(full(v)<>a) then pause,end
+//-------------------------------------------------------------
+//test de la primitives spget
+//--------------------------------------------------------------
+sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+[ij,v]=spget(sp);
+if or(ij<>[1,3;1,5;1,6;2,1;2,4;4,3;4,4;5,1;6,6])|or(v<>[3;2;1;5;4;7;6;8;9]) then pause,end
+zer=sparse([],[],[6,6]);[ij,v]=spget(zer);
+if ij<>[]|v<>[] then pause,end
+//-----------------------------------------------
+// addition and subtraction tests
+//-----------------------------------------------
+// -- real real
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;6 5],[-1;-1;-1],[6 6]);
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+ma=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9),[6 6]);
+mb=sparse([1 6;1 2;6 5],-[-1;-1;-1],[6 6]);
+zer=sparse([],[],[6,6]);
+ac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
+bc=sparse([1 6;1 2;6 5],[-1;-1;-1]+%i*[0;0.3;-1.2],[6 6]);
+vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
+vct=sparse([1 2;1 3;1 4;1 6],[10-3*%i;11;12+5*%i;13+0.5*%i],[1,6]);
+mac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9)-%i*(21:29),[6 6]);
+mbc=sparse([1 6;1 2;6 5],[1;1;1]+%i*[0;-0.3;1.2],[6 6]);
+if or(full(v+sparse([],[],[6,1]))<>full(v)) then pause,end
+if or(full(sparse([],[],[6,1])+v)<>full(v)) then pause,end
+if or(full(v+v)<>full(v)+full(v)) then pause,end
+if or(full(v-v)<>full(v)-full(v)) then pause,end
+if or(full(vt+sparse([],[],[1,6]))<>full(vt)) then pause,end
+if or(full(vt+vt)<>full(vt)+full(vt)) then pause,end
+if or(full(vt-vt)<>full(vt)-full(vt)) then pause,end
+if or(full(zer+zer)<>0*ones(6,6)) then pause,end
+if or(full(a+a)<>full(a)+full(a)) then pause,end
+if or(full(b+b)<>full(b)+full(b)) then pause,end
+if or(full(a+zer)<>full(a)) then pause,end
+if or(full(zer+a)<>full(a)) then pause,end
+if or(full(b+a)<>full(b)+full(a)) then pause,end
+if or(full(a+b)<>full(b)+full(a)) then pause,end
+if or(full(a+ma)<>full(a)+full(ma)) then pause,end
+if or(full(a-a)<>full(a)-full(a)) then pause,end
+if or(full(a-ma)<>full(a)-full(ma)) then pause,end
+if or(full(b-mb)<>full(b)-full(mb)) then pause,end
+if or(full(a-zer)<>full(a)) then pause,end
+if or(full(zer-a)<>-full(a)) then pause,end
+if or(full(a-mb)<>full(a)-full(mb)) then pause,end
+// -- real complex
+if or(full(sparse([],[],[6,1])+vc)<>full(vc)) then pause,end
+if or(full(v+vc)<>full(v)+full(vc)) then pause,end
+if or(full(v-vc)<>full(v)-full(vc)) then pause,end
+if or(full(vt+vct)<>full(vt)+full(vct)) then pause,end
+if or(full(vt-vct)<>full(vt)-full(vct)) then pause,end
+if or(full(a+ac)<>full(a)+full(ac)) then pause,end
+if or(full(b+bc)<>full(b)+full(bc)) then pause,end
+if or(full(a+bc)<>full(a)+full(bc)) then pause,end
+if or(full(zer+ac)<>full(zer)+full(ac)) then pause,end
+if or(full(b+ac)<>full(b)+full(ac)) then pause,end
+if or(full(a-ac)<>full(a)-full(ac)) then pause,end
+if or(full(b-bc)<>full(b)-full(bc)) then pause,end
+if or(full(a-bc)<>full(a)-full(bc)) then pause,end
+if or(full(zer-ac)<>full(zer)-full(ac)) then pause,end
+if or(full(b-ac)<>full(b)-full(ac)) then pause,end
+// -- complex real
+if or(full(vc+v)<>full(vc)+full(v)) then pause,end
+if or(full(vc-v)<>full(vc)-full(v)) then pause,end
+if or(full(vct+vt)<>full(vct)+full(vt)) then pause,end
+if or(full(vct-vt)<>full(vct)-full(vt)) then pause,end
+if or(full(ac+a)<>full(ac)+full(a)) then pause,end
+if or(full(bc+b)<>full(bc)+full(b)) then pause,end
+if or(full(ac+b)<>full(ac)+full(b)) then pause,end
+if or(full(ac+zer)<>full(zer)+full(ac)) then pause,end
+if or(full(bc+a)<>full(bc)+full(a)) then pause,end
+if or(full(ac-a)<>full(ac)-full(a)) then pause,end
+if or(full(bc-b)<>full(bc)-full(b)) then pause,end
+if or(full(ac-b)<>full(ac)-full(b)) then pause,end
+if or(full(ac-zer)<>-full(zer)+full(ac)) then pause,end
+if or(full(bc-a)<>full(bc)-full(a)) then pause,end
+// -- complex complex
+if or(full(vc+vc)<>full(vc)+full(vc)) then pause,end
+if or(full(vc-vc)<>full(vc)-full(vc)) then pause,end
+if or(full(vct+vct)<>full(vct)+full(vct)) then pause,end
+if or(full(vct-vct)<>full(vct)-full(vct)) then pause,end
+if or(full(ac+ac)<>full(ac)+full(ac)) then pause,end
+if or(full(bc+bc)<>full(bc)+full(bc)) then pause,end
+if or(full(ac+bc)<>full(ac)+full(bc)) then pause,end
+if or(full(bc+ac)<>full(bc)+full(ac)) then pause,end
+if or(full(ac-ac)<>full(zer)) then pause,end
+if or(full(bc-bc)<>full(zer)) then pause,end
+if or(full(ac-bc)<>full(ac)-full(bc)) then pause,end
+if or(full(bc-ac)<>full(bc)-full(ac)) then pause,end
+// sparse full and full sparse operation (soft coded apoerations)
+if or(full(a+1)<>full(a)+1) then pause,end
+if or(full(1+a)<>full(a)+1) then pause,end
+if or(full(a+ones(6,6))<>full(a)+ones(6,6)) then pause,end
+if or(full(ones(6,6)+a)<>full(a)+ones(6,6)) then pause,end
+if or(full(a+2*eye())<>full(a)+2*eye()) then pause,end
+if or(full(2*eye()+a)<>full(a)+2*eye()) then pause,end
+if or(full(a-1)<>full(a)-1) then pause,end
+if or(full(1-a)<>1-full(a)) then pause,end
+if or(full(a-ones(6,6))<>full(a)-ones(6,6)) then pause,end
+if or(full(ones(6,6)-a)<>ones(6,6)-full(a)) then pause,end
+if or(full(a-2*eye())<>full(a)-2*eye()) then pause,end
+if or(full(2*eye()-a)<>2*eye()-full(a)) then pause,end
+if or(full(ac+1)<>full(ac)+1) then pause,end
+if or(full(1+ac)<>full(ac)+1) then pause,end
+if or(full(ac+ones(6,6))<>full(ac)+ones(6,6)) then pause,end
+if or(full(ones(6,6)+ac)<>full(ac)+ones(6,6)) then pause,end
+if or(full(ac+2*eye())<>full(ac)+2*eye()) then pause,end
+if or(full(2*eye()+ac)<>full(ac)+2*eye()) then pause,end
+if or(full(ac-1)<>full(ac)-1) then pause,end
+if or(full(1-ac)<>1-full(ac)) then pause,end
+if or(full(ac-ones(6,6))<>full(ac)-ones(6,6)) then pause,end
+if or(full(ones(6,6)-ac)<>ones(6,6)-full(ac)) then pause,end
+if or(full(ac-2*eye())<>full(ac)-2*eye()) then pause,end
+if or(full(2*eye()-ac)<>2*eye()-full(ac)) then pause,end
+if or(full(ac+full(bc))<>full(ac)+full(bc)) then pause,end
+if or(full(ac-full(bc))<>full(ac)-full(bc)) then pause,end
+if or(full(full(ac)+full(bc))<>full(ac)+full(bc)) then pause,end
+end
+if %t then
+//-----------------------------------------------
+// multiplication tests
+//-----------------------------------------------
+// real x real
+// sparse scalar , saclar sparse
+if or(full(a*2)<>full(a)*2) then pause,end
+if or(full(2*a)<>full(a)*2) then pause,end
+if a*[]<>[] then pause,end
+if []*a<>[] then pause,end
+c=rand(6,6);
+if norm(a*c-full(a)*c) >100*%eps then pause,end
+if norm(c*a-c*full(a)) >100*%eps then pause,end
+// sparse sparse
+if or(full(zer*zer)<>full(zer)) then pause,end
+if or(full(a*zer)<>full(zer)) then pause,end
+if or(full(zer*a)<>full(zer)) then pause,end
+if norm(full(a*a)-full(a)*full(a),1)>100*%eps then pause,end
+if norm(full(b*b)-full(b)*full(b),1)>100*%eps then pause,end
+if norm(full(a*b)-full(a)*full(b),1)>100*%eps then pause,end
+if norm(full(b*a)-full(b)*full(a),1)>100*%eps then pause,end
+// complex x real real x complex
+// sparse scalar , scalar sparse
+if or(full(ac*2)<>full(ac)*2) then pause,end
+if or(full(2*ac)<>full(ac)*2) then pause,end
+if norm(full((2+%i)*a)-(2+%i)*full(a),1) >100*%eps then pause,end
+if norm(full(a*(2+%i))-(2+%i)*full(a),1) >100*%eps then pause,end
+if ac*[]<>[] then pause,end
+if []*ac<>[] then pause,end
+c=rand(6,6);
+cc=c+rand(6,6)*%i;
+if norm(ac*c-full(ac)*c) >100*%eps then pause,end
+if norm(cc*a-cc*full(a)) >100*%eps then pause,end
+// sparse sparse
+if or(full(ac*zer)<>full(zer)) then pause,end
+if or(full(zer*ac)<>full(zer)) then pause,end
+if norm(full(ac*a)-full(ac)*full(a),1)>100*%eps then pause,end
+if norm(full(bc*b)-full(bc)*full(b),1)>100*%eps then pause,end
+if norm(full(a*bc)-full(a)*full(bc),1)>100*%eps then pause,end
+if norm(full(b*ac)-full(b)*full(ac),1)>100*%eps then pause,end
+// // complex x complex
+if norm(ac*cc-full(ac)*cc) >100*%eps then pause,end
+if norm(cc*ac-cc*full(ac)) >100*%eps then pause,end
+// sparse sparse
+if norm(full(ac*ac)-full(ac)*full(ac),1)>100*%eps then pause,end
+if norm(full(bc*bc)-full(bc)*full(bc),1)>100*%eps then pause,end
+if norm(full(bc*ac)-full(bc)*full(ac),1)>100*%eps then pause,end
+//----------------------------------------------------------
+// element wise multiplication tests
+//----------------------------------------------------------
+if or(full(ac.*2)<>full(ac)*2) then pause,end
+if or(full((2).*ac)<>full(ac)*2) then pause,end
+if a.*[]<>[] then pause,end
+if [].*a<>[] then pause,end
+c=rand(6,6);
+//if norm(a*c-full(a)*c) >100*%eps then pause,end
+//if norm(c*a-c*full(a)) >100*%eps then pause,end
+// sparse sparse
+if or(full(zer.*zer)<>full(zer)) then pause,end
+if or(full(a.*zer)<>full(zer)) then pause,end
+if or(full(zer.*a)<>full(zer)) then pause,end
+if norm(full(a.*a)-full(a).*full(a),1)>100*%eps then pause,end
+if norm(full(b.*b)-full(b).*full(b),1)>100*%eps then pause,end
+if norm(full(a.*b)-full(a).*full(b),1)>100*%eps then pause,end
+if norm(full(b.*a)-full(b).*full(a),1)>100*%eps then pause,end
+// complex x real real x complex
+// sparse scalar , scalar sparse
+if norm(full((2+%i).*a)-(2+%i).*full(a),1) >100*%eps then pause,end
+if norm(full(a.*(2+%i))-(2+%i).*full(a),1) >100*%eps then pause,end
+if ac.*[]<>[] then pause,end
+if [].*ac<>[] then pause,end
+c=rand(6,6);
+cc=c+rand(6,6)*%i;
+if norm(full(ac.*c)-full(ac).*c) >100*%eps then pause,end
+if norm(full(cc.*a)-cc.*full(a)) >100*%eps then pause,end
+// sparse sparse
+if or(full(ac.*zer)<>full(zer)) then pause,end
+if or(full(zer.*ac)<>full(zer)) then pause,end
+if norm(full(ac.*a)-full(ac).*full(a),1)>100*%eps then pause,end
+if norm(full(bc.*b)-full(bc).*full(b),1)>100*%eps then pause,end
+if norm(full(a.*bc)-full(a).*full(bc),1)>100*%eps then pause,end
+if norm(full(b.*ac)-full(b).*full(ac),1)>100*%eps then pause,end
+// // complex x complex
+if norm(ac.*cc-full(ac).*cc) >100*%eps then pause,end
+if norm(cc.*ac-cc.*full(ac)) >100*%eps then pause,end
+// sparse sparse
+if norm(full(ac.*ac)-full(ac).*full(ac),1)>100*%eps then pause,end
+if norm(full(bc.*bc)-full(bc).*full(bc),1)>100*%eps then pause,end
+if norm(full(bc.*ac)-full(bc).*full(ac),1)>100*%eps then pause,end
+// ----------------------------------------------------------
+// test de la transposition
+//-----------------------------------------------------------
+if or(full(a')<>full(a)') then pause,end
+if or(full(ac')<>full(ac)') then pause,end
+if or(full(zer')<>full(zer)' ) then pause,end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+if or(full(v')<>full(v)') then pause,end
+if or(full((v')')<>full(v)) then pause,end
+vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
+if or(full(vc')<>full(vc)') then pause,end
+if or(full((vc')')<>full(vc)) then pause,end
+// ----------------------------------------------------------
+// test des concatenation
+//-----------------------------------------------------------
+if or(full([a])<>full(a)) then pause,end
+if or(full([a b])<>[full(a) full(b)]) then pause,end
+if or(full([a;b])<>[full(a);full(b)]) then pause,end
+if or(full([a []])<>full(a)) then pause,end
+if or(full([a;[]])<>full(a)) then pause,end
+if or(full([a zer])<>[full(a) full(zer)]) then pause,end
+if or(full([zer;b])<>[full(zer);full(b)]) then pause,end
+if or(full([ac])<>full(ac)) then pause,end
+if or(full([ac b])<>[full(ac) full(b)]) then pause,end
+if or(full([ac;b])<>[full(ac);full(b)]) then pause,end
+if or(full([ac []])<>full(ac)) then pause,end
+if or(full([ac;[]])<>full(ac)) then pause,end
+if or(full([a bc])<>[full(a) full(bc)]) then pause,end
+if or(full([a;bc])<>[full(a);full(bc)]) then pause,end
+if or(full([ac bc])<>[full(ac) full(bc)]) then pause,end
+if or(full([ac;bc])<>[full(ac);full(bc)]) then pause,end
+// ----------------------------------------------------------
+// test des extractions
+//-----------------------------------------------------------
+af=full(a);
+if or(full(a(1,3))<>af(1,3)) then pause,end
+if or(full(a(1,4))<>af(1,4)) then pause,end
+if or(full(a(1,:))<>af(1,:)) then pause,end
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);vf=full(v);
+if or(full(v(:))<>vf(:)) then pause,end
+if or(full(v(3:4))<>vf(3:4)) then pause,end
+if or(full(v([1 5]))<>vf([1 5])) then pause,end
+if or(full(v([4 3]))<>vf([4 3])) then pause,end
+if or(full(v([4 4]))<>vf([4 4])) then pause,end
+if or(full(v([1 1]))<>vf([1 1])) then pause,end
+v=v';vf=vf';
+if or(full(v(:))<>vf(:)) then pause,end
+if or(full(v(3:4))<>vf(3:4)) then pause,end
+if or(full(v([1 5]))<>vf([1 5])) then pause,end
+if or(full(v([4 3]))<>vf([4 3])) then pause,end
+if or(full(v([4 4]))<>vf([4 4])) then pause,end
+if or(full(v([1 1]))<>vf([1 1])) then pause,end
+acff=full(ac);
+if or(full(ac(1,3))<>acff(1,3)) then pause,end
+if or(full(ac(1,4))<>acff(1,4)) then pause,end
+if or(full(ac(1,:))<>acff(1,:)) then pause,end
+vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);vcf=full(vc);
+if or(full(vc(:))<>vcf(:)) then pause,end
+if or(full(vc(3:4))<>vcf(3:4)) then pause,end
+if or(full(vc([1 5]))<>vcf([1 5])) then pause,end
+if or(full(vc([4 3]))<>vcf([4 3])) then pause,end
+if or(full(vc([4 4]))<>vcf([4 4])) then pause,end
+if or(full(vc([1 1]))<>vcf([1 1])) then pause,end
+vc=vc';vcf=vcf';
+if or(full(vc(:))<>vcf(:)) then pause,end
+if or(full(vc(3:4))<>vcf(3:4)) then pause,end
+if or(full(vc([1 5]))<>vcf([1 5])) then pause,end
+if or(full(vc([4 3]))<>vcf([4 3])) then pause,end
+if or(full(vc([4 4]))<>vcf([4 4])) then pause,end
+if or(full(vc([1 1]))<>vcf([1 1])) then pause,end
+// ----------------------------------------------------------
+// test des insertions
+//-----------------------------------------------------------
+end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
+// full line insertion
+//----------------------
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([1 3],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([3 1],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);Vt=full(vt);A([1 3 1],:)=[Vt;2*Vt;3*Vt];
+if or(full(a1)<>A) then pause,end
+// insert zero vector
+vt=sparse([],[],[1,6]);
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([1 3],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([3 1],:)=[Vt;2*Vt];
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);Vt=full(vt);A([1 3 1],:)=[Vt;2*Vt;3*Vt];
+if or(full(a1)<>A) then pause,end
+a=sparse([],[],[6,6]);
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+// insert zero vector
+vt=sparse([],[],[1,6]);
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);
+a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);
+a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
+if or(full(a1)<>A) then pause,end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then pause,end
+v=sparse([],[],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then pause,end
+b=sparse([],[],[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([],[],[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then pause,end
+a=sparse([],[],[6,6]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then pause,end
+v=sparse([],[],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then pause,end
+v=sparse([],[],[6,1]);
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
+if or(full(a1)<>A) then pause,end
+b=sparse([],[],[6,2]);
+a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
+if or(full(a1)<>A) then pause,end
+b=sparse([],[],[6,3]);
+a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
+if or(full(a1)<>A) then pause,end
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 2;1 3;3 3],-(1:3),[3,3]);
+a1=a;a1(1,1)=sparse(30);A=full(a);A(1,1)=30;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,6)=sparse(30);A=full(a);A(1,6)=30;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,8)=sparse(30);A=full(a);A(1,8)=30;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=full(b);
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=full(b);
+if or(full(a1)<>A) then pause,end
+//sparse full
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+vt=11:16;
+// full line insertion
+//----------------------
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);A([1 3],:)=[vt;2*vt];
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);A([3 1],:)=[vt;2*vt];
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);A([1 3 1],:)=[vt;2*vt;3*vt];
+if or(full(a1)<>A) then pause,end
+a=sparse([],[],[6,6]);
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
+if or(full(a1)<>A) then pause,end
+b=[1:6;11:16];
+a1=a;a1([1 3],:)=b;A=full(a);A([1 3],:)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 1],:)=b;A=full(a);A([3 1],:)=b;
+if or(full(a1)<>A) then pause,end
+b=[1:6;11:16;21:26];
+a1=a;a1([1 3 1],:)=b;A=full(a);A([1 3 1],:)=b;
+if or(full(a1)<>A) then pause,end
+// full column insertion
+//----------------------
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+v=(1:6)';
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,3)=v;A=full(a);A(:,3)=v;
+if or(full(a1)<>A) then pause,end
+//
+a1=a;a1(:,7)=v;A=full(a);A(:,7)=v;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,8)=v;A=full(a);A(:,8)=v;
+if or(full(a1)<>A) then pause,end
+b=[(1:6)' (11:16)'];
+a1=a;a1(:,[1 3])=b;A=full(a);A(:,[1 3])=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(:,[3 1])=b;A=full(a);A(:,[3 1])=b;
+if or(full(a1)<>A) then pause,end
+b=[(1:6)' (11:16)' (21:26)'];
+a1=a;a1(:,[1 3 1])=b;A=full(a);A(:,[1 3 1])=b;
+if or(full(a1)<>A) then pause,end
+//********
+// row column insertion
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=-[1 2 3;4 5 6;7 8 9];
+a1=a;a1(1,1)=30;A=full(a);A(1,1)=30;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,6)=30;A=full(a);A(1,6)=30;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1,8)=30;A=full(a);A(1,8)=30;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=b;
+if or(full(a1)<>A) then pause,end
+a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=b;
+if or(full(a1)<>A) then pause,end
+// vector insertion
+v=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);
+v1=v;v1(1)=33;V=full(v);V(1)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=33;V=full(v);V(2)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=33;V=full(v);V(8)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=[5;10;33];V=full(v);V([1 2 8])=[5;10;33];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then pause,end
+v1=v;v1(1)=sparse(33);V=full(v);V(1)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=sparse(33);V=full(v);V(2)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=sparse(33);V=full(v);V(8)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=sparse([5;10;33]);V=full(v);V([1 2 8])=[5;10;33];
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 1])=sparse([5;10;33]);V=full(v);V([1 2 1])=[5;10;33];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(:)=[];
+if or(full(v1)<>[]) then pause,end
+v1=v;v1(:)=sparse([2 1],44,[6 1]);V=full(v);V(:)=[0;44;0;0;0;0];
+if or(full(v1)<>V) then pause,end
+v=v';
+v1=v;v1(1)=33;V=full(v);V(1)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=33;V=full(v);V(2)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=33;V=full(v);V(8)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=[5 10 33];V=full(v);V([1 2 8])=[5 10 33];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(1)=sparse(33);V=full(v);V(1)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(2)=sparse(33);V=full(v);V(2)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1(8)=sparse(33);V=full(v);V(8)=33;
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 8])=sparse([5 10 33]);V=full(v);V([1 2 8])=[5 10 33];
+if or(full(v1)<>V) then pause,end
+v1=v;v1([1 2 1])=sparse([5 10 33]);V=full(v);V([1 2 1])=[5 10 33];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(:)=sparse([1 2],44,[1,6]);V=full(v);V(:)=[0 44 0 0 0 0];
+if or(full(v1)<>V) then pause,end
+v1=v;v1(1)=[];V=full(v);V(1)=[];
+if or(full(v1)<>V) then pause,end
+//test des comparaisons
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;6 5],[10;-1;-1],[6 6]);
+if full(a==a)<>full(a)==full(a) then pause,end
+if full(a<>a)<>(full(a)<>full(a)) then pause,end
+if full(a>sparse(5))<>(full(a)>5) then pause,end
+if full(sparse(5)>a)<>(5>full(a)) then pause,end
+if full(b>a)<>(full(b)>full(a)) then pause,end
+if full(a==full(a))<>full(a)==full(a) then pause,end
+if full(a<>full(a))<>(full(a)<>full(a)) then pause,end
+if full(a>5)<>(full(a)>5) then pause,end
+if full(5>a)<>(5>full(a)) then pause,end
+if full(b>full(a))<>(full(b)>full(a)) then pause,end
+if full(full(a)==a)<>full(a)==full(a) then pause,end
+if full(full(a)<>a)<>(full(a)<>full(a)) then pause,end
+if full(full(a)>sparse(5))<>(full(a)>5) then pause,end
+if full(full(b)>a)<>(full(b)>full(a)) then pause,end
+a=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);
+if full(a==a)<>full(a)==full(a) then pause,end
+if full(a<>a)<>(full(a)<>full(a)) then pause,end
+if full(a>sparse(5))<>(full(a)>5) then pause,end
+if full(sparse(5)>a)<>(5>full(a)) then pause,end
+if full(a==full(a))<>full(a)==full(a) then pause,end
+if full(a<>full(a))<>(full(a)<>full(a)) then pause,end
+if full(a>5)<>(full(a)>5) then pause,end
+if full(5>a)<>(5>full(a)) then pause,end
+if full(full(a)==a)<>full(a)==full(a) then pause,end
+if full(full(a)<>a)<>(full(a)<>full(a)) then pause,end
+if full(full(a)>sparse(5))<>(full(a)>5) then pause,end
+a=a';
+if full(a==a)<>full(a)==full(a) then pause,end
+if full(a<>a)<>(full(a)<>full(a)) then pause,end
+if full(a>sparse(5))<>(full(a)>5) then pause,end
+if full(sparse(5)>a)<>(5>full(a)) then pause,end
+if full(a==full(a))<>full(a)==full(a) then pause,end
+if full(a<>full(a))<>(full(a)<>full(a)) then pause,end
+if full(a>5)<>(full(a)>5) then pause,end
+if full(5>a)<>(5>full(a)) then pause,end
+if full(full(a)==a)<>full(a)==full(a) then pause,end
+if full(full(a)<>a)<>(full(a)<>full(a)) then pause,end
+if full(full(a)>sparse(5))<>(full(a)>5) then pause,end
+a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
+b=sparse([1 6;1 2;5 5],[10;-1;-1],[5 6]);
+if a==b<>%f then pause,end
+if a<>b<>%t then pause,end
+
+a=sparse([%f %t %f %t]);
+b=sparse([%t %f %t %f]);
+assert_checkequal(~a, b);
diff --git a/modules/sparse/tests/unit_tests/sparseBool.dia.ref b/modules/sparse/tests/unit_tests/sparseBool.dia.ref
new file mode 100755
index 000000000..623e8b923
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sparseBool.dia.ref
@@ -0,0 +1,92 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Antoine ELIAS
+// Copyright (C) 2012 - Scilab Enterprises - Cedric Delamarre
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+//
+//
+
+// boolean sparse function
+
+
+//from dense form
+s=[ %t,%f,%f,%f,%f,%f,%f;
+ %f,%t,%f,%f,%f,%f,%f;
+ %f,%f,%t,%f,%f,%f,%f;
+ %f,%f,%t,%t,%f,%f,%f;
+ %f,%f,%t,%t,%t,%f,%f;
+ %f,%f,%t,%t,%f,%t,%f;
+ %f,%f,%t,%t,%f,%t,%t];
+
+
+sp=sparse(s);
+
+assert_checkequal(size(s), size(sp));
+assert_checkequal(full(sp), s);
+
+//from coord
+sp = sparse([1 1;2 2;3 3;4 3;4 4;5 3;5 4;5 5;6 3;6 4;6 6;7 3;7 4;7 6;7 7], [%t %t %t %t %t %t %t %t %t %t %t %t %t %t %t]);
+assert_checkequal(size(s), size(sp));
+assert_checkequal(full(sp), s);
+
+//with size
+newsp = sparse([], [], [10,20]);
+assert_checkequal(size(newsp), [10,20]);
+
+//concatenation
+spc = [sp [%t; %f; %t; %f; %t; %f; %t]];
+sc = [s [%t; %f; %t; %f; %t; %f; %t]];
+assert_checkequal(full(spc), sc);
+
+spc = [sp ;[%t %f %t %f %t %f %t]];
+sc = [s ;[%t %f %t %f %t %f %t]];
+assert_checkequal(full(spc), sc);
+
+spc = [[%t; %f; %t; %f; %t; %f; %t] sp];
+sc = [[%t; %f; %t; %f; %t; %f; %t] s];
+assert_checkequal(full(spc), sc);
+
+spc = [[%t %f %t %f %t %f %t]; sp];
+sc = [[%t %f %t %f %t %f %t]; s];
+assert_checkequal(full(spc), sc);
+
+sc = [s s];
+spc = [sp sp];
+assert_checkequal(full(spc), sc);
+
+sc = [s; s];
+spc = [sp; sp];
+assert_checkequal(full(spc), sc);
+
+sc = [s s];
+spc = [sp sp];
+assert_checkequal(full(spc), sc);
+
+A = sparse(%t);
+A = [A %f];
+A = [A %f];
+A = [A %f];
+
+assert_checkequal(full(A), [%t %f %f %f]);
+assert_checkequal(size(A, 'c'), 4);
+
+//extraction
+assert_checkequal(full(sp(:)), s(:));
+assert_checkequal(size(sp(:)), size(s(:)));
+assert_checkequal(full(sp(1:7, 1:7)), s(1:7, 1:7));
+assert_checkequal(size(sp(1:7, 1:7)), size(s(1:7, 1:7)));
+assert_checkequal(full(sp(1:4, :)), s(1:4, :));
+assert_checkequal(size(sp(1:4, :)), size(s(1:4, :)));
+assert_checkequal(full(sp(:, 2:6)), s(:, 2:6));
+assert_checkequal(size(sp(:, 2:6)), size(s(:, 2:6)));
+assert_checkequal(full(sp(:, $)), s(:, $));
+assert_checkequal(size(sp(:, $)), size(s(:, $)));
+
+
+
+
diff --git a/modules/sparse/tests/unit_tests/sparseBool.tst b/modules/sparse/tests/unit_tests/sparseBool.tst
new file mode 100755
index 000000000..623e8b923
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sparseBool.tst
@@ -0,0 +1,92 @@
+//
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Antoine ELIAS
+// Copyright (C) 2012 - Scilab Enterprises - Cedric Delamarre
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+//
+//
+
+// boolean sparse function
+
+
+//from dense form
+s=[ %t,%f,%f,%f,%f,%f,%f;
+ %f,%t,%f,%f,%f,%f,%f;
+ %f,%f,%t,%f,%f,%f,%f;
+ %f,%f,%t,%t,%f,%f,%f;
+ %f,%f,%t,%t,%t,%f,%f;
+ %f,%f,%t,%t,%f,%t,%f;
+ %f,%f,%t,%t,%f,%t,%t];
+
+
+sp=sparse(s);
+
+assert_checkequal(size(s), size(sp));
+assert_checkequal(full(sp), s);
+
+//from coord
+sp = sparse([1 1;2 2;3 3;4 3;4 4;5 3;5 4;5 5;6 3;6 4;6 6;7 3;7 4;7 6;7 7], [%t %t %t %t %t %t %t %t %t %t %t %t %t %t %t]);
+assert_checkequal(size(s), size(sp));
+assert_checkequal(full(sp), s);
+
+//with size
+newsp = sparse([], [], [10,20]);
+assert_checkequal(size(newsp), [10,20]);
+
+//concatenation
+spc = [sp [%t; %f; %t; %f; %t; %f; %t]];
+sc = [s [%t; %f; %t; %f; %t; %f; %t]];
+assert_checkequal(full(spc), sc);
+
+spc = [sp ;[%t %f %t %f %t %f %t]];
+sc = [s ;[%t %f %t %f %t %f %t]];
+assert_checkequal(full(spc), sc);
+
+spc = [[%t; %f; %t; %f; %t; %f; %t] sp];
+sc = [[%t; %f; %t; %f; %t; %f; %t] s];
+assert_checkequal(full(spc), sc);
+
+spc = [[%t %f %t %f %t %f %t]; sp];
+sc = [[%t %f %t %f %t %f %t]; s];
+assert_checkequal(full(spc), sc);
+
+sc = [s s];
+spc = [sp sp];
+assert_checkequal(full(spc), sc);
+
+sc = [s; s];
+spc = [sp; sp];
+assert_checkequal(full(spc), sc);
+
+sc = [s s];
+spc = [sp sp];
+assert_checkequal(full(spc), sc);
+
+A = sparse(%t);
+A = [A %f];
+A = [A %f];
+A = [A %f];
+
+assert_checkequal(full(A), [%t %f %f %f]);
+assert_checkequal(size(A, 'c'), 4);
+
+//extraction
+assert_checkequal(full(sp(:)), s(:));
+assert_checkequal(size(sp(:)), size(s(:)));
+assert_checkequal(full(sp(1:7, 1:7)), s(1:7, 1:7));
+assert_checkequal(size(sp(1:7, 1:7)), size(s(1:7, 1:7)));
+assert_checkequal(full(sp(1:4, :)), s(1:4, :));
+assert_checkequal(size(sp(1:4, :)), size(s(1:4, :)));
+assert_checkequal(full(sp(:, 2:6)), s(:, 2:6));
+assert_checkequal(size(sp(:, 2:6)), size(s(:, 2:6)));
+assert_checkequal(full(sp(:, $)), s(:, $));
+assert_checkequal(size(sp(:, $)), size(s(:, $)));
+
+
+
+
diff --git a/modules/sparse/tests/unit_tests/spisp.dia.ref b/modules/sparse/tests/unit_tests/spisp.dia.ref
new file mode 100755
index 000000000..7ba74cd43
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/spisp.dia.ref
@@ -0,0 +1,37 @@
+m = 200;
+n = 400;
+mi = 30;
+ni = 40;
+A = sprand(n,m,0.1) + %i*sprand(n,m,0.1);
+B = sprand(mi,ni,0.7) +%i*sprand(mi,ni,0.7);
+ii = ["grand(mi,1,""uin"",1,m)";
+ "-gsort(-grand(mi,1,""uin"",1,m))";
+ "1:mi";
+ "m:-1:(m-mi+1)";
+ "m-5:m+mi-6"];
+jj = ["grand(ni,1,""uin"",1,n)";
+ "-gsort(-grand(ni,1,""uin"",1,n))";
+ "1:ni";
+ "n:-1:(n-ni+1)";
+ "n-2:n+ni-3"];
+switchA = ["real(A)" "A"];
+switchB = ["real(B)" "B"];
+for i=1:5
+ indi = evstr(ii(i));
+ for j=1:5
+ indj = evstr(jj(j));
+ for k=1:2
+ for l=1:2
+ AA = evstr(switchA(k));
+ Af = full(AA);
+ D = evstr(switchB(l));
+ Df = full(D);
+ AA(indi,indj) = D;
+ Af(indi,indj) = Df;
+ if max(abs(Af - full(AA))) > 0 then
+ mprintf('\n\r test (%d,%d,%d,%d) fails',i,j,k,l)
+ end
+ end
+ end
+ end
+end
diff --git a/modules/sparse/tests/unit_tests/spisp.tst b/modules/sparse/tests/unit_tests/spisp.tst
new file mode 100755
index 000000000..13e0d5060
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/spisp.tst
@@ -0,0 +1,51 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+m = 200;
+n = 400;
+mi = 30;
+ni = 40;
+
+A = sprand(n,m,0.1) + %i*sprand(n,m,0.1);
+B = sprand(mi,ni,0.7) +%i*sprand(mi,ni,0.7);
+
+ii = ["grand(mi,1,""uin"",1,m)";
+ "-gsort(-grand(mi,1,""uin"",1,m))";
+ "1:mi";
+ "m:-1:(m-mi+1)";
+ "m-5:m+mi-6"];
+jj = ["grand(ni,1,""uin"",1,n)";
+ "-gsort(-grand(ni,1,""uin"",1,n))";
+ "1:ni";
+ "n:-1:(n-ni+1)";
+ "n-2:n+ni-3"];
+
+
+switchA = ["real(A)" "A"];
+switchB = ["real(B)" "B"];
+
+for i=1:5
+ indi = evstr(ii(i));
+ for j=1:5
+ indj = evstr(jj(j));
+ for k=1:2
+ for l=1:2
+ AA = evstr(switchA(k));
+ Af = full(AA);
+ D = evstr(switchB(l));
+ Df = full(D);
+ AA(indi,indj) = D;
+ Af(indi,indj) = Df;
+ if max(abs(Af - full(AA))) > 0 then
+ mprintf('\n\r test (%d,%d,%d,%d) fails',i,j,k,l)
+ end
+ end
+ end
+ end
+end
diff --git a/modules/sparse/tests/unit_tests/sprand.dia.ref b/modules/sparse/tests/unit_tests/sprand.dia.ref
new file mode 100755
index 000000000..97da5c68a
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sprand.dia.ref
@@ -0,0 +1,90 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// Check default "typ" = "uniform"
+rand("seed",0);
+grand("setsd",0);
+nrows = 1000;
+ncols = 2000;
+density = 1/100;
+s=sprand(nrows,ncols,density);
+assert_checkequal ( size(s) , [nrows,ncols] );
+nnzs=nnz(s);
+[ij,values]=spget(s);
+assert_checkequal ( min(values) >= 0 , %t );
+assert_checkequal ( max(values) <= 1 , %t );
+assert_checkalmostequal ( mean(values) , 0.5 , 1.e-2 );
+// Get empty matrix
+s=sprand(0,0,0.01);
+assert_checkequal ( s , [] );
+// Test the scientific part
+// In the following script, we check that the entries of the matrix have the expected distribution.
+// We use the spget function in order to get the nonzero entries.
+// Then we compute the min, mean and max of the entries and compare them with the limit values.
+rand("seed",0);
+grand("setsd",0);
+typ = "normal";
+nrows = 1000;
+ncols = 2000;
+density = 1/100;
+s=sprand(nrows,ncols,density,typ);
+assert_checkequal ( size(s) , [nrows,ncols] );
+nnzs=nnz(s);
+[ij,values]=spget(s);
+assert_checkequal ( nnzs > 10000 , %t );
+assert_checkequal ( min(values) < -3 , %t );
+assert_checkalmostequal ( mean(values) , 0 , [] , 1.e-2 );
+assert_checkequal ( max(values) > 3 , %t );
+assert_checkalmostequal ( variance(values) , 1 , 1.e-2 );
+rand("seed",0);
+grand("setsd",0);
+typ = "uniform";
+nrows = 1000;
+ncols = 2000;
+density = 1/100;
+s=sprand(nrows,ncols,density,typ);
+assert_checkequal ( size(s) , [nrows,ncols] );
+nnzs=nnz(s);
+[ij,values]=spget(s);
+assert_checkequal ( nnzs > 10000 , %t );
+assert_checkalmostequal ( min(values) , 0 , [] , 1.e-2 );
+assert_checkalmostequal ( mean(values) , 0.5 , 1.e-2 );
+assert_checkalmostequal ( max(values) , 1 , 1.e-2 );
+assert_checkalmostequal ( variance(values) , 1/12 , 1.e-2 );
+// In the following script, we check that the entry indices,
+// which are also chosen at random, have the correct distribution.
+// We generate kmax sparse random matrices with uniform distribution.
+// For each matrix, we consider the indices of the nonzero entries
+// which were generated, i.e. we see if the event Aij = {the entry (i,j) is nonzero}
+// occurred for each i and j, for i=1,2,...,nrows and j=1,2,...,ncols.
+// The matrix C(i,j) stores the number of times that the event Aij occurred.
+// The matrix R(k) stores the actual density of the try number k, where k=1,2,...,kmax.
+rand("seed",0);
+grand("setsd",0);
+kmax = 1000;
+ncols=100;
+nrows=100;
+density=0.01;
+typ="uniform";
+C=zeros(nrows,ncols);
+R=[];
+for k=1:kmax
+ M=sprand(nrows,ncols,density,typ);
+ NZ=find(M<>0);
+ NZratio = size(NZ,"*")/(nrows*ncols);
+ R=[R NZratio];
+ C(NZ)=C(NZ)+1;
+end
+// Now that this algorithm has been performed (which may require some time),
+// we can compute elementary statistics to check that the algorithm performed well.
+// The average number should be close to the expectation.
+assert_checkalmostequal ( density*kmax , mean(C) , 1.e-2 );
+// The density should be close to expected density
+assert_checkalmostequal ( density , mean(R) , 1.e-2 );
+// More deeper tests should involve the particular distribution of
+// C, which follows a binomial law.
+// May be a chi-square test should be used for this.
diff --git a/modules/sparse/tests/unit_tests/sprand.tst b/modules/sparse/tests/unit_tests/sprand.tst
new file mode 100755
index 000000000..2ded8e777
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/sprand.tst
@@ -0,0 +1,103 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+
+
+
+// Check default "typ" = "uniform"
+rand("seed",0);
+grand("setsd",0);
+nrows = 1000;
+ncols = 2000;
+density = 1/100;
+s=sprand(nrows,ncols,density);
+assert_checkequal ( size(s) , [nrows,ncols] );
+nnzs=nnz(s);
+[ij,values]=spget(s);
+assert_checkequal ( min(values) >= 0 , %t );
+assert_checkequal ( max(values) <= 1 , %t );
+assert_checkalmostequal ( mean(values) , 0.5 , 1.e-2 );
+
+// Get empty matrix
+s=sprand(0,0,0.01);
+assert_checkequal ( s , [] );
+
+// Test the scientific part
+// In the following script, we check that the entries of the matrix have the expected distribution.
+// We use the spget function in order to get the nonzero entries.
+// Then we compute the min, mean and max of the entries and compare them with the limit values.
+
+rand("seed",0);
+grand("setsd",0);
+typ = "normal";
+nrows = 1000;
+ncols = 2000;
+density = 1/100;
+s=sprand(nrows,ncols,density,typ);
+assert_checkequal ( size(s) , [nrows,ncols] );
+nnzs=nnz(s);
+[ij,values]=spget(s);
+assert_checkequal ( nnzs > 10000 , %t );
+assert_checkequal ( min(values) < -3 , %t );
+assert_checkalmostequal ( mean(values) , 0 , [] , 1.e-2 );
+assert_checkequal ( max(values) > 3 , %t );
+assert_checkalmostequal ( variance(values) , 1 , 1.e-2 );
+
+rand("seed",0);
+grand("setsd",0);
+typ = "uniform";
+nrows = 1000;
+ncols = 2000;
+density = 1/100;
+s=sprand(nrows,ncols,density,typ);
+assert_checkequal ( size(s) , [nrows,ncols] );
+nnzs=nnz(s);
+[ij,values]=spget(s);
+assert_checkequal ( nnzs > 10000 , %t );
+assert_checkalmostequal ( min(values) , 0 , [] , 1.e-2 );
+assert_checkalmostequal ( mean(values) , 0.5 , 1.e-2 );
+assert_checkalmostequal ( max(values) , 1 , 1.e-2 );
+assert_checkalmostequal ( variance(values) , 1/12 , 1.e-2 );
+
+// In the following script, we check that the entry indices,
+// which are also chosen at random, have the correct distribution.
+// We generate kmax sparse random matrices with uniform distribution.
+// For each matrix, we consider the indices of the nonzero entries
+// which were generated, i.e. we see if the event Aij = {the entry (i,j) is nonzero}
+// occurred for each i and j, for i=1,2,...,nrows and j=1,2,...,ncols.
+// The matrix C(i,j) stores the number of times that the event Aij occurred.
+// The matrix R(k) stores the actual density of the try number k, where k=1,2,...,kmax.
+
+rand("seed",0);
+grand("setsd",0);
+kmax = 1000;
+ncols=100;
+nrows=100;
+density=0.01;
+typ="uniform";
+C=zeros(nrows,ncols);
+R=[];
+for k=1:kmax
+ M=sprand(nrows,ncols,density,typ);
+ NZ=find(M<>0);
+ NZratio = size(NZ,"*")/(nrows*ncols);
+ R=[R NZratio];
+ C(NZ)=C(NZ)+1;
+end
+// Now that this algorithm has been performed (which may require some time),
+// we can compute elementary statistics to check that the algorithm performed well.
+
+// The average number should be close to the expectation.
+assert_checkalmostequal ( density*kmax , mean(C) , 1.e-2 );
+// The density should be close to expected density
+assert_checkalmostequal ( density , mean(R) , 1.e-2 );
+
+// More deeper tests should involve the particular distribution of
+// C, which follows a binomial law.
+// May be a chi-square test should be used for this.
+
+
diff --git a/modules/sparse/tests/unit_tests/spzeros.dia.ref b/modules/sparse/tests/unit_tests/spzeros.dia.ref
new file mode 100755
index 000000000..c1224dc03
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/spzeros.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012-2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+m=spzeros(2,2);
+assert_checkequal(size(m),[2,2]);
+m=spzeros(2,3);
+assert_checkequal(size(m),[2,3]);
+a=rand(10,12);
+m=spzeros(a);
+assert_checkequal(size(m),[10,12]);
+assert_checkequal(sum(m),0);
+m=spzeros(3);
+assert_checkequal(size(m),[1,1]);
+assert_checkequal(sum(spzeros(1000,1000)),0);
diff --git a/modules/sparse/tests/unit_tests/spzeros.tst b/modules/sparse/tests/unit_tests/spzeros.tst
new file mode 100755
index 000000000..86b754b27
--- /dev/null
+++ b/modules/sparse/tests/unit_tests/spzeros.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012-2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+
+
+m=spzeros(2,2);
+assert_checkequal(size(m),[2,2]);
+
+m=spzeros(2,3);
+assert_checkequal(size(m),[2,3]);
+
+a=rand(10,12);
+m=spzeros(a);
+assert_checkequal(size(m),[10,12]);
+assert_checkequal(sum(m),0);
+
+m=spzeros(3);
+assert_checkequal(size(m),[1,1]);
+
+
+assert_checkequal(sum(spzeros(1000,1000)),0);