summaryrefslogtreecommitdiff
path: root/modules/linear_algebra/tests
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/linear_algebra/tests
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/linear_algebra/tests')
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_chol.tst23
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_det.tst21
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_escoufier.tst72
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_inv.tst23
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_matrix_1.tst25
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_matrix_2.tst23
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_matrix_3.tst22
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_matrix_4.tst25
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_spec.tst23
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_sqroot.tst19
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_sva.tst18
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_svd_1.tst27
-rwxr-xr-xmodules/linear_algebra/tests/benchmarks/bench_svd_2.tst27
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10178.dia.ref40
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10178.tst50
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10281.dia.ref25
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10281.tst28
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10519.dia.ref22
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10519.tst24
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10921.dia.ref26
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_10921.tst28
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_12121.dia.ref19
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_12121.tst23
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_12686.dia.ref18
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_12686.tst22
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_2523.dia.ref24
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_2523.tst33
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_2775.dia.ref23
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_2775.tst30
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3312.dia.ref17
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3312.tst20
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3624.dia.ref16
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3624.tst20
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3652.dia.ref24
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3652.tst29
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3827.dia.ref16
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_3827.tst18
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4042.dia.ref28
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4042.tst33
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4311.dia.ref15
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4311.tst18
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4405.dia.ref19
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4405.tst20
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4425.dia.ref29
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4425.tst39
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4759.dia.ref16
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_4759.tst23
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_5017.dia.ref173
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_5017.tst184
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_545.dia.ref37
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_545.tst41
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_6477.dia.ref38
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_6477.tst45
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_6783.dia.ref175
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_6783.tst192
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_7109.dia.ref21
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_7109.tst27
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_7485.dia.ref26
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_7485.tst32
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_7950.dia.ref43
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_7950.tst48
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_8820.dia.ref19
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_8820.tst20
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_9196.dia.ref86
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_9196.tst94
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_9204.dia.ref20
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_9204.tst25
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_F.dia.ref5
-rwxr-xr-xmodules/linear_algebra/tests/nonreg_tests/bug_F.tst13
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/balanc.dia.ref72
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/balanc.tst78
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/bdiag.dia.ref103
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/bdiag.tst121
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/chol.dia.ref37
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/chol.tst45
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/companion.dia.ref55
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/companion.tst57
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/cond.dia.ref61
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/cond.tst87
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/det.dia.ref122
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/det.tst98
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/gspec.dia.ref122
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/gspec.tst139
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/hess.dia.ref48
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/hess.tst53
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/inv.dia.ref56
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/inv.tst56
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/leftmatrixdiv.dia.ref121
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/leftmatrixdiv.tst149
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/lsq.dia.ref96
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/lsq.tst113
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/lu.dia.ref99
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/lu.tst106
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/norm.dia.ref139
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/norm.tst148
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/qr.dia.ref143
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/qr.tst184
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/rcond.dia.ref29
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/rcond.tst33
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/rdiv.dia.ref118
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/rdiv.tst138
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/schur.dia.ref407
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/schur.tst493
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/spec.dia.ref132
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/spec.tst153
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/squeeze.dia.ref31
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/squeeze.tst36
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/svd.dia.ref293
-rwxr-xr-xmodules/linear_algebra/tests/unit_tests/svd.tst376
109 files changed, 7494 insertions, 0 deletions
diff --git a/modules/linear_algebra/tests/benchmarks/bench_chol.tst b/modules/linear_algebra/tests/benchmarks/bench_chol.tst
new file mode 100755
index 000000000..d03eea05d
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_chol.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for chol function
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+a = rand(900, 900, 'n');
+a = a'*a;
+
+// <-- BENCH START -->
+b = chol(a);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_det.tst b/modules/linear_algebra/tests/benchmarks/bench_det.tst
new file mode 100755
index 000000000..042d2bd63
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_det.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for det function
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+a = 0;
+b = 0;
+a = rand(650, 650,'n');
+
+// <-- BENCH START -->
+b = det(a);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_escoufier.tst b/modules/linear_algebra/tests/benchmarks/bench_escoufier.tst
new file mode 100755
index 000000000..06e76355b
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_escoufier.tst
@@ -0,0 +1,72 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for escoufier macro
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+p = 0;
+q = 0;
+vt = 0;
+vr = 0;
+vrt = 0;
+rvt = 0;
+RV = 0;
+j = 0;
+k = 0;
+
+x2 = 0;
+R = 0;
+Rxx = 0;
+Ryy = 0;
+Rxy = 0;
+Ryx = 0;
+Rvmax = 0;
+
+f = 0;
+c = 0;
+d = 0;
+x = abs(rand(37,37,'n'));
+
+// <-- BENCH START -->
+// Calculation of Escoufier's equivalent vectors
+p = size(x, 2);
+vt = [1:p]; // Variables to test
+vr = []; // Result: ordered variables
+RV = [1:p]; // Result: correlations
+
+for j = 1:p // loop on the variable number
+ Rvmax = 0;
+ for k = 1:(p-j+1) // loop on the variables
+ x2 = [x, x(:, vr), x(:, vt(k))]; // New table to test
+ // R = corrcoef(x2); // Correlations table
+ // Not in scilab, so the 5 following lines do it
+ q = size(x2, 1);
+ x2 = x2 - ones (q, 1) * sum (x2, 'r') / q;
+ c = conj(x2' * x2 / (q - 1));
+ d = diag(c);
+ R = c ./ sqrt(d * d');
+ Ryy = R(1:p, 1:p);
+ Rxx = R(p+1:p+j, p+1:p+j);
+ Rxy = R(p+1:p+j, 1:p);
+ Ryx = Rxy';
+ rvt = trace(Ryx*Rxy)/((trace(Ryy^2)*trace(Rxx^2))^0.5); // RV calculation
+ if rvt > Rvmax
+ Rvmax = rvt; // test of RV
+ vrt(j) = vt(k); // temporary held variable
+ end
+ end
+ vr(j) = vrt(j); // Result: variable
+ RV(j) = Rvmax; // Result: correlation
+ f = find(vt~=vr(j)); // identify the held variable
+ vt = vt(f); // reidentify variables to test
+end
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_inv.tst b/modules/linear_algebra/tests/benchmarks/bench_inv.tst
new file mode 100755
index 000000000..28b577ca4
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_inv.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for inv function
+//==============================================================================
+
+// <-- BENCH NB RUN : 100 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+
+a = rand(400, 400,'n');
+
+// <-- BENCH START -->
+b = inv(a);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_matrix_1.tst b/modules/linear_algebra/tests/benchmarks/bench_matrix_1.tst
new file mode 100755
index 000000000..9b3c96e0d
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_matrix_1.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for matrix function
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+
+a = abs(rand(1500,1500,'n')/10);
+
+// <-- BENCH START -->
+b = a';
+a = matrix(b,750,3000);
+b = a';
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_matrix_2.tst b/modules/linear_algebra/tests/benchmarks/bench_matrix_2.tst
new file mode 100755
index 000000000..e9835bbe2
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_matrix_2.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for matrix function
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+a = abs(rand(800, 800, 'n')/2);
+
+// <-- BENCH START -->
+b = a.^1000;
+// <-- BENCH END -->
+
diff --git a/modules/linear_algebra/tests/benchmarks/bench_matrix_3.tst b/modules/linear_algebra/tests/benchmarks/bench_matrix_3.tst
new file mode 100755
index 000000000..ba995330c
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_matrix_3.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for matrix ops
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+a = rand(700,700,'n');
+
+// <-- BENCH START -->
+b = a'*a;
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_matrix_4.tst b/modules/linear_algebra/tests/benchmarks/bench_matrix_4.tst
new file mode 100755
index 000000000..588e82713
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_matrix_4.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for matrix ops
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+
+a = rand(600,600,'n');
+b = 1:600;
+b = b';
+
+// <-- BENCH START -->
+c = a\b;
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_spec.tst b/modules/linear_algebra/tests/benchmarks/bench_spec.tst
new file mode 100755
index 000000000..d6bf9d9b0
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_spec.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for spec function
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+
+a = rand(320,320,'n');
+
+// <-- BENCH START -->
+b = spec(a);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_sqroot.tst b/modules/linear_algebra/tests/benchmarks/bench_sqroot.tst
new file mode 100755
index 000000000..ba0fd93db
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_sqroot.tst
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for sqroot function
+//==============================================================================
+
+// <-- BENCH NB RUN : 10000 -->
+
+X = rand(5,2)*rand(2,5);
+X = X*X';
+
+// <-- BENCH START -->
+W = sqroot(X);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_sva.tst b/modules/linear_algebra/tests/benchmarks/bench_sva.tst
new file mode 100755
index 000000000..ea64e4338
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_sva.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for sva function
+//==============================================================================
+
+// <-- BENCH NB RUN : 1000 -->
+
+A = rand(50,40)*rand(40,50);
+
+// <-- BENCH START -->
+[U,s,V] = sva(A,2);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_svd_1.tst b/modules/linear_algebra/tests/benchmarks/bench_svd_1.tst
new file mode 100755
index 000000000..97f6e4335
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_svd_1.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for svd 1
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+
+a=rand(300,300);
+
+b = a*a';
+[c,d] = lu(b);
+inv(a);
+
+// <-- BENCH START -->
+v = svd(a);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/benchmarks/bench_svd_2.tst b/modules/linear_algebra/tests/benchmarks/bench_svd_2.tst
new file mode 100755
index 000000000..c54fa281f
--- /dev/null
+++ b/modules/linear_algebra/tests/benchmarks/bench_svd_2.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==============================================================================
+// Benchmark for svd 2
+//==============================================================================
+
+// <-- BENCH NB RUN : 10 -->
+
+stacksize(30000000);
+
+a = 0;
+b = 0;
+
+a=rand(300,300);
+
+b = a*a';
+[c,d] = lu(b);
+inv(a);
+
+// <-- BENCH START -->
+[u,s,v]=svd(a);
+// <-- BENCH END -->
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10178.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_10178.dia.ref
new file mode 100755
index 000000000..91b46084a
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10178.dia.ref
@@ -0,0 +1,40 @@
+// =============================================================================
+// 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 10178 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10178
+//
+// <-- Short Description -->
+// norm function falied for some sparse matrices.
+// =============================================================================
+A = [1 0 0 1 0;0 -1 -1 0 -1];
+AS = sparse(A);
+assert_checkalmostequal(norm(A), norm(AS));
+assert_checkalmostequal(norm(A'), norm(AS'));
+assert_checkequal(norm(A, 1), norm(AS, 1));
+assert_checkequal(norm(A, %inf), norm(AS, %inf));
+assert_checkequal(norm(A, 'fro'), norm(AS, 'fro'));
+A = [1 1 1 1 1;-1 -1 -1 -1 -1];
+AS = sparse(A);
+assert_checkalmostequal(norm(A), norm(AS));
+assert_checkalmostequal(norm(A)', norm(AS)');
+assert_checkequal(norm(A, 1), norm(AS, 1));
+assert_checkequal(norm(A, %inf), norm(AS, %inf));
+assert_checkequal(norm(A, 'fro'), norm(AS, 'fro'));
+A = [
+ 0. 0. 0. 0. 0.
+ 0. 0. 0. 0. 0.
+ 0. 0. -1. 0. 1.
+ 0. 0. 0. 0. 0.
+ 0. 0. 1. 0. -1. ];
+AS = sparse(A);
+assert_checkequal(norm(A), norm(AS));
+assert_checkequal(norm(A, 1), norm(AS, 1));
+assert_checkequal(norm(A, %inf), norm(AS, %inf));
+assert_checkequal(norm(A, 'fro'), norm(AS, 'fro'));
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10178.tst b/modules/linear_algebra/tests/nonreg_tests/bug_10178.tst
new file mode 100755
index 000000000..9e4800334
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10178.tst
@@ -0,0 +1,50 @@
+// =============================================================================
+// 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 10178 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10178
+//
+// <-- Short Description -->
+// norm function falied for some sparse matrices.
+// =============================================================================
+
+A = [1 0 0 1 0;0 -1 -1 0 -1];
+AS = sparse(A);
+
+assert_checkalmostequal(norm(A), norm(AS));
+assert_checkalmostequal(norm(A'), norm(AS'));
+assert_checkequal(norm(A, 1), norm(AS, 1));
+assert_checkequal(norm(A, %inf), norm(AS, %inf));
+assert_checkequal(norm(A, 'fro'), norm(AS, 'fro'));
+
+A = [1 1 1 1 1;-1 -1 -1 -1 -1];
+AS = sparse(A);
+
+assert_checkalmostequal(norm(A), norm(AS));
+assert_checkalmostequal(norm(A)', norm(AS)');
+assert_checkequal(norm(A, 1), norm(AS, 1));
+assert_checkequal(norm(A, %inf), norm(AS, %inf));
+assert_checkequal(norm(A, 'fro'), norm(AS, 'fro'));
+
+
+A = [
+ 0. 0. 0. 0. 0.
+ 0. 0. 0. 0. 0.
+ 0. 0. -1. 0. 1.
+ 0. 0. 0. 0. 0.
+ 0. 0. 1. 0. -1. ];
+
+AS = sparse(A);
+
+assert_checkequal(norm(A), norm(AS));
+assert_checkequal(norm(A, 1), norm(AS, 1));
+assert_checkequal(norm(A, %inf), norm(AS, %inf));
+assert_checkequal(norm(A, 'fro'), norm(AS, 'fro'));
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10281.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_10281.dia.ref
new file mode 100755
index 000000000..90e6c5ae7
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10281.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10281 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10281
+//
+// <-- Short Description -->
+// lyap segfaults in some cases
+s=poly(0,'s');
+A=[-1 10;0 1];B=[-2;0];C=[-2 3];D=[-2];
+sis57=syslin('c',A,B,C,D);
+ss2tf(sis57);
+gs=C*inv((s*eye(2,2)-A))*B+D;
+C=[1 1];
+A=[0 1;-0.5 -1];
+X=lyap(A,C,'c');
+assert_checkalmostequal(X,[-1.5,-1]);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10281.tst b/modules/linear_algebra/tests/nonreg_tests/bug_10281.tst
new file mode 100755
index 000000000..fefe52866
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10281.tst
@@ -0,0 +1,28 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10281 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10281
+//
+// <-- Short Description -->
+// lyap segfaults in some cases
+
+s=poly(0,'s');
+A=[-1 10;0 1];B=[-2;0];C=[-2 3];D=[-2];
+sis57=syslin('c',A,B,C,D);
+ss2tf(sis57);
+
+gs=C*inv((s*eye(2,2)-A))*B+D;
+
+C=[1 1];
+A=[0 1;-0.5 -1];
+X=lyap(A,C,'c');
+assert_checkalmostequal(X,[-1.5,-1]);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10519.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_10519.dia.ref
new file mode 100755
index 000000000..6b73bfebc
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10519.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10519 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10519
+//
+// <-- Short Description -->
+// Wrong error message in spec function when input arguments were not square.
+// First input argument is not square
+exectedMsg = msprintf(_("Wrong type for first argument: Square matrix expected.\n"));
+assert_checkerror("spec(rand(1,2),rand(2,4))", exectedMsg);
+// Second input argument is not square
+exectedMsg = msprintf(_("Wrong type for argument #%d: Square matrix expected.\n"), 2);
+assert_checkerror("spec(rand(2,2),rand(2,4))", exectedMsg);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10519.tst b/modules/linear_algebra/tests/nonreg_tests/bug_10519.tst
new file mode 100755
index 000000000..951c495f2
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10519.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10519 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10519
+//
+// <-- Short Description -->
+// Wrong error message in spec function when input arguments were not square.
+
+// First input argument is not square
+exectedMsg = msprintf(_("Wrong type for first argument: Square matrix expected.\n"));
+assert_checkerror("spec(rand(1,2),rand(2,4))", exectedMsg);
+
+// Second input argument is not square
+exectedMsg = msprintf(_("Wrong type for argument #%d: Square matrix expected.\n"), 2);
+assert_checkerror("spec(rand(2,2),rand(2,4))", exectedMsg); \ No newline at end of file
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10921.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_10921.dia.ref
new file mode 100755
index 000000000..1786eafa4
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10921.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// 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 -->
+// <-- ENGLISH IMPOSED -->
+// <-- Non-regression test for bug 10921 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10921
+//
+// <-- Short Description -->
+// For ill-conditioned matrix, inv() prints a wrong value of rcond
+M = [1 0; 0 10^(-8)];
+inv(M);
+Warning :
+matrix is close to singular or badly scaled. rcond = 1.0000D-08
+
+A=diag([1:10]);
+A(1,1) = 10^-8;
+inv(A);
+Warning :
+matrix is close to singular or badly scaled. rcond = 1.0000D-09
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_10921.tst b/modules/linear_algebra/tests/nonreg_tests/bug_10921.tst
new file mode 100755
index 000000000..fa93a6b67
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_10921.tst
@@ -0,0 +1,28 @@
+// =============================================================================
+// 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 -->
+
+// <-- ENGLISH IMPOSED -->
+
+// <-- Non-regression test for bug 10921 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10921
+//
+// <-- Short Description -->
+// For ill-conditioned matrix, inv() prints a wrong value of rcond
+
+M = [1 0; 0 10^(-8)];
+inv(M);
+
+A=diag([1:10]);
+A(1,1) = 10^-8;
+inv(A);
+
+
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_12121.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_12121.dia.ref
new file mode 100755
index 000000000..3b6088ff4
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_12121.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 12121 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12121
+//
+// <-- Short Description -->
+// inv() did not work for complex sparse matrices.
+// =============================================================================
+A = %i*speye(3,3);
+assert_checkequal(inv(A), -A);
+A = rand(5,5)*%i;
+assert_checkalmostequal(full(inv(sparse(A))), inv(A));
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_12121.tst b/modules/linear_algebra/tests/nonreg_tests/bug_12121.tst
new file mode 100755
index 000000000..9ae434198
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_12121.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 12121 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12121
+//
+// <-- Short Description -->
+// inv() did not work for complex sparse matrices.
+// =============================================================================
+
+A = %i*speye(3,3);
+assert_checkequal(inv(A), -A);
+
+A = rand(5,5)*%i;
+assert_checkalmostequal(full(inv(sparse(A))), inv(A));
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_12686.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_12686.dia.ref
new file mode 100755
index 000000000..baf618a1d
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_12686.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- ENGLISH IMPOSED -->
+// <-- Non-regression test for bug 12686 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12686
+//
+// <-- Short Description -->
+// diff() with zero input arguments yielded the wrong error
+// Run with test_run('linear_algebra', 'bug_12686', ['no_check_error_output'])
+refMsg = msprintf(_("%s: Wrong number of input arguments: %d to %d expected.\n"), "diff", 1, 3);
+assert_checkerror("diff()", refMsg);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_12686.tst b/modules/linear_algebra/tests/nonreg_tests/bug_12686.tst
new file mode 100755
index 000000000..e2f300ba2
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_12686.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+// <-- ENGLISH IMPOSED -->
+
+// <-- Non-regression test for bug 12686 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12686
+//
+// <-- Short Description -->
+// diff() with zero input arguments yielded the wrong error
+
+// Run with test_run('linear_algebra', 'bug_12686', ['no_check_error_output'])
+
+refMsg = msprintf(_("%s: Wrong number of input arguments: %d to %d expected.\n"), "diff", 1, 3);
+assert_checkerror("diff()", refMsg);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_2523.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_2523.dia.ref
new file mode 100755
index 000000000..7472c06fd
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_2523.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 2523 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2523
+//
+// <-- Short Description -->
+// slash and backslash matrix divisions involving vectors with %inf or %nan entries
+// hang scilab
+if execstr('[1 %inf]\1 ','errcatch')<>229 then bugmes();quit;end
+if execstr('[1 2]\%inf ','errcatch')<>229 then bugmes();quit;end
+if execstr('[1+%i %inf]\1 ','errcatch')<>229 then bugmes();quit;end
+if execstr('[1+%i %inf]\%i ','errcatch')<>229 then bugmes();quit;end
+if execstr('[1 %i]\%inf ','errcatch')<>229 then bugmes();quit;end
+if execstr('1/[1 %inf] ','errcatch')<>229 then bugmes();quit;end
+if execstr('%inf/[1 2] ','errcatch')<>229 then bugmes();quit;end
+if execstr('1/[1+%i %inf] ','errcatch')<>229 then bugmes();quit;end
+if execstr('%i/[1+%i %inf] ','errcatch')<>229 then bugmes();quit;end
+if execstr('%inf/[1 %i] ','errcatch')<>229 then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_2523.tst b/modules/linear_algebra/tests/nonreg_tests/bug_2523.tst
new file mode 100755
index 000000000..1423437dc
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_2523.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 2523 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2523
+//
+// <-- Short Description -->
+// slash and backslash matrix divisions involving vectors with %inf or %nan entries
+// hang scilab
+
+
+if execstr('[1 %inf]\1 ','errcatch')<>229 then pause,end
+if execstr('[1 2]\%inf ','errcatch')<>229 then pause,end
+
+if execstr('[1+%i %inf]\1 ','errcatch')<>229 then pause,end
+if execstr('[1+%i %inf]\%i ','errcatch')<>229 then pause,end
+
+if execstr('[1 %i]\%inf ','errcatch')<>229 then pause,end
+
+if execstr('1/[1 %inf] ','errcatch')<>229 then pause,end
+if execstr('%inf/[1 2] ','errcatch')<>229 then pause,end
+
+if execstr('1/[1+%i %inf] ','errcatch')<>229 then pause,end
+if execstr('%i/[1+%i %inf] ','errcatch')<>229 then pause,end
+
+if execstr('%inf/[1 %i] ','errcatch')<>229 then pause,end
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_2775.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_2775.dia.ref
new file mode 100755
index 000000000..4e9133ff1
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_2775.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Allan CORNET
+// Copyright (C) 2009 - INRIA - Michael Baudin, Antoine Elias
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 2775 -->
+//
+// <-- CLI SHELL MODE -->
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2775
+//
+// Bibliography :
+// "IEEE Standard for Floating-Point Arithmetic"
+// IEEE Std 754-2008
+// 29 August 2008
+// (Revision of IEEE Std 754-1985)
+res_1 = 0.0 * %nan;
+res_2 = %nan * 0.0;
+assert_checkequal ( res_1 , %nan );
+assert_checkequal ( res_2 , %nan );
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst b/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst
new file mode 100755
index 000000000..86e7a5819
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst
@@ -0,0 +1,30 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Allan CORNET
+// Copyright (C) 2009 - INRIA - Michael Baudin, Antoine Elias
+// Copyright (C) 2010-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 2775 -->
+//
+// <-- CLI SHELL MODE -->
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2775
+//
+
+
+
+// Bibliography :
+// "IEEE Standard for Floating-Point Arithmetic"
+// IEEE Std 754-2008
+// 29 August 2008
+// (Revision of IEEE Std 754-1985)
+
+res_1 = 0.0 * %nan;
+res_2 = %nan * 0.0;
+
+assert_checkequal ( res_1 , %nan );
+assert_checkequal ( res_2 , %nan );
+
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3312.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_3312.dia.ref
new file mode 100755
index 000000000..f08fbc754
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3312.dia.ref
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3312 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3312
+//
+// <-- Short Description -->
+// Wrong companion matrix when the polynomial is complex.
+p=1+%i+2*%s;
+computed=companion(p);
+expected=[-(1+%i)/2];
+if abs(expected-computed)>%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3312.tst b/modules/linear_algebra/tests/nonreg_tests/bug_3312.tst
new file mode 100755
index 000000000..fbb974694
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3312.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3312 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3312
+//
+// <-- Short Description -->
+// Wrong companion matrix when the polynomial is complex.
+
+p=1+%i+2*%s;
+computed=companion(p);
+expected=[-(1+%i)/2];
+if abs(expected-computed)>%eps then pause,end
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3624.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_3624.dia.ref
new file mode 100755
index 000000000..d3af3c95a
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3624.dia.ref
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3624 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3624
+//
+// <-- Short Description -->
+// Nan returned when multiplying large zero vector by its transpose.
+A=zeros(1000,1);
+res = A*A';
+if or(isnan(res)<>%f) then bugmes();quit;end;
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3624.tst b/modules/linear_algebra/tests/nonreg_tests/bug_3624.tst
new file mode 100755
index 000000000..ffba5c266
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3624.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3624 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3624
+//
+// <-- Short Description -->
+// Nan returned when multiplying large zero vector by its transpose.
+
+
+A=zeros(1000,1);
+res = A*A';
+if or(isnan(res)<>%f) then pause,end;
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3652.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_3652.dia.ref
new file mode 100755
index 000000000..47ac10574
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3652.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3652 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3652
+//
+// <-- Short Description -->
+// Instable behaviour of Lapack's zggev
+Areal=[1 0 0;...
+0 1 0;...
+0 0 1];
+A = complex(Areal,0);
+Ereal=[1 1e-14 0;...
+1e-14 1 0;...
+0 0 1];
+E = complex(Ereal,0);
+Scomputed = spec(A,E);
+Sexpected = [1-1e-14;1+1e-14;1];
+if norm(Scomputed - Sexpected) > 1000 * %eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3652.tst b/modules/linear_algebra/tests/nonreg_tests/bug_3652.tst
new file mode 100755
index 000000000..7218d75d5
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3652.tst
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3652 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3652
+//
+// <-- Short Description -->
+// Instable behaviour of Lapack's zggev
+
+
+Areal=[1 0 0;...
+0 1 0;...
+0 0 1];
+A = complex(Areal,0);
+Ereal=[1 1e-14 0;...
+1e-14 1 0;...
+0 0 1];
+E = complex(Ereal,0);
+Scomputed = spec(A,E);
+Sexpected = [1-1e-14;1+1e-14;1];
+if norm(Scomputed - Sexpected) > 1000 * %eps then pause,end
+
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3827.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_3827.dia.ref
new file mode 100755
index 000000000..a909c8648
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3827.dia.ref
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3827 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3827
+//
+// <-- Short Description -->
+// Atlas library crashs scilab with this example
+a=[1 2 3;2 3 4;3 4 5];
+ev=spec(a);
+if or(size(ev)<> [3 1]) then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_3827.tst b/modules/linear_algebra/tests/nonreg_tests/bug_3827.tst
new file mode 100755
index 000000000..373c8352e
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_3827.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3827 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3827
+//
+// <-- Short Description -->
+// Atlas library crashs scilab with this example
+
+a=[1 2 3;2 3 4;3 4 5];
+ev=spec(a);
+if or(size(ev)<> [3 1]) then pause,end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4042.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_4042.dia.ref
new file mode 100755
index 000000000..9796383f9
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4042.dia.ref
@@ -0,0 +1,28 @@
+// =============================================================================
+// 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 4042 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4042
+//
+// <-- Short Description -->
+// squeeze(A(1,1,:)) returned an hypermatrix instead a matrix
+// =============================================================================
+A=ones(3,3);
+A(:,:,2)=3*ones(3,3);
+A(:,:,3)=-1*ones(3,3);
+B=squeeze(A(1,1,:));
+assert_checkequal(type(B), 1);
+// In Scilab 6, the hypermatrix type won't exist
+v = getversion('scilab');
+if v(1) > 5 then
+ C(:,:,1) = zeros(32,32);
+ C(:,:,2) = zeros(32,32);
+ assert_checkequal(typeof(C(:,:,1)), "constant");
+ assert_checkequal(typeof(C(1,:,:)), "constant");
+end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4042.tst b/modules/linear_algebra/tests/nonreg_tests/bug_4042.tst
new file mode 100755
index 000000000..ea5e8b139
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4042.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// 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 4042 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4042
+//
+// <-- Short Description -->
+// squeeze(A(1,1,:)) returned an hypermatrix instead a matrix
+// =============================================================================
+
+A=ones(3,3);
+A(:,:,2)=3*ones(3,3);
+A(:,:,3)=-1*ones(3,3);
+B=squeeze(A(1,1,:));
+
+assert_checkequal(type(B), 1);
+
+// In Scilab 6, the hypermatrix type won't exist
+v = getversion('scilab');
+if v(1) > 5 then
+ C(:,:,1) = zeros(32,32);
+ C(:,:,2) = zeros(32,32);
+ assert_checkequal(typeof(C(:,:,1)), "constant");
+ assert_checkequal(typeof(C(1,:,:)), "constant");
+end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4311.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_4311.dia.ref
new file mode 100755
index 000000000..670c84377
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4311.dia.ref
@@ -0,0 +1,15 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 4311 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4311
+//
+// <-- Short Description -->
+// rcond(eye()) returns eye() instead of 1.
+if rcond(eye()) <> 1 then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4311.tst b/modules/linear_algebra/tests/nonreg_tests/bug_4311.tst
new file mode 100755
index 000000000..c4d5fe168
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4311.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 4311 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4311
+//
+// <-- Short Description -->
+// rcond(eye()) returns eye() instead of 1.
+
+if rcond(eye()) <> 1 then pause,end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4405.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_4405.dia.ref
new file mode 100755
index 000000000..ed870c128
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4405.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// 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 4405 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4405
+//
+// <-- Short Description -->
+// Calling sequence [Q,R,rk,E]=qr(A,"e") should return an error
+A=[1 2; 3 4; 5 6];
+expectedMsg = msprintf(_("%s: Wrong type for input argument #%d: Real scalar expected.\n"), "qr", 2);
+assert_checkerror("[Q,R,rk,E]=qr(A,""e"")",expectedMsg);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4405.tst b/modules/linear_algebra/tests/nonreg_tests/bug_4405.tst
new file mode 100755
index 000000000..c0bea2498
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4405.tst
@@ -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 4405 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4405
+//
+// <-- Short Description -->
+// Calling sequence [Q,R,rk,E]=qr(A,"e") should return an error
+
+A=[1 2; 3 4; 5 6];
+expectedMsg = msprintf(_("%s: Wrong type for input argument #%d: Real scalar expected.\n"), "qr", 2);
+assert_checkerror("[Q,R,rk,E]=qr(A,""e"")",expectedMsg);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4425.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_4425.dia.ref
new file mode 100755
index 000000000..c260b308f
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4425.dia.ref
@@ -0,0 +1,29 @@
+// =============================================================================
+// 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 4425 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4425
+//
+// <-- Short Description -->
+// After [U,S] = schur(A), U * S * U' is not equal to A
+// =============================================================================
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+function A = testmat1(a, n)
+ //eigen values are given by a dilation of nth roots of 1
+ A = diag(a * ones(1, n - 1), 1) + diag((1 / a) * ones(1, n - 1), -1)
+ A(1,n) = 1 / a; A(n,1) = a
+endfunction
+A = testmat1(3,5);
+Ac = testmat1(3 + %i,5);
+[U, S] = schur(A);
+assert_checkalmostequal(Err(U*S*U'-A), 0, [], 200 * %eps);
+[U, S] = schur(Ac);
+assert_checkalmostequal(Err(U*S*U'-Ac), 0, [], 200 * %eps);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4425.tst b/modules/linear_algebra/tests/nonreg_tests/bug_4425.tst
new file mode 100755
index 000000000..068de036d
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4425.tst
@@ -0,0 +1,39 @@
+// =============================================================================
+// 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 4425 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4425
+//
+// <-- Short Description -->
+// After [U,S] = schur(A), U * S * U' is not equal to A
+// =============================================================================
+
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+
+function A = testmat1(a, n)
+ //eigen values are given by a dilation of nth roots of 1
+ A = diag(a * ones(1, n - 1), 1) + diag((1 / a) * ones(1, n - 1), -1)
+ A(1,n) = 1 / a; A(n,1) = a
+endfunction
+
+A = testmat1(3,5);
+Ac = testmat1(3 + %i,5);
+
+[U, S] = schur(A);
+assert_checkalmostequal(Err(U*S*U'-A), 0, [], 200 * %eps);
+
+[U, S] = schur(Ac);
+assert_checkalmostequal(Err(U*S*U'-Ac), 0, [], 200 * %eps);
+
+
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4759.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_4759.dia.ref
new file mode 100755
index 000000000..55c61e6a8
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4759.dia.ref
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 4759 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4759
+//
+// <-- Short Description -->
+// We should provide a better error message in nlev when called with no input argument
+execstr("nlev","errcatch");
+if lasterror()<>msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"),"nlev",2,3) then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_4759.tst b/modules/linear_algebra/tests/nonreg_tests/bug_4759.tst
new file mode 100755
index 000000000..6a556b85d
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_4759.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 4759 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4759
+//
+// <-- Short Description -->
+// We should provide a better error message in nlev when called with no input argument
+
+execstr("nlev","errcatch");
+
+if lasterror()<>msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"),"nlev",2,3) then pause;end
+
+
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_5017.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_5017.dia.ref
new file mode 100755
index 000000000..f39147927
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_5017.dia.ref
@@ -0,0 +1,173 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 5017 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=5017
+//
+// <-- Short Description -->
+// norm() now calls Lapack.
+// Checking sparse compatibility
+rand("seed", 0);
+A = rand(10, 10);
+n = norm(sparse(A));
+assert_checkalmostequal(n, 5.0884897363846);
+//---------------------------------------------------
+// Now, we make sure that the new implementation
+// of norm() yiels the same results as the old one,
+// with respect to the machine precision.
+// Square root of 5, with a 10^-307 padding.
+x1 = 1.e-307*[1 1 1 1 1];
+y1 = norm(x1);
+// Square root of 3, with a 10^-307 padding.
+x2 = 1.e-307*[1 1 1];
+z1 = norm(x2);
+// Now compute the same values with the old norm function:
+warning("off");
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+// Copyright (C) 2009 - INRIA Michael Baudin
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// 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
+//
+// norm --
+// Returns the norm of the given vector/matrix A.
+// Uses scaling to improve accuracy for Pythagorean sums.
+// References
+// Moler C, Morrison D.
+// Replacing square roots by pythagorean sums.
+// IBM Journal of Research and Development 1983; 27(6):577-581.
+//
+function y=norm(A,flag)
+ //compute various matrix norms
+ if argn(2)==1 then flag=2,end
+ if type(A)==1 then
+ if A==[] then y=0,return,end
+ if or(size(A)==1) then // vector norm
+ if type(flag)==10 then //'inf' or 'fro'
+ select convstr(part(flag,1))
+ case "i" then //'inf'
+ y=max(abs(A))
+ case "f" then //'fro'
+ A=A(:)
+ //
+ // Scaling for better floating point accuracy.
+ //
+ //
+ s = max(abs(A));
+ if s==0.0 then
+ y=sqrt(A'*A);
+ else
+ sA = A/s;
+ // return real result
+ y = s * sqrt(abs(sA'*sA));
+ end
+ else
+ error("invalid value for flag")
+ end
+ elseif type(flag)==1 then //p_norm
+ p=flag;
+ if ~isreal(p) then
+ error("flag must be real")
+ end
+ if p==%inf then
+ y=max(abs(A))
+ elseif p==1 then
+ y=sum(abs(A))
+ elseif p==-%inf then
+ y=min(abs(A))
+ elseif isnan(p) then
+ y=%nan
+ elseif p==0 then
+ y=%inf
+ else
+ //
+ // Scaling for better floating point accuracy.
+ //
+ s = max(abs(A));
+ if s==0.0 then
+ y=sum(abs(A).^p)^(1/p);
+ else
+ sA = A/s;
+ y = s * sum(abs(sA).^p)^(1/p);
+ end
+ end
+ else
+ error("invalid value for flag")
+ end
+ else //matrix norm
+ if type(flag)==10 then //'inf' or 'fro'
+ select convstr(part(flag,1))
+ case "i" then //'inf'
+ y=max(sum(abs(A),2))
+ case "f" then //'fro'
+ //
+ // Scaling for better floating point accuracy.
+ //
+ s = max(abs(A));
+ if s==0.0 then
+ if size(A,1)>size(A,2) then
+ y=sqrt(sum(diag(A'*A)))
+ else
+ y=sqrt(sum(diag(A*A')))
+ end
+ else
+ sA = A/s;
+ if size(A,1)>size(A,2) then
+ // return real result
+ y = s * sqrt(sum(abs(diag(sA'*sA))))
+ else
+ y = s * sqrt(sum(abs(diag(sA*sA'))))
+ end
+ end
+ else
+ error("invalid value for flag")
+ end
+ elseif type(flag)==1 then //p_norm
+ p=flag;
+ select p
+ case 1 then
+ y=max(sum(abs(A),1))
+ case 2 then
+ y=max(svd(A))
+ case %inf then
+ y=max(sum(abs(A),2))
+ else
+ error("flag must be 1 2 or inf")
+ end
+ else
+ error("invalid value for flag")
+ end
+ end
+ else
+ if type(A)==16|type(A)==17 then
+ n=getfield(1,A);n=n(1)
+ else
+ [t,n]=typename()
+ n=stripblanks(n(find(t==type(A))))
+ end
+ fun="%"+n+"_norm"
+ if exists(fun)==1 then
+ execstr("y="+fun+"(A,flag)")
+ else
+ error("norm not defined for type """+n+""" ."+..
+ "Check argument or define function "+fun)
+ end
+ end
+endfunction
+y2 = norm(x1);
+z2 = norm(x2);
+assert_checktrue((y1-y2)/y1<=%eps);
+assert_checktrue((z2-z2)/z1<=%eps);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_5017.tst b/modules/linear_algebra/tests/nonreg_tests/bug_5017.tst
new file mode 100755
index 000000000..7e52298f6
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_5017.tst
@@ -0,0 +1,184 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 5017 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=5017
+//
+// <-- Short Description -->
+// norm() now calls Lapack.
+
+// Checking sparse compatibility
+rand("seed", 0);
+A = rand(10, 10);
+n = norm(sparse(A));
+assert_checkalmostequal(n, 5.0884897363846);
+
+//---------------------------------------------------
+// Now, we make sure that the new implementation
+// of norm() yiels the same results as the old one,
+// with respect to the machine precision.
+
+// Square root of 5, with a 10^-307 padding.
+x1 = 1.e-307*[1 1 1 1 1];
+y1 = norm(x1);
+
+// Square root of 3, with a 10^-307 padding.
+x2 = 1.e-307*[1 1 1];
+z1 = norm(x2);
+
+// Now compute the same values with the old norm function:
+
+warning("off");
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+// Copyright (C) 2009 - INRIA Michael Baudin
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// 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
+
+//
+// norm --
+// Returns the norm of the given vector/matrix A.
+// Uses scaling to improve accuracy for Pythagorean sums.
+// References
+// Moler C, Morrison D.
+// Replacing square roots by pythagorean sums.
+// IBM Journal of Research and Development 1983; 27(6):577-581.
+//
+function y=norm(A,flag)
+ //compute various matrix norms
+ if argn(2)==1 then flag=2,end
+
+ if type(A)==1 then
+ if A==[] then y=0,return,end
+ if or(size(A)==1) then // vector norm
+ if type(flag)==10 then //'inf' or 'fro'
+ select convstr(part(flag,1))
+ case "i" then //'inf'
+ y=max(abs(A))
+ case "f" then //'fro'
+ A=A(:)
+ //
+ // Scaling for better floating point accuracy.
+ //
+ //
+ s = max(abs(A));
+ if s==0.0 then
+ y=sqrt(A'*A);
+ else
+ sA = A/s;
+ // return real result
+ y = s * sqrt(abs(sA'*sA));
+ end
+ else
+ error("invalid value for flag")
+ end
+ elseif type(flag)==1 then //p_norm
+ p=flag;
+ if ~isreal(p) then
+ error("flag must be real")
+ end
+ if p==%inf then
+ y=max(abs(A))
+ elseif p==1 then
+ y=sum(abs(A))
+ elseif p==-%inf then
+ y=min(abs(A))
+ elseif isnan(p) then
+ y=%nan
+ elseif p==0 then
+ y=%inf
+ else
+ //
+ // Scaling for better floating point accuracy.
+ //
+ s = max(abs(A));
+ if s==0.0 then
+ y=sum(abs(A).^p)^(1/p);
+ else
+ sA = A/s;
+ y = s * sum(abs(sA).^p)^(1/p);
+ end
+ end
+ else
+ error("invalid value for flag")
+ end
+ else //matrix norm
+ if type(flag)==10 then //'inf' or 'fro'
+ select convstr(part(flag,1))
+ case "i" then //'inf'
+ y=max(sum(abs(A),2))
+ case "f" then //'fro'
+ //
+ // Scaling for better floating point accuracy.
+ //
+ s = max(abs(A));
+ if s==0.0 then
+ if size(A,1)>size(A,2) then
+ y=sqrt(sum(diag(A'*A)))
+ else
+ y=sqrt(sum(diag(A*A')))
+ end
+ else
+ sA = A/s;
+ if size(A,1)>size(A,2) then
+ // return real result
+ y = s * sqrt(sum(abs(diag(sA'*sA))))
+ else
+ y = s * sqrt(sum(abs(diag(sA*sA'))))
+ end
+ end
+ else
+ error("invalid value for flag")
+ end
+ elseif type(flag)==1 then //p_norm
+ p=flag;
+ select p
+ case 1 then
+ y=max(sum(abs(A),1))
+ case 2 then
+ y=max(svd(A))
+ case %inf then
+ y=max(sum(abs(A),2))
+ else
+ error("flag must be 1 2 or inf")
+ end
+ else
+ error("invalid value for flag")
+ end
+ end
+ else
+ if type(A)==16|type(A)==17 then
+ n=getfield(1,A);n=n(1)
+ else
+ [t,n]=typename()
+ n=stripblanks(n(find(t==type(A))))
+ end
+ fun="%"+n+"_norm"
+ if exists(fun)==1 then
+ execstr("y="+fun+"(A,flag)")
+ else
+ error("norm not defined for type """+n+""" ."+..
+ "Check argument or define function "+fun)
+ end
+ end
+endfunction
+
+y2 = norm(x1);
+z2 = norm(x2);
+
+assert_checktrue((y1-y2)/y1<=%eps);
+assert_checktrue((z2-z2)/z1<=%eps);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_545.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_545.dia.ref
new file mode 100755
index 000000000..ecbc78201
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_545.dia.ref
@@ -0,0 +1,37 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- JVM NOT MANDATORY -->
+// <-- Non-regression test for bug 545 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=545
+//
+// <-- Short Description -->
+// Bug Report Id: 031202003109134720
+// This is obviously a conflict between a local variable ndims and the new function ndims().
+// I expect the same problem also in:
+//
+// macros/percent/%b_i_hm.sci
+// macros/percent/%hm_i_hm.sc
+// macros/percent/%p_i_hm.sci
+//
+// Wasn't this an already solved issue??
+// On Scilab CVS with " %i_i_hm " function
+// The Error Messages are:
+// Warning :redefining function: ndims
+// inside function: %i_i_hm
+//
+// Commands:
+// a=int8(hypermat([3 2 2]));b=hypermat([1 2 2]);
+// a(1,:,:)=b
+// Enrico SEGRE on Linux version RH9 distribution with as window manager
+// Israel
+// November 9, 2003 at 13:47:20
+a = int8(hypermat([3 2 2]));
+b = hypermat([1 2 2]);
+a(1,:,:) = b;
+// Just check if there is no "Warning :redefining function: ndims" displayed in .dia.ref
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_545.tst b/modules/linear_algebra/tests/nonreg_tests/bug_545.tst
new file mode 100755
index 000000000..76323e5ba
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_545.tst
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- JVM NOT MANDATORY -->
+
+// <-- Non-regression test for bug 545 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=545
+//
+// <-- Short Description -->
+// Bug Report Id: 031202003109134720
+// This is obviously a conflict between a local variable ndims and the new function ndims().
+// I expect the same problem also in:
+//
+// macros/percent/%b_i_hm.sci
+// macros/percent/%hm_i_hm.sc
+// macros/percent/%p_i_hm.sci
+//
+// Wasn't this an already solved issue??
+// On Scilab CVS with " %i_i_hm " function
+// The Error Messages are:
+// Warning :redefining function: ndims
+// inside function: %i_i_hm
+//
+// Commands:
+// a=int8(hypermat([3 2 2]));b=hypermat([1 2 2]);
+// a(1,:,:)=b
+// Enrico SEGRE on Linux version RH9 distribution with as window manager
+// Israel
+// November 9, 2003 at 13:47:20
+
+a = int8(hypermat([3 2 2]));
+b = hypermat([1 2 2]);
+a(1,:,:) = b;
+
+// Just check if there is no "Warning :redefining function: ndims" displayed in .dia.ref
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_6477.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_6477.dia.ref
new file mode 100755
index 000000000..9ca377de7
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_6477.dia.ref
@@ -0,0 +1,38 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 6477 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6477
+//
+// <-- Short Description -->
+// in some case, schur returned wrong values on Windows.
+function [f] = z_choose(s,t)
+ f = abs(s) > abs(t)
+endfunction
+a=[1 4 5 6; 3 2 5 7; 8 3 4 5; 9 3 5 2];
+b=[3 8 5 7; 1 4 9 3; 9 1 0 7; 9 2 4 8];
+[as, bs, z, dim] = schur(a, b, z_choose);
+if dim <> 2 then bugmes();quit;end
+ref_as = [ - 5.8165015, 4.9422182, - 1.6845626, 1.8997122 ;..
+ 0., 9.4018462, - 14.867682, - 2.1905808 ;..
+ 0., 0., 3.4464284, 2.2480735 ;..
+ 0., 0., - 1.0118069, 1.0484945];
+ref_bs = [0.5173089, 6.2627142, - 2.9573865, 7.2946208 ;..
+ 0., 8.7992813, - 16.353371, - 2.5799548 ;..
+ 0., 0., 8.0516398, 0. ;..
+ 0., 0., 0., 5.6752093 ];
+ref_z = [0.4973431, - 0.6831312, 0.2943626, - 0.4464664; ..
+ 0.4702536, 0.5375540, 0.6832618, 0.1518237; ..
+ 0.0048984, - 0.4789154, 0.1826199, 0.8586419; ..
+ - 0.7290318, - 0.1225046, 0.6427705, - 0.2008765];
+if or(abs(as - ref_as) > 1e10 * %eps) then bugmes();quit;end
+if or(abs(bs - ref_bs) > 1e10 * %eps) then bugmes();quit;end
+if or(abs(z - ref_z) > 1e9 * %eps) then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_6477.tst b/modules/linear_algebra/tests/nonreg_tests/bug_6477.tst
new file mode 100755
index 000000000..a987c3151
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_6477.tst
@@ -0,0 +1,45 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 6477 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6477
+//
+// <-- Short Description -->
+// in some case, schur returned wrong values on Windows.
+
+function [f] = z_choose(s,t)
+ f = abs(s) > abs(t)
+endfunction
+
+a=[1 4 5 6; 3 2 5 7; 8 3 4 5; 9 3 5 2];
+b=[3 8 5 7; 1 4 9 3; 9 1 0 7; 9 2 4 8];
+[as, bs, z, dim] = schur(a, b, z_choose);
+
+if dim <> 2 then pause, end
+
+ref_as = [ - 5.8165015, 4.9422182, - 1.6845626, 1.8997122 ;..
+ 0., 9.4018462, - 14.867682, - 2.1905808 ;..
+ 0., 0., 3.4464284, 2.2480735 ;..
+ 0., 0., - 1.0118069, 1.0484945];
+
+ref_bs = [0.5173089, 6.2627142, - 2.9573865, 7.2946208 ;..
+ 0., 8.7992813, - 16.353371, - 2.5799548 ;..
+ 0., 0., 8.0516398, 0. ;..
+ 0., 0., 0., 5.6752093 ];
+
+ref_z = [0.4973431, - 0.6831312, 0.2943626, - 0.4464664; ..
+ 0.4702536, 0.5375540, 0.6832618, 0.1518237; ..
+ 0.0048984, - 0.4789154, 0.1826199, 0.8586419; ..
+ - 0.7290318, - 0.1225046, 0.6427705, - 0.2008765];
+
+if or(abs(as - ref_as) > 1e10 * %eps) then pause, end
+if or(abs(bs - ref_bs) > 1e10 * %eps) then pause, end
+if or(abs(z - ref_z) > 1e9 * %eps) then pause, end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_6783.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_6783.dia.ref
new file mode 100755
index 000000000..139da95ab
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_6783.dia.ref
@@ -0,0 +1,175 @@
+// =============================================================================
+// 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 6783 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6783
+//
+// <-- Short Description -->
+// Solving a system of linear equation by backslash ("\") will cause a crash to Scilab 5.2.1, when using complex numbers.
+// Replication Code
+S=[
+1.3 24 4.1 29 0.9 33
+0.6 258 0.7 265 0.2 39
+0.5 2 1.4 351 0.5 323
+0.7 63 1.2 19 0.4 318
+17.0 152 29.0 196 6.0 232
+23.0 18 40.0 62 14.0 104
+8.0 213 20.0 177 8.0 147
+12.0 106 26.0 45 11.0 21
+8.1 25 6.4 182 6.9 203
+2.0 282 2.5 20 1.5 114
+5.9 215 5.6 34 4.6 25
+3.7 185 3.6 5 2.8 9
+27.0 134 30.0 290 18.0 321
+23.0 17 26.0 151 9.0 220
+34.0 330 26.0 164 24.0 140
+33.0 187 20.0 18 24.0 350
+2.4 50 3.8 157 3.6 289
+2.2 281 3.7 57 3.0 187
+4.5 322 5.9 149 1.1 48
+1.6 249 3.1 62 1.3 239
+13.0 152 18.0 286 24.0 52
+21.0 77 16.0 166 47.0 298
+41.0 48 34.0 239 4.0 140
+80.0 301 67.0 120 10.0 81
+3.7 43 2.6 215 5.4 290
+3.3 284 3.6 66 3.4 196
+5.6 340 3.7 172 2.1 342
+2.6 272 2.3 72 2.3 274
+34.0 154 23.0 332 32.0 47
+29.0 56 13.0 209 59.0 299
+43.0 62 39.0 241 13.0 89
+91.0 309 75.0 131 15.0 321
+];
+S0=[2.3 278
+0.4 266
+1.1 270
+0 0
+29 141
+21 32
+16 97
+16 4
+5.9 132
+0.3 0
+5.4 327
+3.8 313
+40 244
+12 75
+47 101
+38 343
+1.6 337
+1.5 281
+5.9 34
+2.5 310
+8 37
+8 320
+32 134
+67 29
+2.3 5
+2 307
+7.4 43
+3.2 320
+4 0
+10 357
+34 128
+81 26
+];
+S02=[0.85 258
+0.26 0
+0.33 226
+0.04 0
+14.43 71
+11.48 294
+14.19 65
+16.00 311
+1.74 345
+0.70 178
+2.35 191
+1.74 170
+9.18 105
+4.27 289
+10.32 356
+4.75 0
+2.97 215
+2.87 126
+5.14 242
+4.75 149
+14.98 327
+11.71 193
+10.32 323
+14.82 190
+2.60 100
+2.10 43
+3.40 152
+3.00 65
+23.00 287
+21.00 111
+22.00 229
+52.00 99
+];
+fac=[10
+10
+10
+10
+1
+1
+1
+1
+10
+10
+10
+10
+1
+1
+1
+1
+30
+30
+30
+30
+2
+2
+2
+2
+80
+80
+80
+80
+4
+4
+4
+4];
+if isdef('without')==%T;
+S(without:8:$,:)=[];
+S0(without:8:$,:)=[];
+fac(without:8:$,:)=[];
+else
+end
+S0_a=fac.*S0(:,1);
+S0_w=S0(:,2).*%pi/180;
+S0c=S0_a.*exp(%i*S0_w);
+S0_c2=S0(:,1).*exp(%i*S0_w); // ohne Faktor!!!!
+S02_a=fac.*S02(:,1);
+S02_w=S02(:,2).*%pi/180;
+S02c=S02_a.*exp(%i*S02_w);
+S02_c2=S02(:,1).*exp(%i*S02_w); // ohne Faktor
+S_a=S(:,1:2:$).*[fac fac fac];
+S_wdeg=S(:,2:2:$);
+S_w=S_wdeg*%pi/180;
+M_test=[1000 0 0 0 0 0 760 258
+ 0 0 1000 0 0 0 0 0
+ 0 0 0 0 1000 0 760 210];
+M_a=M_test(:,1:2:$);
+M_wdeg=M_test(:,2:2:$);
+M_w=M_wdeg*%pi/180;
+Sc=[S_a.*exp(%i*S_w) S02c-S0c];
+Mc=M_a.*exp(%i*M_w);
+ierr = execstr("C=Mc''\Sc''","errcatch");
+if ierr <> 0 then bugmes();quit;end
+if size(C) <> [3 32] then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_6783.tst b/modules/linear_algebra/tests/nonreg_tests/bug_6783.tst
new file mode 100755
index 000000000..32611ea39
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_6783.tst
@@ -0,0 +1,192 @@
+// =============================================================================
+// 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 6783 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6783
+//
+// <-- Short Description -->
+// Solving a system of linear equation by backslash ("\") will cause a crash to Scilab 5.2.1, when using complex numbers.
+
+// Replication Code
+S=[
+1.3 24 4.1 29 0.9 33
+0.6 258 0.7 265 0.2 39
+0.5 2 1.4 351 0.5 323
+0.7 63 1.2 19 0.4 318
+17.0 152 29.0 196 6.0 232
+23.0 18 40.0 62 14.0 104
+8.0 213 20.0 177 8.0 147
+12.0 106 26.0 45 11.0 21
+8.1 25 6.4 182 6.9 203
+2.0 282 2.5 20 1.5 114
+5.9 215 5.6 34 4.6 25
+3.7 185 3.6 5 2.8 9
+27.0 134 30.0 290 18.0 321
+23.0 17 26.0 151 9.0 220
+34.0 330 26.0 164 24.0 140
+33.0 187 20.0 18 24.0 350
+2.4 50 3.8 157 3.6 289
+2.2 281 3.7 57 3.0 187
+4.5 322 5.9 149 1.1 48
+1.6 249 3.1 62 1.3 239
+13.0 152 18.0 286 24.0 52
+21.0 77 16.0 166 47.0 298
+41.0 48 34.0 239 4.0 140
+80.0 301 67.0 120 10.0 81
+3.7 43 2.6 215 5.4 290
+3.3 284 3.6 66 3.4 196
+5.6 340 3.7 172 2.1 342
+2.6 272 2.3 72 2.3 274
+34.0 154 23.0 332 32.0 47
+29.0 56 13.0 209 59.0 299
+43.0 62 39.0 241 13.0 89
+91.0 309 75.0 131 15.0 321
+];
+
+
+S0=[2.3 278
+0.4 266
+1.1 270
+0 0
+29 141
+21 32
+16 97
+16 4
+5.9 132
+0.3 0
+5.4 327
+3.8 313
+40 244
+12 75
+47 101
+38 343
+1.6 337
+1.5 281
+5.9 34
+2.5 310
+8 37
+8 320
+32 134
+67 29
+2.3 5
+2 307
+7.4 43
+3.2 320
+4 0
+10 357
+34 128
+81 26
+];
+
+S02=[0.85 258
+0.26 0
+0.33 226
+0.04 0
+14.43 71
+11.48 294
+14.19 65
+16.00 311
+1.74 345
+0.70 178
+2.35 191
+1.74 170
+9.18 105
+4.27 289
+10.32 356
+4.75 0
+2.97 215
+2.87 126
+5.14 242
+4.75 149
+14.98 327
+11.71 193
+10.32 323
+14.82 190
+2.60 100
+2.10 43
+3.40 152
+3.00 65
+23.00 287
+21.00 111
+22.00 229
+52.00 99
+];
+
+
+fac=[10
+10
+10
+10
+1
+1
+1
+1
+10
+10
+10
+10
+1
+1
+1
+1
+30
+30
+30
+30
+2
+2
+2
+2
+80
+80
+80
+80
+4
+4
+4
+4];
+
+if isdef('without')==%T;
+S(without:8:$,:)=[];
+S0(without:8:$,:)=[];
+fac(without:8:$,:)=[];
+else
+end
+
+S0_a=fac.*S0(:,1);
+S0_w=S0(:,2).*%pi/180;
+S0c=S0_a.*exp(%i*S0_w);
+S0_c2=S0(:,1).*exp(%i*S0_w); // ohne Faktor!!!!
+
+S02_a=fac.*S02(:,1);
+S02_w=S02(:,2).*%pi/180;
+S02c=S02_a.*exp(%i*S02_w);
+S02_c2=S02(:,1).*exp(%i*S02_w); // ohne Faktor
+
+
+S_a=S(:,1:2:$).*[fac fac fac];
+S_wdeg=S(:,2:2:$);
+S_w=S_wdeg*%pi/180;
+
+M_test=[1000 0 0 0 0 0 760 258
+ 0 0 1000 0 0 0 0 0
+ 0 0 0 0 1000 0 760 210];
+
+M_a=M_test(:,1:2:$);
+M_wdeg=M_test(:,2:2:$);
+M_w=M_wdeg*%pi/180;
+
+Sc=[S_a.*exp(%i*S_w) S02c-S0c];
+Mc=M_a.*exp(%i*M_w);
+
+ierr = execstr("C=Mc''\Sc''","errcatch");
+if ierr <> 0 then pause,end
+if size(C) <> [3 32] then pause,end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_7109.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_7109.dia.ref
new file mode 100755
index 000000000..d5a3a691e
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_7109.dia.ref
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 7109 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7109
+//
+// <-- Short Description -->
+// 'lu' function with some complex matrices crashed on Windows.
+x = [0.1523 + 0.7685 * %i, -0.8957 + 0.0342 * %i, 2.4353 + 2.7736 * %i; ..
+ -1.1953 + 1.2187 * %i, 1.2118 + 0.2571 * %i, -0.0446 - 1.7768 * %i; ..
+ 0.8038 + 1.3668 * %i, 1.2950 - 1.6929 * %i, 1.6267 + 0.2844 * %i];
+ierr = execstr('[l, u] = lu(x);','errcatch');
+if ierr <> 0 then bugmes();quit;end
+if or(size(l) <> [3 3]) then bugmes();quit;end
+if or(size(u) <> [3 3]) then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_7109.tst b/modules/linear_algebra/tests/nonreg_tests/bug_7109.tst
new file mode 100755
index 000000000..16f2c32a1
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_7109.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 7109 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7109
+//
+// <-- Short Description -->
+// 'lu' function with some complex matrices crashed on Windows.
+
+x = [0.1523 + 0.7685 * %i, -0.8957 + 0.0342 * %i, 2.4353 + 2.7736 * %i; ..
+ -1.1953 + 1.2187 * %i, 1.2118 + 0.2571 * %i, -0.0446 - 1.7768 * %i; ..
+ 0.8038 + 1.3668 * %i, 1.2950 - 1.6929 * %i, 1.6267 + 0.2844 * %i];
+
+ierr = execstr('[l, u] = lu(x);','errcatch');
+if ierr <> 0 then pause, end
+
+if or(size(l) <> [3 3]) then pause, end
+if or(size(u) <> [3 3]) then pause, end
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_7485.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_7485.dia.ref
new file mode 100755
index 000000000..16a883f98
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_7485.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 7485 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7485
+//
+// <-- Short Description -->
+// Division of matrices of complex numbers crashed on Windows.
+L1 = [-22.168 + 14.267*%i -10.428 + 17.817*%i -2.8879 + 14.947*%i 0.4547 + 11.203*%i];
+T = [8.9186 - 3.0399*%i 6.8345 - 4.7536*%i 4.8415 - 5.2106*%i 3.3626 - 5.0337*%i; ..
+79.459 - 58.111*%i 30.562 - 70.097*%i 0.8502 - 55.647*%i -10.784 - 38.795*%i];
+if execstr("a = -real(L1/T);", "errcatch") <> 0 then bugmes();quit;end
+A = [1 , 1, %i];
+B = [1 , 1, 1];
+if execstr("r = A / B;", "errcatch") <> 0 then bugmes();quit;end
+r = [1 , 1, %i]/[1 , 1, 1];
+ref = 0.6666667 + 0.3333333 * %i;
+if abs(r - ref) > %eps * 1e9 then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_7485.tst b/modules/linear_algebra/tests/nonreg_tests/bug_7485.tst
new file mode 100755
index 000000000..0442081f9
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_7485.tst
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 7485 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7485
+//
+// <-- Short Description -->
+// Division of matrices of complex numbers crashed on Windows.
+
+L1 = [-22.168 + 14.267*%i -10.428 + 17.817*%i -2.8879 + 14.947*%i 0.4547 + 11.203*%i];
+T = [8.9186 - 3.0399*%i 6.8345 - 4.7536*%i 4.8415 - 5.2106*%i 3.3626 - 5.0337*%i; ..
+79.459 - 58.111*%i 30.562 - 70.097*%i 0.8502 - 55.647*%i -10.784 - 38.795*%i];
+if execstr("a = -real(L1/T);", "errcatch") <> 0 then pause, end
+
+A = [1 , 1, %i];
+B = [1 , 1, 1];
+if execstr("r = A / B;", "errcatch") <> 0 then pause, end
+
+r = [1 , 1, %i]/[1 , 1, 1];
+ref = 0.6666667 + 0.3333333 * %i;
+
+if abs(r - ref) > %eps * 1e9 then pause, end
+
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_7950.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_7950.dia.ref
new file mode 100755
index 000000000..f5a080f68
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_7950.dia.ref
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 7950 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7950
+//
+// <-- Short Description -->
+// spec function crashed on Windows
+n = [0,10,0,0,10;
+10,0,10,0,0;
+0,10,0,10,0;
+0,0,10,0,10;
+10,0,0,10,0];
+d = [1,3,1,1,3;
+3,1,3,1,1;
+1,3,1,3,1;
+1,1,3,1,3;
+3,1,1,3,1];
+A = n./d;
+r = spec(A);
+ref = [ -5.3934466; ..
+ -5.3934466; ..
+ 2.0601133; ..
+ 2.0601133; ..
+ 6.6666667];
+if norm(r - ref) > 1e9 *%eps then bugmes();quit;end
+ s11 = [ 0.0633728 0.0313074 -0.0021908 -0.0014231 -0.0025785 0.0968961; ..
+ 0.0313074 0.0177124 -0.0010565 -0.0007932 -0.0012911 0.0410817; ..
+ -0.0021908 -0.0010565 0.0001016 0.0000454 0.0000847 -0.0034275; ..
+ -0.0014231 -0.0007932 0.0000454 0.0000428 0.0000659 -0.0019033; ..
+ -0.0025785 -0.0012911 0.0000847 0.0000659 0.0001176 -0.0038904; ..
+ 0.0968961 0.0410817 -0.0034275 -0.0019033 -0.0038904 0.1686615];
+[eigenv, rho] = spec(s11);
+if or(size(eigenv) <> [6 6]) then bugmes();quit;end
+if or(size(rho) <> [6 6]) then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_7950.tst b/modules/linear_algebra/tests/nonreg_tests/bug_7950.tst
new file mode 100755
index 000000000..51811b25a
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_7950.tst
@@ -0,0 +1,48 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 7950 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7950
+//
+// <-- Short Description -->
+// spec function crashed on Windows
+
+
+n = [0,10,0,0,10;
+10,0,10,0,0;
+0,10,0,10,0;
+0,0,10,0,10;
+10,0,0,10,0];
+d = [1,3,1,1,3;
+3,1,3,1,1;
+1,3,1,3,1;
+1,1,3,1,3;
+3,1,1,3,1];
+A = n./d;
+r = spec(A);
+ref = [ -5.3934466; ..
+ -5.3934466; ..
+ 2.0601133; ..
+ 2.0601133; ..
+ 6.6666667];
+if norm(r - ref) > 1e9 *%eps then pause, end
+
+
+ s11 = [ 0.0633728 0.0313074 -0.0021908 -0.0014231 -0.0025785 0.0968961; ..
+ 0.0313074 0.0177124 -0.0010565 -0.0007932 -0.0012911 0.0410817; ..
+ -0.0021908 -0.0010565 0.0001016 0.0000454 0.0000847 -0.0034275; ..
+ -0.0014231 -0.0007932 0.0000454 0.0000428 0.0000659 -0.0019033; ..
+ -0.0025785 -0.0012911 0.0000847 0.0000659 0.0001176 -0.0038904; ..
+ 0.0968961 0.0410817 -0.0034275 -0.0019033 -0.0038904 0.1686615];
+
+[eigenv, rho] = spec(s11);
+if or(size(eigenv) <> [6 6]) then pause, end
+if or(size(rho) <> [6 6]) then pause, end \ No newline at end of file
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_8820.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_8820.dia.ref
new file mode 100755
index 000000000..7fbf43368
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_8820.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8820 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8820
+//
+// <-- Short Description -->
+// squeeze function may return hypermatrix when expected results must be a regular 2D array
+t = rand(2,3,4);
+s = squeeze(t(:,1,:));
+if type(s)<>1 then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_8820.tst b/modules/linear_algebra/tests/nonreg_tests/bug_8820.tst
new file mode 100755
index 000000000..7db455c57
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_8820.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8820 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8820
+//
+// <-- Short Description -->
+// squeeze function may return hypermatrix when expected results must be a regular 2D array
+t = rand(2,3,4);
+s = squeeze(t(:,1,:));
+if type(s)<>1 then pause,end
+
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_9196.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_9196.dia.ref
new file mode 100755
index 000000000..735a8de8e
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_9196.dia.ref
@@ -0,0 +1,86 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+// Copyright (C) 2013 - Michaël Baudin
+// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 9196 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9196
+//
+// <-- Short Description -->
+// The threshold level for conditioning in backslash is too small.
+// =============================================================================
+n=9;
+A = testmatrix("hilb",n);
+b=ones(n,1);
+xexpected=[7129/2520
+ 4861/2520
+ 42131/27720
+ 35201/27720
+ 395243/360360
+ 348911/360360
+ 62575/72072
+ 113567/144144
+ 1768477/2450448];
+x=A\b;
+assert_checkalmostequal(x, xexpected, [], 1e-6);
+Ac=complex(A,zeros(A));
+bc=complex(b,zeros(b));
+xc = Ac\bc;
+xcexpected=complex(xexpected,zeros(xexpected));
+assert_checkalmostequal(xc, xcexpected, [], 1e-5);
+b=(1:n)';
+xexpected=[9;
+ 17819/2520;
+ 82609/13860;
+ 47959/9240;
+ 415567/90090;
+ 299737/72072;
+ 45533/12012;
+ 71761/20592;
+ 988277/306306];
+x=A\b;
+assert_checkalmostequal(x, xexpected, [], 1e-5);
+Ac=complex(A,zeros(A));
+bc=complex(b,zeros(b));
+xc = Ac\bc;
+xcexpected=complex(xexpected,zeros(xexpected));
+assert_checkalmostequal(xc, xcexpected, [], 1e-5);
+b=[1;-1;1;-1;1;-1;1;-1;1];
+xexpected=[1879/2520;
+ 893/2520;
+ 6557/27720;
+ 4993/27720;
+ 52901/360360;
+ 44911/360360;
+ 39173/360360;
+ 69659/720720;
+ 1068047/12252240];
+x=A\b;
+assert_checkalmostequal(x, xexpected, [], 1e-7);
+Ac=complex(A,zeros(A));
+bc=complex(b,zeros(b));
+xc = Ac\bc;
+xcexpected=complex(xexpected,zeros(xexpected));
+assert_checkalmostequal(xc, xcexpected, [], 1e-6);
+n=9;
+A = testmatrix("hilb",n);
+b = ones(n,1);
+x = (b'/A')';
+xexpected=[
+2.82896825396825370e+000
+1.92896825396825400e+000
+1.51987734487734480e+000
+1.26987734487734480e+000
+1.09680042180042170e+000
+9.68228993228993360e-001
+8.68228993228993270e-001
+7.87871850371850480e-001
+7.21695379783615090e-001
+];
+assert_checkalmostequal(x, xexpected, [], 1e-6);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_9196.tst b/modules/linear_algebra/tests/nonreg_tests/bug_9196.tst
new file mode 100755
index 000000000..ec5021569
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_9196.tst
@@ -0,0 +1,94 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+// Copyright (C) 2013 - Michaël Baudin
+// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 9196 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9196
+//
+// <-- Short Description -->
+// The threshold level for conditioning in backslash is too small.
+// =============================================================================
+
+n=9;
+A = testmatrix("hilb",n);
+b=ones(n,1);
+xexpected=[7129/2520
+ 4861/2520
+ 42131/27720
+ 35201/27720
+ 395243/360360
+ 348911/360360
+ 62575/72072
+ 113567/144144
+ 1768477/2450448];
+x=A\b;
+assert_checkalmostequal(x, xexpected, [], 1e-6);
+
+
+Ac=complex(A,zeros(A));
+bc=complex(b,zeros(b));
+xc = Ac\bc;
+xcexpected=complex(xexpected,zeros(xexpected));
+assert_checkalmostequal(xc, xcexpected, [], 1e-5);
+
+b=(1:n)';
+xexpected=[9;
+ 17819/2520;
+ 82609/13860;
+ 47959/9240;
+ 415567/90090;
+ 299737/72072;
+ 45533/12012;
+ 71761/20592;
+ 988277/306306];
+x=A\b;
+assert_checkalmostequal(x, xexpected, [], 1e-5);
+Ac=complex(A,zeros(A));
+bc=complex(b,zeros(b));
+xc = Ac\bc;
+xcexpected=complex(xexpected,zeros(xexpected));
+assert_checkalmostequal(xc, xcexpected, [], 1e-5);
+
+b=[1;-1;1;-1;1;-1;1;-1;1];
+xexpected=[1879/2520;
+ 893/2520;
+ 6557/27720;
+ 4993/27720;
+ 52901/360360;
+ 44911/360360;
+ 39173/360360;
+ 69659/720720;
+ 1068047/12252240];
+x=A\b;
+assert_checkalmostequal(x, xexpected, [], 1e-7);
+Ac=complex(A,zeros(A));
+bc=complex(b,zeros(b));
+xc = Ac\bc;
+xcexpected=complex(xexpected,zeros(xexpected));
+assert_checkalmostequal(xc, xcexpected, [], 1e-6);
+
+n=9;
+A = testmatrix("hilb",n);
+b = ones(n,1);
+x = (b'/A')';
+xexpected=[
+2.82896825396825370e+000
+1.92896825396825400e+000
+1.51987734487734480e+000
+1.26987734487734480e+000
+1.09680042180042170e+000
+9.68228993228993360e-001
+8.68228993228993270e-001
+7.87871850371850480e-001
+7.21695379783615090e-001
+];
+assert_checkalmostequal(x, xexpected, [], 1e-6);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_9204.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_9204.dia.ref
new file mode 100755
index 000000000..e308dd4a6
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_9204.dia.ref
@@ -0,0 +1,20 @@
+// =============================================================================
+// 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 9204 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9204
+//
+// <-- Short Description -->
+// The Frobenius norm of a complex vector was numerically complex.
+x = [1 2 3 -4];
+x = x + %i * x;
+assert_checkalmostequal(norm(x, 'fro'), 7.7459667);
+x = [1 2;3 4];
+x = x + %i * x;
+assert_checkalmostequal(norm(x, 'fro'), 7.7459667);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_9204.tst b/modules/linear_algebra/tests/nonreg_tests/bug_9204.tst
new file mode 100755
index 000000000..674d3ecaa
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_9204.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// 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 9204 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9204
+//
+// <-- Short Description -->
+// The Frobenius norm of a complex vector was numerically complex.
+
+
+x = [1 2 3 -4];
+x = x + %i * x;
+assert_checkalmostequal(norm(x, 'fro'), 7.7459667);
+
+x = [1 2;3 4];
+x = x + %i * x;
+assert_checkalmostequal(norm(x, 'fro'), 7.7459667);
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_F.dia.ref b/modules/linear_algebra/tests/nonreg_tests/bug_F.dia.ref
new file mode 100755
index 000000000..e01e33a36
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_F.dia.ref
@@ -0,0 +1,5 @@
+// <-- Non-regression test for bug F -->
+//
+// <-- OLD BUG -->
+[q,r]=qr((1:3)');
+if (r(2)<>0) | (r(3)<>0) then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/nonreg_tests/bug_F.tst b/modules/linear_algebra/tests/nonreg_tests/bug_F.tst
new file mode 100755
index 000000000..b7ad0d3dc
--- /dev/null
+++ b/modules/linear_algebra/tests/nonreg_tests/bug_F.tst
@@ -0,0 +1,13 @@
+// =============================================================================
+// 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.
+// =============================================================================
+
+// <-- Non-regression test for bug F -->
+//
+// <-- OLD BUG -->
+
+[q,r]=qr((1:3)');
+if (r(2)<>0) | (r(3)<>0) then pause,end
diff --git a/modules/linear_algebra/tests/unit_tests/balanc.dia.ref b/modules/linear_algebra/tests/unit_tests/balanc.dia.ref
new file mode 100755
index 000000000..17a85780c
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/balanc.dia.ref
@@ -0,0 +1,72 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== balanc ==============================
+//==========================================================================
+function A=testmat3(a,n)
+//eigen values are given by a dilation of nth roots of 1
+A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+A(1,n)=1/a;
+endfunction
+A=[];[Ab,X]=balanc(A);
+if Ab<>[]|X<>[] then bugmes();quit;end
+// MATRIX
+//Small dimension
+//---------------
+warning('off')
+//Real Case
+A=testmat3(10000,5);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*X)>200*%eps then bugmes();quit;end
+
+//Complex Case
+A=testmat3(10000+0.01*%i,5);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*X)>200*%eps then bugmes();quit;end
+
+//LArge dimension
+A=testmat3(10000,30);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*X)>1000*%eps then bugmes();quit;end
+
+//Complex Case
+A=testmat3(10000+0.01*%i,30);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*X)>1000*%eps then bugmes();quit;end
+
+// PENCILS
+//Small dimension
+//---------------
+//Real Case
+A=testmat3(10000,5);B=testmat3(1000,5);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>200*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*Y)>200*%eps then bugmes();quit;end
+//complex case
+A=testmat3(10000+0.001*%i,5);B=testmat3(1000+100*%i,5);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>200*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*Y)>200*%eps then bugmes();quit;end
+//Large dimension
+//---------------
+//Real Case
+A=testmat3(10000,20);B=testmat3(1000,20);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>1000*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*Y)>1000*%eps then bugmes();quit;end
+//complex case
+A=testmat3(10000+0.001*%i,20);B=testmat3(1000+100*%i,20);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>1000*%eps then bugmes();quit;end
+if Err(Ab-inv(X)*A*Y)>1000*%eps then bugmes();quit;end
+warning('on')
diff --git a/modules/linear_algebra/tests/unit_tests/balanc.tst b/modules/linear_algebra/tests/unit_tests/balanc.tst
new file mode 100755
index 000000000..e49eab8b4
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/balanc.tst
@@ -0,0 +1,78 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+//==========================================================================
+//============================== balanc ==============================
+//==========================================================================
+function A=testmat3(a,n)
+//eigen values are given by a dilation of nth roots of 1
+A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+A(1,n)=1/a;
+endfunction
+A=[];[Ab,X]=balanc(A);
+if Ab<>[]|X<>[] then pause,end
+// MATRIX
+//Small dimension
+//---------------
+warning('off')
+//Real Case
+A=testmat3(10000,5);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then pause,end
+if Err(Ab-inv(X)*A*X)>200*%eps then pause,end
+
+//Complex Case
+A=testmat3(10000+0.01*%i,5);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then pause,end
+if Err(Ab-inv(X)*A*X)>200*%eps then pause,end
+
+//LArge dimension
+A=testmat3(10000,30);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then pause,end
+if Err(Ab-inv(X)*A*X)>1000*%eps then pause,end
+
+//Complex Case
+A=testmat3(10000+0.01*%i,30);
+[Ab,X]=balanc(A);
+if Err(diag(diag(X))-X)>200*%eps then pause,end
+if Err(Ab-inv(X)*A*X)>1000*%eps then pause,end
+
+// PENCILS
+//Small dimension
+//---------------
+//Real Case
+A=testmat3(10000,5);B=testmat3(1000,5);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>200*%eps then pause,end
+if Err(Ab-inv(X)*A*Y)>200*%eps then pause,end
+
+//complex case
+A=testmat3(10000+0.001*%i,5);B=testmat3(1000+100*%i,5);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>200*%eps then pause,end
+if Err(Ab-inv(X)*A*Y)>200*%eps then pause,end
+
+
+//Large dimension
+//---------------
+//Real Case
+A=testmat3(10000,20);B=testmat3(1000,20);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>1000*%eps then pause,end
+if Err(Ab-inv(X)*A*Y)>1000*%eps then pause,end
+
+//complex case
+A=testmat3(10000+0.001*%i,20);B=testmat3(1000+100*%i,20);
+[Ab,Bb,X,Y]=balanc(A,B);
+if Err(Bb-inv(X)*B*Y)>1000*%eps then pause,end
+if Err(Ab-inv(X)*A*Y)>1000*%eps then pause,end
+warning('on')
+
diff --git a/modules/linear_algebra/tests/unit_tests/bdiag.dia.ref b/modules/linear_algebra/tests/unit_tests/bdiag.dia.ref
new file mode 100755
index 000000000..6db5d7f8e
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/bdiag.dia.ref
@@ -0,0 +1,103 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== bdiag ==============================
+//==========================================================================
+assert_checkequal(bdiag([]),[]);
+[ab,x]=bdiag([]);
+assert_checkequal(ab,[]);
+assert_checkequal(x,[]);
+[ab,x,bs]=bdiag([]);
+assert_checkequal(ab,[]);
+assert_checkequal(x,[]);
+assert_checkequal(bs,[]);
+assert_checktrue(execstr('bdiag([1 2;3 4;5 6])','errcatch')<>0);
+//Small dimension
+//---------------
+//Real case
+e=1.d-1;
+A=[1 1 2 3 4 5
+ 0 1 6 7 8 9
+ 0 0 1 e 3 1
+ 0 0 -e 1 5 9
+ 0 0 0 0 2 e
+ 0 0 0 0 0 3];
+X1=[0.5,0.3,0,0.3,0.3,0.2;
+ 1,0.6,0.5,0.1,0.7,0.4;
+ 0.7,0.1,0.4,0.6,0.1,1;
+ 0,0.6,0.2,0.3,0.4,0.5;
+ 0.6,0.7,0.5,0.7,0.7,0.5;
+ 0.3,0.3,0.4,0.5,0.9,0.6];
+A=inv(X1)*A*X1;
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+[Ab2,X]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(inv(X)*A*X,Ab2,sqrt(%eps),0,"matrix");
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
+[Ab2,X,bs]=bdiag(A,1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(bs,size(A,1));
+//Complex case
+e=1.d-1;
+A=[1 1 2 3 4 5
+ 0 1 6 7 8 9
+ 0 0 1 e 3 1
+ 0 0 -e 1 5 9
+ 0 0 0 0 2 e
+ 0 0 0 0 0 3];
+X1=[0.5,0.3,0,0.3,0.3,0.2;
+ 1,0.6,0.5,0.1,0.7,0.4;
+ 0.7,0.1,0.4,0.6,0.1,1;
+ 0,0.6,0.2,0.3,0.4,0.5;
+ 0.6,0.7,0.5,0.7,0.7,0.5;
+ 0.3,0.3,0.4,0.5,0.9,0.6]+%i*eye(A);
+A=inv(X1)*A*X1;
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+[Ab2,X]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
+//Large dimension
+//---------------
+//Real case
+A=rand(25,25);
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+[Ab2,X]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(size(bs,2),1);
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
+//Complex case
+A=rand(25,25)+%i*rand(25,25);
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+[Ab2,X]=bdiag(A);
+assert_checkalmostequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(size(bs,2),1);
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
diff --git a/modules/linear_algebra/tests/unit_tests/bdiag.tst b/modules/linear_algebra/tests/unit_tests/bdiag.tst
new file mode 100755
index 000000000..efbef8289
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/bdiag.tst
@@ -0,0 +1,121 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+
+//==========================================================================
+//============================== bdiag ==============================
+//==========================================================================
+assert_checkequal(bdiag([]),[]);
+[ab,x]=bdiag([]);
+assert_checkequal(ab,[]);
+assert_checkequal(x,[]);
+
+
+[ab,x,bs]=bdiag([]);
+assert_checkequal(ab,[]);
+assert_checkequal(x,[]);
+assert_checkequal(bs,[]);
+
+assert_checktrue(execstr('bdiag([1 2;3 4;5 6])','errcatch')<>0);
+
+//Small dimension
+//---------------
+//Real case
+e=1.d-1;
+A=[1 1 2 3 4 5
+ 0 1 6 7 8 9
+ 0 0 1 e 3 1
+ 0 0 -e 1 5 9
+ 0 0 0 0 2 e
+ 0 0 0 0 0 3];
+X1=[0.5,0.3,0,0.3,0.3,0.2;
+ 1,0.6,0.5,0.1,0.7,0.4;
+ 0.7,0.1,0.4,0.6,0.1,1;
+ 0,0.6,0.2,0.3,0.4,0.5;
+ 0.6,0.7,0.5,0.7,0.7,0.5;
+ 0.3,0.3,0.4,0.5,0.9,0.6];
+A=inv(X1)*A*X1;
+
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+
+[Ab2,X]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(inv(X)*A*X,Ab2,sqrt(%eps),0,"matrix");
+
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
+
+[Ab2,X,bs]=bdiag(A,1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(bs,size(A,1));
+
+
+//Complex case
+e=1.d-1;
+A=[1 1 2 3 4 5
+ 0 1 6 7 8 9
+ 0 0 1 e 3 1
+ 0 0 -e 1 5 9
+ 0 0 0 0 2 e
+ 0 0 0 0 0 3];
+X1=[0.5,0.3,0,0.3,0.3,0.2;
+ 1,0.6,0.5,0.1,0.7,0.4;
+ 0.7,0.1,0.4,0.6,0.1,1;
+ 0,0.6,0.2,0.3,0.4,0.5;
+ 0.6,0.7,0.5,0.7,0.7,0.5;
+ 0.3,0.3,0.4,0.5,0.9,0.6]+%i*eye(A);
+A=inv(X1)*A*X1;
+
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+[Ab2,X]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
+//Large dimension
+//---------------
+//Real case
+A=rand(25,25);
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+[Ab2,X]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(size(bs,2),1);
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
+
+//Complex case
+A=rand(25,25)+%i*rand(25,25);
+Ab1=bdiag(A);
+assert_checkequal(triu(Ab1,-1),Ab1);
+[Ab2,X]=bdiag(A);
+assert_checkalmostequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+
+[Ab2,X,bs]=bdiag(A);
+assert_checkequal(Ab2,Ab1);
+assert_checkalmostequal(Ab2,inv(X)*A*X,sqrt(%eps),0,"matrix");
+assert_checkequal(size(bs,2),1);
+assert_checkequal(sum(bs),size(A,1));
+assert_checktrue(and(bs>0));
+
diff --git a/modules/linear_algebra/tests/unit_tests/chol.dia.ref b/modules/linear_algebra/tests/unit_tests/chol.dia.ref
new file mode 100755
index 000000000..b86cf8397
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/chol.dia.ref
@@ -0,0 +1,37 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== chol ==============================
+//==========================================================================
+//Empty matrix
+if chol([])<>[] then bugmes();quit;end
+if execstr('chol([1 2;3 4])','errcatch')==0 then bugmes();quit;end
+if execstr('chol([1 2;3 4]+%i)','errcatch')==0 then bugmes();quit;end
+//Small dimension
+//REAL
+A=rand(5,5);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>200*%eps then bugmes();quit;end
+if Err(U'*U-A)>200*%eps then bugmes();quit;end
+//Complex
+A=rand(5,5)+%i*rand(5,5);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>200*%eps then bugmes();quit;end
+if Err(U'*U-A)>200*%eps then bugmes();quit;end
+//Large dimension
+//REAL
+A=rand(50,50);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>10*%eps then bugmes();quit;end
+if Err(U'*U-A)>1000*%eps then bugmes();quit;end
+//Complex
+A=rand(5,5)+%i*rand(5,5);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>10*%eps then bugmes();quit;end
+if Err(U'*U-A)>1000*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/chol.tst b/modules/linear_algebra/tests/unit_tests/chol.tst
new file mode 100755
index 000000000..2c18be4bf
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/chol.tst
@@ -0,0 +1,45 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+//==========================================================================
+//============================== chol ==============================
+//==========================================================================
+
+//Empty matrix
+if chol([])<>[] then pause,end
+
+if execstr('chol([1 2;3 4])','errcatch')==0 then pause,end
+if execstr('chol([1 2;3 4]+%i)','errcatch')==0 then pause,end
+
+//Small dimension
+//REAL
+A=rand(5,5);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>200*%eps then pause,end
+if Err(U'*U-A)>200*%eps then pause,end
+
+//Complex
+A=rand(5,5)+%i*rand(5,5);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>200*%eps then pause,end
+if Err(U'*U-A)>200*%eps then pause,end
+
+//Large dimension
+//REAL
+A=rand(50,50);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>10*%eps then pause,end
+if Err(U'*U-A)>1000*%eps then pause,end
+
+//Complex
+A=rand(5,5)+%i*rand(5,5);A=A*A';
+U=chol(A);
+if Err(triu(U)-U)>10*%eps then pause,end
+if Err(U'*U-A)>1000*%eps then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/companion.dia.ref b/modules/linear_algebra/tests/unit_tests/companion.dia.ref
new file mode 100755
index 000000000..3f57ad5d3
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/companion.dia.ref
@@ -0,0 +1,55 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// companion.tst --
+// Test "companion" for real and complex polynomials
+// with linear, quadratic and cubic polynomials.
+//
+// Linear real polynomial
+p=1+2*%s;
+computed=companion(p);
+expected=[-1/2];
+if abs(expected-computed)>%eps then bugmes();quit;end
+// Quadratic real polynomial
+p=1+2*%s+3*%s^2;
+computed=companion(p);
+expected=[-2/3 , -1/3;1 , 0];
+if abs(expected-computed)>%eps then bugmes();quit;end
+// Cubic real polynomial
+p=1+2*%s+3*%s^2+4*%s^3;
+computed=companion(p);
+expected=[-3/4 , -2/4 , -1/4; 1 , 0 , 0 ; 0 , 1, 0];
+if abs(expected-computed)>%eps then bugmes();quit;end
+// Linear complex polynomial
+p=1+%i+2*%s;
+computed=companion(p);
+expected=[-(1+%i)/2];
+if abs(expected-computed)>%eps then bugmes();quit;end
+// Quadratic complex polynomial
+p=1+%i+2*%s+3*%s^2;
+computed=companion(p);
+expected=[-2/3 , -(1+%i)/3;1 , 0];
+if abs(expected-computed)>%eps then bugmes();quit;end
+// Cubic complex polynomial
+p=1+%i+2*%s+3*%s^2+4*%s^3;
+computed=companion(p);
+expected=[-3/4 , -2/4 , -(1+%i)/4; 1 , 0 , 0 ; 0 , 1, 0];
+if abs(expected-computed)>%eps then bugmes();quit;end
+// Vector of linear polynomials
+p1=1+2*%s;
+p2=1+%i+2*%s;
+vector = [p1 p2];
+computed=companion(vector);
+expected=[-1/2 0;0 -(1+%i)/2];
+if abs(expected-computed)>%eps then bugmes();quit;end
+// Vector of quadratic/cubic real/complex polynomials
+p1=1+2*%s+3*%s^2;
+p2=1+%i+2*%s+3*%s^2+4*%s^3;
+vector = [p1 p2];
+computed=companion(vector);
+expected=[-2/3 -1/3 0 0 0;1 0 0 0 0; 0 0 -3/4 -2/4 -(1+%i)/4;0 0 1 0 0;0 0 0 1 0];
+if abs(expected-computed)>%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/companion.tst b/modules/linear_algebra/tests/unit_tests/companion.tst
new file mode 100755
index 000000000..68d58cc4b
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/companion.tst
@@ -0,0 +1,57 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// companion.tst --
+// Test "companion" for real and complex polynomials
+// with linear, quadratic and cubic polynomials.
+//
+
+// Linear real polynomial
+p=1+2*%s;
+computed=companion(p);
+expected=[-1/2];
+if abs(expected-computed)>%eps then pause,end
+// Quadratic real polynomial
+p=1+2*%s+3*%s^2;
+computed=companion(p);
+expected=[-2/3 , -1/3;1 , 0];
+if abs(expected-computed)>%eps then pause,end
+// Cubic real polynomial
+p=1+2*%s+3*%s^2+4*%s^3;
+computed=companion(p);
+expected=[-3/4 , -2/4 , -1/4; 1 , 0 , 0 ; 0 , 1, 0];
+if abs(expected-computed)>%eps then pause,end
+// Linear complex polynomial
+p=1+%i+2*%s;
+computed=companion(p);
+expected=[-(1+%i)/2];
+if abs(expected-computed)>%eps then pause,end
+// Quadratic complex polynomial
+p=1+%i+2*%s+3*%s^2;
+computed=companion(p);
+expected=[-2/3 , -(1+%i)/3;1 , 0];
+if abs(expected-computed)>%eps then pause,end
+// Cubic complex polynomial
+p=1+%i+2*%s+3*%s^2+4*%s^3;
+computed=companion(p);
+expected=[-3/4 , -2/4 , -(1+%i)/4; 1 , 0 , 0 ; 0 , 1, 0];
+if abs(expected-computed)>%eps then pause,end
+// Vector of linear polynomials
+p1=1+2*%s;
+p2=1+%i+2*%s;
+vector = [p1 p2];
+computed=companion(vector);
+expected=[-1/2 0;0 -(1+%i)/2];
+if abs(expected-computed)>%eps then pause,end
+// Vector of quadratic/cubic real/complex polynomials
+p1=1+2*%s+3*%s^2;
+p2=1+%i+2*%s+3*%s^2+4*%s^3;
+vector = [p1 p2];
+computed=companion(vector);
+expected=[-2/3 -1/3 0 0 0;1 0 0 0 0; 0 0 -3/4 -2/4 -(1+%i)/4;0 0 1 0 0;0 0 0 1 0];
+if abs(expected-computed)>%eps then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/cond.dia.ref b/modules/linear_algebra/tests/unit_tests/cond.dia.ref
new file mode 100755
index 000000000..81794adee
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/cond.dia.ref
@@ -0,0 +1,61 @@
+// =============================================================================
+// 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 cond function
+// =============================================================================
+// Interface
+// ===========
+assert_checkfalse(execstr("cond()", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "cond", 1, 2);
+assert_checkerror("cond()", refMsg);
+assert_checkfalse(execstr("cond(1,2,3)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "cond", 1, 2);
+assert_checkerror("cond(1,2,3)", refMsg);
+assert_checkfalse(execstr("cond(%nan)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: must not contain %s or %s.\n"), "cond", 1, "%nan", "%inf");
+assert_checkerror("cond(%nan)", refMsg);
+assert_checkfalse(execstr("cond(%inf)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: must not contain %s or %s.\n"), "cond", 1, "%nan", "%inf");
+assert_checkerror("cond(%inf)", refMsg);
+assert_checkfalse(execstr("cond(%f)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(%f)", refMsg);
+assert_checkfalse(execstr("cond(""ah"")", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(""ah"")", refMsg);
+assert_checkfalse(execstr("cond(""ah"")", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(""ah"")", refMsg);
+assert_checkfalse(execstr("cond(""ah"", 1)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A square matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(""ah"", 1)", refMsg);
+assert_checkfalse(execstr("cond(1, %f)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A scalar or a string expected.\n"),"cond", 2);
+assert_checkerror("cond(1, %f)", refMsg);
+assert_checkfalse(execstr("cond(1, 3)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: must be %d, %d, %s, ''%s'' or ''%s''.\n"), "cond", 2, 1, 2, "%inf", "inf", "fro");
+assert_checkerror("cond(1, 3)", refMsg);
+assert_checkfalse(execstr("cond([8 5 2;4 5 6], 1)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A square matrix expected.\n"),"cond", 1);
+assert_checkerror("cond([8 5 2;4 5 6], 1)", refMsg);
+// cond(A)
+A = [8 5 2;4 5 6];
+assert_checkalmostequal(cond(A), 3.1529469);
+A = A * %i;
+assert_checkalmostequal(cond(A), 3.1529469);
+A = [9 0 3;2 5 0;7 4 1];
+assert_checkalmostequal(cond(A), 23.411565);
+assert_checkalmostequal(cond(A,1), 33);
+assert_checkalmostequal(cond(A, %inf), 36);
+assert_checkalmostequal(cond(A, 'inf'), 36);
+assert_checkalmostequal(cond(A, 'fro'), 25.702776, 1e-7);
+A = A * %i;
+assert_checkalmostequal(cond(A), 23.411565);
+assert_checkalmostequal(cond(A,1), 33);
+assert_checkalmostequal(cond(A, %inf), 36);
+assert_checkalmostequal(cond(A, 'inf'), 36);
+assert_checkalmostequal(cond(A, 'fro'), 25.702776, 1e-7);
diff --git a/modules/linear_algebra/tests/unit_tests/cond.tst b/modules/linear_algebra/tests/unit_tests/cond.tst
new file mode 100755
index 000000000..f87fc8247
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/cond.tst
@@ -0,0 +1,87 @@
+// =============================================================================
+// 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 cond function
+// =============================================================================
+
+// Interface
+// ===========
+
+assert_checkfalse(execstr("cond()", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "cond", 1, 2);
+assert_checkerror("cond()", refMsg);
+
+assert_checkfalse(execstr("cond(1,2,3)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "cond", 1, 2);
+assert_checkerror("cond(1,2,3)", refMsg);
+
+assert_checkfalse(execstr("cond(%nan)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: must not contain %s or %s.\n"), "cond", 1, "%nan", "%inf");
+assert_checkerror("cond(%nan)", refMsg);
+
+assert_checkfalse(execstr("cond(%inf)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: must not contain %s or %s.\n"), "cond", 1, "%nan", "%inf");
+assert_checkerror("cond(%inf)", refMsg);
+
+assert_checkfalse(execstr("cond(%f)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(%f)", refMsg);
+
+assert_checkfalse(execstr("cond(""ah"")", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(""ah"")", refMsg);
+
+assert_checkfalse(execstr("cond(""ah"")", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(""ah"")", refMsg);
+
+assert_checkfalse(execstr("cond(""ah"", 1)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A square matrix expected.\n"), "cond", 1);
+assert_checkerror("cond(""ah"", 1)", refMsg);
+
+assert_checkfalse(execstr("cond(1, %f)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A scalar or a string expected.\n"),"cond", 2);
+assert_checkerror("cond(1, %f)", refMsg);
+
+assert_checkfalse(execstr("cond(1, 3)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: must be %d, %d, %s, ''%s'' or ''%s''.\n"), "cond", 2, 1, 2, "%inf", "inf", "fro");
+assert_checkerror("cond(1, 3)", refMsg);
+
+assert_checkfalse(execstr("cond([8 5 2;4 5 6], 1)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A square matrix expected.\n"),"cond", 1);
+assert_checkerror("cond([8 5 2;4 5 6], 1)", refMsg);
+
+// cond(A)
+A = [8 5 2;4 5 6];
+assert_checkalmostequal(cond(A), 3.1529469);
+
+A = A * %i;
+assert_checkalmostequal(cond(A), 3.1529469);
+
+A = [9 0 3;2 5 0;7 4 1];
+assert_checkalmostequal(cond(A), 23.411565);
+
+assert_checkalmostequal(cond(A,1), 33);
+
+assert_checkalmostequal(cond(A, %inf), 36);
+
+assert_checkalmostequal(cond(A, 'inf'), 36);
+
+assert_checkalmostequal(cond(A, 'fro'), 25.702776, 1e-7);
+
+A = A * %i;
+assert_checkalmostequal(cond(A), 23.411565);
+
+assert_checkalmostequal(cond(A,1), 33);
+
+assert_checkalmostequal(cond(A, %inf), 36);
+
+assert_checkalmostequal(cond(A, 'inf'), 36);
+
+assert_checkalmostequal(cond(A, 'fro'), 25.702776, 1e-7);
diff --git a/modules/linear_algebra/tests/unit_tests/det.dia.ref b/modules/linear_algebra/tests/unit_tests/det.dia.ref
new file mode 100755
index 000000000..3a218b75b
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/det.dia.ref
@@ -0,0 +1,122 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//==========================================================================
+//============================== det ==============================
+//==========================================================================
+//Small dimension
+//Real
+A=[1 1; 1 2];
+assert_checkalmostequal(det(A), 1);
+[e,m]=det(A);
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(m, 1);
+//Complex
+A=A+%i;
+assert_checkalmostequal(real(det(A)), 1);
+assert_checkalmostequal(imag(det(A)), 1);
+[e,m]=det(A);
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(real(m), 1);
+assert_checkalmostequal(imag(m), 1);
+//Sparse
+A=[1 1; 1 2];
+A=sparse(A);
+assert_checkalmostequal(det(A), 1);
+[e,m]=det(A)
+ m =
+
+ 1.
+ e =
+
+ 0.
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(m, 1);
+//Polynomials
+A=[1+%s 1; 1 2+%s];
+assert_checkequal(det(A), 1+3*%s+%s*%s);
+//Rationals
+A=[1+%s 1/%s; 1 2+%s];
+assert_checkequal(numer(det(A)), -1+2*%s+3*%s^2+%s^3);
+assert_checkequal(denom(det(A)), %s);
+//Sparse complex
+A=[1 1; 1 2];
+A=A+%i;
+A=sparse(A);
+assert_checkalmostequal(real(det(A)), 1);
+assert_checkalmostequal(imag(det(A)), 1);
+[e,m]=det(A);
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(real(m), 1);
+assert_checkalmostequal(imag(m), 1);
+//Large dimension
+//Real
+v=rand(1,21);
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1D-7);
+//Complex
+v=(v+rand(v)*%i)/2;
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1D-7);
+//Sparse
+v=rand(1,21);
+v=sparse(v);
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1d-7);
+//Polynomials
+v=rand(1,21)
+ v =
+
+
+ column 1 to 5
+
+ 0.5866105 0.0477090 0.9416931 0.9613204 0.5583350
+
+ column 6 to 10
+
+ 0.5700629 0.3169258 0.9932628 0.8074780 0.8554797
+
+ column 11 to 15
+
+ 0.5031461 0.0963323 0.7058098 0.8630577 0.0076185
+
+ column 16 to 20
+
+ 0.8048951 0.5963762 0.1176836 0.8010095 0.5132340
+
+ column 21
+
+ 0.201091
+v=v+%s;
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(coeff(det(A)-prod(v))) < 1D-7);
+//Rationals
+v=rand(1,21);
+v=v/%s;
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(coeff(numer(det(A))-numer(prod(v)))) < 1D-7);
+//Sparse complex
+v=rand(1,21);
+v=(v+rand(v)*%i)/2;
+v=sparse(v);
+A=rand(21,21);
+A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+A=sparse(A);
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1d-7);
+//Error messages
+A=[1 1; 1 2];
+errmsg1 = msprintf(_("Wrong type for first argument: Square matrix expected.\n"));
+assert_checkerror("det([1,2;3,4;5,6])", errmsg1, 20);
+errmsg2 = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "det", 1);
+assert_checkerror("det(A,1)", errmsg2, 77);
diff --git a/modules/linear_algebra/tests/unit_tests/det.tst b/modules/linear_algebra/tests/unit_tests/det.tst
new file mode 100755
index 000000000..4b0240755
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/det.tst
@@ -0,0 +1,98 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//==========================================================================
+//============================== det ==============================
+//==========================================================================
+
+//Small dimension
+//Real
+A=[1 1; 1 2];
+assert_checkalmostequal(det(A), 1);
+[e,m]=det(A);
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(m, 1);
+//Complex
+A=A+%i;
+assert_checkalmostequal(real(det(A)), 1);
+assert_checkalmostequal(imag(det(A)), 1);
+[e,m]=det(A);
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(real(m), 1);
+assert_checkalmostequal(imag(m), 1);
+//Sparse
+A=[1 1; 1 2];
+A=sparse(A);
+assert_checkalmostequal(det(A), 1);
+[e,m]=det(A)
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(m, 1);
+//Polynomials
+A=[1+%s 1; 1 2+%s];
+assert_checkequal(det(A), 1+3*%s+%s*%s);
+//Rationals
+A=[1+%s 1/%s; 1 2+%s];
+assert_checkequal(numer(det(A)), -1+2*%s+3*%s^2+%s^3);
+assert_checkequal(denom(det(A)), %s);
+//Sparse complex
+A=[1 1; 1 2];
+A=A+%i;
+A=sparse(A);
+assert_checkalmostequal(real(det(A)), 1);
+assert_checkalmostequal(imag(det(A)), 1);
+[e,m]=det(A);
+assert_checkalmostequal(e, 0);
+assert_checkalmostequal(real(m), 1);
+assert_checkalmostequal(imag(m), 1);
+
+//Large dimension
+//Real
+v=rand(1,21);
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1D-7);
+//Complex
+v=(v+rand(v)*%i)/2;
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1D-7);
+//Sparse
+v=rand(1,21);
+v=sparse(v);
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1d-7);
+//Polynomials
+v=rand(1,21)
+v=v+%s;
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(coeff(det(A)-prod(v))) < 1D-7);
+//Rationals
+v=rand(1,21);
+v=v/%s;
+A=rand(21,21); A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+assert_checktrue(abs(coeff(numer(det(A))-numer(prod(v)))) < 1D-7);
+//Sparse complex
+v=rand(1,21);
+v=(v+rand(v)*%i)/2;
+v=sparse(v);
+A=rand(21,21);
+A=(triu(A,1)+diag(v))*(tril(A,-1)+diag(ones(1,21)));
+A=sparse(A);
+assert_checktrue(abs(det(A) - prod(v)) < 1D-7);
+[e,m]=det(A);
+assert_checktrue(abs(m*(10^e) - prod(v)) < 1d-7);
+
+//Error messages
+A=[1 1; 1 2];
+errmsg1 = msprintf(_("Wrong type for first argument: Square matrix expected.\n"));
+assert_checkerror("det([1,2;3,4;5,6])", errmsg1, 20);
+errmsg2 = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "det", 1);
+assert_checkerror("det(A,1)", errmsg2, 77);
diff --git a/modules/linear_algebra/tests/unit_tests/gspec.dia.ref b/modules/linear_algebra/tests/unit_tests/gspec.dia.ref
new file mode 100755
index 000000000..c78066eb1
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/gspec.dia.ref
@@ -0,0 +1,122 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+rand('normal')
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+//
+// gc_spec.tst --
+// Test spec with 2 RHS (i.e. generalized eigenvalues)
+// and one or several LHS.
+//
+//Empty matrix
+// 1 LHS
+S=spec([],[]);
+if S<>[] then bugmes();quit;end
+// 2 LHS
+[al,be]=spec([],[]);
+if al<>[]|be<>[] then bugmes();quit;end
+// 3 LHS
+[al,be,R]=spec([],[]);
+if al<>[]|be<>[]|R<>[] then bugmes();quit;end
+// 4 LHS
+[al,be,L,R]=spec([],[]);
+if al<>[]|be<>[]|L<>[]|R<>[] then bugmes();quit;end
+//Matrix with Inf or Nan (test de la detection d'erreur
+// 1 A Real, B, Real
+if execstr('spec([%inf 1;2 3],[%inf 1;2 3])','errcatch')==0 then bugmes();quit;end
+if execstr('spec([%inf 1;2 3],[1 2;3 4])','errcatch')==0 then bugmes();quit;end
+if execstr('spec([1 2;3 4],[1 %nan;2 3])','errcatch')==0 then bugmes();quit;end
+// 2 A Complex, B Complex
+if execstr('spec([%inf %i;2 3],[%inf %i;2 3])','errcatch')==0 then bugmes();quit;end
+// 3 A Real, B Complex
+if execstr('spec([%inf 1;2 3],[%inf %i;2 3])','errcatch')==0 then bugmes();quit;end
+// 4 A Complex, B Real
+if execstr('spec([%inf %i;2 3],[%inf 1;2 3])','errcatch')==0 then bugmes();quit;end
+errorlevel = 1000*%eps;
+//Small dimension
+//---------------
+//Real Case
+A=testmat1(3,5);
+E=testmat1(-2,5);
+// 1 LHS
+S=spec(A,E);
+// 2 LHS
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+// 3 LHS
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+// 4 LHS
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then bugmes();quit;end
+// Complex Case : A complex, E complex
+A=testmat1(3-%i,5);
+E=testmat1(-2+0.1*%i,5);
+// 1 LHS
+S=spec(A,E);
+// 2 LHS
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+// 3 LHS
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+// 4 LHS
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then bugmes();quit;end
+// Mixed case : A real, E complex
+A = eye(3,3);
+E = eye(3,3) * %i;
+[Sa,Se,R]=spec(A,E);
+S=Sa./Se;
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+// Mixed case : A complex, E real
+A = eye(3,3) * %i;
+E = eye(3,3);
+[Sa,Se,R]=spec(A,E);
+S=Sa./Se;
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+//Large dimension
+//---------------
+//Real Case
+A=testmat1(3,30);
+E=testmat1(-2,30);
+S=spec(A,E);
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then bugmes();quit;end
+//Complex Case
+A=testmat1(3-%i,30);
+E=testmat1(-2+0.1*%i,30);
+S=spec(A,E);
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>20*%eps then bugmes();quit;end
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>20*%eps then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>20*%eps then bugmes();quit;end
+if Err(A*R-E*R*diag(S))>errorlevel then bugmes();quit;end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/gspec.tst b/modules/linear_algebra/tests/unit_tests/gspec.tst
new file mode 100755
index 000000000..f7b5ca616
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/gspec.tst
@@ -0,0 +1,139 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+rand('normal')
+
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+
+
+//
+// gc_spec.tst --
+// Test spec with 2 RHS (i.e. generalized eigenvalues)
+// and one or several LHS.
+//
+
+//Empty matrix
+// 1 LHS
+S=spec([],[]);
+if S<>[] then pause,end
+// 2 LHS
+[al,be]=spec([],[]);
+if al<>[]|be<>[] then pause,end
+// 3 LHS
+[al,be,R]=spec([],[]);
+if al<>[]|be<>[]|R<>[] then pause,end
+// 4 LHS
+[al,be,L,R]=spec([],[]);
+if al<>[]|be<>[]|L<>[]|R<>[] then pause,end
+
+
+//Matrix with Inf or Nan (test de la detection d'erreur
+
+// 1 A Real, B, Real
+if execstr('spec([%inf 1;2 3],[%inf 1;2 3])','errcatch')==0 then pause,end
+if execstr('spec([%inf 1;2 3],[1 2;3 4])','errcatch')==0 then pause,end
+if execstr('spec([1 2;3 4],[1 %nan;2 3])','errcatch')==0 then pause,end
+// 2 A Complex, B Complex
+if execstr('spec([%inf %i;2 3],[%inf %i;2 3])','errcatch')==0 then pause,end
+// 3 A Real, B Complex
+if execstr('spec([%inf 1;2 3],[%inf %i;2 3])','errcatch')==0 then pause,end
+// 4 A Complex, B Real
+if execstr('spec([%inf %i;2 3],[%inf 1;2 3])','errcatch')==0 then pause,end
+
+errorlevel = 1000*%eps;
+
+//Small dimension
+//---------------
+//Real Case
+A=testmat1(3,5);
+E=testmat1(-2,5);
+// 1 LHS
+S=spec(A,E);
+// 2 LHS
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+// 3 LHS
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+// 4 LHS
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then pause,end
+
+// Complex Case : A complex, E complex
+A=testmat1(3-%i,5);
+E=testmat1(-2+0.1*%i,5);
+// 1 LHS
+S=spec(A,E);
+// 2 LHS
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+// 3 LHS
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+// 4 LHS
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then pause,end
+
+// Mixed case : A real, E complex
+A = eye(3,3);
+E = eye(3,3) * %i;
+[Sa,Se,R]=spec(A,E);
+S=Sa./Se;
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+
+// Mixed case : A complex, E real
+A = eye(3,3) * %i;
+E = eye(3,3);
+[Sa,Se,R]=spec(A,E);
+S=Sa./Se;
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+
+//Large dimension
+//---------------
+
+//Real Case
+A=testmat1(3,30);
+E=testmat1(-2,30);
+S=spec(A,E);
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>errorlevel then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then pause,end
+
+//Complex Case
+
+A=testmat1(3-%i,30);
+E=testmat1(-2+0.1*%i,30);
+S=spec(A,E);
+[Sa,Se]=spec(A,E);
+if Err(S-Sa./Se)>20*%eps then pause,end
+[Sa,Se,R]=spec(A,E);
+if Err(S-Sa./Se)>20*%eps then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+[Sa,Se,L,R]=spec(A,E);
+if Err(S-Sa./Se)>20*%eps then pause,end
+if Err(A*R-E*R*diag(S))>errorlevel then pause,end
+if Err(L'*A-diag(S)*L'*E)>errorlevel then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/hess.dia.ref b/modules/linear_algebra/tests/unit_tests/hess.dia.ref
new file mode 100755
index 000000000..ceff6d278
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/hess.dia.ref
@@ -0,0 +1,48 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== hess ==============================
+//==========================================================================
+//Empty matrix
+if hess([])<>[] then bugmes();quit;end
+[U,H]=hess([]);
+if U<>[]|H<>[] then bugmes();quit;end
+if execstr('hess(rand(2,5))','errcatch')==0 then bugmes();quit;end
+if execstr('[U,H]=hess(rand(2,5))','errcatch')==0 then bugmes();quit;end
+if execstr('hess(rand(2,5)+%i)','errcatch')==0 then bugmes();quit;end
+if execstr('[U,H]=hess(rand(2,5)+%i)','errcatch')==0 then bugmes();quit;end
+//Small dimension
+//Real case
+A=rand(5,5);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>200*%eps then bugmes();quit;end
+if Err(U'*U-eye()) >200*%eps then bugmes();quit;end
+if Err(U'*A*U-H1) >200*%eps then bugmes();quit;end
+//complex case
+A=rand(5,5)+%i*rand(5,5);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>200*%eps then bugmes();quit;end
+if Err(U'*U-eye()) >200*%eps then bugmes();quit;end
+if Err(U'*A*U-H1) >200*%eps then bugmes();quit;end
+//Large dimension
+A=rand(20,20);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>200*%eps then bugmes();quit;end
+if Err(U'*U-eye()) >1000*%eps then bugmes();quit;end
+if Err(U'*A*U-H1) >1000*%eps then bugmes();quit;end
+//complex case
+A=rand(20,20)+%i*rand(20,20);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>1000*%eps then bugmes();quit;end
+if Err(U'*U-eye()) >1000*%eps then bugmes();quit;end
+if Err(U'*A*U-H1) >1000*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/hess.tst b/modules/linear_algebra/tests/unit_tests/hess.tst
new file mode 100755
index 000000000..8fce2bc5d
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/hess.tst
@@ -0,0 +1,53 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+//==========================================================================
+//============================== hess ==============================
+//==========================================================================
+
+//Empty matrix
+if hess([])<>[] then pause,end
+[U,H]=hess([]);
+if U<>[]|H<>[] then pause,end
+
+if execstr('hess(rand(2,5))','errcatch')==0 then pause,end
+if execstr('[U,H]=hess(rand(2,5))','errcatch')==0 then pause,end
+if execstr('hess(rand(2,5)+%i)','errcatch')==0 then pause,end
+if execstr('[U,H]=hess(rand(2,5)+%i)','errcatch')==0 then pause,end
+
+//Small dimension
+//Real case
+A=rand(5,5);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>200*%eps then pause,end
+if Err(U'*U-eye()) >200*%eps then pause,end
+if Err(U'*A*U-H1) >200*%eps then pause,end
+//complex case
+A=rand(5,5)+%i*rand(5,5);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>200*%eps then pause,end
+if Err(U'*U-eye()) >200*%eps then pause,end
+if Err(U'*A*U-H1) >200*%eps then pause,end
+//Large dimension
+A=rand(20,20);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>200*%eps then pause,end
+if Err(U'*U-eye()) >1000*%eps then pause,end
+if Err(U'*A*U-H1) >1000*%eps then pause,end
+//complex case
+A=rand(20,20)+%i*rand(20,20);
+H=hess(A);
+[U,H1]=hess(A);
+if Err(H-H1)>1000*%eps then pause,end
+if Err(U'*U-eye()) >1000*%eps then pause,end
+if Err(U'*A*U-H1) >1000*%eps then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/inv.dia.ref b/modules/linear_algebra/tests/unit_tests/inv.dia.ref
new file mode 100755
index 000000000..aaad5e325
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/inv.dia.ref
@@ -0,0 +1,56 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+//==========================================================================
+//============================== inv ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+if inv(A)<>[] then bugmes();quit;end
+//Singular matrix
+if execstr('inv([0 0;2 3])','errcatch')==0 then bugmes();quit;end
+if execstr('inv([0 0;%i 3])','errcatch')==0 then bugmes();quit;end
+//Rectangular matrix
+if execstr('inv(rand(2,3))','errcatch')==0 then bugmes();quit;end
+if execstr('inv(rand(2,3)+%i*eye())','errcatch')==0 then bugmes();quit;end
+//Small dimension
+//---------------
+//Unsymetric
+A=testmat1(3,5);Ac=testmat1(3+%i,5);
+//Real Case
+if Err(A*inv(A)-eye(A)) >200*%eps then bugmes();quit;end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >200*%eps then bugmes();quit;end
+//Symetric
+A=A*A';Ac=Ac*Ac';
+//Real Case
+if Err(A*inv(A)-eye(A)) >1000*%eps then bugmes();quit;end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >1000*%eps then bugmes();quit;end
+//Large dimension
+//---------------
+//Unsymetric
+A=testmat1(3,50);Ac=testmat1(3+%i,50);
+//Real Case
+if Err(A*inv(A)-eye(A)) >1000*%eps then bugmes();quit;end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >2000*%eps then bugmes();quit;end
+//Symetric
+A=A*A';Ac=Ac*Ac';
+//Real Case
+if Err(A*inv(A)-eye(A)) >1.d-10 then bugmes();quit;end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >4.d-10 then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/inv.tst b/modules/linear_algebra/tests/unit_tests/inv.tst
new file mode 100755
index 000000000..df88e0fdf
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/inv.tst
@@ -0,0 +1,56 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+//==========================================================================
+//============================== inv ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+if inv(A)<>[] then pause,end
+//Singular matrix
+if execstr('inv([0 0;2 3])','errcatch')==0 then pause,end
+if execstr('inv([0 0;%i 3])','errcatch')==0 then pause,end
+//Rectangular matrix
+if execstr('inv(rand(2,3))','errcatch')==0 then pause,end
+if execstr('inv(rand(2,3)+%i*eye())','errcatch')==0 then pause,end
+//Small dimension
+//---------------
+//Unsymetric
+A=testmat1(3,5);Ac=testmat1(3+%i,5);
+//Real Case
+if Err(A*inv(A)-eye(A)) >200*%eps then pause,end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >200*%eps then pause,end
+//Symetric
+A=A*A';Ac=Ac*Ac';
+//Real Case
+if Err(A*inv(A)-eye(A)) >1000*%eps then pause,end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >1000*%eps then pause,end
+//Large dimension
+//---------------
+//Unsymetric
+A=testmat1(3,50);Ac=testmat1(3+%i,50);
+//Real Case
+if Err(A*inv(A)-eye(A)) >1000*%eps then pause,end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >2000*%eps then pause,end
+//Symetric
+A=A*A';Ac=Ac*Ac';
+//Real Case
+if Err(A*inv(A)-eye(A)) >1.d-10 then pause,end
+//Complex Case
+if Err(Ac*inv(Ac)-eye(A)) >4.d-10 then pause,end
diff --git a/modules/linear_algebra/tests/unit_tests/leftmatrixdiv.dia.ref b/modules/linear_algebra/tests/unit_tests/leftmatrixdiv.dia.ref
new file mode 100755
index 000000000..bca84064a
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/leftmatrixdiv.dia.ref
@@ -0,0 +1,121 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+//==========================================================================
+//============================== \ ==============================
+//==========================================================================
+function x=leftmatrixdiv(A,B)
+ x=A\B
+endfunction
+//scalar division
+//-----Square matrix-----
+n=5; A=rand(n,n);b=rand(2,n+1);
+if leftmatrixdiv(A,[]) <>[] then bugmes();quit;end
+if execstr('leftmatrixdiv(A,B)','errcatch')==0 then bugmes();quit;end
+//Small dimensions real
+n=5;
+b=rand(n,2);A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>200*%eps then bugmes();quit;end
+//Small dimensions complex
+b=rand(n,2)+%i;A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>500*%eps then bugmes();quit;end
+b=rand(n,2);A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>200*%eps then bugmes();quit;end
+b=rand(n,2)+%i;A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>200*%eps then bugmes();quit;end
+//Large dimensions real
+n=50;
+b=rand(n,2);A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>10^6*%eps then bugmes();quit;end
+//Small dimensions complex
+b=rand(n,2)+%i;A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>50000*%eps then bugmes();quit;end
+b=rand(n,2);A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>50000*%eps then bugmes();quit;end
+b=rand(n,2)+%i;A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>50000*%eps then bugmes();quit;end
+//-----Rectangular matrix-----
+n=5;m=3; A=rand(m,n);b=rand(n+1,2);
+if leftmatrixdiv(A,[]) <>[] then bugmes();quit;end
+if execstr('leftmatrixdiv(A,b)','errcatch')==0 then bugmes();quit;end
+//Small dimensions real
+n=5;m=3;
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>200*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then bugmes();quit;end
+//Small dimensions complex
+n=5;m=3;
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then bugmes();quit;end
+n=5;m=3;
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then bugmes();quit;end
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then bugmes();quit;end
+//LArge dimension real
+n=40;m=20;
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
+//Large dimensions complex
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/leftmatrixdiv.tst b/modules/linear_algebra/tests/unit_tests/leftmatrixdiv.tst
new file mode 100755
index 000000000..ee61b4362
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/leftmatrixdiv.tst
@@ -0,0 +1,149 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+
+//==========================================================================
+//============================== \ ==============================
+//==========================================================================
+function x=leftmatrixdiv(A,B)
+ x=A\B
+endfunction
+//scalar division
+
+//-----Square matrix-----
+n=5; A=rand(n,n);b=rand(2,n+1);
+if leftmatrixdiv(A,[]) <>[] then pause,end
+if execstr('leftmatrixdiv(A,B)','errcatch')==0 then pause,end
+//Small dimensions real
+n=5;
+b=rand(n,2);A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>200*%eps then pause,end
+//Small dimensions complex
+b=rand(n,2)+%i;A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>500*%eps then pause,end
+
+b=rand(n,2);A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>200*%eps then pause,end
+
+
+b=rand(n,2)+%i;A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>200*%eps then pause,end
+
+
+//Large dimensions real
+n=50;
+b=rand(n,2);A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>10^6*%eps then pause,end
+//Small dimensions complex
+b=rand(n,2)+%i;A=rand(n,n);
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>50000*%eps then pause,end
+
+b=rand(n,2);A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>50000*%eps then pause,end
+
+b=rand(n,2)+%i;A=rand(n,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A*x-b)>50000*%eps then pause,end
+
+//-----Rectangular matrix-----
+n=5;m=3; A=rand(m,n);b=rand(n+1,2);
+if leftmatrixdiv(A,[]) <>[] then pause,end
+if execstr('leftmatrixdiv(A,b)','errcatch')==0 then pause,end
+
+//Small dimensions real
+n=5;m=3;
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>200*%eps then pause,end
+
+n=3;m=5;
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then pause,end
+//Small dimensions complex
+n=5;m=3;
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then pause,end
+n=5;m=3;
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then pause,end
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then pause,end
+
+n=3;m=5;
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then pause,end
+
+n=3;m=5;
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then pause,end
+
+n=3;m=5;
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>1000*%eps then pause,end
+
+//LArge dimension real
+
+n=40;m=20;
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+
+b=rand(m,2);A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+//Large dimensions complex
+
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+
+
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+
+
+b=rand(m,2)+%i;A=rand(m,n);
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+
+b=rand(m,2);A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+
+b=rand(m,2)+%i;A=rand(m,n)+%i;
+x=leftmatrixdiv(A,b);
+if Err(A'*A*x-A'*b)>10000*%eps then pause,end
+
+
diff --git a/modules/linear_algebra/tests/unit_tests/lsq.dia.ref b/modules/linear_algebra/tests/unit_tests/lsq.dia.ref
new file mode 100755
index 000000000..5fefb8a24
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/lsq.dia.ref
@@ -0,0 +1,96 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== lsq ==============================
+//==========================================================================
+//Empty matrix
+if lsq([],[])<>[] then bugmes();quit;end
+if execstr('lsq([],1)','errcatch')==0 then bugmes();quit;end
+if execstr('lsq(1,[])','errcatch')==0 then bugmes();quit;end
+if execstr('lsq(rand(3,2),rand(2,1))','errcatch')==0 then bugmes();quit;end
+//Small dimensions
+//Real full rank fat
+A=rand(3,5);b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+//Real rank deficient fat
+A=[1 2 3;1 2 3];b=[4;5];
+X=lsq(A,b);
+if Err(A'*A*X-A'*b)> 200*%eps then bugmes();quit;end
+//Real tall
+A=[1 2;4 2;0 1];b=[1;1;1];
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then bugmes();quit;end
+//Complex full rank fat
+A=rand(3,5)+%i*rand(3,5);b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+A=rand(3,5);b=rand(3,2)+%i*rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+A=rand(3,5)+%i*rand(3,5);b=rand(3,2)+%i*rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+//Complex rank deficient fat
+A=[1 2 3;1 2 3]+%i;b=[4;5];
+X=lsq(A,b);
+A=[1 2 3;1 2 3];b=[4;5]+%i;
+X=lsq(A,b);
+if Err(A'*A*X-A'*b)>200*%eps then bugmes();quit;end
+if Err(A'*A*X-A'*b)>200*%eps then bugmes();quit;end
+A=[1 2 3;1 2 3]+%i;b=[4;5]+%i;
+X=lsq(A,b);
+if Err(A'*A*X-A'*b)>1000*%eps then bugmes();quit;end
+//Complex full rank tall
+A=[1 2;4 2;0 1]+%i;b=[1;1;1];
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then bugmes();quit;end
+A=[1 2;4 2;0 1];b=[1;1;1]+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then bugmes();quit;end
+A=[1 2;4 2;0 1]+%i;b=[1;1;1]+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then bugmes();quit;end
+//LArge dimension
+//Real full rank fat
+A=rand(3,50);b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+//Real full rank tall
+A=rand(50,3);b=rand(50,2);
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then bugmes();quit;end
+//Complex full rank fat
+A=rand(3,50)+%i;b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+A=rand(3,50);b=rand(3,2)+%i;
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+A=rand(3,50);b=rand(3,2)+%i;
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then bugmes();quit;end
+//Complex full rank tall
+A=rand(50,3)+%i;b=rand(50,2);
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then bugmes();quit;end
+A=rand(50,3);b=rand(50,2)+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then bugmes();quit;end
+A=rand(50,3)+%i;b=rand(50,2)+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/lsq.tst b/modules/linear_algebra/tests/unit_tests/lsq.tst
new file mode 100755
index 000000000..8123a612c
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/lsq.tst
@@ -0,0 +1,113 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+//==========================================================================
+//============================== lsq ==============================
+//==========================================================================
+
+//Empty matrix
+if lsq([],[])<>[] then pause,end
+if execstr('lsq([],1)','errcatch')==0 then pause,end
+if execstr('lsq(1,[])','errcatch')==0 then pause,end
+if execstr('lsq(rand(3,2),rand(2,1))','errcatch')==0 then pause,end
+
+//Small dimensions
+//Real full rank fat
+A=rand(3,5);b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+//Real rank deficient fat
+A=[1 2 3;1 2 3];b=[4;5];
+X=lsq(A,b);
+if Err(A'*A*X-A'*b)> 200*%eps then pause,end
+//Real tall
+A=[1 2;4 2;0 1];b=[1;1;1];
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then pause,end
+//Complex full rank fat
+A=rand(3,5)+%i*rand(3,5);b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+
+A=rand(3,5);b=rand(3,2)+%i*rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+
+A=rand(3,5)+%i*rand(3,5);b=rand(3,2)+%i*rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+//Complex rank deficient fat
+A=[1 2 3;1 2 3]+%i;b=[4;5];
+X=lsq(A,b);
+A=[1 2 3;1 2 3];b=[4;5]+%i;
+X=lsq(A,b);
+if Err(A'*A*X-A'*b)>200*%eps then pause,end
+
+if Err(A'*A*X-A'*b)>200*%eps then pause,end
+A=[1 2 3;1 2 3]+%i;b=[4;5]+%i;
+X=lsq(A,b);
+if Err(A'*A*X-A'*b)>1000*%eps then pause,end
+
+//Complex full rank tall
+A=[1 2;4 2;0 1]+%i;b=[1;1;1];
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then pause,end
+
+A=[1 2;4 2;0 1];b=[1;1;1]+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then pause,end
+
+A=[1 2;4 2;0 1]+%i;b=[1;1;1]+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:2,:))*b1(1:2);
+if Err(X-X1)>200*%eps then pause,end
+
+
+
+//LArge dimension
+//Real full rank fat
+A=rand(3,50);b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+//Real full rank tall
+A=rand(50,3);b=rand(50,2);
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then pause,end
+
+//Complex full rank fat
+A=rand(3,50)+%i;b=rand(3,2);
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+A=rand(3,50);b=rand(3,2)+%i;
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+
+A=rand(3,50);b=rand(3,2)+%i;
+X=lsq(A,b);
+if Err(A*X-b)>200*%eps then pause,end
+//Complex full rank tall
+A=rand(50,3)+%i;b=rand(50,2);
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then pause,end
+
+A=rand(50,3);b=rand(50,2)+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then pause,end
+A=rand(50,3)+%i;b=rand(50,2)+%i;
+X=lsq(A,b);
+[Q,R]=qr(A);b1=Q'*b;X1=inv(R(1:3,:))*b1(1:3,:);
+if Err(X-X1)>200*%eps then pause,end
+
+
diff --git a/modules/linear_algebra/tests/unit_tests/lu.dia.ref b/modules/linear_algebra/tests/unit_tests/lu.dia.ref
new file mode 100755
index 000000000..23a614213
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/lu.dia.ref
@@ -0,0 +1,99 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== lu ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+[L,U]=lu(A);
+if L<>[]|U<>[] then bugmes();quit;end
+[L,U,E]=lu(A);
+if L<>[]|U<>[]|E<>[] then bugmes();quit;end
+//Non full rank
+A=rand(5,2);A=A*A';;Ac=rand(5,2)+%i*rand(5,2);Ac=Ac*Ac';
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then bugmes();quit;end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then bugmes();quit;end
+//Small dimension
+//---------------
+//Square
+A=rand(5,5);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >200*%eps then bugmes();quit;end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then bugmes();quit;end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >200*%eps then bugmes();quit;end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then bugmes();quit;end
+//Fat
+A=rand(3,5);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >200*%eps then bugmes();quit;end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then bugmes();quit;end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >200*%eps then bugmes();quit;end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then bugmes();quit;end
+//Tall
+A=rand(5,3);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >200*%eps then bugmes();quit;end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then bugmes();quit;end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >200*%eps then bugmes();quit;end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then bugmes();quit;end
+//large dimension
+//---------------
+//Square
+A=rand(50,50);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >1000*%eps then bugmes();quit;end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >1000*%eps then bugmes();quit;end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >1000*%eps then bugmes();quit;end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >1000*%eps then bugmes();quit;end
+//Fat
+A=rand(30,50);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >1000*%eps then bugmes();quit;end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >1000*%eps then bugmes();quit;end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >1000*%eps then bugmes();quit;end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >1000*%eps then bugmes();quit;end
+//Tall
+A=rand(50,30);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >1000*%eps then bugmes();quit;end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >1000*%eps then bugmes();quit;end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >1000*%eps then bugmes();quit;end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >1000*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/lu.tst b/modules/linear_algebra/tests/unit_tests/lu.tst
new file mode 100755
index 000000000..2bed8cd8f
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/lu.tst
@@ -0,0 +1,106 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+//==========================================================================
+//============================== lu ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+[L,U]=lu(A);
+if L<>[]|U<>[] then pause,end
+[L,U,E]=lu(A);
+if L<>[]|U<>[]|E<>[] then pause,end
+//Non full rank
+A=rand(5,2);A=A*A';;Ac=rand(5,2)+%i*rand(5,2);Ac=Ac*Ac';
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then pause,end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then pause,end
+
+//Small dimension
+//---------------
+//Square
+A=rand(5,5);Ac=A+%i*rand(A);
+//Real case
+
+[L,U]=lu(A);
+if Err(L*U-A) >200*%eps then pause,end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then pause,end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >200*%eps then pause,end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then pause,end
+//Fat
+A=rand(3,5);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >200*%eps then pause,end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then pause,end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >200*%eps then pause,end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then pause,end
+//Tall
+A=rand(5,3);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >200*%eps then pause,end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >200*%eps then pause,end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >200*%eps then pause,end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >200*%eps then pause,end
+
+//large dimension
+//---------------
+//Square
+A=rand(50,50);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >1000*%eps then pause,end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >1000*%eps then pause,end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >1000*%eps then pause,end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >1000*%eps then pause,end
+//Fat
+A=rand(30,50);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >1000*%eps then pause,end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >1000*%eps then pause,end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >1000*%eps then pause,end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >1000*%eps then pause,end
+//Tall
+A=rand(50,30);Ac=A+%i*rand(A);
+//Real case
+[L,U]=lu(A);
+if Err(L*U-A) >1000*%eps then pause,end
+[L,U,E]=lu(A);
+if Err(L*U-E*A) >1000*%eps then pause,end
+//Complex case
+[L,U]=lu(Ac);
+if Err(L*U-Ac) >1000*%eps then pause,end
+[L,U,E]=lu(Ac);
+if Err(L*U-E*Ac) >1000*%eps then pause,end
+
+
+
diff --git a/modules/linear_algebra/tests/unit_tests/norm.dia.ref b/modules/linear_algebra/tests/unit_tests/norm.dia.ref
new file mode 100755
index 000000000..b3b71ddf3
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/norm.dia.ref
@@ -0,0 +1,139 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA Michael Baudin
+// Copyright (C) 2011 - DIGITEO - Michael Baudin
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added performance and IEE compliance tests
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// TODO : use relative error criteria instead of absolute error
+eps = 100*%eps;
+// Inf
+assert_checkequal ( norm([1,2,3,-1,-2,-3],0) , %inf );
+assert_checkequal ( norm([1,2,3,-1,-2,-3],%nan) , %nan );
+assert_checkequal ( norm([]) , 0 );
+// Vector
+x = [1, 2, 3, -4];
+assert_checkalmostequal ( norm(x,1) , sum(abs(x)) , eps );
+assert_checkalmostequal ( norm(x,2) , sqrt(sum(abs(x).*abs(x))) , eps );
+assert_checkalmostequal ( norm(x,2) , norm(x) , eps );
+assert_checkalmostequal ( norm(x,-%inf) , min(abs(x)) , eps );
+p = 0.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x).^p).^(1/p) , eps );
+p = 2.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x).^p).^(1/p) , eps );
+assert_checkalmostequal ( norm(x,"inf") , max(abs(x)) , eps );
+assert_checkalmostequal ( norm(x,"inf") , norm(x,%inf) , eps );
+assert_checkalmostequal ( norm(x,"fro") , norm(x,2) , eps );
+// Complex
+x = x + %i*x;
+assert_checkalmostequal ( norm(x,1) , sum(abs(x)) , eps );
+assert_checkalmostequal ( norm(x,2) , sqrt(sum(abs(x).*abs(x))) , eps );
+assert_checkalmostequal ( norm(x,2) , norm(x) , eps );
+assert_checkalmostequal ( norm(x,-%inf) , min(abs(x)) , eps );
+p = 0.5;
+// 100*%eps is needed for linux
+assert_checkalmostequal ( norm(x,p) , max(abs(x))*sum((abs(x)/max(abs(x))).^p).^(1/p) , 100*%eps );
+p = 2.5;
+assert_checkalmostequal ( norm(x,p) , max(abs(x))*sum((abs(x)/max(abs(x))).^p).^(1/p) , 100*%eps );
+assert_checkalmostequal ( norm(x,"inf") , max(abs(x)) , 100*%eps);
+assert_checkalmostequal ( norm(x,"inf") , norm(x,%inf) , 100*%eps);
+// The Frobenius norm of this complex input x can be numerically complex,
+// e.g. 7.7459667 - 1.147D-16i
+// See http://bugzilla.scilab.org/show_bug.cgi?id=9204
+// assert_checkalmostequal ( norm(x,'fro') , norm(x,2) , 100*%eps , %eps );
+// Scalar
+x = [1.23];
+assert_checkalmostequal ( norm(x,1) , sum(abs(x)) , 100*%eps );
+assert_checkalmostequal ( norm(x,2) , sqrt(sum(abs(x).*abs(x))) , 100*%eps );
+assert_checkalmostequal ( norm(x,2) , norm(x) , 100*%eps );
+p = 0.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x)^p)^(1/p) , 100*%eps );
+p = 2.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x)^p)^(1/p) , 100*%eps );
+assert_checkalmostequal ( norm(x,"inf") , max(abs(x)) , 100*%eps);
+assert_checkalmostequal ( norm(x,"inf") , norm(x,%inf) , 100*%eps );
+assert_checkalmostequal ( norm(x,"fro") , norm(x,2) , 100*%eps );
+// Matrices
+a = rand(10, 10, "g");
+assert_checkalmostequal ( norm(a,1) , max(sum(abs(a),"r")) , 100*%eps );
+assert_checkalmostequal ( norm(a,"inf") , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,%inf) , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,2) , max(svd(a)) , 100*%eps );
+assert_checkalmostequal ( norm(a,"fro") , norm(matrix(a,1,size(a,"*")),2), 100*%eps );
+a = a + %i*a;
+assert_checkalmostequal ( norm(a,1) , max(sum(abs(a),"r")) , 100*%eps );
+assert_checkalmostequal ( norm(a,"inf") , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,%inf) , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,2) , max(svd(a)) , 100*%eps );
+// See http://bugzilla.scilab.org/show_bug.cgi?id=9204
+// assert_checkalmostequal ( norm(a,'fro') , norm(matrix(a,1,size(a,'*')),2), 100*%eps );
+//
+// Difficult cases for large/small vectors
+//
+// Norm 2
+x = 1.e307 * [1 1];
+assert_checkequal ( norm(x) , sqrt(2) * 1.e307 );
+x = 1.e-307 * [1 1];
+assert_checkalmostequal ( norm(x) , sqrt(2) * 1.e-307 , 1.e308);
+// Norm f
+x = 1.e307 * [1 1];
+assert_checkequal ( norm(x,"f") , sqrt(2) * 1.e307 );
+x = 1.e-307 * [1 1];
+assert_checkequal ( norm(x,"f") , sqrt(2) * 1.e-307 );
+//
+// Difficult cases for large/small matrices
+//
+// Norm f - case 1 : n < m
+x = 1.e307 * ones(10, 20);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e307 );
+x = 1.e-307 * ones(10, 20);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e-307 );
+// norm f - case 2 : n > m
+x = 1.e307 * ones(20, 10);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e307 );
+x = 1.e-307 * ones(20, 10);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e-307 );
+//
+// Special cases for zero vectors
+//
+// Norm 2 of a zero vector
+x = [0 0 0];
+assert_checkequal ( norm(x,2) , 0.0 );
+// Norm f of a zero vector
+x = zeros(4, 1);
+assert_checkequal ( norm(x,"f") , 0.0 );
+// Norm f of a zero matrix, case 1 n > m
+x = zeros(4, 2);
+assert_checkequal ( norm(x,"f") , 0.0 );
+// Norm f of a zero matrix, case 2 m > n
+x = zeros(2, 4);
+assert_checkequal ( norm(x,"f") , 0.0 );
+//
+// Norm 2 performance check,
+// See https://bugzilla.scilab.org/show_bug.cgi?id=5017
+//
+n = 100000;
+x = ones(n, 1);
+x(n+1) = 1.e9;
+tic();
+for i = 1:1000
+ norm(x);
+end
+t = toc();
+assert_checktrue( t < 4 );
+//
+// IEEE compliance
+//
+refMsg = msprintf(_("%s: Wrong value for argument #%d: Must not contain NaN or Inf.\n"), "norm", 1);
+assert_checkerror("norm(%nan)", refMsg);
+assert_checkerror("norm([%i %nan])", refMsg);
+assert_checkerror("norm([%i %inf])", refMsg);
+assert_checkerror("norm([%i; %nan])", refMsg);
+assert_checkerror("norm([%i; %inf])", refMsg);
+assert_checkerror("norm([1 0; %nan 0])", refMsg);
+assert_checkerror("norm([1 0; %inf 0]);", refMsg);
+assert_checkerror("norm([%inf 0; %nan 0]);", refMsg);
diff --git a/modules/linear_algebra/tests/unit_tests/norm.tst b/modules/linear_algebra/tests/unit_tests/norm.tst
new file mode 100755
index 000000000..2685065bf
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/norm.tst
@@ -0,0 +1,148 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA Michael Baudin
+// Copyright (C) 2011 - DIGITEO - Michael Baudin
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added performance and IEE compliance tests
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+
+// TODO : use relative error criteria instead of absolute error
+eps = 100*%eps;
+
+// Inf
+assert_checkequal ( norm([1,2,3,-1,-2,-3],0) , %inf );
+assert_checkequal ( norm([1,2,3,-1,-2,-3],%nan) , %nan );
+assert_checkequal ( norm([]) , 0 );
+// Vector
+x = [1, 2, 3, -4];
+assert_checkalmostequal ( norm(x,1) , sum(abs(x)) , eps );
+assert_checkalmostequal ( norm(x,2) , sqrt(sum(abs(x).*abs(x))) , eps );
+assert_checkalmostequal ( norm(x,2) , norm(x) , eps );
+assert_checkalmostequal ( norm(x,-%inf) , min(abs(x)) , eps );
+p = 0.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x).^p).^(1/p) , eps );
+p = 2.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x).^p).^(1/p) , eps );
+assert_checkalmostequal ( norm(x,"inf") , max(abs(x)) , eps );
+assert_checkalmostequal ( norm(x,"inf") , norm(x,%inf) , eps );
+assert_checkalmostequal ( norm(x,"fro") , norm(x,2) , eps );
+// Complex
+x = x + %i*x;
+assert_checkalmostequal ( norm(x,1) , sum(abs(x)) , eps );
+assert_checkalmostequal ( norm(x,2) , sqrt(sum(abs(x).*abs(x))) , eps );
+assert_checkalmostequal ( norm(x,2) , norm(x) , eps );
+assert_checkalmostequal ( norm(x,-%inf) , min(abs(x)) , eps );
+p = 0.5;
+// 100*%eps is needed for linux
+assert_checkalmostequal ( norm(x,p) , max(abs(x))*sum((abs(x)/max(abs(x))).^p).^(1/p) , 100*%eps );
+p = 2.5;
+assert_checkalmostequal ( norm(x,p) , max(abs(x))*sum((abs(x)/max(abs(x))).^p).^(1/p) , 100*%eps );
+assert_checkalmostequal ( norm(x,"inf") , max(abs(x)) , 100*%eps);
+assert_checkalmostequal ( norm(x,"inf") , norm(x,%inf) , 100*%eps);
+// The Frobenius norm of this complex input x can be numerically complex,
+// e.g. 7.7459667 - 1.147D-16i
+// See http://bugzilla.scilab.org/show_bug.cgi?id=9204
+// assert_checkalmostequal ( norm(x,'fro') , norm(x,2) , 100*%eps , %eps );
+
+// Scalar
+
+x = [1.23];
+assert_checkalmostequal ( norm(x,1) , sum(abs(x)) , 100*%eps );
+assert_checkalmostequal ( norm(x,2) , sqrt(sum(abs(x).*abs(x))) , 100*%eps );
+assert_checkalmostequal ( norm(x,2) , norm(x) , 100*%eps );
+p = 0.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x)^p)^(1/p) , 100*%eps );
+p = 2.5;
+assert_checkalmostequal ( norm(x,p) , sum(abs(x)^p)^(1/p) , 100*%eps );
+assert_checkalmostequal ( norm(x,"inf") , max(abs(x)) , 100*%eps);
+assert_checkalmostequal ( norm(x,"inf") , norm(x,%inf) , 100*%eps );
+assert_checkalmostequal ( norm(x,"fro") , norm(x,2) , 100*%eps );
+
+// Matrices
+a = rand(10, 10, "g");
+assert_checkalmostequal ( norm(a,1) , max(sum(abs(a),"r")) , 100*%eps );
+assert_checkalmostequal ( norm(a,"inf") , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,%inf) , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,2) , max(svd(a)) , 100*%eps );
+assert_checkalmostequal ( norm(a,"fro") , norm(matrix(a,1,size(a,"*")),2), 100*%eps );
+
+a = a + %i*a;
+assert_checkalmostequal ( norm(a,1) , max(sum(abs(a),"r")) , 100*%eps );
+assert_checkalmostequal ( norm(a,"inf") , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,%inf) , max(sum(abs(a),"c")) , 100*%eps );
+assert_checkalmostequal ( norm(a,2) , max(svd(a)) , 100*%eps );
+// See http://bugzilla.scilab.org/show_bug.cgi?id=9204
+// assert_checkalmostequal ( norm(a,'fro') , norm(matrix(a,1,size(a,'*')),2), 100*%eps );
+
+//
+// Difficult cases for large/small vectors
+//
+// Norm 2
+x = 1.e307 * [1 1];
+assert_checkequal ( norm(x) , sqrt(2) * 1.e307 );
+x = 1.e-307 * [1 1];
+assert_checkalmostequal ( norm(x) , sqrt(2) * 1.e-307 , 1.e308);
+// Norm f
+x = 1.e307 * [1 1];
+assert_checkequal ( norm(x,"f") , sqrt(2) * 1.e307 );
+x = 1.e-307 * [1 1];
+assert_checkequal ( norm(x,"f") , sqrt(2) * 1.e-307 );
+//
+// Difficult cases for large/small matrices
+//
+// Norm f - case 1 : n < m
+x = 1.e307 * ones(10, 20);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e307 );
+x = 1.e-307 * ones(10, 20);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e-307 );
+// norm f - case 2 : n > m
+x = 1.e307 * ones(20, 10);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e307 );
+x = 1.e-307 * ones(20, 10);
+assert_checkequal ( norm(x,"f") , sqrt(200) * 1.e-307 );
+//
+// Special cases for zero vectors
+//
+// Norm 2 of a zero vector
+x = [0 0 0];
+assert_checkequal ( norm(x,2) , 0.0 );
+// Norm f of a zero vector
+x = zeros(4, 1);
+assert_checkequal ( norm(x,"f") , 0.0 );
+// Norm f of a zero matrix, case 1 n > m
+x = zeros(4, 2);
+assert_checkequal ( norm(x,"f") , 0.0 );
+// Norm f of a zero matrix, case 2 m > n
+x = zeros(2, 4);
+assert_checkequal ( norm(x,"f") , 0.0 );
+
+//
+// Norm 2 performance check,
+// See https://bugzilla.scilab.org/show_bug.cgi?id=5017
+//
+n = 100000;
+x = ones(n, 1);
+x(n+1) = 1.e9;
+tic();
+for i = 1:1000
+ norm(x);
+end
+t = toc();
+assert_checktrue( t < 4 );
+
+//
+// IEEE compliance
+//
+refMsg = msprintf(_("%s: Wrong value for argument #%d: Must not contain NaN or Inf.\n"), "norm", 1);
+assert_checkerror("norm(%nan)", refMsg);
+assert_checkerror("norm([%i %nan])", refMsg);
+assert_checkerror("norm([%i %inf])", refMsg);
+assert_checkerror("norm([%i; %nan])", refMsg);
+assert_checkerror("norm([%i; %inf])", refMsg);
+assert_checkerror("norm([1 0; %nan 0])", refMsg);
+assert_checkerror("norm([1 0; %inf 0]);", refMsg);
+assert_checkerror("norm([%inf 0; %nan 0]);", refMsg);
diff --git a/modules/linear_algebra/tests/unit_tests/qr.dia.ref b/modules/linear_algebra/tests/unit_tests/qr.dia.ref
new file mode 100755
index 000000000..925bf476d
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/qr.dia.ref
@@ -0,0 +1,143 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== qr ==============================
+//==========================================================================
+//Empty matrix
+e=[];
+if qr(e)<>[] then bugmes();quit;end
+if qr(e,"e")<>[] then bugmes();quit;end
+[Q,R]=qr(e);
+if Q<>[]|R<>[] then bugmes();quit;end
+[Q,R]=qr(e,"e");
+if Q<>[]|R<>[] then bugmes();quit;end
+[Q,R,x]=qr(e);
+if Q<>[]|R<>[]|x<>[] then bugmes();quit;end
+[Q,R,x]=qr(e,"e");
+if Q<>[]|R<>[]|x<>[] then bugmes();quit;end
+//Small dimension
+//---------------
+A=rand(3,2);Ac=A+rand(A)*%i;
+//Real Case
+Q=qr(A);
+if Err(Q*Q'-eye())> 200*%eps then bugmes();quit;end
+Q=qr(A,"e");
+if Err(Q'*Q-eye())> 200*%eps then bugmes();quit;end
+[Q,R]=qr(A);
+if Err(Q*R-A)> 200*%eps then bugmes();quit;end
+[Q,R]=qr(A,"e");
+if Err(Q*R-A)> 200*%eps then bugmes();quit;end
+if Err(Q'*Q-eye())> 200*%eps then bugmes();quit;end
+Q=qr(A');
+if Err(Q*Q'-eye())> 200*%eps then bugmes();quit;end
+Q=qr(A',"e");
+if Err(Q*Q'-eye())> 200*%eps then bugmes();quit;end
+[Q,R]=qr(A');
+if Err(Q*R-A')> 200*%eps then bugmes();quit;end
+[Q,R]=qr(A',"e");
+if Err(Q*R-A')> 200*%eps then bugmes();quit;end
+[Q,R,x]=qr(A);
+if Err(Q*R*x'-A)> 200*%eps then bugmes();quit;end
+[Q,R,x]=qr(A,"e");
+if Err(Q*R*x'-A)> 200*%eps then bugmes();quit;end
+//Complex case
+Q=qr(Ac);
+if Err(Q*Q'-eye())> 200*%eps then bugmes();quit;end
+Q=qr(Ac,"e");
+if Err(Q'*Q-eye())> 200*%eps then bugmes();quit;end
+[Q,R]=qr(Ac);
+if Err(Q*R-Ac)> 200*%eps then bugmes();quit;end
+[Q,R]=qr(Ac,"e");
+if Err(Q*R-Ac)> 200*%eps then bugmes();quit;end
+if Err(Q'*Q-eye())> 200*%eps then bugmes();quit;end
+Q=qr(Ac');
+if Err(Q*Q'-eye())> 200*%eps then bugmes();quit;end
+Q=qr(Ac',"e");
+if Err(Q*Q'-eye())> 200*%eps then bugmes();quit;end
+[Q,R]=qr(Ac');
+if Err(Q*R-Ac')> 200*%eps then bugmes();quit;end
+[Q,R]=qr(Ac',"e");
+if Err(Q*R-Ac')> 200*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac);
+if Err(Q*R-Ac*x)> 200*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac,"e");
+if Err(Q*R-Ac*x)> 200*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac');
+if Err(Q*R-Ac'*x)> 200*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac',"e");
+if Err(Q*R-Ac'*x)> 200*%eps then bugmes();quit;end
+//Rank detection (obsolete)
+[Q,R,rk,x]=qr(A);
+if Err(Q*R*x'-A)> 200*%eps | rk<>2 then bugmes();quit;end
+[Q,R,rk,x]=qr(A,1.d-8);
+if Err(Q*R*x'-A)> 200*%eps | rk<>2 then bugmes();quit;end
+[Q,R,rk,x]=qr(Ac);
+if Err(Q*R*x'-Ac)> 200*%eps | rk<>2 then bugmes();quit;end
+[Q,R,rk,x]=qr(Ac,1.d-8);
+if Err(Q*R*x'-Ac)> 200*%eps | rk<>2 then bugmes();quit;end
+//Large dimension
+//---------------
+A=rand(150,60);Ac=A+rand(A)*%i;
+//Real Case
+Q=qr(A);
+if Err(Q*Q'-eye())> 1000*%eps then bugmes();quit;end
+Q=qr(A,"e");
+if Err(Q'*Q-eye())> 1000*%eps then bugmes();quit;end
+[Q,R]=qr(A);
+if Err(Q*R-A)> 1000*%eps then bugmes();quit;end
+[Q,R]=qr(A,"e");
+if Err(Q*R-A)> 1000*%eps then bugmes();quit;end
+if Err(Q'*Q-eye())> 1000*%eps then bugmes();quit;end
+Q=qr(A');
+if Err(Q*Q'-eye())> 1000*%eps then bugmes();quit;end
+Q=qr(A',"e");
+if Err(Q*Q'-eye())> 1000*%eps then bugmes();quit;end
+[Q,R]=qr(A');
+if Err(Q*R-A')> 1000*%eps then bugmes();quit;end
+[Q,R]=qr(A',"e");
+if Err(Q*R-A')> 1000*%eps then bugmes();quit;end
+[Q,R,x]=qr(A);
+if Err(Q*R*x'-A)> 1000*%eps then bugmes();quit;end
+[Q,R,x]=qr(A,"e");
+if Err(Q*R*x'-A)> 1000*%eps then bugmes();quit;end
+//Complex case
+Q=qr(Ac);
+if Err(Q*Q'-eye())> 2000*%eps then bugmes();quit;end
+Q=qr(Ac,"e");
+if Err(Q'*Q-eye())> 2000*%eps then bugmes();quit;end
+[Q,R]=qr(Ac);
+if Err(Q*R-Ac)> 2000*%eps then bugmes();quit;end
+[Q,R]=qr(Ac,"e");
+if Err(Q*R-Ac)> 2000*%eps then bugmes();quit;end
+if Err(Q'*Q-eye())> 2000*%eps then bugmes();quit;end
+Q=qr(Ac');
+if Err(Q*Q'-eye())> 2000*%eps then bugmes();quit;end
+Q=qr(Ac',"e");
+if Err(Q*Q'-eye())> 2000*%eps then bugmes();quit;end
+[Q,R]=qr(Ac');
+if Err(Q*R-Ac')> 2000*%eps then bugmes();quit;end
+[Q,R]=qr(Ac',"e");
+if Err(Q*R-Ac')> 2000*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac);
+if Err(Q*R-Ac*x)> 2000*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac,"e");
+if Err(Q*R-Ac*x)> 2000*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac');
+if Err(Q*R-Ac'*x)> 2000*%eps then bugmes();quit;end
+[Q,R,x]=qr(Ac',"e");
+if Err(Q*R-Ac'*x)> 2000*%eps then bugmes();quit;end
+//Rank detection (obsolete)
+[Q,R,rk,x]=qr(A);
+if Err(Q*R*x'-A)> 2000*%eps | rk<>60 then bugmes();quit;end
+[Q,R,rk,x]=qr(A,1.d-8);
+if Err(Q*R*x'-A)> 2000*%eps | rk<>60 then bugmes();quit;end
+[Q,R,rk,x]=qr(Ac);
+if Err(Q*R*x'-Ac)> 2000*%eps | rk<>60 then bugmes();quit;end
+[Q,R,rk,x]=qr(Ac,1.d-8);
+if Err(Q*R*x'-Ac)> 2000*%eps | rk<>60 then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/qr.tst b/modules/linear_algebra/tests/unit_tests/qr.tst
new file mode 100755
index 000000000..8bdf1c82b
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/qr.tst
@@ -0,0 +1,184 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== qr ==============================
+//==========================================================================
+//Empty matrix
+
+e=[];
+if qr(e)<>[] then pause,end
+if qr(e,"e")<>[] then pause,end
+
+[Q,R]=qr(e);
+if Q<>[]|R<>[] then pause,end
+[Q,R]=qr(e,"e");
+if Q<>[]|R<>[] then pause,end
+
+[Q,R,x]=qr(e);
+if Q<>[]|R<>[]|x<>[] then pause,end
+[Q,R,x]=qr(e,"e");
+if Q<>[]|R<>[]|x<>[] then pause,end
+
+//Small dimension
+//---------------
+A=rand(3,2);Ac=A+rand(A)*%i;
+
+//Real Case
+Q=qr(A);
+if Err(Q*Q'-eye())> 200*%eps then pause,end
+Q=qr(A,"e");
+if Err(Q'*Q-eye())> 200*%eps then pause,end
+
+[Q,R]=qr(A);
+if Err(Q*R-A)> 200*%eps then pause,end
+
+[Q,R]=qr(A,"e");
+if Err(Q*R-A)> 200*%eps then pause,end
+if Err(Q'*Q-eye())> 200*%eps then pause,end
+
+Q=qr(A');
+if Err(Q*Q'-eye())> 200*%eps then pause,end
+Q=qr(A',"e");
+if Err(Q*Q'-eye())> 200*%eps then pause,end
+
+[Q,R]=qr(A');
+if Err(Q*R-A')> 200*%eps then pause,end
+
+[Q,R]=qr(A',"e");
+if Err(Q*R-A')> 200*%eps then pause,end
+
+[Q,R,x]=qr(A);
+if Err(Q*R*x'-A)> 200*%eps then pause,end
+
+[Q,R,x]=qr(A,"e");
+if Err(Q*R*x'-A)> 200*%eps then pause,end
+
+//Complex case
+Q=qr(Ac);
+if Err(Q*Q'-eye())> 200*%eps then pause,end
+Q=qr(Ac,"e");
+if Err(Q'*Q-eye())> 200*%eps then pause,end
+
+[Q,R]=qr(Ac);
+if Err(Q*R-Ac)> 200*%eps then pause,end
+[Q,R]=qr(Ac,"e");
+if Err(Q*R-Ac)> 200*%eps then pause,end
+if Err(Q'*Q-eye())> 200*%eps then pause,end
+
+Q=qr(Ac');
+if Err(Q*Q'-eye())> 200*%eps then pause,end
+Q=qr(Ac',"e");
+if Err(Q*Q'-eye())> 200*%eps then pause,end
+
+
+[Q,R]=qr(Ac');
+if Err(Q*R-Ac')> 200*%eps then pause,end
+[Q,R]=qr(Ac',"e");
+if Err(Q*R-Ac')> 200*%eps then pause,end
+
+[Q,R,x]=qr(Ac);
+if Err(Q*R-Ac*x)> 200*%eps then pause,end
+[Q,R,x]=qr(Ac,"e");
+if Err(Q*R-Ac*x)> 200*%eps then pause,end
+
+[Q,R,x]=qr(Ac');
+if Err(Q*R-Ac'*x)> 200*%eps then pause,end
+[Q,R,x]=qr(Ac',"e");
+if Err(Q*R-Ac'*x)> 200*%eps then pause,end
+
+//Rank detection (obsolete)
+[Q,R,rk,x]=qr(A);
+if Err(Q*R*x'-A)> 200*%eps | rk<>2 then pause,end
+[Q,R,rk,x]=qr(A,1.d-8);
+if Err(Q*R*x'-A)> 200*%eps | rk<>2 then pause,end
+
+[Q,R,rk,x]=qr(Ac);
+if Err(Q*R*x'-Ac)> 200*%eps | rk<>2 then pause,end
+
+[Q,R,rk,x]=qr(Ac,1.d-8);
+if Err(Q*R*x'-Ac)> 200*%eps | rk<>2 then pause,end
+
+//Large dimension
+//---------------
+A=rand(150,60);Ac=A+rand(A)*%i;
+//Real Case
+Q=qr(A);
+if Err(Q*Q'-eye())> 1000*%eps then pause,end
+Q=qr(A,"e");
+if Err(Q'*Q-eye())> 1000*%eps then pause,end
+
+[Q,R]=qr(A);
+if Err(Q*R-A)> 1000*%eps then pause,end
+
+[Q,R]=qr(A,"e");
+if Err(Q*R-A)> 1000*%eps then pause,end
+if Err(Q'*Q-eye())> 1000*%eps then pause,end
+
+Q=qr(A');
+if Err(Q*Q'-eye())> 1000*%eps then pause,end
+Q=qr(A',"e");
+if Err(Q*Q'-eye())> 1000*%eps then pause,end
+
+[Q,R]=qr(A');
+if Err(Q*R-A')> 1000*%eps then pause,end
+
+[Q,R]=qr(A',"e");
+if Err(Q*R-A')> 1000*%eps then pause,end
+
+[Q,R,x]=qr(A);
+if Err(Q*R*x'-A)> 1000*%eps then pause,end
+
+[Q,R,x]=qr(A,"e");
+if Err(Q*R*x'-A)> 1000*%eps then pause,end
+
+//Complex case
+Q=qr(Ac);
+if Err(Q*Q'-eye())> 2000*%eps then pause,end
+Q=qr(Ac,"e");
+if Err(Q'*Q-eye())> 2000*%eps then pause,end
+
+[Q,R]=qr(Ac);
+if Err(Q*R-Ac)> 2000*%eps then pause,end
+[Q,R]=qr(Ac,"e");
+if Err(Q*R-Ac)> 2000*%eps then pause,end
+if Err(Q'*Q-eye())> 2000*%eps then pause,end
+
+Q=qr(Ac');
+if Err(Q*Q'-eye())> 2000*%eps then pause,end
+Q=qr(Ac',"e");
+if Err(Q*Q'-eye())> 2000*%eps then pause,end
+
+
+[Q,R]=qr(Ac');
+if Err(Q*R-Ac')> 2000*%eps then pause,end
+[Q,R]=qr(Ac',"e");
+if Err(Q*R-Ac')> 2000*%eps then pause,end
+
+[Q,R,x]=qr(Ac);
+if Err(Q*R-Ac*x)> 2000*%eps then pause,end
+[Q,R,x]=qr(Ac,"e");
+if Err(Q*R-Ac*x)> 2000*%eps then pause,end
+
+[Q,R,x]=qr(Ac');
+if Err(Q*R-Ac'*x)> 2000*%eps then pause,end
+[Q,R,x]=qr(Ac',"e");
+if Err(Q*R-Ac'*x)> 2000*%eps then pause,end
+
+//Rank detection (obsolete)
+[Q,R,rk,x]=qr(A);
+if Err(Q*R*x'-A)> 2000*%eps | rk<>60 then pause,end
+[Q,R,rk,x]=qr(A,1.d-8);
+if Err(Q*R*x'-A)> 2000*%eps | rk<>60 then pause,end
+
+[Q,R,rk,x]=qr(Ac);
+if Err(Q*R*x'-Ac)> 2000*%eps | rk<>60 then pause,end
+
+[Q,R,rk,x]=qr(Ac,1.d-8);
+if Err(Q*R*x'-Ac)> 2000*%eps | rk<>60 then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/rcond.dia.ref b/modules/linear_algebra/tests/unit_tests/rcond.dia.ref
new file mode 100755
index 000000000..28de8c3db
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/rcond.dia.ref
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== rcond ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+if rcond(A)<>[] then bugmes();quit;end
+//Rectangular matrix
+if execstr('rcond(rand(2,3))','errcatch')==0 then bugmes();quit;end
+if execstr('rcond(rand(2,3)+%i*eye())','errcatch')==0 then bugmes();quit;end
+//Small dimension
+//---------------
+//Real Case
+if Err(rcond(eye(5,5))-1)>10*%eps then bugmes();quit;end
+//Complex Case
+if Err(rcond(eye(5,5)*(1+%i))-1)>10*%eps then bugmes();quit;end
+//Large dimension
+//---------------
+//Real Case
+if Err(rcond(eye(50,50))-1)>10*%eps then bugmes();quit;end
+//Complex Case
+if Err(rcond(eye(50,50)*(1+%i))-1)>10*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/rcond.tst b/modules/linear_algebra/tests/unit_tests/rcond.tst
new file mode 100755
index 000000000..ca2b6101f
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/rcond.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+//==========================================================================
+//============================== rcond ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+if rcond(A)<>[] then pause,end
+
+//Rectangular matrix
+if execstr('rcond(rand(2,3))','errcatch')==0 then pause,end
+if execstr('rcond(rand(2,3)+%i*eye())','errcatch')==0 then pause,end
+//Small dimension
+//---------------
+//Real Case
+if Err(rcond(eye(5,5))-1)>10*%eps then pause,end
+//Complex Case
+if Err(rcond(eye(5,5)*(1+%i))-1)>10*%eps then pause,end
+
+
+//Large dimension
+//---------------
+//Real Case
+if Err(rcond(eye(50,50))-1)>10*%eps then pause,end
+//Complex Case
+if Err(rcond(eye(50,50)*(1+%i))-1)>10*%eps then pause,end
diff --git a/modules/linear_algebra/tests/unit_tests/rdiv.dia.ref b/modules/linear_algebra/tests/unit_tests/rdiv.dia.ref
new file mode 100755
index 000000000..ee39fc494
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/rdiv.dia.ref
@@ -0,0 +1,118 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+//==========================================================================
+//============================== / ==============================
+//==========================================================================
+//function x=rdiv(A,B),x=slash(A,B),endfunction
+function x=rdiv(A,B),x=A/B,endfunction
+//scalar division
+//-----Square matrix-----
+n=5; A=rand(n,n);b=rand(2,n+1);
+if rdiv([],A) <>[] then bugmes();quit;end
+if execstr('rdiv(b,A)','errcatch')==0 then bugmes();quit;end
+//Small dimensions real
+n=5;
+b=rand(2,n);A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>200*%eps then bugmes();quit;end
+//Small dimensions complex
+b=rand(2,n)+%i;A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>500*%eps then bugmes();quit;end
+b=rand(2,n);A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>500*%eps then bugmes();quit;end
+b=rand(2,n)+%i;A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>500*%eps then bugmes();quit;end
+//Large dimensions real
+n=50;
+b=rand(2,n);A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then bugmes();quit;end
+//Small dimensions complex
+b=rand(2,n)+%i;A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then bugmes();quit;end
+b=rand(2,n);A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then bugmes();quit;end
+b=rand(2,n)+%i;A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then bugmes();quit;end
+//-----Rectangular matrix-----
+n=5;m=3; A=rand(m,n);b=rand(2,n+1);
+if rdiv([],A) <>[] then bugmes();quit;end
+if execstr('rdiv(b,A)','errcatch')==0 then bugmes();quit;end
+//Small dimensions real
+n=5;m=3;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then bugmes();quit;end
+//Small dimensions complex
+n=5;m=3;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then bugmes();quit;end
+n=5;m=3;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then bugmes();quit;end
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+n=3;m=5;
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+//LArge dimension real
+n=50;m=30;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+n=30;m=50;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+//Large dimensions complex
+n=50;m=30;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+n=50;m=30;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+n=30;m=50;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+n=30;m=50;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
+n=30;m=50;
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/rdiv.tst b/modules/linear_algebra/tests/unit_tests/rdiv.tst
new file mode 100755
index 000000000..6e558dddc
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/rdiv.tst
@@ -0,0 +1,138 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x),r=norm(x,1),endfunction
+rand('normal')
+
+//==========================================================================
+//============================== / ==============================
+//==========================================================================
+//function x=rdiv(A,B),x=slash(A,B),endfunction
+function x=rdiv(A,B),x=A/B,endfunction
+//scalar division
+
+//-----Square matrix-----
+n=5; A=rand(n,n);b=rand(2,n+1);
+if rdiv([],A) <>[] then pause,end
+if execstr('rdiv(b,A)','errcatch')==0 then pause,end
+//Small dimensions real
+n=5;
+b=rand(2,n);A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>200*%eps then pause,end
+//Small dimensions complex
+b=rand(2,n)+%i;A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>500*%eps then pause,end
+
+b=rand(2,n);A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>500*%eps then pause,end
+
+b=rand(2,n)+%i;A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>500*%eps then pause,end
+
+//Large dimensions real
+n=50;
+b=rand(2,n);A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then pause,end
+//Small dimensions complex
+b=rand(2,n)+%i;A=rand(n,n);
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then pause,end
+
+b=rand(2,n);A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then pause,end
+
+b=rand(2,n)+%i;A=rand(n,n)+%i;
+x=rdiv(b,A);
+if Err(x*A-b)>10000*%eps then pause,end
+
+//-----Rectangular matrix-----
+n=5;m=3; A=rand(m,n);b=rand(2,n+1);
+if rdiv([],A) <>[] then pause,end
+if execstr('rdiv(b,A)','errcatch')==0 then pause,end
+
+//Small dimensions real
+n=5;m=3;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then pause,end
+
+n=3;m=5;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then pause,end
+//Small dimensions complex
+n=5;m=3;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then pause,end
+n=5;m=3;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then pause,end
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>200*%eps then pause,end
+
+n=3;m=5;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
+n=3;m=5;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
+n=3;m=5;
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
+//LArge dimension real
+
+n=50;m=30;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
+n=30;m=50;
+b=rand(2,n);A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+//Large dimensions complex
+n=50;m=30;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+n=50;m=30;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
+n=30;m=50;
+b=rand(2,n)+%i;A=rand(m,n);
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
+n=30;m=50;
+b=rand(2,n);A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
+n=30;m=50;
+b=rand(2,n)+%i;A=rand(m,n)+%i;
+x=rdiv(b,A);
+if Err(x*A*A'-b*A')>1000*%eps then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/schur.dia.ref b/modules/linear_algebra/tests/unit_tests/schur.dia.ref
new file mode 100755
index 000000000..50a543ab5
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/schur.dia.ref
@@ -0,0 +1,407 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+//==========================================================================
+//============================== schur ==============================
+//==========================================================================
+clear sel
+function t=sel(R),t=real(R)<0 ,endfunction
+//Empty matrix
+A=[];
+if schur(A)<>[] then bugmes();quit;end
+if schur(A,'real')<>[] then bugmes();quit;end
+if schur(A,'complex')<>[] then bugmes();quit;end
+if schur(A,'c')<>[] then bugmes();quit;end
+if schur(A,'d')<>[] then bugmes();quit;end
+if schur(A,sel)<>[] then bugmes();quit;end
+[U,S]=schur(A);
+if U<>[]|S<>[] then bugmes();quit;end
+[U,S]=schur(A,'real');
+if U<>[]|S<>[] then bugmes();quit;end
+[U,S]=schur(A,'complex');
+if U<>[]|S<>[] then bugmes();quit;end
+[U,N]=schur(A,'c');
+if U<>[]|N<>0 then bugmes();quit;end
+[U,N]=schur(A,'d');
+if U<>[]|N<>0 then bugmes();quit;end
+[U,N]=schur(A,sel);
+if U<>[]|N<>0 then bugmes();quit;end
+[U,N,S]=schur(A,'c');
+if U<>[]|N<>0|S<>[] then bugmes();quit;end
+[U,N,S]=schur(A,'d');
+if U<>[]|N<>0|S<>[] then bugmes();quit;end
+[U,N,S]=schur(A,sel);
+if U<>[]|N<>0|S<>[] then bugmes();quit;end
+//Rectangular matrix
+if execstr('schur(rand(2,3))','errcatch')==0 then bugmes();quit;end
+if execstr('[U,S]=schur(rand(2,3))','errcatch')==0 then bugmes();quit;end
+if execstr('schur(rand(2,3)+%i*eye())','errcatch')==0 then bugmes();quit;end
+if execstr('[U,S]=schur(rand(2,3)+%i*eye())','errcatch')==0 then bugmes();quit;end
+//Small dimension
+A=testmat1(3,5);Ac=testmat1(3+%i,5);
+//Real
+[U,S]=schur(A);
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-A)>200*%eps then bugmes();quit;end
+if Err(schur(A)-S) >%eps then bugmes();quit;end
+[U,S]=schur(A,'real');
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-A)>200*%eps then bugmes();quit;end
+if Err(schur(A)-S) >%eps then bugmes();quit;end
+[U,S]=schur(A,'complex');
+if Err(triu(S)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-A)>200*%eps then bugmes();quit;end
+if Err(schur(A,'complex')-S) >%eps then bugmes();quit;end
+[U,n]=schur(A,'c');S=U'*A*U;
+if n<>2 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+[U,n]=schur(A,'d');S=U'*A*U;
+if n<>0 then bugmes();quit;end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then bugmes();quit;end
+[U,n]=schur(A,sel);S=U'*A*U;
+if n<>2 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+//Complex
+[U,S]=schur(Ac);
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-Ac)>200*%eps then bugmes();quit;end
+if Err(schur(Ac)-S) >%eps then bugmes();quit;end
+[U,S]=schur(Ac,'complex');
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-Ac)>200*%eps then bugmes();quit;end
+if Err(schur(Ac)-S) >%eps then bugmes();quit;end
+[U,n]=schur(Ac,'c');S=U'*Ac*U;
+if n<>3 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+[U,n]=schur(Ac,'d');S=U'*A*U;
+if n<>0 then bugmes();quit;end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then bugmes();quit;end
+[U,n]=schur(Ac,sel);S=U'*Ac*U;
+if n<>3 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+//Large dimension
+A=testmat1(3,50);Ac=testmat1(3+%i,50);
+//Real
+[U,S]=schur(A);
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-A)>1000*%eps then bugmes();quit;end
+if Err(schur(A)-S) >%eps then bugmes();quit;end
+[U,S]=schur(A,'real');
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-A)>1000*%eps then bugmes();quit;end
+if Err(schur(A)-S) >%eps then bugmes();quit;end
+[U,S]=schur(A,'complex');
+if Err(triu(S)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-A)>1000*%eps then bugmes();quit;end
+if Err(schur(A,'complex')-S) >%eps then bugmes();quit;end
+[U,n]=schur(A,'c');S=U'*A*U;
+if n<>25 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+[U,n]=schur(A,'d');S=U'*A*U;
+if n<>0 then bugmes();quit;end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then bugmes();quit;end
+[U,n]=schur(A,sel);S=U'*A*U;
+if n<>25 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+//Complex
+[U,S]=schur(Ac);
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-Ac)>1000*%eps then bugmes();quit;end
+if Err(schur(Ac)-S) >%eps then bugmes();quit;end
+[U,S]=schur(Ac,'complex');
+if Err(triu(S,-1)-S)>%eps then bugmes();quit;end
+if Err(U*S*U'-Ac)>1000*%eps then bugmes();quit;end
+if Err(schur(Ac)-S) >%eps then bugmes();quit;end
+[U,n]=schur(Ac,'c');S=U'*Ac*U;
+if n<>25 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+[U,n]=schur(Ac,'d');S=U'*Ac*U;
+if n<>0 then bugmes();quit;end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then bugmes();quit;end
+[U,n]=schur(Ac,sel);S=U'*Ac*U;
+if n<>25 then bugmes();quit;end
+if or(real(spec(S(1:n,1:n)))>=0) then bugmes();quit;end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then bugmes();quit;end
+//==========================================================================
+//============================== schur part II ========================
+//==========================================================================
+//Empty matrix
+[As,Es]=schur([],[]);
+if As<>[]|Es<>[] then bugmes();quit;end
+[As,dim]=schur([],[],'c');
+if As<>[]|dim<>0 then bugmes();quit;end
+[As,dim]=schur([],[],'d');
+if As<>[]|dim<>0 then bugmes();quit;end
+[As,dim]=schur([],[],sel);
+if As<>[]|dim<>0 then bugmes();quit;end
+[As,Es,Q,Z]=schur([],[]);
+if As<>[]|Es<>[]|Q<>[]|Z<>[] then bugmes();quit;end
+[As,Es,dim]=schur([],[],'c');
+if As<>[]|Es<>[]|dim<>0 then bugmes();quit;end
+[As,Es,dim]=schur([],[],'d');
+if As<>[]|Es<>[]|dim<>0 then bugmes();quit;end
+[As,Es,dim]=schur([],[],sel);
+if As<>[]|Es<>[]|dim<>0 then bugmes();quit;end
+[Z,dim]=schur([],[],'c');
+if Z<>[]|dim<>0 then bugmes();quit;end
+[Z,dim]=schur([],[],'d');
+if Z<>[]|dim<>0 then bugmes();quit;end
+[Z,dim]=schur([],[],sel);
+if Z<>[]|dim<>0 then bugmes();quit;end
+//Rectangular matrix
+if execstr('[As,Es]=schur(rand(2,3),rand(2,3))','errcatch')==0 then bugmes();quit;end
+if execstr('[As,Es,Q,Z]=schur(rand(2,3),rand(2,3))','errcatch')==0 then bugmes();quit;end
+if execstr('[As,Es,dim]=schur(rand(2,3),rand(2,3),''c'')','errcatch')==0 then bugmes();quit;end
+if execstr('[Z,dim]=schur(rand(2,3),rand(2,3),sel)','errcatch')==0 then bugmes();quit;end
+//Small dimension
+//----Real------------
+A=testmat1(1,5);E=testmat1(-2,5) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then bugmes();quit;end
+if Err(Es1-Es)>10*%eps then bugmes();quit;end
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>5 then bugmes();quit;end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>5 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>5 then bugmes();quit;end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>5 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta),t=real(Alpha)>-0.2*real(Beta) ,endfunction
+dim=schur(A,E,sel);
+if dim<>2 then bugmes();quit;end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>2 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>2 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+//----Complex------------
+A=testmat1(1+%i,5);E=testmat1(-2-3*%i,5) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then bugmes();quit;end
+if Err(Es1-Es)>10*%eps then bugmes();quit;end
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>5 then bugmes();quit;end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>5 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>5 then bugmes();quit;end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>5 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta),t=imag(Alpha)>0 ,endfunction
+dim=schur(A,E,sel);
+if dim<>3 then bugmes();quit;end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>3 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>3 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+//Large dimension
+//----Real------------
+A=testmat1(1,50);E=testmat1(-2,50) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then bugmes();quit;end
+if Err(Es1-Es)>10*%eps then bugmes();quit;end
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>50 then bugmes();quit;end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>50 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>50 then bugmes();quit;end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>50 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta)
+ t=real(Alpha)>-0.2*real(Beta)
+endfunction
+dim=schur(A,E,sel); // plante ici DGGES LAPACK 3.1
+if dim<>12 then bugmes();quit;end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>12 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>12 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >200*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >200*%eps then bugmes();quit;end
+//----Complex------------
+A=testmat1(1+%i,50);E=testmat1(-2-3*%i,50) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >1000*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >1000*%eps then bugmes();quit;end
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then bugmes();quit;end
+if Err(Es1-Es)>10*%eps then bugmes();quit;end
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>50 then bugmes();quit;end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>50 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >1000*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >1000*%eps then bugmes();quit;end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>50 then bugmes();quit;end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>50 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >1000*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >1000*%eps then bugmes();quit;end
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta),t=imag(Alpha)>0 ,endfunction
+dim=schur(A,E,sel);
+if dim<>32 then bugmes();quit;end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if dim<>32 then bugmes();quit;end
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>32 then bugmes();quit;end
+if Err(Q*Q'-eye(Q)) >200*%eps then bugmes();quit;end
+if Err(Z*Z'-eye(Z)) >200*%eps then bugmes();quit;end
+if Err(As-Q'*A*Z) >1000*%eps then bugmes();quit;end
+if Err(Es-Q'*E*Z) >1000*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/schur.tst b/modules/linear_algebra/tests/unit_tests/schur.tst
new file mode 100755
index 000000000..1e3fc341b
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/schur.tst
@@ -0,0 +1,493 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;A(n,1)=a
+endfunction
+
+//==========================================================================
+//============================== schur ==============================
+//==========================================================================
+clear sel
+function t=sel(R),t=real(R)<0 ,endfunction
+//Empty matrix
+A=[];
+if schur(A)<>[] then pause,end
+if schur(A,'real')<>[] then pause,end
+if schur(A,'complex')<>[] then pause,end
+
+if schur(A,'c')<>[] then pause,end
+if schur(A,'d')<>[] then pause,end
+if schur(A,sel)<>[] then pause,end
+
+[U,S]=schur(A);
+if U<>[]|S<>[] then pause,end
+[U,S]=schur(A,'real');
+if U<>[]|S<>[] then pause,end
+[U,S]=schur(A,'complex');
+if U<>[]|S<>[] then pause,end
+
+
+
+[U,N]=schur(A,'c');
+if U<>[]|N<>0 then pause,end
+[U,N]=schur(A,'d');
+if U<>[]|N<>0 then pause,end
+[U,N]=schur(A,sel);
+if U<>[]|N<>0 then pause,end
+
+[U,N,S]=schur(A,'c');
+if U<>[]|N<>0|S<>[] then pause,end
+[U,N,S]=schur(A,'d');
+if U<>[]|N<>0|S<>[] then pause,end
+[U,N,S]=schur(A,sel);
+if U<>[]|N<>0|S<>[] then pause,end
+
+//Rectangular matrix
+if execstr('schur(rand(2,3))','errcatch')==0 then pause,end
+if execstr('[U,S]=schur(rand(2,3))','errcatch')==0 then pause,end
+
+if execstr('schur(rand(2,3)+%i*eye())','errcatch')==0 then pause,end
+if execstr('[U,S]=schur(rand(2,3)+%i*eye())','errcatch')==0 then pause,end
+
+//Small dimension
+A=testmat1(3,5);Ac=testmat1(3+%i,5);
+//Real
+[U,S]=schur(A);
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-A)>200*%eps then pause,end
+if Err(schur(A)-S) >%eps then pause,end
+
+[U,S]=schur(A,'real');
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-A)>200*%eps then pause,end
+if Err(schur(A)-S) >%eps then pause,end
+
+[U,S]=schur(A,'complex');
+if Err(triu(S)-S)>%eps then pause,end
+if Err(U*S*U'-A)>200*%eps then pause,end
+if Err(schur(A,'complex')-S) >%eps then pause,end
+
+[U,n]=schur(A,'c');S=U'*A*U;
+if n<>2 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+
+[U,n]=schur(A,'d');S=U'*A*U;
+if n<>0 then pause,end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then pause,end
+
+[U,n]=schur(A,sel);S=U'*A*U;
+if n<>2 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+
+
+//Complex
+[U,S]=schur(Ac);
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-Ac)>200*%eps then pause,end
+if Err(schur(Ac)-S) >%eps then pause,end
+
+[U,S]=schur(Ac,'complex');
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-Ac)>200*%eps then pause,end
+if Err(schur(Ac)-S) >%eps then pause,end
+
+
+[U,n]=schur(Ac,'c');S=U'*Ac*U;
+if n<>3 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+
+[U,n]=schur(Ac,'d');S=U'*A*U;
+if n<>0 then pause,end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then pause,end
+
+[U,n]=schur(Ac,sel);S=U'*Ac*U;
+if n<>3 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+
+
+//Large dimension
+A=testmat1(3,50);Ac=testmat1(3+%i,50);
+//Real
+[U,S]=schur(A);
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-A)>1000*%eps then pause,end
+if Err(schur(A)-S) >%eps then pause,end
+
+[U,S]=schur(A,'real');
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-A)>1000*%eps then pause,end
+if Err(schur(A)-S) >%eps then pause,end
+
+[U,S]=schur(A,'complex');
+if Err(triu(S)-S)>%eps then pause,end
+if Err(U*S*U'-A)>1000*%eps then pause,end
+if Err(schur(A,'complex')-S) >%eps then pause,end
+
+
+[U,n]=schur(A,'c');S=U'*A*U;
+if n<>25 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+
+[U,n]=schur(A,'d');S=U'*A*U;
+if n<>0 then pause,end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then pause,end
+
+[U,n]=schur(A,sel);S=U'*A*U;
+if n<>25 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+
+//Complex
+[U,S]=schur(Ac);
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-Ac)>1000*%eps then pause,end
+if Err(schur(Ac)-S) >%eps then pause,end
+
+[U,S]=schur(Ac,'complex');
+if Err(triu(S,-1)-S)>%eps then pause,end
+if Err(U*S*U'-Ac)>1000*%eps then pause,end
+if Err(schur(Ac)-S) >%eps then pause,end
+
+[U,n]=schur(Ac,'c');S=U'*Ac*U;
+if n<>25 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+
+[U,n]=schur(Ac,'d');S=U'*Ac*U;
+if n<>0 then pause,end
+if or(abs(spec(S(n+1:$,n+1:$)))<1) then pause,end
+
+[U,n]=schur(Ac,sel);S=U'*Ac*U;
+if n<>25 then pause,end
+if or(real(spec(S(1:n,1:n)))>=0) then pause,end
+if or(real(spec(S(n+1:$,n+1:$)))<0) then pause,end
+//==========================================================================
+//============================== schur part II ========================
+//==========================================================================
+//Empty matrix
+[As,Es]=schur([],[]);
+if As<>[]|Es<>[] then pause,end
+
+[As,dim]=schur([],[],'c');
+if As<>[]|dim<>0 then pause,end
+[As,dim]=schur([],[],'d');
+if As<>[]|dim<>0 then pause,end
+[As,dim]=schur([],[],sel);
+if As<>[]|dim<>0 then pause,end
+
+[As,Es,Q,Z]=schur([],[]);
+if As<>[]|Es<>[]|Q<>[]|Z<>[] then pause,end
+
+[As,Es,dim]=schur([],[],'c');
+if As<>[]|Es<>[]|dim<>0 then pause,end
+[As,Es,dim]=schur([],[],'d');
+if As<>[]|Es<>[]|dim<>0 then pause,end
+[As,Es,dim]=schur([],[],sel);
+if As<>[]|Es<>[]|dim<>0 then pause,end
+
+[Z,dim]=schur([],[],'c');
+if Z<>[]|dim<>0 then pause,end
+[Z,dim]=schur([],[],'d');
+if Z<>[]|dim<>0 then pause,end
+[Z,dim]=schur([],[],sel);
+if Z<>[]|dim<>0 then pause,end
+
+
+//Rectangular matrix
+if execstr('[As,Es]=schur(rand(2,3),rand(2,3))','errcatch')==0 then pause,end
+if execstr('[As,Es,Q,Z]=schur(rand(2,3),rand(2,3))','errcatch')==0 then pause,end
+if execstr('[As,Es,dim]=schur(rand(2,3),rand(2,3),''c'')','errcatch')==0 then pause,end
+if execstr('[Z,dim]=schur(rand(2,3),rand(2,3),sel)','errcatch')==0 then pause,end
+
+//Small dimension
+//----Real------------
+A=testmat1(1,5);E=testmat1(-2,5) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then pause,end
+if Err(Es1-Es)>10*%eps then pause,end
+
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>5 then pause,end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>5 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>5 then pause,end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>5 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta),t=real(Alpha)>-0.2*real(Beta) ,endfunction
+
+dim=schur(A,E,sel);
+if dim<>2 then pause,end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>2 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>2 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+//----Complex------------
+A=testmat1(1+%i,5);E=testmat1(-2-3*%i,5) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then pause,end
+if Err(Es1-Es)>10*%eps then pause,end
+
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>5 then pause,end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>5 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>5 then pause,end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>5 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>5 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta),t=imag(Alpha)>0 ,endfunction
+
+dim=schur(A,E,sel);
+if dim<>3 then pause,end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>3 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>3 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+
+//Large dimension
+
+//----Real------------
+A=testmat1(1,50);E=testmat1(-2,50) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then pause,end
+if Err(Es1-Es)>10*%eps then pause,end
+
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>50 then pause,end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>50 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>50 then pause,end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>50 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta)
+ t=real(Alpha)>-0.2*real(Beta)
+endfunction
+
+dim=schur(A,E,sel); // plante ici DGGES LAPACK 3.1
+if dim<>12 then pause,end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>12 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>12 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >200*%eps then pause,end
+if Err(Es-Q'*E*Z) >200*%eps then pause,end
+//----Complex------------
+A=testmat1(1+%i,50);E=testmat1(-2-3*%i,50) ;
+[As,Es,Q,Z]=schur(A,E);
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >1000*%eps then pause,end
+if Err(Es-Q'*E*Z) >1000*%eps then pause,end
+
+[As1,Es1]=schur(A,E);
+if Err(As1-As)>10*%eps then pause,end
+if Err(Es1-Es)>10*%eps then pause,end
+
+// Ordered 'c'
+dim=schur(A,E,'c');
+if dim<>50 then pause,end
+[Z,dim]=schur(A,E,'c');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'c');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>50 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >1000*%eps then pause,end
+if Err(Es-Q'*E*Z) >1000*%eps then pause,end
+// Ordered 'd'
+dim=schur(A,E,'d');
+if dim<>50 then pause,end
+[Z,dim]=schur(A,E,'d');
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,'d');
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>50 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,'d');
+if dim<>50 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >1000*%eps then pause,end
+if Err(Es-Q'*E*Z) >1000*%eps then pause,end
+
+//ordered sel
+clear sel
+function t=sel(Alpha,Beta),t=imag(Alpha)>0 ,endfunction
+
+dim=schur(A,E,sel);
+if dim<>32 then pause,end
+[Z,dim]=schur(A,E,sel);
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+
+[Q,Z1,dim]=schur(A,E,sel);
+if Err(Z1-Z)>10*%eps then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if dim<>32 then pause,end
+
+[As,Es,Z,dim]=schur(A,E,sel);
+if dim<>32 then pause,end
+if Err(Q*Q'-eye(Q)) >200*%eps then pause,end
+if Err(Z*Z'-eye(Z)) >200*%eps then pause,end
+if Err(As-Q'*A*Z) >1000*%eps then pause,end
+if Err(Es-Q'*E*Z) >1000*%eps then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/spec.dia.ref b/modules/linear_algebra/tests/unit_tests/spec.dia.ref
new file mode 100755
index 000000000..2626a0fab
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/spec.dia.ref
@@ -0,0 +1,132 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// easy and simple test
+A=[0,2,0,1;2,2,3,2;4,-3,0,1.;6,1,-6,-5];
+refA=[ 4.1774842;-4.8201083;-1.1786879+%i*3.1987051;-1.1786879-%i*3.1987051];
+assert_checkalmostequal(spec(A),refA, 10^-7);
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;
+ A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+//
+// spec.tst --
+// Test spec with 1 RHS and one or several LHS.
+//
+function r=Checktestmat1(a,n)
+ A=testmat1(a,n);
+ S=spec(A);
+ SR=real(S);
+ SI=imag(S);
+ dt=2*%i*%pi/n;
+ Z=exp(dt*(1:n)');
+ ZR=real(Z*((1+a*a')/a));
+ ZI=-imag(Z*((a*a'-1)/a));
+ r=max(norm(gsort(SR)-gsort(ZR)),norm(gsort(SI)-gsort(ZI)))
+endfunction
+function A=testmat2(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=testmat1(a,n);
+ A=A+A'
+endfunction
+function r=Checktestmat2(a,n)
+ A=testmat2(a,n);
+ S=spec(A);
+ SR=real(S);
+ SI=imag(S);
+ dt=2*%i*%pi/n;
+ Z=exp(dt*(1:n)');
+ ZR=2*real(Z*((1+a*a')/a));
+ ZI=0*ZR;
+ r=max(norm(gsort(SR)-gsort(ZR)),norm(gsort(SI)-gsort(ZI)))
+endfunction
+// Empty matrix
+A=[];
+B=[];
+// 1. One RHS, one LHS
+S=spec(A);
+if S<>[] then bugmes();quit;end
+// 2. One RHS, two LHS
+[al,be]=spec(A);
+if al<>[] then bugmes();quit;end
+if be<>[] then bugmes();quit;end
+//Matrix with Inf or Nan (test de la detection d'erreur)
+// 1. Real
+// 1.1 Not symetric
+if execstr('spec([%inf 1;2 3])','errcatch')==0 then bugmes();quit;end
+if execstr('spec([1 %nan;2 3])','errcatch')==0 then bugmes();quit;end
+// 1.2 Symetric
+if execstr('spec([%inf 1;1 3])','errcatch')==0 then bugmes();quit;end
+// 2. Complex
+// 2.1 Not symetric
+if execstr('spec([%inf %i;2 3])','errcatch')==0 then bugmes();quit;end
+if execstr('spec([%i %i;%nan 3])','errcatch')==0 then bugmes();quit;end
+// 2.2 Symetric
+if execstr('spec([%inf %i;-%i 3])','errcatch')==0 then bugmes();quit;end
+//Small dimension
+//---------------
+//Real Case
+//Unsymetric, 2 LHS
+if Checktestmat1(3,5)>200*%eps then bugmes();quit;end
+[U,S]=spec(testmat1(3,5));
+if Err(U*S/U-testmat1(3,5))>200*%eps then bugmes();quit;end
+//Symmetric, 2 LHS
+if Checktestmat2(3,5)>200*%eps then bugmes();quit;end
+[U,S]=spec(testmat2(3,5));
+if Err(U*S/U-testmat2(3,5))>200*%eps then bugmes();quit;end
+//Unsymetric, 1 LHS
+Scomputed = spec([2,1;3,4]);
+Sexpected = [1;5];
+if Err(Scomputed - Sexpected)>200*%eps then bugmes();quit;end
+//Symmetric, 1 LHS
+Scomputed=spec([2,1;1,2]);
+Sexpected = [1;3];
+if Err(Scomputed - Sexpected)>200*%eps then bugmes();quit;end
+//Complex Case
+//Unsymetric
+if Checktestmat1(3+2*%i,5)>200*%eps then bugmes();quit;end
+[U,S]=spec(testmat1(3+2*%i,5));
+if Err(U*S/U-testmat1(3+2*%i,5))>200*%eps then bugmes();quit;end
+//Symmetric
+if Checktestmat2(3+2*%i,5)>200*%eps then bugmes();quit;end
+[U,S]=spec(testmat2(3+2*%i,5));
+if Err(U*S/U-testmat2(3+2*%i,5))>200*%eps then bugmes();quit;end
+//Unsymetric, 1 LHS
+Scomputed = spec([2*%i,1*%i;3*%i,4*%i]);
+Sexpected = [%i;5*%i];
+if Err(Scomputed - Sexpected)>200*%eps then bugmes();quit;end
+//Symmetric, 1 LHS
+Scomputed=spec([2,%i;-%i,2]);
+Sexpected = [1;3];
+if Err(Scomputed - Sexpected)>200*%eps then bugmes();quit;end
+//Large dimension
+//---------------
+//Real Case
+//Unsymetric
+if Checktestmat1(3,50)>1000*%eps then bugmes();quit;end
+[U,S]=spec(testmat1(3,50));
+if Err(U*S/U-testmat1(3,50))>1000*%eps then bugmes();quit;end
+//Symmetric
+if Checktestmat2(3,50)>1000*%eps then bugmes();quit;end
+[U,S]=spec(testmat2(3,50));
+if Err(U*S/U-testmat2(3,50))>1000*%eps then bugmes();quit;end
+//Complex Case
+//Unsymetric
+if Checktestmat1(3+2*%i,50)>1000*%eps then bugmes();quit;end
+[U,S]=spec(testmat1(3+2*%i,50));
+if Err(U*S/U-testmat1(3+2*%i,50))>1000*%eps then bugmes();quit;end
+//Symmetric
+if Checktestmat2(3+2*%i,50)>1000*%eps then bugmes();quit;end
+[U,S]=spec(testmat2(3+2*%i,50));
+if Err(U*S/U-testmat2(3+2*%i,50))>10000*%eps then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/spec.tst b/modules/linear_algebra/tests/unit_tests/spec.tst
new file mode 100755
index 000000000..fbd54e228
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/spec.tst
@@ -0,0 +1,153 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// easy and simple test
+
+A=[0,2,0,1;2,2,3,2;4,-3,0,1.;6,1,-6,-5];
+refA=[ 4.1774842;-4.8201083;-1.1786879+%i*3.1987051;-1.1786879-%i*3.1987051];
+assert_checkalmostequal(spec(A),refA, 10^-7);
+
+
+//define tools
+function A=testmat1(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=diag(a*ones(1,n-1),1)+diag((1/a)*ones(1,n-1),-1)
+ A(1,n)=1/a;
+ A(n,1)=a
+endfunction
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+
+//
+// spec.tst --
+// Test spec with 1 RHS and one or several LHS.
+//
+
+function r=Checktestmat1(a,n)
+ A=testmat1(a,n);
+ S=spec(A);
+ SR=real(S);
+ SI=imag(S);
+ dt=2*%i*%pi/n;
+ Z=exp(dt*(1:n)');
+ ZR=real(Z*((1+a*a')/a));
+ ZI=-imag(Z*((a*a'-1)/a));
+ r=max(norm(gsort(SR)-gsort(ZR)),norm(gsort(SI)-gsort(ZI)))
+endfunction
+function A=testmat2(a,n)
+ //eigen values are given by a dilation of nth roots of 1
+ A=testmat1(a,n);
+ A=A+A'
+endfunction
+function r=Checktestmat2(a,n)
+ A=testmat2(a,n);
+ S=spec(A);
+ SR=real(S);
+ SI=imag(S);
+ dt=2*%i*%pi/n;
+ Z=exp(dt*(1:n)');
+ ZR=2*real(Z*((1+a*a')/a));
+ ZI=0*ZR;
+ r=max(norm(gsort(SR)-gsort(ZR)),norm(gsort(SI)-gsort(ZI)))
+endfunction
+
+
+
+// Empty matrix
+A=[];
+B=[];
+// 1. One RHS, one LHS
+S=spec(A);
+if S<>[] then pause,end
+// 2. One RHS, two LHS
+[al,be]=spec(A);
+if al<>[] then pause,end
+if be<>[] then pause,end
+
+//Matrix with Inf or Nan (test de la detection d'erreur)
+// 1. Real
+// 1.1 Not symetric
+if execstr('spec([%inf 1;2 3])','errcatch')==0 then pause,end
+if execstr('spec([1 %nan;2 3])','errcatch')==0 then pause,end
+// 1.2 Symetric
+if execstr('spec([%inf 1;1 3])','errcatch')==0 then pause,end
+// 2. Complex
+// 2.1 Not symetric
+if execstr('spec([%inf %i;2 3])','errcatch')==0 then pause,end
+if execstr('spec([%i %i;%nan 3])','errcatch')==0 then pause,end
+// 2.2 Symetric
+if execstr('spec([%inf %i;-%i 3])','errcatch')==0 then pause,end
+
+//Small dimension
+//---------------
+//Real Case
+//Unsymetric, 2 LHS
+if Checktestmat1(3,5)>200*%eps then pause,end
+[U,S]=spec(testmat1(3,5));
+if Err(U*S/U-testmat1(3,5))>200*%eps then pause,end
+//Symmetric, 2 LHS
+if Checktestmat2(3,5)>200*%eps then pause,end
+[U,S]=spec(testmat2(3,5));
+if Err(U*S/U-testmat2(3,5))>200*%eps then pause,end
+//Unsymetric, 1 LHS
+Scomputed = spec([2,1;3,4]);
+Sexpected = [1;5];
+if Err(Scomputed - Sexpected)>200*%eps then pause,end
+//Symmetric, 1 LHS
+Scomputed=spec([2,1;1,2]);
+Sexpected = [1;3];
+if Err(Scomputed - Sexpected)>200*%eps then pause,end
+
+//Complex Case
+//Unsymetric
+if Checktestmat1(3+2*%i,5)>200*%eps then pause,end
+[U,S]=spec(testmat1(3+2*%i,5));
+if Err(U*S/U-testmat1(3+2*%i,5))>200*%eps then pause,end
+
+//Symmetric
+if Checktestmat2(3+2*%i,5)>200*%eps then pause,end
+[U,S]=spec(testmat2(3+2*%i,5));
+if Err(U*S/U-testmat2(3+2*%i,5))>200*%eps then pause,end
+
+//Unsymetric, 1 LHS
+Scomputed = spec([2*%i,1*%i;3*%i,4*%i]);
+Sexpected = [%i;5*%i];
+if Err(Scomputed - Sexpected)>200*%eps then pause,end
+//Symmetric, 1 LHS
+Scomputed=spec([2,%i;-%i,2]);
+Sexpected = [1;3];
+if Err(Scomputed - Sexpected)>200*%eps then pause,end
+
+
+//Large dimension
+//---------------
+//Real Case
+//Unsymetric
+if Checktestmat1(3,50)>1000*%eps then pause,end
+[U,S]=spec(testmat1(3,50));
+if Err(U*S/U-testmat1(3,50))>1000*%eps then pause,end
+
+//Symmetric
+if Checktestmat2(3,50)>1000*%eps then pause,end
+[U,S]=spec(testmat2(3,50));
+if Err(U*S/U-testmat2(3,50))>1000*%eps then pause,end
+
+//Complex Case
+//Unsymetric
+if Checktestmat1(3+2*%i,50)>1000*%eps then pause,end
+[U,S]=spec(testmat1(3+2*%i,50));
+if Err(U*S/U-testmat1(3+2*%i,50))>1000*%eps then pause,end
+
+//Symmetric
+if Checktestmat2(3+2*%i,50)>1000*%eps then pause,end
+[U,S]=spec(testmat2(3+2*%i,50));
+if Err(U*S/U-testmat2(3+2*%i,50))>10000*%eps then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/squeeze.dia.ref b/modules/linear_algebra/tests/unit_tests/squeeze.dia.ref
new file mode 100755
index 000000000..d72bb1da2
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/squeeze.dia.ref
@@ -0,0 +1,31 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - INRIA - Serge.Steer@inria.fr
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+C=cell(1,6);C.entries=list(1,%s+1,[3,4],[%f %t],int32(8),-24);
+S=[];S.a=1;S(6).a=33;
+data=list(1:6,string(1:6),(1:6)+%s,(1:6)>2, int32(1:6),C,S);
+//check with hypermatrices and hyper cells
+for v=data
+ a=matrix(v,[1 2 3]);
+ if or(squeeze(a)<>matrix(v,[2 3])) then bugmes();quit;end
+ a=matrix(v,[1 2 1 3]);
+ if or(squeeze(a)<>matrix(v,[2 3])) then bugmes();quit;end
+end
+//check with matrices and 2D cells the function should return the input
+for v=data
+ a=matrix(v,[2 3]);
+ if or(squeeze(a)<>matrix(v,[2 3])) then bugmes();quit;end
+end
+//scalar case
+a=33;
+if or(size(squeeze(a))<>[1 1]) then bugmes();quit;end
+c=cell(1,1);c(1).entries=1:3;
+if or(size(squeeze(c))<>[1 1]) then bugmes();quit;end
+//empty matrix
+if or(size(squeeze([]))<>[0 0]) then bugmes();quit;end
+if or(size(squeeze(cell()))<>[0 0]) then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/squeeze.tst b/modules/linear_algebra/tests/unit_tests/squeeze.tst
new file mode 100755
index 000000000..59fc65596
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/squeeze.tst
@@ -0,0 +1,36 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - INRIA - Serge.Steer@inria.fr
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+
+C=cell(1,6);C.entries=list(1,%s+1,[3,4],[%f %t],int32(8),-24);
+S=[];S.a=1;S(6).a=33;
+
+data=list(1:6,string(1:6),(1:6)+%s,(1:6)>2, int32(1:6),C,S);
+//check with hypermatrices and hyper cells
+for v=data
+ a=matrix(v,[1 2 3]);
+ if or(squeeze(a)<>matrix(v,[2 3])) then pause,end
+
+ a=matrix(v,[1 2 1 3]);
+ if or(squeeze(a)<>matrix(v,[2 3])) then pause,end
+end
+//check with matrices and 2D cells the function should return the input
+for v=data
+ a=matrix(v,[2 3]);
+ if or(squeeze(a)<>matrix(v,[2 3])) then pause,end
+end
+
+//scalar case
+a=33;
+if or(size(squeeze(a))<>[1 1]) then pause,end
+c=cell(1,1);c(1).entries=1:3;
+if or(size(squeeze(c))<>[1 1]) then pause,end
+//empty matrix
+if or(size(squeeze([]))<>[0 0]) then pause,end
+if or(size(squeeze(cell()))<>[0 0]) then pause,end
+
diff --git a/modules/linear_algebra/tests/unit_tests/svd.dia.ref b/modules/linear_algebra/tests/unit_tests/svd.dia.ref
new file mode 100755
index 000000000..e323097ff
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/svd.dia.ref
@@ -0,0 +1,293 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+//==========================================================================
+//============================== svd ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+[U,S,V]=svd(A);
+if U<>[]|V<>[]|S<>[] then bugmes();quit;end
+S=svd(A);
+if S<>[] then bugmes();quit;end
+[U,S,V]=svd(A,"e");
+if U<>[]|V<>[]|S<>[] then bugmes();quit;end
+S=svd(A,"e");
+if S<>[] then bugmes();quit;end
+//Matrix with inf or nan
+if execstr('svd([%inf 1;2 3])','errcatch')==0 then bugmes();quit;end
+if execstr('svd([1 %nan;2 3])','errcatch')==0 then bugmes();quit;end
+if execstr('svd([%inf %i;2 3])','errcatch')==0 then bugmes();quit;end
+if execstr('svd([%i %i;%nan 3])','errcatch')==0 then bugmes();quit;end
+//Small dimension
+//---------------
+A=rand(3,5);
+Ac=A+%i*rand(A);
+//Real Case
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>200*%eps then bugmes();quit;end
+if Err(svd(A)-diag(S))> 200*%eps then bugmes();quit;end
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>200*%eps then bugmes();quit;end
+A=A';
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>200*%eps then bugmes();quit;end
+if Err(svd(A)-diag(S))> 200*%eps then bugmes();quit;end
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>200*%eps then bugmes();quit;end
+//Complex Case
+[U,S,V]=svd(Ac);
+if Err(U*S*V'-Ac)>200*%eps then bugmes();quit;end
+if Err(svd(Ac)-diag(S))> 200*%eps then bugmes();quit;end
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>200*%eps then bugmes();quit;end
+Ac=Ac';
+[U,S,V]=svd(Ac);U*S*V'-Ac;
+if Err(U*S*V'-Ac)>200*%eps then bugmes();quit;end
+if Err(svd(Ac)-diag(S))> 200*%eps then bugmes();quit;end
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>200*%eps then bugmes();quit;end
+//Large dimension
+//---------------
+A=rand(150,60);
+Ac=A+rand(A)*%i;
+//Real Case
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>10000*%eps then bugmes();quit;end
+if Err(svd(A)-diag(S))> 10000*%eps then bugmes();quit;end
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>10000*%eps then bugmes();quit;end
+A=A';
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>10000*%eps then bugmes();quit;end
+if Err(svd(A)-diag(S))> 10000*%eps then bugmes();quit;end
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>10000*%eps then bugmes();quit;end
+//Complex Case
+[U,S,V]=svd(Ac);
+if Err(U*S*V'-Ac)>10000*%eps then bugmes();quit;end
+if Err(svd(Ac)-diag(S))> 10000*%eps then bugmes();quit;end
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>10000*%eps then bugmes();quit;end
+Ac=Ac';
+[U,S,V]=svd(Ac);U*S*V'-Ac;
+if Err(U*S*V'-Ac)>10000*%eps then bugmes();quit;end
+if Err(svd(Ac)-diag(S))> 10000*%eps then bugmes();quit;end
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>10000*%eps then bugmes();quit;end
+//==========================================================================
+//============================== svd part II =======================
+//==========================================================================
+//Empty matrix
+if svd([])<>[] then bugmes();quit;end
+if svd([],"e")<>[] then bugmes();quit;end
+[U,S]=svd([]);
+if U<>[]|S<>[] then bugmes();quit;end
+[U,S,V]=svd([]);
+if U<>[]|S<>[]|V<>[] then bugmes();quit;end
+[U,S,V,rk]=svd([]);
+if U<>[]|S<>[]|V<>[]|rk<>0 then bugmes();quit;end
+[U,S,V,rk]=svd([],%eps);
+if U<>[]|S<>[]|V<>[]|rk<>0 then bugmes();quit;end
+if execstr('[U,S,V,rk]=svd([],'"e'")','errcatch') == 0 then bugmes();quit;end
+//Small dimension
+//Real Case Fat
+A=rand(3,5);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>10*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>200*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>200*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >200*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U-U1)>10*%eps then bugmes();quit;end
+if Err(U1*S1*V1'-A) >200*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U-U1)>200*%eps then bugmes();quit;end
+if Err(V-V1) >200*%eps then bugmes();quit;end
+if rk<>3 then bugmes();quit;end
+//Real Case Tall
+A=rand(5,3);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>200*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>200*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>200*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >200*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if size(U1,2)<>3 then bugmes();quit;end
+if Err(U1*S1*V1'-A) >200*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U-U1)>200*%eps then bugmes();quit;end
+if Err(V-V1) >200*%eps then bugmes();quit;end
+if rk<>3 then bugmes();quit;end
+//Complex Case Fat
+A=rand(3,5)+%i*rand(3,5);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>200*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>200*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>200*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >30*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U-U1)>200*%eps then bugmes();quit;end
+if Err(U1*S1*V1'-A) >200*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U-U1)>200*%eps then bugmes();quit;end
+if Err(V-V1) >200*%eps then bugmes();quit;end
+if rk<>3 then bugmes();quit;end
+//Complex Case Tall
+A=rand(5,3)+%i*rand(5,3);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>200*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>200*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U'*U-eye())>200*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >200*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if size(U1,2)<>3 then bugmes();quit;end
+if Err(U1*S1*V1'-A) >200*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then bugmes();quit;end
+if Err(U-U1)>200*%eps then bugmes();quit;end
+if Err(V-V1) >200*%eps then bugmes();quit;end
+if rk<>3 then bugmes();quit;end
+//Large dimension
+//Real Case Fat
+A=rand(30,50);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>1000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>1000*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>1000*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>1000*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>1000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>1000*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >1000*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>1000*%eps then bugmes();quit;end
+if Err(U-U1)>10*%eps then bugmes();quit;end
+if Err(U1*S1*V1'-A) >1000*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>1000*%eps then bugmes();quit;end
+if Err(U-U1)>5000*%eps then bugmes();quit;end
+if Err(V-V1) >5000*%eps then bugmes();quit;end
+if rk<>30 then bugmes();quit;end
+//Real Case Tall
+A=rand(50,30);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>5000*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>5000*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>5000*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >5000*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if size(U1,2)<>30 then bugmes();quit;end
+if Err(U1*S1*V1'-A) >5000*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U-U1)>5000*%eps then bugmes();quit;end
+if Err(V-V1) >5000*%eps then bugmes();quit;end
+if rk<>30 then bugmes();quit;end
+//Complex Case Fat
+A=rand(30,50)+%i*rand(30,50);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>5000*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>5000*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>5000*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >5000*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U-U1)>5000*%eps then bugmes();quit;end
+if Err(U1*S1*V1'-A) >5000*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U-U1)>5000*%eps then bugmes();quit;end
+if Err(V-V1) >5000*%eps then bugmes();quit;end
+if rk<>30 then bugmes();quit;end
+//Complex Case Tall
+A=rand(50,30)+%i*rand(50,30);
+S=svd(A);
+if or(S<0) then bugmes();quit;end
+if gsort(S)<>S then bugmes();quit;end
+[U,S1]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>5000*%eps then bugmes();quit;end
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U1'*U1-eye())>5000*%eps then bugmes();quit;end
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U'*U-eye())>5000*%eps then bugmes();quit;end
+if Err(U1*S1*V'-A) >5000*%eps then bugmes();quit;end
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if size(U1,2)<>30 then bugmes();quit;end
+if Err(U1*S1*V1'-A) >5000*%eps then bugmes();quit;end
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>5000*%eps then bugmes();quit;end
+if Err(U-U1)>5000*%eps then bugmes();quit;end
+if Err(V-V1) >5000*%eps then bugmes();quit;end
+if rk<>30 then bugmes();quit;end
diff --git a/modules/linear_algebra/tests/unit_tests/svd.tst b/modules/linear_algebra/tests/unit_tests/svd.tst
new file mode 100755
index 000000000..68c2ca6e0
--- /dev/null
+++ b/modules/linear_algebra/tests/unit_tests/svd.tst
@@ -0,0 +1,376 @@
+// =============================================================================
+// 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.
+// =============================================================================
+function r=Err(x)
+ r=norm(x,1)
+endfunction
+rand('normal')
+
+//==========================================================================
+//============================== svd ==============================
+//==========================================================================
+//Empty matrix
+A=[];
+[U,S,V]=svd(A);
+if U<>[]|V<>[]|S<>[] then pause,end
+S=svd(A);
+if S<>[] then pause,end
+[U,S,V]=svd(A,"e");
+if U<>[]|V<>[]|S<>[] then pause,end
+
+S=svd(A,"e");
+if S<>[] then pause,end
+
+//Matrix with inf or nan
+if execstr('svd([%inf 1;2 3])','errcatch')==0 then pause,end
+if execstr('svd([1 %nan;2 3])','errcatch')==0 then pause,end
+
+if execstr('svd([%inf %i;2 3])','errcatch')==0 then pause,end
+if execstr('svd([%i %i;%nan 3])','errcatch')==0 then pause,end
+
+
+//Small dimension
+//---------------
+A=rand(3,5);
+Ac=A+%i*rand(A);
+
+//Real Case
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>200*%eps then pause,end
+if Err(svd(A)-diag(S))> 200*%eps then pause,end
+
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>200*%eps then pause,end
+
+A=A';
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>200*%eps then pause,end
+if Err(svd(A)-diag(S))> 200*%eps then pause,end
+
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>200*%eps then pause,end
+
+
+//Complex Case
+[U,S,V]=svd(Ac);
+if Err(U*S*V'-Ac)>200*%eps then pause,end
+if Err(svd(Ac)-diag(S))> 200*%eps then pause,end
+
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>200*%eps then pause,end
+
+Ac=Ac';
+[U,S,V]=svd(Ac);U*S*V'-Ac;
+if Err(U*S*V'-Ac)>200*%eps then pause,end
+if Err(svd(Ac)-diag(S))> 200*%eps then pause,end
+
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>200*%eps then pause,end
+
+
+//Large dimension
+//---------------
+A=rand(150,60);
+Ac=A+rand(A)*%i;
+//Real Case
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>10000*%eps then pause,end
+if Err(svd(A)-diag(S))> 10000*%eps then pause,end
+
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>10000*%eps then pause,end
+
+A=A';
+[U,S,V]=svd(A);
+if Err(U*S*V'-A)>10000*%eps then pause,end
+if Err(svd(A)-diag(S))> 10000*%eps then pause,end
+
+[U,S,V]=svd(A,"e");
+if Err(U*S*V'-A)>10000*%eps then pause,end
+
+
+//Complex Case
+[U,S,V]=svd(Ac);
+if Err(U*S*V'-Ac)>10000*%eps then pause,end
+if Err(svd(Ac)-diag(S))> 10000*%eps then pause,end
+
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>10000*%eps then pause,end
+
+Ac=Ac';
+[U,S,V]=svd(Ac);U*S*V'-Ac;
+if Err(U*S*V'-Ac)>10000*%eps then pause,end
+if Err(svd(Ac)-diag(S))> 10000*%eps then pause,end
+
+[U,S,V]=svd(Ac,"e");
+if Err(U*S*V'-Ac)>10000*%eps then pause,end
+
+//==========================================================================
+//============================== svd part II =======================
+//==========================================================================
+//Empty matrix
+if svd([])<>[] then pause,end
+if svd([],"e")<>[] then pause,end
+
+[U,S]=svd([]);
+if U<>[]|S<>[] then pause,end
+[U,S,V]=svd([]);
+if U<>[]|S<>[]|V<>[] then pause,end
+[U,S,V,rk]=svd([]);
+if U<>[]|S<>[]|V<>[]|rk<>0 then pause,end
+[U,S,V,rk]=svd([],%eps);
+if U<>[]|S<>[]|V<>[]|rk<>0 then pause,end
+
+if execstr('[U,S,V,rk]=svd([],'"e'")','errcatch') == 0 then pause,end
+
+//Small dimension
+//Real Case Fat
+A=rand(3,5);
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>10*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U1'*U1-eye())>200*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>200*%eps then pause,end
+if Err(U1*S1*V'-A) >200*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U-U1)>10*%eps then pause,end
+if Err(U1*S1*V1'-A) >200*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U-U1)>200*%eps then pause,end
+if Err(V-V1) >200*%eps then pause,end
+if rk<>3 then pause,end
+
+//Real Case Tall
+A=rand(5,3);
+
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>200*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U1'*U1-eye())>200*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>200*%eps then pause,end
+if Err(U1*S1*V'-A) >200*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if size(U1,2)<>3 then pause,end
+if Err(U1*S1*V1'-A) >200*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U-U1)>200*%eps then pause,end
+if Err(V-V1) >200*%eps then pause,end
+if rk<>3 then pause,end
+
+//Complex Case Fat
+A=rand(3,5)+%i*rand(3,5);
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>200*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U1'*U1-eye())>200*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>200*%eps then pause,end
+if Err(U1*S1*V'-A) >30*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U-U1)>200*%eps then pause,end
+if Err(U1*S1*V1'-A) >200*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U-U1)>200*%eps then pause,end
+if Err(V-V1) >200*%eps then pause,end
+if rk<>3 then pause,end
+
+//Complex Case Tall
+A=rand(5,3)+%i*rand(5,3);
+
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>200*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U1'*U1-eye())>200*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U'*U-eye())>200*%eps then pause,end
+if Err(U1*S1*V'-A) >200*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>200*%eps then pause,end
+if size(U1,2)<>3 then pause,end
+if Err(U1*S1*V1'-A) >200*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>200*%eps then pause,end
+if Err(U-U1)>200*%eps then pause,end
+if Err(V-V1) >200*%eps then pause,end
+if rk<>3 then pause,end
+
+
+//Large dimension
+//Real Case Fat
+A=rand(30,50);
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>1000*%eps then pause,end
+if Err(U'*U-eye())>1000*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>1000*%eps then pause,end
+if Err(U1'*U1-eye())>1000*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>1000*%eps then pause,end
+if Err(U'*U-eye())>1000*%eps then pause,end
+if Err(U1*S1*V'-A) >1000*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>1000*%eps then pause,end
+if Err(U-U1)>10*%eps then pause,end
+if Err(U1*S1*V1'-A) >1000*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>1000*%eps then pause,end
+if Err(U-U1)>5000*%eps then pause,end
+if Err(V-V1) >5000*%eps then pause,end
+if rk<>30 then pause,end
+
+//Real Case Tall
+A=rand(50,30);
+
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U'*U-eye())>5000*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U1'*U1-eye())>5000*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U'*U-eye())>5000*%eps then pause,end
+if Err(U1*S1*V'-A) >5000*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then pause,end
+if size(U1,2)<>30 then pause,end
+if Err(U1*S1*V1'-A) >5000*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U-U1)>5000*%eps then pause,end
+if Err(V-V1) >5000*%eps then pause,end
+if rk<>30 then pause,end
+
+//Complex Case Fat
+A=rand(30,50)+%i*rand(30,50);
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U'*U-eye())>5000*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U1'*U1-eye())>5000*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U'*U-eye())>5000*%eps then pause,end
+if Err(U1*S1*V'-A) >5000*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U-U1)>5000*%eps then pause,end
+if Err(U1*S1*V1'-A) >5000*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U-U1)>5000*%eps then pause,end
+if Err(V-V1) >5000*%eps then pause,end
+if rk<>30 then pause,end
+
+//Complex Case Tall
+A=rand(50,30)+%i*rand(50,30);
+
+S=svd(A);
+if or(S<0) then pause,end
+if gsort(S)<>S then pause,end
+
+[U,S1]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U'*U-eye())>5000*%eps then pause,end
+
+[U1,S1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U1'*U1-eye())>5000*%eps then pause,end
+
+[U1,S1,V]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U'*U-eye())>5000*%eps then pause,end
+if Err(U1*S1*V'-A) >5000*%eps then pause,end
+
+[U1,S1,V1]=svd(A,"e");
+if Err(S-diag(S1))>5000*%eps then pause,end
+if size(U1,2)<>30 then pause,end
+if Err(U1*S1*V1'-A) >5000*%eps then pause,end
+
+[U1,S1,V1,rk]=svd(A);
+if Err(S-diag(S1))>5000*%eps then pause,end
+if Err(U-U1)>5000*%eps then pause,end
+if Err(V-V1) >5000*%eps then pause,end
+if rk<>30 then pause,end
+
+