summaryrefslogtreecommitdiff
path: root/modules/cacsd/tests
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/cacsd/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/cacsd/tests')
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_10370.dia.ref25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_10370.tst29
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_11092.dia.ref43
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_11092.tst23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_11300.dia.ref21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_11300.tst25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_11941.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_11941.tst20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_1198.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_1198.tst21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_11980.tst32
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12115.dia.ref20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12115.tst21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12174.dia.ref31
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12174.tst34
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12221.dia.ref24
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12221.tst25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12629.dia.ref21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12629.tst23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12828.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12828.tst20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12829.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12829.tst20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12875.dia.ref17
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_12875.tst18
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13170.dia.ref23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13170.tst26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13233.dia.ref39
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13233.tst41
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13359.dia.ref24
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13359.tst26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13482.dia.ref21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13482.tst23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13791.dia.ref26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_13791.tst28
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_1508.dia.ref18
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_1508.tst22
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_2252.dia.ref23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_2252.tst26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_2836.dia.ref26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_2836.tst29
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3323.dia.ref16
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3323.tst19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3767.dia.ref22
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3767.tst27
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3783.dia.ref22
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3783.tst21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3796.dia.ref43
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3796.tst53
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3880.dia.ref24
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3880.tst20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3934.dia.ref49
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3934.tst56
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3967.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_3967.tst24
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4275.dia.ref18
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4275.tst20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4297.dia.ref15
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4297.tst20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4319.dia.ref48
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4319.tst33
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4383.dia.ref24
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4383.tst26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4505.dia.ref43
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4505.tst41
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4596.dia.ref25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4596.tst22
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4731.dia.ref25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4731.tst26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4767.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4767.tst22
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4799.dia.ref25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_4799.tst31
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_549.dia.ref30
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_549.tst33
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6538.dia.ref20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6538.tst23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6635.dia.ref29
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6635.tst36
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6744.dia.ref23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6744.tst26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6745.dia.ref21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6745.tst23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_68.dia.ref123
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_68.tst137
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6829.dia.ref26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6829.tst29
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6883.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_6883.tst21
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_7566.dia.ref43
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_7566.tst56
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_7828.dia.ref17
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_7828.tst18
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_7960.dia.ref39
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_7960.tst42
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_8162.dia.ref26
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_8162.tst27
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_8174.dia.ref25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_8174.tst25
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_8319.dia.ref20
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_8319.tst22
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_9098.dia.ref22
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_9098.tst23
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_9285.dia.ref63
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_9285.tst41
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_9836.tst39
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_9836.unix.dia.ref36
-rwxr-xr-xmodules/cacsd/tests/nonreg_tests/bug_9836.win.dia.ref36
-rwxr-xr-xmodules/cacsd/tests/unit_tests/arma.dia.ref78
-rwxr-xr-xmodules/cacsd/tests/unit_tests/arma.tst98
-rwxr-xr-xmodules/cacsd/tests/unit_tests/arma2ss.dia.ref83
-rwxr-xr-xmodules/cacsd/tests/unit_tests/arma2ss.tst80
-rwxr-xr-xmodules/cacsd/tests/unit_tests/bode.dia.ref133
-rwxr-xr-xmodules/cacsd/tests/unit_tests/bode.tst145
-rwxr-xr-xmodules/cacsd/tests/unit_tests/calfrq.dia.ref85
-rwxr-xr-xmodules/cacsd/tests/unit_tests/calfrq.tst104
-rwxr-xr-xmodules/cacsd/tests/unit_tests/coff.dia.ref12
-rwxr-xr-xmodules/cacsd/tests/unit_tests/coff.tst13
-rwxr-xr-xmodules/cacsd/tests/unit_tests/contr.dia.ref57
-rwxr-xr-xmodules/cacsd/tests/unit_tests/contr.tst71
-rwxr-xr-xmodules/cacsd/tests/unit_tests/contrss.dia.ref39
-rwxr-xr-xmodules/cacsd/tests/unit_tests/contrss.tst48
-rwxr-xr-xmodules/cacsd/tests/unit_tests/csim.dia.ref111
-rwxr-xr-xmodules/cacsd/tests/unit_tests/csim.tst143
-rwxr-xr-xmodules/cacsd/tests/unit_tests/damp.dia.ref100
-rwxr-xr-xmodules/cacsd/tests/unit_tests/damp.tst115
-rwxr-xr-xmodules/cacsd/tests/unit_tests/dhinf.dia.ref58
-rwxr-xr-xmodules/cacsd/tests/unit_tests/dhinf.tst59
-rwxr-xr-xmodules/cacsd/tests/unit_tests/dscr.dia.ref44
-rwxr-xr-xmodules/cacsd/tests/unit_tests/dscr.tst52
-rwxr-xr-xmodules/cacsd/tests/unit_tests/flts.dia.ref22
-rwxr-xr-xmodules/cacsd/tests/unit_tests/flts.tst26
-rwxr-xr-xmodules/cacsd/tests/unit_tests/freq.dia.ref27
-rwxr-xr-xmodules/cacsd/tests/unit_tests/freq.tst30
-rwxr-xr-xmodules/cacsd/tests/unit_tests/freqplots.dia.ref51
-rwxr-xr-xmodules/cacsd/tests/unit_tests/freqplots.tst50
-rwxr-xr-xmodules/cacsd/tests/unit_tests/hinf.dia.ref47
-rwxr-xr-xmodules/cacsd/tests/unit_tests/hinf.tst56
-rwxr-xr-xmodules/cacsd/tests/unit_tests/linmeq.dia.ref831
-rwxr-xr-xmodules/cacsd/tests/unit_tests/linmeq.tst914
-rwxr-xr-xmodules/cacsd/tests/unit_tests/margins.dia.ref123
-rwxr-xr-xmodules/cacsd/tests/unit_tests/margins.tst151
-rwxr-xr-xmodules/cacsd/tests/unit_tests/nyquist.dia.ref154
-rwxr-xr-xmodules/cacsd/tests/unit_tests/nyquist.tst158
-rwxr-xr-xmodules/cacsd/tests/unit_tests/odedi.dia.ref22
-rwxr-xr-xmodules/cacsd/tests/unit_tests/odedi.tst28
-rwxr-xr-xmodules/cacsd/tests/unit_tests/plzr.dia.ref126
-rwxr-xr-xmodules/cacsd/tests/unit_tests/plzr.tst137
-rwxr-xr-xmodules/cacsd/tests/unit_tests/rankqr.dia.ref23
-rwxr-xr-xmodules/cacsd/tests/unit_tests/rankqr.tst25
-rwxr-xr-xmodules/cacsd/tests/unit_tests/ricc.dia.ref16
-rwxr-xr-xmodules/cacsd/tests/unit_tests/ricc.tst18
-rwxr-xr-xmodules/cacsd/tests/unit_tests/riccati.dia.ref31
-rwxr-xr-xmodules/cacsd/tests/unit_tests/riccati.tst44
-rwxr-xr-xmodules/cacsd/tests/unit_tests/routh_t.dia.ref45
-rwxr-xr-xmodules/cacsd/tests/unit_tests/routh_t.tst53
-rwxr-xr-xmodules/cacsd/tests/unit_tests/ss2tf.dia.ref84
-rwxr-xr-xmodules/cacsd/tests/unit_tests/ss2tf.tst50
-rwxr-xr-xmodules/cacsd/tests/unit_tests/sylv.dia.ref19
-rwxr-xr-xmodules/cacsd/tests/unit_tests/sylv.tst29
-rwxr-xr-xmodules/cacsd/tests/unit_tests/syslin.dia.ref73
-rwxr-xr-xmodules/cacsd/tests/unit_tests/syslin.tst83
-rwxr-xr-xmodules/cacsd/tests/unit_tests/tf2ss.dia.ref47
-rwxr-xr-xmodules/cacsd/tests/unit_tests/tf2ss.tst53
164 files changed, 8521 insertions, 0 deletions
diff --git a/modules/cacsd/tests/nonreg_tests/bug_10370.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_10370.dia.ref
new file mode 100755
index 000000000..a3eafa7ec
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_10370.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10370 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10370
+//
+// <-- Short Description -->
+// ss2tf returned a wrong value on Windows 64 bit
+A2 = [0 1 0
+ 1 0 1
+ 0 0 -1];
+B2 = [0;0;10.523];
+C2 = [1 0 0];
+sl2 = syslin('c', A2,B2,C2);
+G2 = clean(ss2tf(sl2));
+REF = 10.523/ (-1 -%s + (%s*%s) + (%s*%s*%s));
+assert_checkalmostequal(coeff(G2(2)), coeff(REF(2)));
+assert_checkalmostequal(coeff(G2(3)), coeff(REF(3)));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_10370.tst b/modules/cacsd/tests/nonreg_tests/bug_10370.tst
new file mode 100755
index 000000000..b7fea6f80
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_10370.tst
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 10370 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=10370
+//
+// <-- Short Description -->
+// ss2tf returned a wrong value on Windows 64 bit
+
+
+A2 = [0 1 0
+ 1 0 1
+ 0 0 -1];
+B2 = [0;0;10.523];
+C2 = [1 0 0];
+
+sl2 = syslin('c', A2,B2,C2);
+G2 = clean(ss2tf(sl2));
+REF = 10.523/ (-1 -%s + (%s*%s) + (%s*%s*%s));
+assert_checkalmostequal(coeff(G2(2)), coeff(REF(2)));
+assert_checkalmostequal(coeff(G2(3)), coeff(REF(3)));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_11092.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_11092.dia.ref
new file mode 100755
index 000000000..001b8b840
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_11092.dia.ref
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- ENGLISH IMPOSED -->
+//
+//
+// <-- Non-regression test for bug 11092 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11092
+//
+// <-- Short Description -->
+//Incorrect argument check in h_inf
+G=syslin("c",1/%s^3);
+[P,r]=macglov(G);
+assert_checktrue(execstr("[K,ro]=h_inf(P,r,0,1,30)","errcatch")==0);
+h_inf: P22 is stabilizable.
+h_inf: P22 is detectable.
+ gama = 1.4142135624 Unfeasible (Hx hamiltonian) test = 0.30000E+01
+ gama = 2.0000000000 Unfeasible (Hx hamiltonian) test = 0.15613E+01
+ gama = 2.8284271247 Unfeasible (Hx hamiltonian) test = 0.13582E+01
+ gama = 4.0000000000 Unfeasible (Hx hamiltonian) test = 0.20258E+01
+ gama = 5.6568542495 Unfeasible (Hx hamiltonian) test = 0.16526E+02
+ gama = 5.8423739467 Unfeasible (Hx hamiltonian) test = 0.60242E+02
+ gama = 5.8916775545 Unfeasible (Hx hamiltonian) test = 0.19635E+03
+ gama = 5.9041997314 Unfeasible (Hx hamiltonian) test = 0.45849E+03
+ gama = 5.9104908357 Unfeasible (Hx hamiltonian) test = 0.13893E+04
+ gama = 5.9120667565 Unfeasible (Hx hamiltonian) test = 0.28256E+04
+ gama = 5.9128551898 Unfeasible (Hx hamiltonian) test = 0.58522E+04
+ gama = 5.9132495247 Unfeasible (Hx hamiltonian) test = 0.12603E+05
+ gama = 5.9134467218 Unfeasible (Hx hamiltonian) test = 0.29787E+05
+ gama = 5.9135453277 Unfeasible (Hx hamiltonian) test = 0.93598E+05
+ gama = 5.9135699799 Unfeasible (Hx hamiltonian) test = 0.20153E+06
+ gama = 5.9135823062 Unfeasible (Hx hamiltonian) test = 0.47597E+06
+ gama = 5.9135884693 Unfeasible (Hx hamiltonian) test = 0.14915E+07
+ gama = 5.9135900101 Unfeasible (Hx hamiltonian) test = 0.31966E+07
+ gama = 5.9135907805 Unfeasible (Hx hamiltonian) test = 0.74615E+07
+ gama = 5.9135911657 Unfeasible (Hx hamiltonian) test = 0.22414E+08
+ gama = 5.9135912620 Unfeasible (Hx hamiltonian) test = 0.44919E+08
diff --git a/modules/cacsd/tests/nonreg_tests/bug_11092.tst b/modules/cacsd/tests/nonreg_tests/bug_11092.tst
new file mode 100755
index 000000000..4fcfc187d
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_11092.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+// <-- ENGLISH IMPOSED -->
+//
+//
+// <-- Non-regression test for bug 11092 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11092
+//
+// <-- Short Description -->
+//Incorrect argument check in h_inf
+
+
+G=syslin("c",1/%s^3);
+[P,r]=macglov(G);
+assert_checktrue(execstr("[K,ro]=h_inf(P,r,0,1,30)","errcatch")==0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_11300.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_11300.dia.ref
new file mode 100755
index 000000000..7434e0692
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_11300.dia.ref
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+//
+// <-- Non-regression test for bug 11300 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11300
+//
+// <-- Short Description -->
+// freson calculates wrong frequencies
+s = %s;
+h = syslin('c', 0.5 * (2*s+1)/s^2 / (s^2 + 0.4*s + 4));
+hc = (2*h) /. 1;
+ref= [0.3098445669312;0.0720289283079];
+assert_checkalmostequal(freson(hc), ref);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_11300.tst b/modules/cacsd/tests/nonreg_tests/bug_11300.tst
new file mode 100755
index 000000000..7c8c77a50
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_11300.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+//
+//
+// <-- Non-regression test for bug 11300 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11300
+//
+// <-- Short Description -->
+// freson calculates wrong frequencies
+
+s = %s;
+h = syslin('c', 0.5 * (2*s+1)/s^2 / (s^2 + 0.4*s + 4));
+hc = (2*h) /. 1;
+
+ref= [0.3098445669312;0.0720289283079];
+
+assert_checkalmostequal(freson(hc), ref);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_11941.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_11941.dia.ref
new file mode 100755
index 000000000..06a58a021
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_11941.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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 11941 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11941
+//
+// <-- Short Description -->
+// show_margins() fails in 'nyquist' mode if the system is in state-space form. It
+// assumes the system is in transfer function form and calls horner() with it.
+h=syslin('c',0.02909+0.11827*%s+0.12823*%s^2+0.35659*%s^3+0.256*%s^4+0.1*%s^5,..
+ 0.0409+0.1827*%s+1.28225*%s^2+3.1909*%s^3+2.56*%s^4+%s^5);
+h1=tf2ss(h);
+assert_checktrue(execstr("show_margins(h1,""nyquist"");","errcatch")==0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_11941.tst b/modules/cacsd/tests/nonreg_tests/bug_11941.tst
new file mode 100755
index 000000000..711e3b616
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_11941.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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 11941 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11941
+//
+// <-- Short Description -->
+// show_margins() fails in 'nyquist' mode if the system is in state-space form. It
+// assumes the system is in transfer function form and calls horner() with it.
+
+h=syslin('c',0.02909+0.11827*%s+0.12823*%s^2+0.35659*%s^3+0.256*%s^4+0.1*%s^5,..
+ 0.0409+0.1827*%s+1.28225*%s^2+3.1909*%s^3+2.56*%s^4+%s^5);
+h1=tf2ss(h);
+assert_checktrue(execstr("show_margins(h1,""nyquist"");","errcatch")==0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_1198.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_1198.dia.ref
new file mode 100755
index 000000000..bf479b645
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_1198.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 1198 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=1198
+//
+// <-- Short Description -->
+// For the latest version of Scilab scilab-3.0-u-20050128 on a
+// Windows 2000 platform.
+//
+// The program crashes instead of reporting a syntax error.
+G = syslin('c', [1 0 ; 0 1], [ 1; 1], [1 1]);
+err = execstr("minss(G)(""A"");","errcatch");
+if err <> 250 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_1198.tst b/modules/cacsd/tests/nonreg_tests/bug_1198.tst
new file mode 100755
index 000000000..44cdafe46
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_1198.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 1198 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=1198
+//
+// <-- Short Description -->
+// For the latest version of Scilab scilab-3.0-u-20050128 on a
+// Windows 2000 platform.
+//
+// The program crashes instead of reporting a syntax error.
+
+G = syslin('c', [1 0 ; 0 1], [ 1; 1], [1 1]);
+err = execstr("minss(G)(""A"");","errcatch");
+if err <> 250 then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_11980.tst b/modules/cacsd/tests/nonreg_tests/bug_11980.tst
new file mode 100755
index 000000000..bcd48c19a
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_11980.tst
@@ -0,0 +1,32 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// English imposed for warnings
+// <-- ENGLISH IMPOSED -->
+//
+// Ref not checked because of many lsode outputs which are different according to platform (x86/x64).
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 11980 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11980
+//
+// <-- Short Description -->
+// Submatrix incorrectly defined.
+// at line 148 of function csim called by :
+// y=csim('step',t,numerador/denominador).
+
+s=poly(0,'s'); funcprot(0);
+kp=96.770532;
+ki=42.568724;
+kd=18.711118;
+numerador=s^5*kd+s^4*(60*kd+kp)+s^3*(1500*kd-60*kp+ki)+s^2*(-15000*kd+1500*kp-60*ki)+s*(-15000*kp+1500*ki)-15000*ki;
+denominador=s^5*(kd)+s^4*(-1-60*kd+kp)+s^3*(-1500-60+1500*kd-60*kp+ki)+s^2*(-15000-1500-15000*kd+1500*kp-60*ki)+s*(-15000-15000*kp+1500*ki)-15000*ki;
+t=0:0.01:100;
+errMsg = msprintf(_("%s: Simulation failed before final time is reached.\n"),"csim");
+assert_checkerror("csim(""step"",t,numerador/denominador);", errMsg);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12115.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_12115.dia.ref
new file mode 100755
index 000000000..c1285d097
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12115.dia.ref
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12115 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12115
+//
+// <-- Short Description -->
+// phaseplot(frq,db,phi) did not work.
+s=poly(0,"s");
+h=syslin("c",(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+h1=h*syslin("c",(s^2+2*0.1*15.1*s+228.01)/(s^2+2*0.9*15*s+225));
+[frq,repf]=repfreq([h;h1],0.01,100);
+[phi,db]=phasemag(repf);
+phaseplot(frq,db,phi)
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12115.tst b/modules/cacsd/tests/nonreg_tests/bug_12115.tst
new file mode 100755
index 000000000..dad1a5b5c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12115.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12115 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12115
+//
+// <-- Short Description -->
+// phaseplot(frq,db,phi) did not work.
+
+s=poly(0,"s");
+h=syslin("c",(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+h1=h*syslin("c",(s^2+2*0.1*15.1*s+228.01)/(s^2+2*0.9*15*s+225));
+[frq,repf]=repfreq([h;h1],0.01,100);
+[phi,db]=phasemag(repf);
+phaseplot(frq,db,phi)
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12174.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_12174.dia.ref
new file mode 100755
index 000000000..6809cde8c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12174.dia.ref
@@ -0,0 +1,31 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12174 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12174
+//
+// <-- Short Description -->
+// The function routh_t gives incorrect output for all denominators that include
+// gain value "k".
+s = poly(0, 's');
+k = poly(0,'k');
+P=s*(s+7)*(s+11);
+h=1/P;
+r_rat=routh_t(h,k,%t);
+r_poly=routh_t(h,k,%f);
+ref_rat=[1 77; 18 k;(1386-k)/18 0; k 0];
+numref=numer(ref_rat);
+numref(3)=1386 - k;
+denr=denom(r_rat);
+denr=horner(denr,1);
+denref=denom(ref_rat);
+denref(3)=18;
+ref_poly=[1 77; 18 k; 1386-k 0; 1386*k-k*k 0];
+assert_checkequal(numer(r_rat)/denr,numref/denref);
+assert_checkequal(r_poly,ref_poly);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12174.tst b/modules/cacsd/tests/nonreg_tests/bug_12174.tst
new file mode 100755
index 000000000..518753e27
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12174.tst
@@ -0,0 +1,34 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12174 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12174
+//
+// <-- Short Description -->
+// The function routh_t gives incorrect output for all denominators that include
+// gain value "k".
+
+s = poly(0, 's');
+k = poly(0,'k');
+P=s*(s+7)*(s+11);
+h=1/P;
+r_rat=routh_t(h,k,%t);
+r_poly=routh_t(h,k,%f);
+
+ref_rat=[1 77; 18 k;(1386-k)/18 0; k 0];
+numref=numer(ref_rat);
+numref(3)=1386 - k;
+denr=denom(r_rat);
+denr=horner(denr,1);
+denref=denom(ref_rat);
+denref(3)=18;
+ref_poly=[1 77; 18 k; 1386-k 0; 1386*k-k*k 0];
+
+assert_checkequal(numer(r_rat)/denr,numref/denref);
+assert_checkequal(r_poly,ref_poly);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12221.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_12221.dia.ref
new file mode 100755
index 000000000..9c0d457fb
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12221.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12221 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12221
+//
+// <-- Short Description -->
+// fspec is not documented and there was an error message "undefined variable: Sl".
+a=-1000;
+b=5;
+c=5;
+d=5;
+sl=syslin('c',a,b,c,d);
+res=fspec(sl);
+ref=[-1000 5 2.2305056 2.236068 0];
+for i=1:5
+assert_checkalmostequal(ref(i),res(i+1));
+end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12221.tst b/modules/cacsd/tests/nonreg_tests/bug_12221.tst
new file mode 100755
index 000000000..264b68515
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12221.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12221 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12221
+//
+// <-- Short Description -->
+// fspec is not documented and there was an error message "undefined variable: Sl".
+
+a=-1000;
+b=5;
+c=5;
+d=5;
+sl=syslin('c',a,b,c,d);
+res=fspec(sl);
+ref=[-1000 5 2.2305056 2.236068 0];
+for i=1:5
+assert_checkalmostequal(ref(i),res(i+1));
+end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12629.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_12629.dia.ref
new file mode 100755
index 000000000..2da963d0a
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12629.dia.ref
@@ -0,0 +1,21 @@
+// =============================================================================
+// 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 12629 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12629
+//
+// <-- Short Description -->
+// Last example of csim help page defines a function input() overwriting the scilab one
+s=poly(0,'s');
+rand('seed',0);
+w=ssrand(1,1,3);
+w('A')=w('A')-2*eye();
+t=0:0.05:5;
+assert_checktrue(execstr("deff(''u=timefun(t)'',''u=abs(sin(t))'');", "errcatch") == 0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12629.tst b/modules/cacsd/tests/nonreg_tests/bug_12629.tst
new file mode 100755
index 000000000..746e1d763
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12629.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 12629 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12629
+//
+// <-- Short Description -->
+// Last example of csim help page defines a function input() overwriting the scilab one
+
+s=poly(0,'s');
+rand('seed',0);
+w=ssrand(1,1,3);
+w('A')=w('A')-2*eye();
+t=0:0.05:5;
+assert_checktrue(execstr("deff(''u=timefun(t)'',''u=abs(sin(t))'');", "errcatch") == 0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12828.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_12828.dia.ref
new file mode 100755
index 000000000..e2629daa0
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12828.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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12828 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12828
+//
+// <-- Short Description -->
+// routh_t() function with two input argument (routh_t(h,kp)) gives a wrong table for the special case
+// in which the first element of a row is zero.
+s=%s;
+P=s^3+3*s;
+kp=2;
+routh_t(1/P, kp);
+assert_checkequal(routh_t(1/P, kp), routh_t(P+kp));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12828.tst b/modules/cacsd/tests/nonreg_tests/bug_12828.tst
new file mode 100755
index 000000000..8da7c4590
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12828.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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12828 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12828
+//
+// <-- Short Description -->
+// routh_t() function with two input argument (routh_t(h,kp)) gives a wrong table for the special case
+// in which the first element of a row is zero.
+
+s=%s;
+P=s^3+3*s;
+kp=2;
+routh_t(1/P, kp);
+assert_checkequal(routh_t(1/P, kp), routh_t(P+kp));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12829.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_12829.dia.ref
new file mode 100755
index 000000000..75085a4ae
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12829.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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12829 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12829
+//
+// <-- Short Description -->
+// routh_t() function with two input argument (routh_t(h,kp)) gives a wrong table for the special case
+// in which the first element of a row is zero.
+s=%s;
+P=5*s^3-10*s^2+7*s+20;
+routh_t((1+s)/P,10);
+[r, num]=routh_t(P);
+assert_checkequal(num, 2);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12829.tst b/modules/cacsd/tests/nonreg_tests/bug_12829.tst
new file mode 100755
index 000000000..8f543e5a8
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12829.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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12829 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12829
+//
+// <-- Short Description -->
+// routh_t() function with two input argument (routh_t(h,kp)) gives a wrong table for the special case
+// in which the first element of a row is zero.
+
+s=%s;
+P=5*s^3-10*s^2+7*s+20;
+routh_t((1+s)/P,10);
+[r, num]=routh_t(P);
+assert_checkequal(num, 2);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12875.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_12875.dia.ref
new file mode 100755
index 000000000..a7f04b74c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12875.dia.ref
@@ -0,0 +1,17 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12875 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12875
+//
+// <-- Short Description -->
+// phasemag returns an error for vector containing zero.
+assert_checkequal(phasemag([0 0]), [0 0]);
+assert_checkequal(phasemag([%i 0]), [90 0]);
+assert_checkequal(phasemag([-%i 0]), [-90 0]);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_12875.tst b/modules/cacsd/tests/nonreg_tests/bug_12875.tst
new file mode 100755
index 000000000..de1870572
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_12875.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12875 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12875
+//
+// <-- Short Description -->
+// phasemag returns an error for vector containing zero.
+
+assert_checkequal(phasemag([0 0]), [0 0]);
+assert_checkequal(phasemag([%i 0]), [90 0]);
+assert_checkequal(phasemag([-%i 0]), [-90 0]);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13170.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_13170.dia.ref
new file mode 100755
index 000000000..b99d7a75b
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13170.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13170 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13170
+//
+// <-- Short Description -->
+// plzr plotted wrong legends.
+s = %s;
+G1 = syslin("c", 1, s^3+s^2+5*s+2);
+G2 = syslin("c", s+3, s^3+s^2+5*s+2);
+plzr(G1);
+a = gce();
+assert_checkequal(a.text, _("Poles"));
+plzr(G2);
+b = gce();
+assert_checkequal(b.text, [_("Poles"); _("Zeros")]);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13170.tst b/modules/cacsd/tests/nonreg_tests/bug_13170.tst
new file mode 100755
index 000000000..41e3d90c1
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13170.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13170 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13170
+//
+// <-- Short Description -->
+// plzr plotted wrong legends.
+
+s = %s;
+G1 = syslin("c", 1, s^3+s^2+5*s+2);
+G2 = syslin("c", s+3, s^3+s^2+5*s+2);
+
+plzr(G1);
+a = gce();
+assert_checkequal(a.text, _("Poles"));
+
+plzr(G2);
+b = gce();
+assert_checkequal(b.text, [_("Poles"); _("Zeros")]);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13233.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_13233.dia.ref
new file mode 100755
index 000000000..290a3e18d
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13233.dia.ref
@@ -0,0 +1,39 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13233 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13233
+//
+// <-- Short Description -->
+// There is an offset in the result of a step response for transfer function
+// (a*s^2+b*s+c)/(d*s^2+e*s+f)
+s=poly(0,'s');
+Uo=6;
+Da=0.5;
+Go=1/15;
+L=0.00009;
+Rl=0.05;
+C=0.0004;
+Rc=0.1;
+Rt=0.2;
+Rd=0.07;
+Rz=Rl+Rt*Da+Rd*(1-Da);
+Cz=C*(1+Rc*Go);A0=Uo*Rz;
+A1=Uo*(L+C*Rc*Rz);
+A2=Uo*L*C*Rc;
+B0=1+Rz*Go;
+B1=L*Go+C*Rc+Rz*Cz;
+B2=L*Cz;
+H=syslin('c',-(A2*s^2+A1*s+A0)/(B2*s^2+B1*s+B0));
+t=[0:0.000001:0.005];
+ycsim=csim('step',t,H);
+sl=tf2ss(H);
+deff("[ydot]=%sim2(t,y)","ydot=sl.a*y+sl.b*1");
+x=ode("adams",zeros(2,1),0,t,414d-9,0.000001,%sim2);
+yode=sl.c*x+sl.d*1;
+assert_checkalmostequal(ycsim,yode,[],1e-4);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13233.tst b/modules/cacsd/tests/nonreg_tests/bug_13233.tst
new file mode 100755
index 000000000..205d1cf30
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13233.tst
@@ -0,0 +1,41 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13233 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13233
+//
+// <-- Short Description -->
+// There is an offset in the result of a step response for transfer function
+// (a*s^2+b*s+c)/(d*s^2+e*s+f)
+
+s=poly(0,'s');
+Uo=6;
+Da=0.5;
+Go=1/15;
+L=0.00009;
+Rl=0.05;
+C=0.0004;
+Rc=0.1;
+Rt=0.2;
+Rd=0.07;
+Rz=Rl+Rt*Da+Rd*(1-Da);
+Cz=C*(1+Rc*Go);A0=Uo*Rz;
+A1=Uo*(L+C*Rc*Rz);
+A2=Uo*L*C*Rc;
+B0=1+Rz*Go;
+B1=L*Go+C*Rc+Rz*Cz;
+B2=L*Cz;
+H=syslin('c',-(A2*s^2+A1*s+A0)/(B2*s^2+B1*s+B0));
+t=[0:0.000001:0.005];
+ycsim=csim('step',t,H);
+
+sl=tf2ss(H);
+deff("[ydot]=%sim2(t,y)","ydot=sl.a*y+sl.b*1");
+x=ode("adams",zeros(2,1),0,t,414d-9,0.000001,%sim2);
+yode=sl.c*x+sl.d*1;
+assert_checkalmostequal(ycsim,yode,[],1e-4);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13359.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_13359.dia.ref
new file mode 100755
index 000000000..40c1cf894
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13359.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13359 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13359
+//
+// <-- Short Description -->
+// Nyquist datatip were not displaying negative frequencies properly
+//
+// <-- TEST WITH GRAPHIC -->
+s = poly(0, 's');
+h = syslin('c', 1 / (s + 1));
+nyquist(h);
+ax = gca();
+pl = ax.children(1).children(2);
+d1 = datatipCreate(pl, 200);
+txt_datatip = d1.text;
+assert_checkequal(strindex(txt_datatip(2), "-"), 1);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13359.tst b/modules/cacsd/tests/nonreg_tests/bug_13359.tst
new file mode 100755
index 000000000..d5e208dbf
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13359.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13359 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13359
+//
+// <-- Short Description -->
+// Nyquist datatip were not displaying negative frequencies properly
+//
+// <-- TEST WITH GRAPHIC -->
+
+s = poly(0, 's');
+h = syslin('c', 1 / (s + 1));
+nyquist(h);
+
+ax = gca();
+pl = ax.children(1).children(2);
+d1 = datatipCreate(pl, 200);
+txt_datatip = d1.text;
+assert_checkequal(strindex(txt_datatip(2), "-"), 1);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13482.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_13482.dia.ref
new file mode 100755
index 000000000..325521c42
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13482.dia.ref
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13482 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13482
+//
+// <-- Short Description -->
+// pfss changed the variable of the rational fractions
+//
+// <-- CLI SHELL MODE -->
+f = %z / (2-%z) / (%z+1);
+d = pfss(f);
+// f and d must have the same variable name
+assert_checkequal(varn(f), varn(d(1)));
+assert_checkequal(varn(f), varn(d(2)));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13482.tst b/modules/cacsd/tests/nonreg_tests/bug_13482.tst
new file mode 100755
index 000000000..49cd2092a
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13482.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13482 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13482
+//
+// <-- Short Description -->
+// pfss changed the variable of the rational fractions
+//
+// <-- CLI SHELL MODE -->
+
+f = %z / (2-%z) / (%z+1);
+d = pfss(f);
+
+// f and d must have the same variable name
+assert_checkequal(varn(f), varn(d(1)));
+assert_checkequal(varn(f), varn(d(2)));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13791.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_13791.dia.ref
new file mode 100755
index 000000000..4f2583592
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13791.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 13791 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13791
+//
+// <-- Short Description -->
+// ricc() no longer accepts the 'invf' method.
+//
+F = rand(3,3);
+G1 = rand(3,2);
+R = rand(2,2);
+G2 = R*R'+eye();
+G = G1/G2*G1';
+C = rand(3,3);
+H = C*C';
+ierr = execstr("X=ricc(F,G,H,""disc"",""invf"");", "errcatch");
+assert_checktrue(ierr==0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_13791.tst b/modules/cacsd/tests/nonreg_tests/bug_13791.tst
new file mode 100755
index 000000000..191b674d8
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_13791.tst
@@ -0,0 +1,28 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 13791 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13791
+//
+// <-- Short Description -->
+// ricc() no longer accepts the 'invf' method.
+//
+
+F = rand(3,3);
+G1 = rand(3,2);
+R = rand(2,2);
+G2 = R*R'+eye();
+G = G1/G2*G1';
+C = rand(3,3);
+H = C*C';
+
+ierr = execstr("X=ricc(F,G,H,""disc"",""invf"");", "errcatch");
+assert_checktrue(ierr==0); \ No newline at end of file
diff --git a/modules/cacsd/tests/nonreg_tests/bug_1508.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_1508.dia.ref
new file mode 100755
index 000000000..7a2f85c3a
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_1508.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 1508 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=1508
+//
+// <-- Short Description -->
+// A transfer function with small numeric values is assumed not to be SISO, when used in 'csim'.
+clear;
+s=poly(0,"s");
+t=0:1e-25:1e-20;
+s1=syslin("c",1/(1+1e-21*s));
+if execstr("s2=csim(""step"",t,s1);","errcatch")<>0 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_1508.tst b/modules/cacsd/tests/nonreg_tests/bug_1508.tst
new file mode 100755
index 000000000..b0c7fe469
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_1508.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Vincent COUVERT
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 1508 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=1508
+//
+// <-- Short Description -->
+// A transfer function with small numeric values is assumed not to be SISO, when used in 'csim'.
+
+clear;
+s=poly(0,"s");
+t=0:1e-25:1e-20;
+s1=syslin("c",1/(1+1e-21*s));
+
+if execstr("s2=csim(""step"",t,s1);","errcatch")<>0 then pause,end
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_2252.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_2252.dia.ref
new file mode 100755
index 000000000..7bd177506
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_2252.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 2252 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2252
+//
+// <-- Short Description -->
+// csim produces unusual results for the following nonminimum phase system
+// Problem due to state basis change used to block diagonalize the state matrix
+s=poly(0,'s');
+p=(1-s)/(1+s)^2;
+p=syslin('c',p);
+t=0:0.01:20;
+ycsim=csim('step',t,p);
+sl=syslin('c',[-1 -2;0 -1],[1;1],[-1 0]);
+function ydot=sim(t,y),ydot=sl.a*y+sl.b,endfunction
+yode=sl.c*ode(zeros(2,1),0,t,1.414D-09,0.0000001,sim);
+assert_checkalmostequal(ycsim, yode, [], 7e-3, "matrix");
diff --git a/modules/cacsd/tests/nonreg_tests/bug_2252.tst b/modules/cacsd/tests/nonreg_tests/bug_2252.tst
new file mode 100755
index 000000000..2e576ceeb
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_2252.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 2252 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=2252
+//
+// <-- Short Description -->
+// csim produces unusual results for the following nonminimum phase system
+// Problem due to state basis change used to block diagonalize the state matrix
+s=poly(0,'s');
+p=(1-s)/(1+s)^2;
+p=syslin('c',p);
+t=0:0.01:20;
+ycsim=csim('step',t,p);
+
+sl=syslin('c',[-1 -2;0 -1],[1;1],[-1 0]);
+function ydot=sim(t,y),ydot=sl.a*y+sl.b,endfunction
+yode=sl.c*ode(zeros(2,1),0,t,1.414D-09,0.0000001,sim);
+
+assert_checkalmostequal(ycsim, yode, [], 7e-3, "matrix");
diff --git a/modules/cacsd/tests/nonreg_tests/bug_2836.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_2836.dia.ref
new file mode 100755
index 000000000..cd304b791
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_2836.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// 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 3836 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3836
+//
+// <-- Short Description -->
+//Problem with the function csim when using state space form. When using this
+//function with two output arguments [y, x] (output and state of the dynamical
+//system), with an observation matrix C=[1 0], the output is not equal to the first
+//component of the state.
+Ks = 2; z = 0.9; w = 10;
+A=[0 1 ; -w^2 -2*z*w];
+B=[0 ; Ks*w^2];
+C=[1 0];
+sys=syslin('c',A,B,C);
+u=[2*ones(1,280) 0.5*ones(1,240) 1.5*ones(1,380) ones(1,160)];
+N=length(u);
+t=linspace(0,2,N);
+[y,x] = csim(u,t,sys);
+if norm(y-x(1,:))>%eps then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_2836.tst b/modules/cacsd/tests/nonreg_tests/bug_2836.tst
new file mode 100755
index 000000000..f51be9da3
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_2836.tst
@@ -0,0 +1,29 @@
+// =============================================================================
+// 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 3836 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3836
+//
+// <-- Short Description -->
+//Problem with the function csim when using state space form. When using this
+//function with two output arguments [y, x] (output and state of the dynamical
+//system), with an observation matrix C=[1 0], the output is not equal to the first
+//component of the state.
+
+Ks = 2; z = 0.9; w = 10;
+A=[0 1 ; -w^2 -2*z*w];
+B=[0 ; Ks*w^2];
+C=[1 0];
+sys=syslin('c',A,B,C);
+u=[2*ones(1,280) 0.5*ones(1,240) 1.5*ones(1,380) ones(1,160)];
+N=length(u);
+t=linspace(0,2,N);
+[y,x] = csim(u,t,sys);
+if norm(y-x(1,:))>%eps then pause,end
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3323.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_3323.dia.ref
new file mode 100755
index 000000000..9fdcf4922
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3323.dia.ref
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3323 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3323
+//
+// <-- Short Description -->
+// In ss2tf.sci, it is claimed that one may enter the second argument, rmax, as "b".
+z=poly(0,'z');
+h=[1,1/z;1/(z^2+1),z/(z^2-2)];
+if norm(coeff(numer(clean(ss2tf(tf2ss(h),'b'))-h)),1) >100*%eps then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3323.tst b/modules/cacsd/tests/nonreg_tests/bug_3323.tst
new file mode 100755
index 000000000..f61a0be58
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3323.tst
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3323 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3323
+//
+// <-- Short Description -->
+// In ss2tf.sci, it is claimed that one may enter the second argument, rmax, as "b".
+z=poly(0,'z');
+h=[1,1/z;1/(z^2+1),z/(z^2-2)];
+if norm(coeff(numer(clean(ss2tf(tf2ss(h),'b'))-h)),1) >100*%eps then pause,end
+
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3767.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_3767.dia.ref
new file mode 100755
index 000000000..618b9ecfc
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3767.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// 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 3767 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3767
+//
+// <-- Short Description -->
+// Atlas library crashs scilab with this example
+A=rand(3,3);
+B=rand(3,2);
+C=rand(3,3);
+C=C*C';
+R=rand(2,2);
+R=R*R'+eye();
+B=B*inv(R)*B';
+X=ricc(A,B,C,'disc');
+if or(size(X)<>[3 3]) then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3767.tst b/modules/cacsd/tests/nonreg_tests/bug_3767.tst
new file mode 100755
index 000000000..e76ee296b
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3767.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// 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 3767 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3767
+//
+// <-- Short Description -->
+// Atlas library crashs scilab with this example
+
+A=rand(3,3);
+B=rand(3,2);
+C=rand(3,3);
+C=C*C';
+R=rand(2,2);
+R=R*R'+eye();
+
+B=B*inv(R)*B';
+
+X=ricc(A,B,C,'disc');
+
+if or(size(X)<>[3 3]) then pause,end \ No newline at end of file
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3783.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_3783.dia.ref
new file mode 100755
index 000000000..0a20590cf
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3783.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Vincent Couvert
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3783 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3783
+//
+// <-- Short Description -->
+// Using the command trfmod in version 5.0.3 (at least) in windows (at least) the program is blocked.
+// <-- INTERACTIVE TEST -->
+h=syslin('c',1/%s);
+// Please click the 'OK' button, the program must return
+trfmod(h)
+ ans =
+
+ 1
+ -
+ s
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3783.tst b/modules/cacsd/tests/nonreg_tests/bug_3783.tst
new file mode 100755
index 000000000..7c6c144a7
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3783.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Vincent Couvert
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3783 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3783
+//
+// <-- Short Description -->
+// Using the command trfmod in version 5.0.3 (at least) in windows (at least) the program is blocked.
+
+
+// <-- INTERACTIVE TEST -->
+
+h=syslin('c',1/%s);
+// Please click the 'OK' button, the program must return
+trfmod(h)
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3796.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_3796.dia.ref
new file mode 100755
index 000000000..b0e238e1c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3796.dia.ref
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 3796 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3796
+//
+// <-- Short Description -->
+//In some situation the "tf2ss()" function is not capable to compute
+//correctly the state space representation of a transfer function.
+s = poly(0,'s');
+E = 15.0 ;
+Vo = 5.0 ;
+D = Vo/E ;
+Delta_Vo = 0.1;
+Ts = 1*10^(-3);
+t_on = D*Ts ;
+t_of = Ts-t_on;
+Ro = 5.1 ;
+L = 2.28*10^(-3);
+Error=0.1; // ramp error desired
+Delta_i_L=(E*(1-D)*D*Ts)/L;
+C = (Delta_i_L*Ts)/(8*Delta_Vo);
+fdt_Vo_d = syslin('c',E,((L*C)*s^(2)+(L/Ro)*s+1) );
+fa0 = 50; // [Hertz]
+wa0 = 2*%pi*fa0; // [rad/sec] pulsation
+Kc=1/(E*Error);
+Ctipo=syslin('c',Kc,s);
+K=10^(35/20);
+ma=20;
+wta=0.8;
+Ca=syslin('c',1+(wta/wa0)*s,1+s*(wta/wa0)/ma);
+Cds = K*Ctipo*Ca*Ca;
+Lds = Cds*fdt_Vo_d;
+uno = syslin('c',1,1);
+Wds =Lds/.uno;
+Wds_ss = tf2ss(Wds);
+if size(Wds_ss.A)<>5 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3796.tst b/modules/cacsd/tests/nonreg_tests/bug_3796.tst
new file mode 100755
index 000000000..de9522202
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3796.tst
@@ -0,0 +1,53 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 3796 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3796
+//
+// <-- Short Description -->
+
+//In some situation the "tf2ss()" function is not capable to compute
+//correctly the state space representation of a transfer function.
+
+s = poly(0,'s');
+
+E = 15.0 ;
+Vo = 5.0 ;
+
+D = Vo/E ;
+Delta_Vo = 0.1;
+Ts = 1*10^(-3);
+t_on = D*Ts ;
+t_of = Ts-t_on;
+Ro = 5.1 ;
+L = 2.28*10^(-3);
+
+Error=0.1; // ramp error desired
+Delta_i_L=(E*(1-D)*D*Ts)/L;
+C = (Delta_i_L*Ts)/(8*Delta_Vo);
+fdt_Vo_d = syslin('c',E,((L*C)*s^(2)+(L/Ro)*s+1) );
+fa0 = 50; // [Hertz]
+wa0 = 2*%pi*fa0; // [rad/sec] pulsation
+
+Kc=1/(E*Error);
+Ctipo=syslin('c',Kc,s);
+
+K=10^(35/20);
+ma=20;
+wta=0.8;
+Ca=syslin('c',1+(wta/wa0)*s,1+s*(wta/wa0)/ma);
+Cds = K*Ctipo*Ca*Ca;
+Lds = Cds*fdt_Vo_d;
+uno = syslin('c',1,1);
+Wds =Lds/.uno;
+
+Wds_ss = tf2ss(Wds);
+if size(Wds_ss.A)<>5 then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3880.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_3880.dia.ref
new file mode 100755
index 000000000..fcf127bed
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3880.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA - Serge.Steer@inria.fr
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3880 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3880
+//
+// <-- Short Description -->
+// division by zero occurs in g_margin with Scilab v5.0.3
+//
+s=%s/(2*%pi);
+g=20*(s+1)/(s*(s+5)*(s^2+2*s+10));
+gs=syslin('c',g)
+ gs =
+
+ 20 + 3.1830989s
+ -------------------------------------------------
+ 2 3 4
+ 7.9577472s + 0.5066059s + 0.0282201s + 0.0006416s
+if execstr('[gg,wcp]=g_margin(gs)','errcatch')<>0 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3880.tst b/modules/cacsd/tests/nonreg_tests/bug_3880.tst
new file mode 100755
index 000000000..be1b5bfc7
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3880.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA - Serge.Steer@inria.fr
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3880 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3880
+//
+// <-- Short Description -->
+// division by zero occurs in g_margin with Scilab v5.0.3
+//
+s=%s/(2*%pi);
+g=20*(s+1)/(s*(s+5)*(s^2+2*s+10));
+gs=syslin('c',g)
+if execstr('[gg,wcp]=g_margin(gs)','errcatch')<>0 then pause,end
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3934.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_3934.dia.ref
new file mode 100755
index 000000000..7935e44c2
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3934.dia.ref
@@ -0,0 +1,49 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+// Copyright (C) 2009 - 2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3934 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3439
+//
+// <-- Short Description -->
+// Online Help of ricc() function crashes Scilab
+//Standard formulas to compute Riccati solutions
+A=rand(3,3);
+B=rand(3,2);
+C=rand(3,3);
+C=C*C';
+R=rand(2,2);
+R=R*R'+eye();
+B=B*inv(R)*B';
+X=ricc(A,B,C,'cont');
+computed = A'*X+X*A-X*B*X+C;
+expected = zeros(3,3);
+assert_checkalmostequal ( computed, expected, [] , 1.e4 * %eps );
+H=[A -B;-C -A'];
+[T,d]=schur(eye(H),H,'cont');
+T=T(:,1:d);
+X1=T(4:6,:)/T(1:3,:);
+assert_checkalmostequal ( X1, X, 1.e4 * %eps );
+[T,d]=schur(H,'cont');
+T=T(:,1:d);
+X2=T(4:6,:)/T(1:3,:);
+assert_checkalmostequal ( X2, X, 1.e4 * %eps );
+// Discrete time case
+F=A;
+B=rand(3,2);
+G1=B;
+G2=R;
+G=G1/G2*G1';
+H=C;
+X=ricc(F,G,H,'disc');
+expected = [
+ 2.0390067 1.3494625 1.3988904
+ 1.3494625 1.4794503 1.6987296
+ 1.3988904 1.6987296 2.3494632
+ ];
+assert_checkalmostequal ( computed, expected, 1.e7 );
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3934.tst b/modules/cacsd/tests/nonreg_tests/bug_3934.tst
new file mode 100755
index 000000000..90d0d21dd
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3934.tst
@@ -0,0 +1,56 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+// Copyright (C) 2009 - 2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 3934 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3439
+//
+// <-- Short Description -->
+// Online Help of ricc() function crashes Scilab
+
+//Standard formulas to compute Riccati solutions
+A=rand(3,3);
+B=rand(3,2);
+C=rand(3,3);
+C=C*C';
+R=rand(2,2);
+R=R*R'+eye();
+B=B*inv(R)*B';
+X=ricc(A,B,C,'cont');
+computed = A'*X+X*A-X*B*X+C;
+expected = zeros(3,3);
+assert_checkalmostequal ( computed, expected, [] , 1.e4 * %eps );
+
+H=[A -B;-C -A'];
+[T,d]=schur(eye(H),H,'cont');
+T=T(:,1:d);
+X1=T(4:6,:)/T(1:3,:);
+assert_checkalmostequal ( X1, X, 1.e4 * %eps );
+
+[T,d]=schur(H,'cont');
+T=T(:,1:d);
+X2=T(4:6,:)/T(1:3,:);
+assert_checkalmostequal ( X2, X, 1.e4 * %eps );
+
+// Discrete time case
+F=A;
+B=rand(3,2);
+G1=B;
+G2=R;
+G=G1/G2*G1';
+H=C;
+X=ricc(F,G,H,'disc');
+expected = [
+ 2.0390067 1.3494625 1.3988904
+ 1.3494625 1.4794503 1.6987296
+ 1.3988904 1.6987296 2.3494632
+ ];
+assert_checkalmostequal ( computed, expected, 1.e7 );
+
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3967.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_3967.dia.ref
new file mode 100755
index 000000000..467a0cb52
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3967.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// 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.
+// =============================================================================
+// <-- Non-regression test for bug 3967 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3967
+//
+// <-- Short Description -->
+// when called with a transfer function, pfss returns a set of state-space systems as a result.
+// pfss used to return a transfer functions when called with a transfer function (verified of 4.1.2).
+// When called with a tf, pfss should of course return a tf.
+tf = syslin("c", 1/%s);
+ss = tf2ss(tf);
+if pfss(tf)<>list(tf) then bugmes();quit;end
+if pfss(ss)<>list(ss) then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_3967.tst b/modules/cacsd/tests/nonreg_tests/bug_3967.tst
new file mode 100755
index 000000000..0bed3f7fa
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_3967.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// 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.
+// =============================================================================
+
+// <-- Non-regression test for bug 3967 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3967
+//
+// <-- Short Description -->
+// when called with a transfer function, pfss returns a set of state-space systems as a result.
+// pfss used to return a transfer functions when called with a transfer function (verified of 4.1.2).
+// When called with a tf, pfss should of course return a tf.
+//
+// <-- CLI SHELL MODE -->
+
+tf = syslin("c", 1/%s);
+ss = tf2ss(tf);
+
+if pfss(tf)<>list(tf) then pause;end
+if pfss(ss)<>list(ss) then pause;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4275.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4275.dia.ref
new file mode 100755
index 000000000..a5fea1aa7
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4275.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 4275 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4275
+//
+// <-- Short Description -->
+// g_margin function does not work properly
+s=poly(0,'s');
+L = syslin('c',1,s*(1+s)^2);
+[g,f]=g_margin(L);
+if abs(f*2*%pi-1)>100*%eps then bugmes();quit;end
+if abs(g-20*log10(2))>100*%eps then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4275.tst b/modules/cacsd/tests/nonreg_tests/bug_4275.tst
new file mode 100755
index 000000000..e3f7f4bdc
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4275.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 4275 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4275
+//
+// <-- Short Description -->
+// g_margin function does not work properly
+
+s=poly(0,'s');
+L = syslin('c',1,s*(1+s)^2);
+[g,f]=g_margin(L);
+if abs(f*2*%pi-1)>100*%eps then pause,end
+if abs(g-20*log10(2))>100*%eps then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4297.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4297.dia.ref
new file mode 100755
index 000000000..a51679780
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4297.dia.ref
@@ -0,0 +1,15 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Sylvestre LEDRU
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 4297 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4297
+//
+// <-- Short Description -->
+// A spelling mistake was causing in some cases with the pfss function
+W=ssrand(1,1,6);
+if execstr("pfss(W,10);","errcatch")<>0 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4297.tst b/modules/cacsd/tests/nonreg_tests/bug_4297.tst
new file mode 100755
index 000000000..fa19b3070
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4297.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Sylvestre LEDRU
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 4297 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4297
+//
+// <-- Short Description -->
+// A spelling mistake was causing in some cases with the pfss function
+W=ssrand(1,1,6);
+if execstr("pfss(W,10);","errcatch")<>0 then pause,end
+
+
+
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4319.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4319.dia.ref
new file mode 100755
index 000000000..048ce220c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4319.dia.ref
@@ -0,0 +1,48 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 4319 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4319
+//
+// <-- Short Description -->
+// The function nthresh called by the function parrt in ccontrg.sci is
+// missing
+//2 states
+A = [-5,-6;
+ 6,-4]
+ A =
+
+ - 5. - 6.
+ 6. - 4.
+//five inputs
+B = [0,-14,17,2,9;
+ 2,17,19,-10,-9]
+ B =
+
+ 0. - 14. 17. 2. 9.
+ 2. 17. 19. - 10. - 9.
+//three outputs
+C = [0,-17;
+ 3,-14;
+ 8,7]
+ C =
+
+ 0. - 17.
+ 3. - 14.
+ 8. 7.
+D = [1,1,1,3,4;
+ 1,1,6,0,2;
+ 1,1,7,5,5]
+ D =
+
+ 1. 1. 1. 3. 4.
+ 1. 1. 6. 0. 2.
+ 1. 1. 7. 5. 5.
+PP=syslin('c',A,B,C,D);
+gopt=gamitg(PP,[1 1]);
+if execstr('KK=ccontrg(PP,[1 1],gopt+0.1)','errcatch')<>0 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4319.tst b/modules/cacsd/tests/nonreg_tests/bug_4319.tst
new file mode 100755
index 000000000..415c4791b
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4319.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 4319 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4319
+//
+// <-- Short Description -->
+// The function nthresh called by the function parrt in ccontrg.sci is
+// missing
+//2 states
+A = [-5,-6;
+ 6,-4]
+//five inputs
+B = [0,-14,17,2,9;
+ 2,17,19,-10,-9]
+//three outputs
+C = [0,-17;
+ 3,-14;
+ 8,7]
+
+D = [1,1,1,3,4;
+ 1,1,6,0,2;
+ 1,1,7,5,5]
+PP=syslin('c',A,B,C,D);
+gopt=gamitg(PP,[1 1]);
+
+if execstr('KK=ccontrg(PP,[1 1],gopt+0.1)','errcatch')<>0 then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4383.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4383.dia.ref
new file mode 100755
index 000000000..21e6ad739
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4383.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// 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 -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- Non-regression test for bug 4383 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4383
+//
+// <-- Short Description -->
+// csim with "step" and "impuls" does not work with direct feedthrough.
+s = poly(0,'s');
+t = 0:5;
+u = ones(1,6);
+G = syslin('c',1+s,2+s);
+y = csim('step',t,G);
+ya = csim(u,t,G);
+assert_checkalmostequal(y,ya);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4383.tst b/modules/cacsd/tests/nonreg_tests/bug_4383.tst
new file mode 100755
index 000000000..5b8f01891
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4383.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// 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 -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- Non-regression test for bug 4383 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4383
+//
+// <-- Short Description -->
+// csim with "step" and "impuls" does not work with direct feedthrough.
+
+s = poly(0,'s');
+t = 0:5;
+u = ones(1,6);
+G = syslin('c',1+s,2+s);
+y = csim('step',t,G);
+ya = csim(u,t,G);
+assert_checkalmostequal(y,ya);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4505.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4505.dia.ref
new file mode 100755
index 000000000..2cc42d62d
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4505.dia.ref
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 -INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 4505 -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4505
+//
+// <-- Short Description -->
+// A red vertical bar appeared for some bode plots of continuous time systems.
+//check there is not Shannon limit curve for continuous systems
+sys=syslin('c',1/(1+%s))
+ sys =
+
+ 1
+ -----
+ 1 + s
+clf();bode(sys,0.001,1000)
+f=gcf();
+a_phase=f.children(1);
+a_modulus=f.children(2);
+phase_curves=a_phase.children;
+if size(phase_curves,'*')<>1 then bugmes();quit;end
+modulus_curves=a_modulus.children;
+if size(modulus_curves,'*')<>1 then bugmes();quit;end
+//check there is Shannon limit curve for discrete systems
+sys=dscr(sys,0.01);
+clf();bode(sys,0.001,1000)
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+f=gcf();
+a_phase=f.children(1);
+a_modulus=f.children(2);
+phase_curves=a_phase.children;
+if size(phase_curves,'*')<>2 then bugmes();quit;end
+if or(size(phase_curves(1).data)<>[2 2]) then bugmes();quit;end
+modulus_curves=a_modulus.children;
+if size(modulus_curves,'*')<>2 then bugmes();quit;end
+if or(size(modulus_curves(1).data)<>[2 2]) then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4505.tst b/modules/cacsd/tests/nonreg_tests/bug_4505.tst
new file mode 100755
index 000000000..a34dd3d13
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4505.tst
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 -INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 4505 -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4505
+//
+// <-- Short Description -->
+// A red vertical bar appeared for some bode plots of continuous time systems.
+
+
+//check there is not Shannon limit curve for continuous systems
+sys=syslin('c',1/(1+%s))
+clf();bode(sys,0.001,1000)
+f=gcf();
+a_phase=f.children(1);
+a_modulus=f.children(2);
+phase_curves=a_phase.children;
+if size(phase_curves,'*')<>1 then pause,end
+modulus_curves=a_modulus.children;
+if size(modulus_curves,'*')<>1 then pause,end
+
+//check there is Shannon limit curve for discrete systems
+sys=dscr(sys,0.01);
+clf();bode(sys,0.001,1000)
+f=gcf();
+a_phase=f.children(1);
+a_modulus=f.children(2);
+phase_curves=a_phase.children;
+if size(phase_curves,'*')<>2 then pause,end
+if or(size(phase_curves(1).data)<>[2 2]) then pause,end
+modulus_curves=a_modulus.children;
+if size(modulus_curves,'*')<>2 then pause,end
+if or(size(modulus_curves(1).data)<>[2 2]) then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4596.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4596.dia.ref
new file mode 100755
index 000000000..56492b5c8
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4596.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 4596 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4596
+//
+// <-- Short Description -->
+// g_margin fails to return the gain margins in some cases.
+s=%s;
+K=485000.;
+h=syslin('c', K / ( s * (s+100)^2 ) );
+[gm,fr]=g_margin(h)
+ fr =
+
+ 15.915494
+ gm =
+
+ 12.305765
+if gm==[] then bugmes();quit;end
+if abs(2*%pi*fr-100)>100*%eps then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4596.tst b/modules/cacsd/tests/nonreg_tests/bug_4596.tst
new file mode 100755
index 000000000..401296700
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4596.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 4596 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4596
+//
+// <-- Short Description -->
+// g_margin fails to return the gain margins in some cases.
+
+s=%s;
+K=485000.;
+h=syslin('c', K / ( s * (s+100)^2 ) );
+
+[gm,fr]=g_margin(h)
+if gm==[] then pause,end
+if abs(2*%pi*fr-100)>100*%eps then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4731.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4731.dia.ref
new file mode 100755
index 000000000..d32e879f3
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4731.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 4731 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4731
+//
+// <-- Short Description -->
+// lqr fails if dt argument of syslin is a number
+A=[0.5 0.3;0.3 0.9];B=[0.9; 0.3];
+Q=diag([2,5]);R=2;
+Big=sysdiag(Q,R);
+[w,wp]=fullrf(Big);C1=wp(:,1:2);D12=wp(:,3:$);
+P=syslin(1,A,B,C1,D12);
+[K,X]=lqr(P);
+S=spec(A+B*K);
+R=norm(A'*X*A-(A'*X*B)*pinv(B'*X*B+R)*(B'*X*A)+Q-X,1);
+assert_checkalmostequal(real(S),[0.24977769272823835; 0.47346570058644721]);
+assert_checkequal(imag(S),[0;0]);
+assert_checktrue(R<100*%eps);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4731.tst b/modules/cacsd/tests/nonreg_tests/bug_4731.tst
new file mode 100755
index 000000000..09cbbf80c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4731.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 4731 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4731
+//
+// <-- Short Description -->
+// lqr fails if dt argument of syslin is a number
+
+A=[0.5 0.3;0.3 0.9];B=[0.9; 0.3];
+Q=diag([2,5]);R=2;
+Big=sysdiag(Q,R);
+[w,wp]=fullrf(Big);C1=wp(:,1:2);D12=wp(:,3:$);
+P=syslin(1,A,B,C1,D12);
+[K,X]=lqr(P);
+S=spec(A+B*K);
+R=norm(A'*X*A-(A'*X*B)*pinv(B'*X*B+R)*(B'*X*A)+Q-X,1);
+assert_checkalmostequal(real(S),[0.24977769272823835; 0.47346570058644721]);
+assert_checkequal(imag(S),[0;0]);
+assert_checktrue(R<100*%eps);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4767.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4767.dia.ref
new file mode 100755
index 000000000..d34c9817c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4767.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// 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.
+// =============================================================================
+// <-- Non-regression test for bug 4767 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4767
+//
+// <-- Short Description -->
+// minreal.sci contains a couple of references to the variable 'T', which is not defined in the function
+A = [-eye(2,2),rand(2,2);zeros(2,2),-2*eye(2,2)];
+B = [rand(2,2);zeros(2,2)];
+C = rand(2,4);
+sl = syslin('c',A,B,C);
+ierr = execstr('slb = minreal(sl);','errcatch');
+if ierr <> 0 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4767.tst b/modules/cacsd/tests/nonreg_tests/bug_4767.tst
new file mode 100755
index 000000000..86d1fc63f
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4767.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// 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.
+// =============================================================================
+
+// <-- Non-regression test for bug 4767 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4767
+//
+// <-- Short Description -->
+// minreal.sci contains a couple of references to the variable 'T', which is not defined in the function
+
+A = [-eye(2,2),rand(2,2);zeros(2,2),-2*eye(2,2)];
+B = [rand(2,2);zeros(2,2)];
+C = rand(2,4);
+sl = syslin('c',A,B,C);
+ierr = execstr('slb = minreal(sl);','errcatch');
+if ierr <> 0 then pause,end
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4799.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_4799.dia.ref
new file mode 100755
index 000000000..5b974550e
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4799.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 4799 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4799
+//
+// <-- Short Description -->
+// Some times the bode, nyquist , ... function report a "non convergence" error
+s = poly(0,'s');
+tau=.011; a=82.794; b=103.089;
+S = a/(s*tau-b);
+n=22; Sn = (1+S)^n-1; Snw = syslin('c',Sn);
+if execstr('[frq,bnds,splitf]=calfrq(Snw,100,20000)','errcatch')<>0 then bugmes();quit;end
+if execstr('[frq,bnds,splitf]=calfrq(Snw,0.01,1000000)','errcatch')<>0 then bugmes();quit;end
+s = poly(0,'s');
+tau=11; a=82.794; b=103.089;
+S = a/(s*tau-b);
+n=20; Sn = (1+S)^n-1; Snw = syslin('c',Sn);
+if execstr('[frq,bnds,splitf]=calfrq(Snw,0.1,20)','errcatch')<>0 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_4799.tst b/modules/cacsd/tests/nonreg_tests/bug_4799.tst
new file mode 100755
index 000000000..90d4b2965
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_4799.tst
@@ -0,0 +1,31 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 4799 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4799
+//
+// <-- Short Description -->
+// Some times the bode, nyquist , ... function report a "non convergence" error
+
+
+s = poly(0,'s');
+tau=.011; a=82.794; b=103.089;
+S = a/(s*tau-b);
+n=22; Sn = (1+S)^n-1; Snw = syslin('c',Sn);
+
+if execstr('[frq,bnds,splitf]=calfrq(Snw,100,20000)','errcatch')<>0 then pause,end
+if execstr('[frq,bnds,splitf]=calfrq(Snw,0.01,1000000)','errcatch')<>0 then pause,end
+
+s = poly(0,'s');
+tau=11; a=82.794; b=103.089;
+S = a/(s*tau-b);
+n=20; Sn = (1+S)^n-1; Snw = syslin('c',Sn);
+if execstr('[frq,bnds,splitf]=calfrq(Snw,0.1,20)','errcatch')<>0 then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_549.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_549.dia.ref
new file mode 100755
index 000000000..b44591994
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_549.dia.ref
@@ -0,0 +1,30 @@
+// =============================================================================
+// 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 549 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=549
+//
+// <-- Short Description -->
+// Bug Report Id: 0321220031018153842
+// Le probl�me n'intervient qu'avec la version Linux de Scilab !!!
+// On Scilab 2.7 with " csim " function
+// The Error Messages are:
+// warning
+// matrix is close to singular or badly scaled. rcond = 1.0000E-08
+// computing least squares solution. (see lsq)
+// Commands: G = syslin('c', (1-p)/((p+1)*(p+3)));
+// t = [0:1/100:8];
+// csim('step',t,G);
+// Allard Benoit on Linux version 3.0 / 9.1 distribution Debian / Mandrake with WMaker / KDE as window manager
+// France
+// November 18, 2003 at 15:38:42
+// <-- CLI SHELL MODE -->
+p = poly(0,'p');
+G = syslin('c', (1-p)/((p+1)*(p+3)));
+t = [0:1/100:8];
+csim('step',t,G);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_549.tst b/modules/cacsd/tests/nonreg_tests/bug_549.tst
new file mode 100755
index 000000000..7a0c8e444
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_549.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// 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 549 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=549
+//
+// <-- Short Description -->
+// Bug Report Id: 0321220031018153842
+// Le probl�me n'intervient qu'avec la version Linux de Scilab !!!
+// On Scilab 2.7 with " csim " function
+// The Error Messages are:
+// warning
+// matrix is close to singular or badly scaled. rcond = 1.0000E-08
+// computing least squares solution. (see lsq)
+// Commands: G = syslin('c', (1-p)/((p+1)*(p+3)));
+// t = [0:1/100:8];
+// csim('step',t,G);
+// Allard Benoit on Linux version 3.0 / 9.1 distribution Debian / Mandrake with WMaker / KDE as window manager
+// France
+// November 18, 2003 at 15:38:42
+
+// <-- CLI SHELL MODE -->
+
+p = poly(0,'p');
+G = syslin('c', (1-p)/((p+1)*(p+3)));
+t = [0:1/100:8];
+csim('step',t,G);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6538.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_6538.dia.ref
new file mode 100755
index 000000000..fc918ca0c
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6538.dia.ref
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Cedric Delamarre
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 6538 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6538
+//
+// <-- Short Description -->
+// unobs() ignores its 'tol' argument when it is present, always calculating its ow
+a = ones(3, 3);
+b = ones(3, 3) * 2;
+c = unobs(a, b);
+assert_checkequal(c, 2);
+c = unobs(a, b, 0.8);
+assert_checkequal(c, 3);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6538.tst b/modules/cacsd/tests/nonreg_tests/bug_6538.tst
new file mode 100755
index 000000000..0d523eafe
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6538.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Cedric Delamarre
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 6538 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6538
+//
+// <-- Short Description -->
+// unobs() ignores its 'tol' argument when it is present, always calculating its ow
+
+a = ones(3, 3);
+b = ones(3, 3) * 2;
+
+c = unobs(a, b);
+assert_checkequal(c, 2);
+
+c = unobs(a, b, 0.8);
+assert_checkequal(c, 3);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6635.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_6635.dia.ref
new file mode 100755
index 000000000..aab1d59dd
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6635.dia.ref
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 6635 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6635
+//
+// <-- Short Description -->
+// Incorrectly drawn Bode plots (calfrq bug).
+num=real(poly([0.75788802401980426;-0.74488662950015194;0.71042740727148268+%i*0.32150242887306801;
+ 0.71042740727148268-%i*0.32150242887306801;0.88108463001435433;
+ 0.65688756930625614+%i*0.70651639282163481;0.65688756930625614-%i*0.70651639282163481;
+ 0.87396240470428910+%i*0.38544888973757035;0.87396240470428910-%i*0.38544888973757035;
+ 0.96638845127253781+%i*0.20986303449468094;0.96638845127253781-%i*0.20986303449468094;
+ 0.99463810059227120+%i*0.1259837606842592;0.99463810059227120-%i*0.1259837606842592;
+ -8.33517712317947712],'z'));
+den=real(poly([0.44209498830922006+%i*0.58376435045145136;0.44209498830922006-%i*0.58376435045145136;
+ 0.74984178464015416+%i*0.23826316198364383;0.74984178464015416-%i*0.23826316198364383;
+ 0.88908657183242579;0.78005500218689083;0.73910333806015660+%i*0.66143232274074371;
+ 0.73910333806015660-%i*0.66143232274074371;0.91630828475086279+%i*0.37654428560847641;
+ 0.91630828475086279-%i*0.37654428560847641;0.97669896242019394+%i*0.19145035111644124;
+ 0.97669896242019394-%i*0.19145035111644124;0.98956694435920334+%i*0.09896014014807389;
+ 0.98956694435920334-%i*0.09896014014807389],'z'));
+[frq,bnds,splitf]=calfrq(rlist(num,den,0.00999897500976181),1,10);
+if or(diff(frq)<0) then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6635.tst b/modules/cacsd/tests/nonreg_tests/bug_6635.tst
new file mode 100755
index 000000000..d563c57e7
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6635.tst
@@ -0,0 +1,36 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 6635 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6635
+//
+// <-- Short Description -->
+// Incorrectly drawn Bode plots (calfrq bug).
+
+num=real(poly([0.75788802401980426;-0.74488662950015194;0.71042740727148268+%i*0.32150242887306801;
+ 0.71042740727148268-%i*0.32150242887306801;0.88108463001435433;
+ 0.65688756930625614+%i*0.70651639282163481;0.65688756930625614-%i*0.70651639282163481;
+ 0.87396240470428910+%i*0.38544888973757035;0.87396240470428910-%i*0.38544888973757035;
+ 0.96638845127253781+%i*0.20986303449468094;0.96638845127253781-%i*0.20986303449468094;
+ 0.99463810059227120+%i*0.1259837606842592;0.99463810059227120-%i*0.1259837606842592;
+ -8.33517712317947712],'z'));
+
+
+
+den=real(poly([0.44209498830922006+%i*0.58376435045145136;0.44209498830922006-%i*0.58376435045145136;
+ 0.74984178464015416+%i*0.23826316198364383;0.74984178464015416-%i*0.23826316198364383;
+ 0.88908657183242579;0.78005500218689083;0.73910333806015660+%i*0.66143232274074371;
+ 0.73910333806015660-%i*0.66143232274074371;0.91630828475086279+%i*0.37654428560847641;
+ 0.91630828475086279-%i*0.37654428560847641;0.97669896242019394+%i*0.19145035111644124;
+ 0.97669896242019394-%i*0.19145035111644124;0.98956694435920334+%i*0.09896014014807389;
+ 0.98956694435920334-%i*0.09896014014807389],'z'));
+
+
+[frq,bnds,splitf]=calfrq(rlist(num,den,0.00999897500976181),1,10);
+if or(diff(frq)<0) then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6744.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_6744.dia.ref
new file mode 100755
index 000000000..361d66ac8
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6744.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 6744 -->
+// <-- CLI SHELL MODE -->
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6744
+//
+// <-- Short Description -->
+// p_margin() returns an erroneous result
+z=poly(0,'z');
+num=(0.0373327-0.0405775*z-0.1413155*z^2+0.1783403*z^3);
+den=(-0.0373327+0.0405775*z+0.1413155*z^2-0.1783403*z^3+0.04867*z^4-0.04007*z^5-0.17482*z^6+0.2*z^7);
+H=syslin(1.0,num/den);
+[m,fr]=p_margin(H);
+r=repfreq(H,fr);
+//check if fr give a response with modulus=1
+if abs(abs(r)-1)>1d-10 then bugmes();quit;end
+if abs(m-58.03)>0.01 then bugmes();quit;end
+if abs(m-pmodulo(atand(imag(r),real(r))-180,360))>1d-10 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6744.tst b/modules/cacsd/tests/nonreg_tests/bug_6744.tst
new file mode 100755
index 000000000..2e83cfbc4
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6744.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 6744 -->
+// <-- CLI SHELL MODE -->
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6744
+//
+// <-- Short Description -->
+// p_margin() returns an erroneous result
+z=poly(0,'z');
+num=(0.0373327-0.0405775*z-0.1413155*z^2+0.1783403*z^3);
+den=(-0.0373327+0.0405775*z+0.1413155*z^2-0.1783403*z^3+0.04867*z^4-0.04007*z^5-0.17482*z^6+0.2*z^7);
+H=syslin(1.0,num/den);
+[m,fr]=p_margin(H);
+
+
+r=repfreq(H,fr);
+//check if fr give a response with modulus=1
+if abs(abs(r)-1)>1d-10 then pause,end
+if abs(m-58.03)>0.01 then pause,end
+if abs(m-pmodulo(atand(imag(r),real(r))-180,360))>1d-10 then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6745.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_6745.dia.ref
new file mode 100755
index 000000000..a5a2e52ae
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6745.dia.ref
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 6745 -->
+// <-- CLI SHELL MODE -->
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6745
+//
+// <-- Short Description -->
+// g_margin() returned an erroneous result
+z=poly(0,'z');
+Hbo=syslin(1,(0.042-0.03933*z-0.15407*z^2+0.18518*z^3+6.939e-18*z^4)/(-0.042+0.088*z+0.114*z^2-0.36*z^3+0.2*z^4));
+[m,fr]=g_margin(Hbo);
+if abs(fr-0.5)>1d-10 then bugmes();quit;end
+r=repfreq(Hbo,fr);
+if ~isreal(r,1e-10) then bugmes();quit;end
+if real(r)>0 then bugmes();quit;end
+if abs(20*log10(1/abs(r))-m)>1d-10 then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6745.tst b/modules/cacsd/tests/nonreg_tests/bug_6745.tst
new file mode 100755
index 000000000..aeecb0a13
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6745.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 6745 -->
+// <-- CLI SHELL MODE -->
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6745
+//
+// <-- Short Description -->
+// g_margin() returned an erroneous result
+
+z=poly(0,'z');
+Hbo=syslin(1,(0.042-0.03933*z-0.15407*z^2+0.18518*z^3+6.939e-18*z^4)/(-0.042+0.088*z+0.114*z^2-0.36*z^3+0.2*z^4));
+[m,fr]=g_margin(Hbo);
+if abs(fr-0.5)>1d-10 then pause,end
+r=repfreq(Hbo,fr);
+if ~isreal(r,1e-10) then pause,end
+if real(r)>0 then pause,end
+if abs(20*log10(1/abs(r))-m)>1d-10 then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_68.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_68.dia.ref
new file mode 100755
index 000000000..f2305dc12
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_68.dia.ref
@@ -0,0 +1,123 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA -Serge Steer
+// Copyright (C) 2009-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 68 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=68
+//
+// <-- Short Description -->
+//Precision problem with the trzeros function,
+//
+// sort_merge --
+// Returns the sorted array x.
+// Arguments
+// x : the array to sort
+// compfun : the comparison function
+// data : an optional data to pass to the comparison function
+// Bruno Pincon
+// "quelques tests de rapidit´e entre diff´erents logiciels matriciels"
+// Modified by Michael Baudin to manage a comparison function
+//
+function [x] = sort_merge ( varargin )
+ [lhs,rhs]=argn();
+ if ( ( rhs<>1 ) & ( rhs<>2 ) & ( rhs<>3 ) ) then
+ errmsg = sprintf("Unexpected number of arguments : %d provided while 1, 2 or 3 are expected.",rhs);
+ error(errmsg)
+ end
+ // Get the array x
+ x = varargin(1);
+ // Get the comparison function compfun
+ if rhs==1 then
+ compfun = sort_merge_comparison;
+ else
+ compfun = varargin(2);
+ if ( rhs == 3 ) then
+ data = varargin(3);
+ end
+ end
+ // Proceed...
+ n = length(x)
+ if n > 1 then
+ m = floor(n/2);
+ p = n-m
+ if ( rhs == 3 ) then
+ x1 = sort_merge ( x(1:m) , compfun , data )
+ x2 = sort_merge ( x(m+1:n) , compfun , data )
+ else
+ x1 = sort_merge ( x(1:m) , compfun )
+ x2 = sort_merge ( x(m+1:n) , compfun )
+ end
+ i = 1;
+ i1 = 1;
+ i2 = 1;
+ for i = 1:n
+ if ( rhs == 3 ) then
+ order = compfun ( x1(i1) , x2(i2) , data );
+ else
+ order = compfun ( x1(i1) , x2(i2) );
+ end
+ if order<=0 then
+ x(i) = x1(i1)
+ i1 = i1+1
+ if (i1 > m) then
+ x(i+1:n) = x2(i2:p)
+ break
+ end
+ else
+ x(i) = x2(i2)
+ i2 = i2+1
+ if (i2 > p) then
+ x(i+1:n) = x1(i1:m)
+ break
+ end
+ end
+ end
+ end
+endfunction
+//
+// sort_merge_comparison --
+// The default comparison function used in the sort-merge.
+// Returns -1 if x < y,
+// returns 0 if x==y,
+// returns +1 if x > y
+//
+function order = sort_merge_comparison ( x , y )
+ if x < y then
+ order = -1
+ elseif x==y then
+ order = 0
+ else
+ order = 1
+ end
+endfunction
+function order = mycomparison ( x , y , data )
+ order = assert_comparecomplex(x,y,data(1),data(2))
+endfunction
+s=poly(0,"s");
+A=[-113.63636,-2840909.1,113.63636,2840909.1,0,0;
+1,0,0,0,0,0;
+347.22222,8680555.6,-366.66667,-11111111,19.444444,2430555.6;
+0,0,1,0,0,0;
+0,0,50,6250000,-50,-6250000;
+0,0,0,0,1,0];
+System =syslin("c",A,[1;0;0;0;0;0],[0 0 0 1 0 0]);
+Td=1/0.1;
+alpha=1000;
+Ti=1/0.1;
+Tr=1/10000;
+Kp=1e2;
+PID=tf2ss(syslin("c",Kp*(1+Td*s)/(1+Td/alpha*s)));
+Hrond1=PID*System;
+closed1=(1/.(Hrond1));
+ClosedZeros1=trzeros(closed1);
+Hrond2=System*PID;
+closed2=(1/.(Hrond2));
+ClosedZeros2=trzeros(closed2);
+computed1 = sort_merge ( ClosedZeros1 , mycomparison , [ 10 * %eps , 0.0 ] );
+computed2 = sort_merge ( ClosedZeros2 , mycomparison , [ 10 * %eps , 0.0 ] );
+assert_checkalmostequal ( computed1 , computed2, [] , 1.e-7 );
diff --git a/modules/cacsd/tests/nonreg_tests/bug_68.tst b/modules/cacsd/tests/nonreg_tests/bug_68.tst
new file mode 100755
index 000000000..720dd6d75
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_68.tst
@@ -0,0 +1,137 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2005-2008 - INRIA -Serge Steer
+// Copyright (C) 2009-2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 68 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=68
+//
+// <-- Short Description -->
+//Precision problem with the trzeros function,
+
+
+//
+// sort_merge --
+// Returns the sorted array x.
+// Arguments
+// x : the array to sort
+// compfun : the comparison function
+// data : an optional data to pass to the comparison function
+// Bruno Pincon
+// "quelques tests de rapidit´e entre diff´erents logiciels matriciels"
+// Modified by Michael Baudin to manage a comparison function
+//
+function [x] = sort_merge ( varargin )
+ [lhs,rhs]=argn();
+ if ( ( rhs<>1 ) & ( rhs<>2 ) & ( rhs<>3 ) ) then
+ errmsg = sprintf("Unexpected number of arguments : %d provided while 1, 2 or 3 are expected.",rhs);
+ error(errmsg)
+ end
+ // Get the array x
+ x = varargin(1);
+ // Get the comparison function compfun
+ if rhs==1 then
+ compfun = sort_merge_comparison;
+ else
+ compfun = varargin(2);
+ if ( rhs == 3 ) then
+ data = varargin(3);
+ end
+ end
+ // Proceed...
+ n = length(x)
+ if n > 1 then
+ m = floor(n/2);
+ p = n-m
+ if ( rhs == 3 ) then
+ x1 = sort_merge ( x(1:m) , compfun , data )
+ x2 = sort_merge ( x(m+1:n) , compfun , data )
+ else
+ x1 = sort_merge ( x(1:m) , compfun )
+ x2 = sort_merge ( x(m+1:n) , compfun )
+ end
+ i = 1;
+ i1 = 1;
+ i2 = 1;
+ for i = 1:n
+ if ( rhs == 3 ) then
+ order = compfun ( x1(i1) , x2(i2) , data );
+ else
+ order = compfun ( x1(i1) , x2(i2) );
+ end
+ if order<=0 then
+ x(i) = x1(i1)
+ i1 = i1+1
+ if (i1 > m) then
+ x(i+1:n) = x2(i2:p)
+ break
+ end
+ else
+ x(i) = x2(i2)
+ i2 = i2+1
+ if (i2 > p) then
+ x(i+1:n) = x1(i1:m)
+ break
+ end
+ end
+ end
+ end
+endfunction
+
+//
+// sort_merge_comparison --
+// The default comparison function used in the sort-merge.
+// Returns -1 if x < y,
+// returns 0 if x==y,
+// returns +1 if x > y
+//
+function order = sort_merge_comparison ( x , y )
+ if x < y then
+ order = -1
+ elseif x==y then
+ order = 0
+ else
+ order = 1
+ end
+endfunction
+
+function order = mycomparison ( x , y , data )
+ order = assert_comparecomplex(x,y,data(1),data(2))
+endfunction
+
+
+s=poly(0,"s");
+A=[-113.63636,-2840909.1,113.63636,2840909.1,0,0;
+1,0,0,0,0,0;
+347.22222,8680555.6,-366.66667,-11111111,19.444444,2430555.6;
+0,0,1,0,0,0;
+0,0,50,6250000,-50,-6250000;
+0,0,0,0,1,0];
+
+System =syslin("c",A,[1;0;0;0;0;0],[0 0 0 1 0 0]);
+
+Td=1/0.1;
+alpha=1000;
+Ti=1/0.1;
+Tr=1/10000;
+Kp=1e2;
+PID=tf2ss(syslin("c",Kp*(1+Td*s)/(1+Td/alpha*s)));
+
+Hrond1=PID*System;
+closed1=(1/.(Hrond1));
+ClosedZeros1=trzeros(closed1);
+
+Hrond2=System*PID;
+closed2=(1/.(Hrond2));
+ClosedZeros2=trzeros(closed2);
+
+computed1 = sort_merge ( ClosedZeros1 , mycomparison , [ 10 * %eps , 0.0 ] );
+computed2 = sort_merge ( ClosedZeros2 , mycomparison , [ 10 * %eps , 0.0 ] );
+
+assert_checkalmostequal ( computed1 , computed2, [] , 1.e-7 );
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6829.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_6829.dia.ref
new file mode 100755
index 000000000..2616fdd1b
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6829.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 6829 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6829
+//
+// <-- Short Description -->
+// kpure fails to compute gains when applied to an high degree system
+num=real(poly([-1+%i*1, -1-%i*1, 2+%i*8 2-%i*8 -2.5+%i*13 -2.5-%i*13],'s'));
+den=real(poly([1 1 3+%i*3 3-%i*3 -15+%i*7 -15-%i*7 -3 -7 -11],'s'));
+h=num/den;
+[K,Y]=kpure(h);
+n=size(K,'*');
+if n<>4 then bugmes();quit;end
+for i=1:n
+ r=roots(denom(h/.K(i)));
+ r=r(abs(real(r))<1e-6);//pure imaginary
+ r=r(imag(r)>0); //retains only positive imaginary part
+ if r==[] then bugmes();quit;end
+ if abs(r-Y(i))>1e-10 then bugmes();quit;end
+end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6829.tst b/modules/cacsd/tests/nonreg_tests/bug_6829.tst
new file mode 100755
index 000000000..d69cffc37
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6829.tst
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 6829 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6829
+//
+// <-- Short Description -->
+// kpure fails to compute gains when applied to an high degree system
+
+num=real(poly([-1+%i*1, -1-%i*1, 2+%i*8 2-%i*8 -2.5+%i*13 -2.5-%i*13],'s'));
+den=real(poly([1 1 3+%i*3 3-%i*3 -15+%i*7 -15-%i*7 -3 -7 -11],'s'));
+h=num/den;
+
+[K,Y]=kpure(h);
+n=size(K,'*');
+if n<>4 then pause,end
+for i=1:n
+ r=roots(denom(h/.K(i)));
+ r=r(abs(real(r))<1e-6);//pure imaginary
+ r=r(imag(r)>0); //retains only positive imaginary part
+ if r==[] then pause,end
+ if abs(r-Y(i))>1e-10 then pause,end
+end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6883.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_6883.dia.ref
new file mode 100755
index 000000000..3a7a8efa7
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6883.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Yann COLLETTE
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 6883 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6883
+//
+// <-- Short Description -->
+// black fails to plot integrators
+s = poly (0, "s");
+P1= syslin('c',(1/s));
+frq=0.001:0.01:100;
+[frq1,rep]=repfreq(P1,frq);
+ierr = execstr('black(frq1,rep)','errcatch');
+if ierr then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_6883.tst b/modules/cacsd/tests/nonreg_tests/bug_6883.tst
new file mode 100755
index 000000000..34af58544
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_6883.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Yann COLLETTE
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 6883 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6883
+//
+// <-- Short Description -->
+// black fails to plot integrators
+
+s = poly (0, "s");
+P1= syslin('c',(1/s));
+frq=0.001:0.01:100;
+[frq1,rep]=repfreq(P1,frq);
+ierr = execstr('black(frq1,rep)','errcatch');
+if ierr then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_7566.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_7566.dia.ref
new file mode 100755
index 000000000..8266b2042
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_7566.dia.ref
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 6829 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6829
+//
+// <-- Short Description -->
+// The cacsd module graphic function (bode, black, nyquist,...) do not preserve the immediate_drawing property value.
+fig=gcf();
+s=poly(0,'s');
+h=syslin('c',(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+clf();fig.immediate_drawing="off";
+bode(h);
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+gainplot(h);
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+show_margins(h);
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+black(h);
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+nyquist(h);
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+hallchart();
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+nicholschart();
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+sgrid();
+if fig.immediate_drawing=="on" then bugmes();quit;end
+clf();fig.immediate_drawing="off";
+zgrid();
+if fig.immediate_drawing=="on" then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_7566.tst b/modules/cacsd/tests/nonreg_tests/bug_7566.tst
new file mode 100755
index 000000000..358c6420a
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_7566.tst
@@ -0,0 +1,56 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 6829 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6829
+//
+// <-- Short Description -->
+// The cacsd module graphic function (bode, black, nyquist,...) do not preserve the immediate_drawing property value.
+
+fig=gcf();
+s=poly(0,'s');
+h=syslin('c',(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+
+
+clf();fig.immediate_drawing="off";
+bode(h);
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+gainplot(h);
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+show_margins(h);
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+black(h);
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+nyquist(h);
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+hallchart();
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+nicholschart();
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+sgrid();
+if fig.immediate_drawing=="on" then pause,end
+
+clf();fig.immediate_drawing="off";
+zgrid();
+if fig.immediate_drawing=="on" then pause,end
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_7828.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_7828.dia.ref
new file mode 100755
index 000000000..84a2f4bde
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_7828.dia.ref
@@ -0,0 +1,17 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- Non-regression test for bug 7828 -->
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7828
+//
+// <-- Short Description -->
+// slight improvements in nicholschart.
+assert_checktrue(execstr("nicholschart()","errcatch")==0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_7828.tst b/modules/cacsd/tests/nonreg_tests/bug_7828.tst
new file mode 100755
index 000000000..3ed0c4e35
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_7828.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 7828 -->
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7828
+//
+// <-- Short Description -->
+// slight improvements in nicholschart.
+
+assert_checktrue(execstr("nicholschart()","errcatch")==0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_7960.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_7960.dia.ref
new file mode 100755
index 000000000..59a771bcc
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_7960.dia.ref
@@ -0,0 +1,39 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 7960 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7960
+//
+// <-- Short Description -->
+// plzr can not produce a pole zero plot of many simple transfer functions
+z=poly(0,'z');
+Num=0.64-1.5054092*z+z*z;
+Den=0.970225-1.9652966*z+z*z;
+HZ=Num/Den;
+zr_ref=roots(Num);
+pl_ref=roots(Den);
+plzr(HZ);
+a=gca();
+// Check poles
+pl=a.children(3);
+assert_checkequal(pl.type, "Polyline");
+assert_checkalmostequal(pl.data(1), real(pl_ref(1)));
+assert_checkalmostequal(pl.data(2), real(pl_ref(2)));
+assert_checkalmostequal(pl.data(3), imag(pl_ref(1)));
+assert_checkalmostequal(pl.data(4), imag(pl_ref(2)));
+// Check zeros
+zr=a.children(4);
+assert_checkequal(zr.type, "Polyline");
+assert_checkalmostequal(zr.data(1), real(zr_ref(1)));
+assert_checkalmostequal(zr.data(2), real(zr_ref(2)));
+assert_checkalmostequal(zr.data(3), imag(zr_ref(1)));
+assert_checkalmostequal(zr.data(4), imag(zr_ref(2)));
+close;
diff --git a/modules/cacsd/tests/nonreg_tests/bug_7960.tst b/modules/cacsd/tests/nonreg_tests/bug_7960.tst
new file mode 100755
index 000000000..d9665ee52
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_7960.tst
@@ -0,0 +1,42 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 7960 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7960
+//
+// <-- Short Description -->
+// plzr can not produce a pole zero plot of many simple transfer functions
+
+z=poly(0,'z');
+Num=0.64-1.5054092*z+z*z;
+Den=0.970225-1.9652966*z+z*z;
+HZ=Num/Den;
+zr_ref=roots(Num);
+pl_ref=roots(Den);
+
+plzr(HZ);
+a=gca();
+// Check poles
+pl=a.children(3);
+assert_checkequal(pl.type, "Polyline");
+assert_checkalmostequal(pl.data(1), real(pl_ref(1)));
+assert_checkalmostequal(pl.data(2), real(pl_ref(2)));
+assert_checkalmostequal(pl.data(3), imag(pl_ref(1)));
+assert_checkalmostequal(pl.data(4), imag(pl_ref(2)));
+
+// Check zeros
+zr=a.children(4);
+assert_checkequal(zr.type, "Polyline");
+assert_checkalmostequal(zr.data(1), real(zr_ref(1)));
+assert_checkalmostequal(zr.data(2), real(zr_ref(2)));
+assert_checkalmostequal(zr.data(3), imag(zr_ref(1)));
+assert_checkalmostequal(zr.data(4), imag(zr_ref(2)));
+close;
diff --git a/modules/cacsd/tests/nonreg_tests/bug_8162.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_8162.dia.ref
new file mode 100755
index 000000000..73fa768c9
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_8162.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 8162 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8162
+//
+// <-- Short Description -->
+// Area of stability in continuous is wrong
+s=poly(0,'s');
+n=[1+s 2+3*s+4*s^2 5; 0 1-s s];
+d=[1+3*s 5-s^3 s+1;1+s 1+s+s^2 3*s-1];
+h=syslin('c',n./d);
+assert_checktrue(execstr("plzr(h)","errcatch")==0);
+fig=gcf();
+ax=fig.children;
+assert_checktrue(ax.children(2).type=='Segs');
+assert_checktrue(ax.children(2).data-[0,-1.6289709;0,1.6289709]<1d-5);
+close
diff --git a/modules/cacsd/tests/nonreg_tests/bug_8162.tst b/modules/cacsd/tests/nonreg_tests/bug_8162.tst
new file mode 100755
index 000000000..930660024
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_8162.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// 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.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 8162 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8162
+//
+// <-- Short Description -->
+// Area of stability in continuous is wrong
+
+s=poly(0,'s');
+n=[1+s 2+3*s+4*s^2 5; 0 1-s s];
+d=[1+3*s 5-s^3 s+1;1+s 1+s+s^2 3*s-1];
+h=syslin('c',n./d);
+assert_checktrue(execstr("plzr(h)","errcatch")==0);
+fig=gcf();
+ax=fig.children;
+assert_checktrue(ax.children(2).type=='Segs');
+assert_checktrue(ax.children(2).data-[0,-1.6289709;0,1.6289709]<1d-5);
+close
diff --git a/modules/cacsd/tests/nonreg_tests/bug_8174.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_8174.dia.ref
new file mode 100755
index 000000000..9f67984c4
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_8174.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8174 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8174
+//
+// <-- Short Description -->
+// ss2tf produces bad results if applied to a complex state space system
+//A real dynamical system represented in its eigen state space basis
+//(A,B,C) matrices are complex but the system is real
+A = [ 0.75+%i*0.6,0;0, 0.75-%i*0.6];
+B = [ 0.2-%i*0.45; 0.2+%i*0.45];
+C = [-0.04+%i*0.1,-0.04-%i*0.1];
+Sys =syslin('d',A,B,C,0);
+H = ss2tf(Sys);
+if norm(coeff((H.num-(-0.1011+0.074*%z))))>10*%eps then bugmes();quit;end
+if norm(coeff((H.den-(0.9225-1.5*%z+%z^2))))>10*%eps then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_8174.tst b/modules/cacsd/tests/nonreg_tests/bug_8174.tst
new file mode 100755
index 000000000..4b136fed1
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_8174.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8174 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8174
+//
+// <-- Short Description -->
+// ss2tf produces bad results if applied to a complex state space system
+//A real dynamical system represented in its eigen state space basis
+//(A,B,C) matrices are complex but the system is real
+A = [ 0.75+%i*0.6,0;0, 0.75-%i*0.6];
+B = [ 0.2-%i*0.45; 0.2+%i*0.45];
+C = [-0.04+%i*0.1,-0.04-%i*0.1];
+Sys =syslin('d',A,B,C,0);
+H = ss2tf(Sys);
+if norm(coeff((H.num-(-0.1011+0.074*%z))))>10*%eps then pause,end
+if norm(coeff((H.den-(0.9225-1.5*%z+%z^2))))>10*%eps then pause,end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_8319.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_8319.dia.ref
new file mode 100755
index 000000000..b41053752
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_8319.dia.ref
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8319 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8319
+//
+// <-- Short Description -->
+// dbphi(hypermat) and phasemag(hypermat) return a matrix instead of hypermat
+x = rand(2,2,2);
+c = x*(1+%i);
+[dB phi] = dbphi(c);
+assert_checktrue(typeof(phi) == 'hypermat');
+assert_checkequal(size(phi), size(x));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_8319.tst b/modules/cacsd/tests/nonreg_tests/bug_8319.tst
new file mode 100755
index 000000000..e10ef2f1e
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_8319.tst
@@ -0,0 +1,22 @@
+// =============================================================================
+// 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 8319 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8319
+//
+// <-- Short Description -->
+// dbphi(hypermat) and phasemag(hypermat) return a matrix instead of hypermat
+
+x = rand(2,2,2);
+c = x*(1+%i);
+[dB phi] = dbphi(c);
+assert_checktrue(typeof(phi) == 'hypermat');
+assert_checkequal(size(phi), size(x));
diff --git a/modules/cacsd/tests/nonreg_tests/bug_9098.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_9098.dia.ref
new file mode 100755
index 000000000..69e6db576
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_9098.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9098 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9098
+//
+// <-- Short Description -->
+// demo CACSD --> Robust control failed on Windows 64 bit
+// decrease optimization on sci_f_linmeq.f
+s = poly(0,'s');
+G = syslin("c", 1/s^3);
+[N, M] = lcf(tf2ss(G));
+nk = hankelsv([N, M]);
+assert_checktrue(size(nk,'*') == 6);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_9098.tst b/modules/cacsd/tests/nonreg_tests/bug_9098.tst
new file mode 100755
index 000000000..73dd09608
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_9098.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9098 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9098
+//
+// <-- Short Description -->
+// demo CACSD --> Robust control failed on Windows 64 bit
+// decrease optimization on sci_f_linmeq.f
+
+s = poly(0,'s');
+G = syslin("c", 1/s^3);
+[N, M] = lcf(tf2ss(G));
+nk = hankelsv([N, M]);
+assert_checktrue(size(nk,'*') == 6);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_9285.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_9285.dia.ref
new file mode 100755
index 000000000..e391ddd03
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_9285.dia.ref
@@ -0,0 +1,63 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9285 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9285
+//
+// <-- Short Description -->
+// g_margin returned bad results in some special cases.
+s=%s;
+Kp=2.054;
+Ki=0.13383297644539613;
+Td=0.605;
+Kd=5.0;
+ts=0.25;
+k=0.001712328003555509;
+tw=1.4731525037117905;
+ta=8.678149822856799;
+au=0.0;
+ty=0.1;
+Process=(k*s^2-tw*s+1)/((k*s^2+(tw/2)*s+1)*(1+ts*s)^2*(ta*s+au))
+ Process =
+
+ 2
+ 1 - 1.4731525s + 0.0017123s
+ -------------------------------------------------------------
+ 2 3 4 5
+ 8.6781498s + 10.731194s + 3.7533037s + 0.4069374s + 0.0009287s
+FeedBack=1/((ty*ty)*s^2+(ty*2^0.5)*s+1) * (1 + (Kd*Td*s)/(Kd+Td*s))
+ FeedBack =
+
+ 5 + 3.63s
+ -------------------------------------
+ 2 3
+ 5 + 1.3121068s + 0.1355599s + 0.00605s
+REG=(Kp * ( 1 + Ki/s));
+FT20_0_ = syslin('c', REG * Process * FeedBack);
+[gm,fr]=g_margin(FT20_0_)
+ fr =
+
+ 0.1173008
+ gm =
+
+ 6.6932617
+if ~assert_checkalmostequal(fr,0.11730083,0,6e-9) then bugmes();quit;end
+if ~assert_checkalmostequal(gm,6.69326173,0,6e-9) then bugmes();quit;end
+FT20_0 = tf2ss(FT20_0_);
+[gm,fr]=g_margin(FT20_0)
+ fr =
+
+ 0.1173008
+ gm =
+
+ 6.6932617
+if ~assert_checkalmostequal(fr,0.11730083,0,6e-9) then bugmes();quit;end
+if ~assert_checkalmostequal(gm,6.69326173,0,6e-9) then bugmes();quit;end
diff --git a/modules/cacsd/tests/nonreg_tests/bug_9285.tst b/modules/cacsd/tests/nonreg_tests/bug_9285.tst
new file mode 100755
index 000000000..632c56869
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_9285.tst
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- NOT FIXED -->
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9285 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9285
+//
+// <-- Short Description -->
+// g_margin returned bad results in some special cases.
+s=%s;
+Kp=2.054;
+Ki=0.13383297644539613;
+Td=0.605;
+Kd=5.0;
+ts=0.25;
+k=0.001712328003555509;
+tw=1.4731525037117905;
+ta=8.678149822856799;
+au=0.0;
+ty=0.1;
+
+Process=(k*s^2-tw*s+1)/((k*s^2+(tw/2)*s+1)*(1+ts*s)^2*(ta*s+au))
+FeedBack=1/((ty*ty)*s^2+(ty*2^0.5)*s+1) * (1 + (Kd*Td*s)/(Kd+Td*s))
+REG=(Kp * ( 1 + Ki/s));
+
+FT20_0_ = syslin('c', REG * Process * FeedBack);
+[gm,fr]=g_margin(FT20_0_)
+assert_checkalmostequal(fr,0.11730083,0,6e-9);
+assert_checkalmostequal(gm,6.69326173,0,6e-9);
+
+FT20_0 = tf2ss(FT20_0_);
+[gm,fr]=g_margin(FT20_0)
+assert_checkalmostequal(fr,0.11730083,0,6e-9);
+assert_checkalmostequal(gm,6.69326173,0,6e-9);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_9836.tst b/modules/cacsd/tests/nonreg_tests/bug_9836.tst
new file mode 100755
index 000000000..637227375
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_9836.tst
@@ -0,0 +1,39 @@
+// =============================================================================
+// 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 -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- Non-regression test for bug 9836 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9836
+//
+// <-- Short Description -->
+// repfreq failed due to "singular problem
+
+s=%s;
+num=1+8*s-8*s^2-16*s^3;
+den=32*s^2+64*s^3+32*s^4+8*s^5+s^6;
+H=syslin('c',num,den); //The system includes 2 integrators
+
+
+f=2^(-29);//evaluate at a very low frequency
+
+r_ref=-2.2815502244818564e14-imult(1.60210611463226081e7);//computed with Maple
+
+assert_checkalmostequal(repfreq(H,f),r_ref);
+
+S1=syslin('c',cont_frm(H.num,H.den));
+
+assert_checkalmostequal(repfreq(S1,f),r_ref);
+
+//using tf2ss make the error explode, just check if repfreq returns
+//without error (warning must be issued)
+S2=tf2ss(H);
+assert_checkequal(execstr("repfreq(S2,f)","errcatch"),0);
diff --git a/modules/cacsd/tests/nonreg_tests/bug_9836.unix.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_9836.unix.dia.ref
new file mode 100755
index 000000000..53da84286
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_9836.unix.dia.ref
@@ -0,0 +1,36 @@
+// =============================================================================
+// 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 -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- Non-regression test for bug 9836 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9836
+//
+// <-- Short Description -->
+// repfreq failed due to "singular problem
+s=%s;
+num=1+8*s-8*s^2-16*s^3;
+den=32*s^2+64*s^3+32*s^4+8*s^5+s^6;
+H=syslin('c',num,den); //The system includes 2 integrators
+f=2^(-29);//evaluate at a very low frequency
+r_ref=-2.2815502244818564e14-imult(1.60210611463226081e7);//computed with Maple
+assert_checkalmostequal(repfreq(H,f),r_ref);
+S1=syslin('c',cont_frm(H.num,H.den));
+assert_checkalmostequal(repfreq(S1,f),r_ref);
+Warning :
+matrix is close to singular or badly scaled. rcond = 9.8309D-18
+
+//using tf2ss make the error explode, just check if repfreq returns
+//without error (warning must be issued)
+S2=tf2ss(H);
+assert_checkequal(execstr("repfreq(S2,f)","errcatch"),0);
+Warning :
+matrix is close to singular or badly scaled. rcond = 2.5434D-17
+
diff --git a/modules/cacsd/tests/nonreg_tests/bug_9836.win.dia.ref b/modules/cacsd/tests/nonreg_tests/bug_9836.win.dia.ref
new file mode 100755
index 000000000..ad2844f11
--- /dev/null
+++ b/modules/cacsd/tests/nonreg_tests/bug_9836.win.dia.ref
@@ -0,0 +1,36 @@
+// =============================================================================
+// 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 -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- Non-regression test for bug 9836 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9836
+//
+// <-- Short Description -->
+// repfreq failed due to "singular problem
+s=%s;
+num=1+8*s-8*s^2-16*s^3;
+den=32*s^2+64*s^3+32*s^4+8*s^5+s^6;
+H=syslin('c',num,den); //The system includes 2 integrators
+f=2^(-29);//evaluate at a very low frequency
+r_ref=-2.2815502244818564e14-imult(1.60210611463226081e7);//computed with Maple
+assert_checkalmostequal(repfreq(H,f),r_ref);
+S1=syslin('c',cont_frm(H.num,H.den));
+assert_checkalmostequal(repfreq(S1,f),r_ref);
+Warning :
+matrix is close to singular or badly scaled. rcond = 9.8309D-18
+
+//using tf2ss make the error explode, just check if repfreq returns
+//without error (warning must be issued)
+S2=tf2ss(H);
+assert_checkequal(execstr("repfreq(S2,f)","errcatch"),0);
+Warning :
+matrix is close to singular or badly scaled. rcond = 7.0487D-17
+
diff --git a/modules/cacsd/tests/unit_tests/arma.dia.ref b/modules/cacsd/tests/unit_tests/arma.dia.ref
new file mode 100755
index 000000000..8b6537330
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/arma.dia.ref
@@ -0,0 +1,78 @@
+// y_{n+1} = y_n + 2*y_{n-1} + [1,2,3]*U_{n+1} + sig*1*e_{n+1}
+Ar=armac([1,-1,-2],[1,2,3],[1],1,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,18,48,108] then bugmes();quit;end
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+// y_{n+1} = y_n + 2*y_{n-1} + [1,2,3]*U_{n} + sig*1*e_{n+1}
+Ar=armac([1,-1,-2],[0,0,0,1,2,3],[1],1,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[0,6,18,48] then bugmes();quit;end
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+// y_{n+1} = y_n + 2*y_{n-1} + [1,2,3]*U_{n+1} -[4,5,6]*U_{n}+[7,8,9]*U_{n-1} + sig*1*e_{n+1}
+Ar=armac([1,-1,-2],[1,2,3,-4,-5,-6,7,8,9],[1],1,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,3,27,60] then bugmes();quit;end
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+// y_{n+1} = eye(2,2)*y_n + 2*eye(2,2)*y_{n-1} + [1,2,3;1,2,3]*U_{n+1} -[4,5,6;4,5,6]*U_{n}
+// +[7,8,9;7,8,9]*U_{n-1} + sig*eye(2,2)*e_{n+1}
+Ar=armac([1,-1,-2].*.eye(2,2),[1,2,3,-4,-5,-6,7,8,9].*.[1;1],[eye(2,2)],2,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,3,27,60].*.[1;1] then bugmes();quit;end
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+// y_{n+1} = ones(2,2)*y_n + 2*ones(2,2)*y_{n-1} + [1,2,3;1,2,3]*U_{n+1} -[4,5,6;4,5,6]*U_{n}
+// +[7,8,9;7,8,9]*U_{n-1} + sig*eye(2,2)*e_{n+1}
+Ar=armac([eye(2,2),-ones(2,2),-2*ones(2,2)],[1,2,3,-4,-5,-6,7,8,9].*.[1;1],[eye(2,2)],2,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,9,54,171].*.[1;1] then bugmes();quit;end
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
+// y_{n+1} = ones(2,2)*y_n + 2*ones(2,2)*y_{n-1} + [1,2,3;1,2,3]*U_{n+1} -[4,5,6;4,5,6]*U_{n}
+// +[7,8,9;7,8,9]*U_{n-1} + sig*D*e_{n+1}
+// D=rand(2,10)
+D=rand(2,10);
+Ar=armac([eye(2,2),-ones(2,2),-2*ones(2,2)],[1,2,3,-4,-5,-6,7,8,9].*.[1;1],[D],2,3,1.0);
+u= (1:4).*.ones(3,1);
+a=rand('seed');
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then bugmes();quit;end;
diff --git a/modules/cacsd/tests/unit_tests/arma.tst b/modules/cacsd/tests/unit_tests/arma.tst
new file mode 100755
index 000000000..dec7f3879
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/arma.tst
@@ -0,0 +1,98 @@
+// =============================================================================
+// 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.
+// =============================================================================
+
+// y_{n+1} = y_n + 2*y_{n-1} + [1,2,3]*U_{n+1} + sig*1*e_{n+1}
+
+Ar=armac([1,-1,-2],[1,2,3],[1],1,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,18,48,108] then pause,end
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+
+// y_{n+1} = y_n + 2*y_{n-1} + [1,2,3]*U_{n} + sig*1*e_{n+1}
+
+Ar=armac([1,-1,-2],[0,0,0,1,2,3],[1],1,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[0,6,18,48] then pause,end
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+
+// y_{n+1} = y_n + 2*y_{n-1} + [1,2,3]*U_{n+1} -[4,5,6]*U_{n}+[7,8,9]*U_{n-1} + sig*1*e_{n+1}
+
+Ar=armac([1,-1,-2],[1,2,3,-4,-5,-6,7,8,9],[1],1,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,3,27,60] then pause,end
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+
+// y_{n+1} = eye(2,2)*y_n + 2*eye(2,2)*y_{n-1} + [1,2,3;1,2,3]*U_{n+1} -[4,5,6;4,5,6]*U_{n}
+// +[7,8,9;7,8,9]*U_{n-1} + sig*eye(2,2)*e_{n+1}
+
+Ar=armac([1,-1,-2].*.eye(2,2),[1,2,3,-4,-5,-6,7,8,9].*.[1;1],[eye(2,2)],2,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,3,27,60].*.[1;1] then pause,end
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+
+// y_{n+1} = ones(2,2)*y_n + 2*ones(2,2)*y_{n-1} + [1,2,3;1,2,3]*U_{n+1} -[4,5,6;4,5,6]*U_{n}
+// +[7,8,9;7,8,9]*U_{n-1} + sig*eye(2,2)*e_{n+1}
+
+Ar=armac([eye(2,2),-ones(2,2),-2*ones(2,2)],[1,2,3,-4,-5,-6,7,8,9].*.[1;1],[eye(2,2)],2,3,0);
+u= (1:4).*.ones(3,1);
+y1=arsimul(Ar,u);
+if y1<>[6,9,54,171].*.[1;1] then pause,end
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+a=rand('seed');
+Ar('sig')=1;
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+
+// y_{n+1} = ones(2,2)*y_n + 2*ones(2,2)*y_{n-1} + [1,2,3;1,2,3]*U_{n+1} -[4,5,6;4,5,6]*U_{n}
+// +[7,8,9;7,8,9]*U_{n-1} + sig*D*e_{n+1}
+// D=rand(2,10)
+D=rand(2,10);
+Ar=armac([eye(2,2),-ones(2,2),-2*ones(2,2)],[1,2,3,-4,-5,-6,7,8,9].*.[1;1],[D],2,3,1.0);
+u= (1:4).*.ones(3,1);
+a=rand('seed');
+y1=arsimul(Ar,u);
+rand('seed',a);
+y2=narsimul(Ar,u);
+if y1<>y2 then pause,end;
+
+
+
diff --git a/modules/cacsd/tests/unit_tests/arma2ss.dia.ref b/modules/cacsd/tests/unit_tests/arma2ss.dia.ref
new file mode 100755
index 000000000..acd870fcf
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/arma2ss.dia.ref
@@ -0,0 +1,83 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+ny=1,nu=1,sig=0.01;
+ ny =
+
+ 1.
+ nu =
+
+ 1.
+ar=armac(1,[0,0.2],[0,1],ny,nu,sig);
+[S,Sn]=arma2ss(ar);
+A=[0,0.2;0,0];B=[0;1];C=[1,0];D=0;
+assert_checkequal(S.A,A);
+assert_checkequal(S.B,B);
+assert_checkequal(S.C,C);
+assert_checkequal(S.D,D);
+A=[0,1;0,0];B=[0;0.01];C=[1,0];D=0;
+assert_checkequal(Sn.A,A);
+assert_checkequal(Sn.B,B);
+assert_checkequal(Sn.C,C);
+assert_checkequal(Sn.D,D);
+//
+ny=1,nu=1;
+ ny =
+
+ 1.
+ar=armac([1,-0.8,0.2],0.001,0,ny,nu,0);
+[S,Sn]=arma2ss(ar);
+A=[0.8,-0.2;1,0];B=[0.001;0];C=[1,0];D=0;
+assert_checkequal(S.A,A);
+assert_checkequal(S.B,B);
+assert_checkequal(S.C,C);
+assert_checkequal(S.D,D);
+A=[0.8,-0.2;1,0];B=[0;0];C=[1,0];D=0;
+assert_checkequal(Sn.A,A);
+assert_checkequal(Sn.B,B);
+assert_checkequal(Sn.C,C);
+assert_checkequal(Sn.D,D);
+a=[1,-2.851,2.717,-0.865].*.eye(2,2);
+b=[0,1,1,1].*.[1;1];
+d=[1,0.7,0.2].*.eye(2,2);
+sig=eye(2,2);
+ar=armac(a,b,d,2,1,sig);
+[S,Sn]=arma2ss(ar);
+A=[2.851,0, -2.717,0, 0.865,0, 1,1,1;
+ 0, 2.851,0, -2.717,0, 0.865,1,1,1;
+ 1, 0, 0, 0, 0, 0, 0,0,0;
+ 0, 1, 0, 0, 0, 0, 0,0,0;
+ 0, 0, 1, 0, 0, 0, 0,0,0;
+ 0, 0, 0, 1, 0, 0, 0,0,0;
+ 0, 0, 0, 0, 0, 0, 0,0,0;
+ 0, 0, 0, 0, 0, 0, 1,0,0;
+ 0, 0, 0, 0, 0, 0, 0,1,0];
+B=[0;0;0;0;0;0;1;0;0];
+C=[1,0,0,0,0,0,0,0,0;
+ 0,1,0,0,0,0,0,0,0];
+D=[0;0];
+assert_checkequal(S.A,A);
+assert_checkequal(S.B,B);
+assert_checkequal(S.C,C);
+assert_checkequal(S.D,D);
+A=[2.851,0,-2.717,0,0.865,0,0.7,0,0.2,0;
+ 0,2.851,0,-2.717,0,0.865,0,0.7,0,0.2;
+ 1,0,0,0,0,0,0,0,0,0;
+ 0,1,0,0,0,0,0,0,0,0;
+ 0,0,1,0,0,0,0,0,0,0;
+ 0,0,0,1,0,0,0,0,0,0;
+ 0,0,0,0,0,0,0,0,0,0;
+ 0,0,0,0,0,0,0,0,0,0;
+ 0,0,0,0,0,0,1,0,0,0;
+ 0,0,0,0,0,0,0,1,0,0];
+B=[1,0;0,1;0,0;0,0;0,0;0,0;1,0;0,1;0,0;0,0];
+C=[1,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0,0,0];
+D=[0,0;0,0];
+assert_checkequal(Sn.A,A);
+assert_checkequal(Sn.B,B);
+assert_checkequal(Sn.C,C);
+assert_checkequal(Sn.D,D);
diff --git a/modules/cacsd/tests/unit_tests/arma2ss.tst b/modules/cacsd/tests/unit_tests/arma2ss.tst
new file mode 100755
index 000000000..e41261eb0
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/arma2ss.tst
@@ -0,0 +1,80 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+ny=1,nu=1,sig=0.01;
+ar=armac(1,[0,0.2],[0,1],ny,nu,sig);
+[S,Sn]=arma2ss(ar);
+A=[0,0.2;0,0];B=[0;1];C=[1,0];D=0;
+assert_checkequal(S.A,A);
+assert_checkequal(S.B,B);
+assert_checkequal(S.C,C);
+assert_checkequal(S.D,D);
+A=[0,1;0,0];B=[0;0.01];C=[1,0];D=0;
+assert_checkequal(Sn.A,A);
+assert_checkequal(Sn.B,B);
+assert_checkequal(Sn.C,C);
+assert_checkequal(Sn.D,D);
+//
+ny=1,nu=1;
+ar=armac([1,-0.8,0.2],0.001,0,ny,nu,0);
+[S,Sn]=arma2ss(ar);
+A=[0.8,-0.2;1,0];B=[0.001;0];C=[1,0];D=0;
+assert_checkequal(S.A,A);
+assert_checkequal(S.B,B);
+assert_checkequal(S.C,C);
+assert_checkequal(S.D,D);
+A=[0.8,-0.2;1,0];B=[0;0];C=[1,0];D=0;
+assert_checkequal(Sn.A,A);
+assert_checkequal(Sn.B,B);
+assert_checkequal(Sn.C,C);
+assert_checkequal(Sn.D,D);
+
+
+
+a=[1,-2.851,2.717,-0.865].*.eye(2,2);
+b=[0,1,1,1].*.[1;1];
+d=[1,0.7,0.2].*.eye(2,2);
+sig=eye(2,2);
+ar=armac(a,b,d,2,1,sig);
+
+[S,Sn]=arma2ss(ar);
+
+A=[2.851,0, -2.717,0, 0.865,0, 1,1,1;
+ 0, 2.851,0, -2.717,0, 0.865,1,1,1;
+ 1, 0, 0, 0, 0, 0, 0,0,0;
+ 0, 1, 0, 0, 0, 0, 0,0,0;
+ 0, 0, 1, 0, 0, 0, 0,0,0;
+ 0, 0, 0, 1, 0, 0, 0,0,0;
+ 0, 0, 0, 0, 0, 0, 0,0,0;
+ 0, 0, 0, 0, 0, 0, 1,0,0;
+ 0, 0, 0, 0, 0, 0, 0,1,0];
+B=[0;0;0;0;0;0;1;0;0];
+C=[1,0,0,0,0,0,0,0,0;
+ 0,1,0,0,0,0,0,0,0];
+D=[0;0];
+assert_checkequal(S.A,A);
+assert_checkequal(S.B,B);
+assert_checkequal(S.C,C);
+assert_checkequal(S.D,D);
+
+A=[2.851,0,-2.717,0,0.865,0,0.7,0,0.2,0;
+ 0,2.851,0,-2.717,0,0.865,0,0.7,0,0.2;
+ 1,0,0,0,0,0,0,0,0,0;
+ 0,1,0,0,0,0,0,0,0,0;
+ 0,0,1,0,0,0,0,0,0,0;
+ 0,0,0,1,0,0,0,0,0,0;
+ 0,0,0,0,0,0,0,0,0,0;
+ 0,0,0,0,0,0,0,0,0,0;
+ 0,0,0,0,0,0,1,0,0,0;
+ 0,0,0,0,0,0,0,1,0,0];
+B=[1,0;0,1;0,0;0,0;0,0;0,0;1,0;0,1;0,0;0,0];
+C=[1,0,0,0,0,0,0,0,0,0;0,1,0,0,0,0,0,0,0,0];
+D=[0,0;0,0];
+assert_checkequal(Sn.A,A);
+assert_checkequal(Sn.B,B);
+assert_checkequal(Sn.C,C);
+assert_checkequal(Sn.D,D);
diff --git a/modules/cacsd/tests/unit_tests/bode.dia.ref b/modules/cacsd/tests/unit_tests/bode.dia.ref
new file mode 100755
index 000000000..e0c1effdc
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/bode.dia.ref
@@ -0,0 +1,133 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+function r=checkbode(h,leg)
+ fig=gcf();
+ r=%t;
+ ap=fig.children(1);
+ am=fig.children(2);
+ if am.log_flags<>"lnn" then r=%f;return,end
+ if or(am.axes_visible<>["on","on","on"]) then r=%f;return,end
+ if ap.log_flags<>"lnn" then r=%f;return,end
+ if or(ap.axes_visible<>["on","on","on"]) then r=%f;return,end
+ n=size(am.children($).children,"*");
+ if n<>size(h,1) then bugmes();quit;end
+ for k=1:n;
+ pm=am.children($).children(n+1-k);
+ pp=ap.children($).children(n+1-k);
+ if or(pm.data(:,1)<>pp.data(:,1)) then ;r=%f;return,end
+ [frq,rf]=repfreq(h(k,1),pm.data(:,1));[phi,d]=phasemag(rf);
+ if norm(d(:)-pm.data(:,2))> 1d-15 then r=%f;return,end
+ end
+ if argn(2)==2 then
+ if size(ap.children,"*")<2 then r=%f;return,end
+ if ap.children(1).type<>"Legend" then r=%f;return,end
+ if size(ap.children(1).links,"*")<>n then r=%f;return,end
+ if or(ap.children(1).text<>leg(:)) then r=%f;return,end
+ end
+endfunction
+s=poly(0,"s");
+n=1+s;d=1+2*s;
+h=syslin("c",n,d);
+sl=tf2ss(h);
+sld=dscr(sl,0.01);
+hd=ss2tf(sld);
+[w,rf]=repfreq(h,0.01,100);
+// Continuous time
+clf();bode(h);
+if ~checkbode(h) then bugmes();quit;end
+clf();bode(h,"h");
+if ~checkbode(h,"h") then bugmes();quit;end
+clf();bode(h,0.01,100);
+if ~checkbode(h) then bugmes();quit;end
+clf();bode(h,0.01,100,"h");
+if ~checkbode(h,"h") then bugmes();quit;end
+clf();bode(h,0.01,100,0.01);
+if ~checkbode(h) then bugmes();quit;end
+clf();bode(sl,0.01,100);
+if ~checkbode(sl) then bugmes();quit;end
+clf();bode(sl,0.01,100,0.01);
+// Continuous time SIMO
+h=[h;h+1];sl=[sl;sl+1];
+clf();bode(h);
+if ~checkbode(h) then bugmes();quit;end
+clf();bode(h,["h";"h+1"]);
+if ~checkbode(h,["h";"h+1"]) then bugmes();quit;end
+clf();bode(h,0.01,100);
+if ~checkbode(h) then bugmes();quit;end
+clf();bode(h,0.01,100,["h";"h+1"]);
+if ~checkbode(h,["h";"h+1"]) then bugmes();quit;end
+clf();bode(h,0.01,100,0.01);
+if ~checkbode(h) then bugmes();quit;end
+clf();bode(sl,0.01,100);
+if ~checkbode(sl) then bugmes();quit;end
+clf();bode(sl,0.01,100,0.01);
+// Discrete case
+clf();bode(hd);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd) then bugmes();quit;end
+clf();bode(hd,"h");
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd,"h") then bugmes();quit;end
+clf();bode(hd,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd) then bugmes();quit;end
+clf();bode(hd,0.01,100,"h");
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd,"h") then bugmes();quit;end
+clf();bode(hd,0.01,100,0.01);
+if ~checkbode(hd) then bugmes();quit;end
+clf();bode(sld,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(sld) then bugmes();quit;end
+clf();bode(sl,0.01,100,0.01);
+// Discrete case SIMO
+hd=[hd;hd+1];sld=[sld;sld+1];
+clf();bode(hd);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd) then bugmes();quit;end
+clf();bode(hd,["h";"h+1"]);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd,["h";"h+1"]) then bugmes();quit;end
+clf();bode(hd,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd) then bugmes();quit;end
+clf();bode(hd,0.01,100,["h";"h+1"]);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(hd,["h";"h+1"]) then bugmes();quit;end
+clf();bode(hd,0.01,100,0.01);
+if ~checkbode(hd) then bugmes();quit;end
+clf();bode(sld,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if ~checkbode(sld) then bugmes();quit;end
+clf();bode(sl,0.01,100,0.01);
+// bode given by precomputed frequency response
+h=syslin("c",n,d);
+clf();bode(h,0.01,100);
+fig=gcf();
+dp=fig.children(1).children($).children.data;
+dm=fig.children(2).children($).children.data;
+[w,rf]=repfreq(h,0.01,100);
+clf(); bode(w,rf);
+fig=gcf();
+if norm(dp-fig.children(1).children($).children.data)>1d-13 then bugmes();quit;end
+if norm(dm-fig.children(2).children($).children.data)>1d-13 then bugmes();quit;end
+clf(); bode(w,20*log(abs(rf))/log(10),(180/%pi)*atan(imag(rf),real(rf)))
+fig=gcf();
+if norm(dp-fig.children(1).children($).children.data)>1d-13 then bugmes();quit;end
+if norm(dm-fig.children(2).children($).children.data)>1d-13 then bugmes();quit;end
+// Bode_asymp()
+s = %s;
+G = (s+10)/(s*(s+100)); // A rational matrix
+sys = syslin("c", G); // A continuous-time linear system in transfer matrix representation.
+f_min = .0001; f_max = 1600; // Frequencies in Hz
+clf(); bode(sys, f_min, f_max, "rad"); // The optional argument "rad" converts Hz to rad/s
+bode_asymp(sys, 10, 1000); // Plots asymptotes in the given range of frequency (in rad/s).
diff --git a/modules/cacsd/tests/unit_tests/bode.tst b/modules/cacsd/tests/unit_tests/bode.tst
new file mode 100755
index 000000000..36a941752
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/bode.tst
@@ -0,0 +1,145 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- ENGLISH IMPOSED -->
+//
+
+function r=checkbode(h,leg)
+ fig=gcf();
+ r=%t;
+ ap=fig.children(1);
+ am=fig.children(2);
+ if am.log_flags<>"lnn" then r=%f;return,end
+ if or(am.axes_visible<>["on","on","on"]) then r=%f;return,end
+ if ap.log_flags<>"lnn" then r=%f;return,end
+ if or(ap.axes_visible<>["on","on","on"]) then r=%f;return,end
+
+ n=size(am.children($).children,"*");
+ if n<>size(h,1) then pause,end
+ for k=1:n;
+ pm=am.children($).children(n+1-k);
+ pp=ap.children($).children(n+1-k);
+ if or(pm.data(:,1)<>pp.data(:,1)) then ;r=%f;return,end
+ [frq,rf]=repfreq(h(k,1),pm.data(:,1));[phi,d]=phasemag(rf);
+ if norm(d(:)-pm.data(:,2))> 1d-15 then r=%f;return,end
+ end
+ if argn(2)==2 then
+ if size(ap.children,"*")<2 then r=%f;return,end
+ if ap.children(1).type<>"Legend" then r=%f;return,end
+ if size(ap.children(1).links,"*")<>n then r=%f;return,end
+ if or(ap.children(1).text<>leg(:)) then r=%f;return,end
+ end
+endfunction
+
+s=poly(0,"s");
+n=1+s;d=1+2*s;
+h=syslin("c",n,d);
+sl=tf2ss(h);
+sld=dscr(sl,0.01);
+hd=ss2tf(sld);
+
+[w,rf]=repfreq(h,0.01,100);
+
+// Continuous time
+clf();bode(h);
+if ~checkbode(h) then pause,end
+clf();bode(h,"h");
+if ~checkbode(h,"h") then pause,end
+
+clf();bode(h,0.01,100);
+if ~checkbode(h) then pause,end
+clf();bode(h,0.01,100,"h");
+if ~checkbode(h,"h") then pause,end
+
+clf();bode(h,0.01,100,0.01);
+if ~checkbode(h) then pause,end
+clf();bode(sl,0.01,100);
+if ~checkbode(sl) then pause,end
+clf();bode(sl,0.01,100,0.01);
+
+// Continuous time SIMO
+h=[h;h+1];sl=[sl;sl+1];
+clf();bode(h);
+if ~checkbode(h) then pause,end
+clf();bode(h,["h";"h+1"]);
+if ~checkbode(h,["h";"h+1"]) then pause,end
+
+clf();bode(h,0.01,100);
+if ~checkbode(h) then pause,end
+clf();bode(h,0.01,100,["h";"h+1"]);
+if ~checkbode(h,["h";"h+1"]) then pause,end
+
+clf();bode(h,0.01,100,0.01);
+if ~checkbode(h) then pause,end
+clf();bode(sl,0.01,100);
+if ~checkbode(sl) then pause,end
+clf();bode(sl,0.01,100,0.01);
+
+
+// Discrete case
+clf();bode(hd);
+if ~checkbode(hd) then pause,end
+clf();bode(hd,"h");
+if ~checkbode(hd,"h") then pause,end
+
+clf();bode(hd,0.01,100);
+if ~checkbode(hd) then pause,end
+clf();bode(hd,0.01,100,"h");
+if ~checkbode(hd,"h") then pause,end
+
+clf();bode(hd,0.01,100,0.01);
+if ~checkbode(hd) then pause,end
+clf();bode(sld,0.01,100);
+if ~checkbode(sld) then pause,end
+clf();bode(sl,0.01,100,0.01);
+
+// Discrete case SIMO
+hd=[hd;hd+1];sld=[sld;sld+1];
+clf();bode(hd);
+if ~checkbode(hd) then pause,end
+clf();bode(hd,["h";"h+1"]);
+if ~checkbode(hd,["h";"h+1"]) then pause,end
+
+clf();bode(hd,0.01,100);
+if ~checkbode(hd) then pause,end
+clf();bode(hd,0.01,100,["h";"h+1"]);
+if ~checkbode(hd,["h";"h+1"]) then pause,end
+
+clf();bode(hd,0.01,100,0.01);
+if ~checkbode(hd) then pause,end
+clf();bode(sld,0.01,100);
+if ~checkbode(sld) then pause,end
+clf();bode(sl,0.01,100,0.01);
+
+// bode given by precomputed frequency response
+h=syslin("c",n,d);
+clf();bode(h,0.01,100);
+fig=gcf();
+dp=fig.children(1).children($).children.data;
+dm=fig.children(2).children($).children.data;
+[w,rf]=repfreq(h,0.01,100);
+
+clf(); bode(w,rf);
+fig=gcf();
+if norm(dp-fig.children(1).children($).children.data)>1d-13 then pause,end
+if norm(dm-fig.children(2).children($).children.data)>1d-13 then pause,end
+
+clf(); bode(w,20*log(abs(rf))/log(10),(180/%pi)*atan(imag(rf),real(rf)))
+fig=gcf();
+if norm(dp-fig.children(1).children($).children.data)>1d-13 then pause,end
+if norm(dm-fig.children(2).children($).children.data)>1d-13 then pause,end
+
+// Bode_asymp()
+s = %s;
+G = (s+10)/(s*(s+100)); // A rational matrix
+sys = syslin("c", G); // A continuous-time linear system in transfer matrix representation.
+f_min = .0001; f_max = 1600; // Frequencies in Hz
+
+clf(); bode(sys, f_min, f_max, "rad"); // The optional argument "rad" converts Hz to rad/s
+bode_asymp(sys, 10, 1000); // Plots asymptotes in the given range of frequency (in rad/s).
diff --git a/modules/cacsd/tests/unit_tests/calfrq.dia.ref b/modules/cacsd/tests/unit_tests/calfrq.dia.ref
new file mode 100755
index 000000000..87e39b7aa
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/calfrq.dia.ref
@@ -0,0 +1,85 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+K=0.001; // Minimum relative prediction error in the nyquist plan
+Epss=0.002; // minimum frequency distance with a singularity
+nptmax=5000; //maximum number of discretization points
+pas=100/(2*%pi);
+s=%s;
+h=syslin('c',1/%s);n=1;
+[f,bnds,split]=calfrq(h,0.01,100);
+if split<>1 then bugmes();quit;end
+rf=freq(h.num,h.den,2*%pi*%i*f);
+//finite difference derivative estimate
+ddf=diff(f)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then bugmes();quit;end
+h=syslin('c',[1/(%s+0.5);1/(%s+0.3)]);n=2;
+[f,bnds,split]=calfrq(h,0.01,100);
+if split<>1 then bugmes();quit;end
+rf=freq(h.num,h.den,2*%pi*%i*f);
+//finite difference derivative estimate
+ddf=diff(f)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then bugmes();quit;end
+h=syslin('c',(%s^2+2*0.9*10*%s+100)/(%s^2+2*0.3*10.1*%s+102.01));
+//h=h*syslin('c',(%s)/(%s^2+81)) ;
+n=1;
+[f,bnds,split]=calfrq(h,0.01,100);
+if size(split,1)<>1 then bugmes();quit;end
+rf=freq(h.num,h.den,2*%pi*%i*f);
+//finite difference derivative estimate
+ddf=diff(f)/100;
+drf=(freq(h.num,h.den,2*%pi*%i*(f(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*100);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then bugmes();quit;end
+//case with singularity
+h=syslin('c',(%s)/(%s^2+81)) ;
+sing=9/(2*%pi);
+n=1;
+[f,bnds,split]=calfrq(h,0.01,100);
+if size(split,2)<>2 then bugmes();quit;end
+ks=split(2);
+if abs(f(ks-1)-f(ks))*2*%pi<Epss then bugmes();quit;end
+if f(ks-1)>sing|f(ks)<sing then bugmes();quit;end
+//finite difference derivative estimate
+f1=f(1:ks-15);//remove points near singularity for which pasmin constraint may be active
+rf=freq(h.num,h.den,2*%pi*%i*f1);
+ddf=diff(f1)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f1(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then bugmes();quit;end
+f1=f(ks+15:$);//remove points near singularity for which pasmin constraint may be active
+rf=freq(h.num,h.den,2*%pi*%i*f1);
+ddf=diff(f1)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f1(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then bugmes();quit;end
+//state space case
+sl=tf2ss(h);
+n=1;
+[f1,bnds1,split1]=calfrq(sl,0.01,100);
+if norm(f-f1)>1d-13 then bugmes();quit;end
+if or(split<>split1) then bugmes();quit;end
+//discrete case
+h=syslin('c',(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+hd=ss2tf(dscr(h,0.01));
+[f,bnds,split]=calfrq(hd,0.00001,3);
+if size(split,1)<>1 then bugmes();quit;end
+rf=freq(h.num,h.den,exp(2*%pi*%i*f));
+//finite difference derivative estimate
+ddf=diff(f)/pas;
+drf=(freq(h.num,h.den,exp(2*%pi*%i*(f(1:$-1)+ddf)))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/calfrq.tst b/modules/cacsd/tests/unit_tests/calfrq.tst
new file mode 100755
index 000000000..807726d72
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/calfrq.tst
@@ -0,0 +1,104 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+K=0.001; // Minimum relative prediction error in the nyquist plan
+Epss=0.002; // minimum frequency distance with a singularity
+nptmax=5000; //maximum number of discretization points
+pas=100/(2*%pi);
+s=%s;
+
+h=syslin('c',1/%s);n=1;
+
+
+[f,bnds,split]=calfrq(h,0.01,100);
+if split<>1 then pause,end
+rf=freq(h.num,h.den,2*%pi*%i*f);
+//finite difference derivative estimate
+ddf=diff(f)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then pause,end
+
+h=syslin('c',[1/(%s+0.5);1/(%s+0.3)]);n=2;
+[f,bnds,split]=calfrq(h,0.01,100);
+if split<>1 then pause,end
+rf=freq(h.num,h.den,2*%pi*%i*f);
+//finite difference derivative estimate
+ddf=diff(f)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then pause,end
+
+
+
+h=syslin('c',(%s^2+2*0.9*10*%s+100)/(%s^2+2*0.3*10.1*%s+102.01));
+//h=h*syslin('c',(%s)/(%s^2+81)) ;
+n=1;
+[f,bnds,split]=calfrq(h,0.01,100);
+if size(split,1)<>1 then pause,end
+
+rf=freq(h.num,h.den,2*%pi*%i*f);
+//finite difference derivative estimate
+ddf=diff(f)/100;
+drf=(freq(h.num,h.den,2*%pi*%i*(f(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*100);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then pause,end
+
+
+
+
+
+
+//case with singularity
+h=syslin('c',(%s)/(%s^2+81)) ;
+sing=9/(2*%pi);
+n=1;
+[f,bnds,split]=calfrq(h,0.01,100);
+if size(split,2)<>2 then pause,end
+ks=split(2);
+if abs(f(ks-1)-f(ks))*2*%pi<Epss then pause,end
+if f(ks-1)>sing|f(ks)<sing then pause,end
+
+//finite difference derivative estimate
+f1=f(1:ks-15);//remove points near singularity for which pasmin constraint may be active
+rf=freq(h.num,h.den,2*%pi*%i*f1);
+ddf=diff(f1)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f1(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then pause,end
+f1=f(ks+15:$);//remove points near singularity for which pasmin constraint may be active
+rf=freq(h.num,h.den,2*%pi*%i*f1);
+ddf=diff(f1)/pas;
+drf=(freq(h.num,h.den,2*%pi*%i*(f1(1:$-1)+ddf))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then pause,end
+
+
+//state space case
+sl=tf2ss(h);
+n=1;
+[f1,bnds1,split1]=calfrq(sl,0.01,100);
+if norm(f-f1)>1d-13 then pause,end
+if or(split<>split1) then pause,end
+
+//discrete case
+h=syslin('c',(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+hd=ss2tf(dscr(h,0.01));
+[f,bnds,split]=calfrq(hd,0.00001,3);
+if size(split,1)<>1 then pause,end
+
+rf=freq(h.num,h.den,exp(2*%pi*%i*f));
+//finite difference derivative estimate
+ddf=diff(f)/pas;
+drf=(freq(h.num,h.den,exp(2*%pi*%i*(f(1:$-1)+ddf)))-rf(:,1:$-1));
+//error between computed and extrapolated value
+e=rf(:,2:$)-(rf(:,1:$-1)+drf*pas);
+if max([abs(real(e))/max(bnds(2)-bnds(1),1); abs(imag(e))/max(bnds(4)- bnds(3),1)])>K then pause,end
diff --git a/modules/cacsd/tests/unit_tests/coff.dia.ref b/modules/cacsd/tests/unit_tests/coff.dia.ref
new file mode 100755
index 000000000..e9bd1aa4c
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/coff.dia.ref
@@ -0,0 +1,12 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+M=[1,2;0,3];
+[N,d]=coff(M);
+if norm(coeff(N-[-3+%s,2;0,-1+%s]))>1d-14 then bugmes();quit;end
+if norm(coeff(d-(3-4*%s+%s^2)))>1d-14 then bugmes();quit;end
+[N,d]=coff([]);
+if N<>[]|d<>1 then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/coff.tst b/modules/cacsd/tests/unit_tests/coff.tst
new file mode 100755
index 000000000..f0deec864
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/coff.tst
@@ -0,0 +1,13 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+M=[1,2;0,3];
+[N,d]=coff(M);
+if norm(coeff(N-[-3+%s,2;0,-1+%s]))>1d-14 then pause,end
+if norm(coeff(d-(3-4*%s+%s^2)))>1d-14 then pause,end
+[N,d]=coff([]);
+if N<>[]|d<>1 then pause,end
diff --git a/modules/cacsd/tests/unit_tests/contr.dia.ref b/modules/cacsd/tests/unit_tests/contr.dia.ref
new file mode 100755
index 000000000..acab228db
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/contr.dia.ref
@@ -0,0 +1,57 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+assert_checkfalse(execstr("contr()", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "contr", 2, 3);
+assert_checkerror("contr()", refMsg);
+A = ones(3,3) + 0 * %i;
+B = ones(3,3) * 2;
+assert_checkfalse(execstr("contr(A, B)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 1);
+assert_checkerror("contr(A, B)", refMsg);
+A = ones(3,3);
+assert_checkfalse(execstr("contr(A, complex(B))", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 2);
+assert_checkerror("contr(A, complex(B))", refMsg);
+assert_checkfalse(execstr("contr(sparse(A), B)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 1);
+assert_checkerror("contr(sparse(A), B)", refMsg);
+assert_checkfalse(execstr("contr(A, sparse(B))", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 2);
+assert_checkerror("contr(A, sparse(B))", refMsg);
+a = [0.8604043 , 0.0070020 , 0.6223373 , -1.356213 , -4.2301775
+ 0.159714 , 0.0857791 , -0.2367751 , 0.4958580 , 0.6398817
+ -4.3054931 , -0.0365878 , 2.1784911 , 0.0314793 , 2.3728994
+ -3.7115779 , -0.5370809 , 2.4291716 , -0.6352663 , 2.6972781
+ 6.3580966 , 0.1377712 , -4.0461243 , -0.5192899 , -4.0394083];
+b = [-0.0532544 , -0.1494083 , -0.0098619
+ -0.0355030 , -0.0162722 , 0.1045365
+ -0.1301775 , 0.1736686 , -0.0611440
+ 0.1834320 , 0.1757396 , -0.5956607
+ 0.1775148 , -0.1186391 , 0.1439842];
+c = [2 , 7 , -2 , 5 , 1
+ 0 , -1 , 3 , 0 , 2];
+d = [1 , 0 , 0
+ 0 , 0 , 0];
+assert_checkequal(contr(a, b), 4);
+[n,U]=contr(a,b);a1=U'*a*U;
+assert_checkalmostequal(abs(spec(a1(n+1:$,n+1:$))), 0, [], 1e-7);
+[n,U,ind,V,Ac,Bc]=contr(a,b);
+assert_checkequal(n, 4);
+assert_checkalmostequal(norm(Ac(n+1:$,:),1), 0, [], 1e-7);
+assert_checkalmostequal(norm(U'*a*U-Ac,1), 0, [], 1e-6);
+assert_checkalmostequal(norm(U'*b*V-Bc), 0, [], 1e-10);
+assert_checkfalse(execstr("contr(a,1)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong values for input arguments #%d and #%d.\n"), "contr", 1, 2);
+assert_checkerror("contr(a,1)", refMsg);
+assert_checkfalse(execstr("contr(a+%s,b)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 1);
+assert_checkerror("contr(a+%s,b)", refMsg);
+assert_checkfalse(execstr("contr(a,b,''ee'')", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real scalar expected.\n"), "contr", 3);
+assert_checkerror("contr(a,b,''ee'')", refMsg);
+assert_checkequal(contr(a',c',0.0001), 3);
diff --git a/modules/cacsd/tests/unit_tests/contr.tst b/modules/cacsd/tests/unit_tests/contr.tst
new file mode 100755
index 000000000..fe4942b06
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/contr.tst
@@ -0,0 +1,71 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+assert_checkfalse(execstr("contr()", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "contr", 2, 3);
+assert_checkerror("contr()", refMsg);
+
+A = ones(3,3) + 0 * %i;
+B = ones(3,3) * 2;
+assert_checkfalse(execstr("contr(A, B)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 1);
+assert_checkerror("contr(A, B)", refMsg);
+
+A = ones(3,3);
+assert_checkfalse(execstr("contr(A, complex(B))", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 2);
+assert_checkerror("contr(A, complex(B))", refMsg);
+
+assert_checkfalse(execstr("contr(sparse(A), B)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 1);
+assert_checkerror("contr(sparse(A), B)", refMsg);
+
+assert_checkfalse(execstr("contr(A, sparse(B))", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 2);
+assert_checkerror("contr(A, sparse(B))", refMsg);
+
+a = [0.8604043 , 0.0070020 , 0.6223373 , -1.356213 , -4.2301775
+ 0.159714 , 0.0857791 , -0.2367751 , 0.4958580 , 0.6398817
+ -4.3054931 , -0.0365878 , 2.1784911 , 0.0314793 , 2.3728994
+ -3.7115779 , -0.5370809 , 2.4291716 , -0.6352663 , 2.6972781
+ 6.3580966 , 0.1377712 , -4.0461243 , -0.5192899 , -4.0394083];
+b = [-0.0532544 , -0.1494083 , -0.0098619
+ -0.0355030 , -0.0162722 , 0.1045365
+ -0.1301775 , 0.1736686 , -0.0611440
+ 0.1834320 , 0.1757396 , -0.5956607
+ 0.1775148 , -0.1186391 , 0.1439842];
+c = [2 , 7 , -2 , 5 , 1
+ 0 , -1 , 3 , 0 , 2];
+d = [1 , 0 , 0
+ 0 , 0 , 0];
+
+assert_checkequal(contr(a, b), 4);
+
+[n,U]=contr(a,b);a1=U'*a*U;
+assert_checkalmostequal(abs(spec(a1(n+1:$,n+1:$))), 0, [], 1e-7);
+
+[n,U,ind,V,Ac,Bc]=contr(a,b);
+assert_checkequal(n, 4);
+assert_checkalmostequal(norm(Ac(n+1:$,:),1), 0, [], 1e-7);
+assert_checkalmostequal(norm(U'*a*U-Ac,1), 0, [], 1e-6);
+assert_checkalmostequal(norm(U'*b*V-Bc), 0, [], 1e-10);
+
+assert_checkfalse(execstr("contr(a,1)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong values for input arguments #%d and #%d.\n"), "contr", 1, 2);
+assert_checkerror("contr(a,1)", refMsg);
+
+assert_checkfalse(execstr("contr(a+%s,b)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "contr", 1);
+assert_checkerror("contr(a+%s,b)", refMsg);
+
+assert_checkfalse(execstr("contr(a,b,''ee'')", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real scalar expected.\n"), "contr", 3);
+assert_checkerror("contr(a,b,''ee'')", refMsg);
+
+assert_checkequal(contr(a',c',0.0001), 3);
+
+
diff --git a/modules/cacsd/tests/unit_tests/contrss.dia.ref b/modules/cacsd/tests/unit_tests/contrss.dia.ref
new file mode 100755
index 000000000..57ade92f7
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/contrss.dia.ref
@@ -0,0 +1,39 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+a = [0.8604043 , 0.0070020 , 0.6223373 , -1.356213 , -4.2301775
+ 0.159714 , 0.0857791 , -0.2367751 , 0.4958580 , 0.6398817
+ -4.3054931 , -0.0365878 , 2.1784911 , 0.0314793 , 2.3728994
+ -3.7115779 , -0.5370809 , 2.4291716 , -0.6352663 , 2.6972781
+ 6.3580966 , 0.1377712 , -4.0461243 , -0.5192899 , -4.0394083];
+b = [-0.0532544 , -0.1494083 , -0.0098619
+ -0.0355030 , -0.0162722 , 0.1045365
+ -0.1301775 , 0.1736686 , -0.0611440
+ 0.1834320 , 0.1757396 , -0.5956607
+ 0.1775148 , -0.1186391 , 0.1439842];
+c = [2 , 7 , -2 , 5 , 1
+ 0 , -1 , 3 , 0 , 2];
+d = [1 , 0 , 0
+ 0 , 0 , 0];
+sl=syslin('c',a,b,c,d);
+slc=contrss(sl,%eps);
+if size(slc.A,1)<>5 then bugmes();quit;end
+slc=contrss(sl);
+n=size(slc.A,1);
+if n<>4 then bugmes();quit;end
+[n,U,ind,V,Ac,Bc]=contr(a,b);
+if norm(Ac(1:n,1:n)-slc.A)>1d-14 then bugmes();quit;end
+slo=obsvss(sl);
+if size(slo.A,1)<>5 then bugmes();quit;end
+slo=obsvss(sl,0.0001);
+n=size(slo.A,1);
+if n<>3 then bugmes();quit;end
+[n,U,ind,V,Ao,Co]=contr(a',c',0.0001);
+if norm(Ao(1:n,1:n)'-slo.A)>1d-14 then bugmes();quit;end
+slm=minss(sl);
+if size(slm.A,1)<>5 then bugmes();quit;end
+slm=minss(sl,0.0001);
+if size(slm.A,1)<>2 then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/contrss.tst b/modules/cacsd/tests/unit_tests/contrss.tst
new file mode 100755
index 000000000..07009d7da
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/contrss.tst
@@ -0,0 +1,48 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+a = [0.8604043 , 0.0070020 , 0.6223373 , -1.356213 , -4.2301775
+ 0.159714 , 0.0857791 , -0.2367751 , 0.4958580 , 0.6398817
+ -4.3054931 , -0.0365878 , 2.1784911 , 0.0314793 , 2.3728994
+ -3.7115779 , -0.5370809 , 2.4291716 , -0.6352663 , 2.6972781
+ 6.3580966 , 0.1377712 , -4.0461243 , -0.5192899 , -4.0394083];
+b = [-0.0532544 , -0.1494083 , -0.0098619
+ -0.0355030 , -0.0162722 , 0.1045365
+ -0.1301775 , 0.1736686 , -0.0611440
+ 0.1834320 , 0.1757396 , -0.5956607
+ 0.1775148 , -0.1186391 , 0.1439842];
+c = [2 , 7 , -2 , 5 , 1
+ 0 , -1 , 3 , 0 , 2];
+d = [1 , 0 , 0
+ 0 , 0 , 0];
+
+
+sl=syslin('c',a,b,c,d);
+slc=contrss(sl,%eps);
+if size(slc.A,1)<>5 then pause,end
+
+slc=contrss(sl);
+n=size(slc.A,1);
+if n<>4 then pause,end
+[n,U,ind,V,Ac,Bc]=contr(a,b);
+if norm(Ac(1:n,1:n)-slc.A)>1d-14 then pause,end
+
+
+
+slo=obsvss(sl);
+if size(slo.A,1)<>5 then pause,end
+
+slo=obsvss(sl,0.0001);
+n=size(slo.A,1);
+if n<>3 then pause,end
+[n,U,ind,V,Ao,Co]=contr(a',c',0.0001);
+if norm(Ao(1:n,1:n)'-slo.A)>1d-14 then pause,end
+
+slm=minss(sl);
+if size(slm.A,1)<>5 then pause,end
+
+slm=minss(sl,0.0001);
+if size(slm.A,1)<>2 then pause,end
diff --git a/modules/cacsd/tests/unit_tests/csim.dia.ref b/modules/cacsd/tests/unit_tests/csim.dia.ref
new file mode 100755
index 000000000..bb4ada45b
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/csim.dia.ref
@@ -0,0 +1,111 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- ENGLISH IMPOSED -->
+// Unit test for csim function
+a=0;b=1;c=2;
+t=0:0.1:1;
+sl=syslin('c',a,b,c);
+u=ones(1,11);
+xrefstep = 0:0.1:1;
+yrefstep=0:0.2:2;
+//step
+y=csim('step',t,sl);
+assert_checkalmostequal(y, yrefstep);
+y=csim('step',[],sl);
+assert_checkequal(y, []);
+[y1,x]=csim('step',[],sl);
+assert_checkequal(y1, []);
+assert_checkequal(x, []);
+[y1,x]=csim('step',t,sl);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+y=csim('step',t,sl,0);
+assert_checkalmostequal(y, yrefstep);
+[y1,x]=csim('step',t,sl,0);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+y=csim('step',t,sl,1);
+assert_checkalmostequal(y, yrefstep);
+y=csim('step',t,sl,0,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefstep);
+[y1,x]=csim('step',t,sl,1,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+//impulse
+yrefimp=2*ones(1,11);
+xrefimp=ones(1,11);
+y=csim('impulse',t,sl);
+assert_checkalmostequal(y, yrefimp);
+y=csim('impulse',[],sl);
+assert_checkequal(y, []);
+[y1,x]=csim('impulse',[],sl);
+assert_checkequal(y1, []);
+assert_checkequal(x, []);
+w=ones(t)-eye(t);
+y=csim('impulse',t,sl);
+assert_checkalmostequal(y, yrefimp);
+[y1,x]=csim('impulse',t,sl);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+y=csim('impulse',t,sl,0);
+assert_checkalmostequal(y, yrefimp);
+[y1,x]=csim('impulse',t,sl,0);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+y=csim('impulse',t,sl,1);
+assert_checkalmostequal(y, yrefimp);
+[y1,x]=csim('impulse',t,sl,1);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+y=csim('impulse',t,sl,0,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefimp);
+[y1,x]=csim('impulse',t,sl,1,[10*%eps %eps]);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+//function
+function y=step(t),if t<0 then y=0,else y=1,end,endfunction
+y=csim(step,t,sl);
+assert_checkalmostequal(y, yrefstep);
+y=csim(step,[],sl);
+assert_checkequal(y, []);
+[y1,x]=csim(step,[],sl);
+assert_checkequal(y1, []);
+assert_checkequal(x, []);
+y=csim(step,t',sl);
+assert_checkalmostequal(y, yrefstep);
+[y1,x]=csim(step,t,sl);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+y=csim(step,t,sl,0);
+assert_checkalmostequal(y, yrefstep);
+[y1,x]=csim(step,t,sl,0);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+yrefstep2=2:0.2:4;
+xrefstep2=1:0.1:2;
+y=csim(step,t,sl,1);
+assert_checkalmostequal(y, yrefstep2);
+[y1,x]=csim(step,t,sl,1);
+assert_checkalmostequal(y1, yrefstep2);
+assert_checkalmostequal(x, xrefstep2);
+y=csim(step,t,sl,0,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefstep);
+//with transfer function
+y=csim(step,t,ss2tf(sl));
+assert_checkalmostequal(y, yrefstep);
+//with parameter
+function y=step(t,t0),if t<t0 then y=0,else y=1,end,endfunction
+Warning : redefining function: step . Use funcprot(0) to avoid this message
+
+y=csim(list(step,0),t,sl);
+Warning : redefining function: uu . Use funcprot(0) to avoid this message
+
+assert_checkalmostequal(y, yrefstep);
+y=csim(list(step,0),t,ss2tf(sl));
+Warning : redefining function: uu . Use funcprot(0) to avoid this message
+
+assert_checkalmostequal(y, yrefstep);
diff --git a/modules/cacsd/tests/unit_tests/csim.tst b/modules/cacsd/tests/unit_tests/csim.tst
new file mode 100755
index 000000000..4a46e6e95
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/csim.tst
@@ -0,0 +1,143 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- ENGLISH IMPOSED -->
+
+// Unit test for csim function
+
+a=0;b=1;c=2;
+t=0:0.1:1;
+sl=syslin('c',a,b,c);
+u=ones(1,11);
+xrefstep = 0:0.1:1;
+yrefstep=0:0.2:2;
+
+//step
+y=csim('step',t,sl);
+assert_checkalmostequal(y, yrefstep);
+y=csim('step',[],sl);
+assert_checkequal(y, []);
+[y1,x]=csim('step',[],sl);
+assert_checkequal(y1, []);
+assert_checkequal(x, []);
+
+[y1,x]=csim('step',t,sl);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+
+y=csim('step',t,sl,0);
+assert_checkalmostequal(y, yrefstep);
+
+[y1,x]=csim('step',t,sl,0);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+
+y=csim('step',t,sl,1);
+assert_checkalmostequal(y, yrefstep);
+
+y=csim('step',t,sl,0,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefstep);
+
+[y1,x]=csim('step',t,sl,1,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+
+
+//impulse
+yrefimp=2*ones(1,11);
+xrefimp=ones(1,11);
+
+y=csim('impulse',t,sl);
+assert_checkalmostequal(y, yrefimp);
+
+y=csim('impulse',[],sl);
+assert_checkequal(y, []);
+
+[y1,x]=csim('impulse',[],sl);
+assert_checkequal(y1, []);
+assert_checkequal(x, []);
+
+w=ones(t)-eye(t);
+y=csim('impulse',t,sl);
+assert_checkalmostequal(y, yrefimp);
+
+[y1,x]=csim('impulse',t,sl);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+
+y=csim('impulse',t,sl,0);
+assert_checkalmostequal(y, yrefimp);
+
+[y1,x]=csim('impulse',t,sl,0);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+
+y=csim('impulse',t,sl,1);
+assert_checkalmostequal(y, yrefimp);
+
+[y1,x]=csim('impulse',t,sl,1);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+
+y=csim('impulse',t,sl,0,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefimp);
+
+[y1,x]=csim('impulse',t,sl,1,[10*%eps %eps]);
+assert_checkalmostequal(y1, yrefimp);
+assert_checkalmostequal(x, xrefimp);
+
+//function
+function y=step(t),if t<0 then y=0,else y=1,end,endfunction
+
+y=csim(step,t,sl);
+assert_checkalmostequal(y, yrefstep);
+
+y=csim(step,[],sl);
+assert_checkequal(y, []);
+
+[y1,x]=csim(step,[],sl);
+assert_checkequal(y1, []);
+assert_checkequal(x, []);
+
+y=csim(step,t',sl);
+assert_checkalmostequal(y, yrefstep);
+
+[y1,x]=csim(step,t,sl);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+
+y=csim(step,t,sl,0);
+assert_checkalmostequal(y, yrefstep);
+
+[y1,x]=csim(step,t,sl,0);
+assert_checkalmostequal(y1, yrefstep);
+assert_checkalmostequal(x, xrefstep);
+
+yrefstep2=2:0.2:4;
+xrefstep2=1:0.1:2;
+y=csim(step,t,sl,1);
+assert_checkalmostequal(y, yrefstep2);
+
+[y1,x]=csim(step,t,sl,1);
+assert_checkalmostequal(y1, yrefstep2);
+assert_checkalmostequal(x, xrefstep2);
+
+y=csim(step,t,sl,0,[10*%eps %eps]);
+assert_checkalmostequal(y, yrefstep);
+
+//with transfer function
+y=csim(step,t,ss2tf(sl));
+assert_checkalmostequal(y, yrefstep);
+
+//with parameter
+function y=step(t,t0),if t<t0 then y=0,else y=1,end,endfunction
+
+y=csim(list(step,0),t,sl);
+assert_checkalmostequal(y, yrefstep);
+
+y=csim(list(step,0),t,ss2tf(sl));
+assert_checkalmostequal(y, yrefstep);
diff --git a/modules/cacsd/tests/unit_tests/damp.dia.ref b/modules/cacsd/tests/unit_tests/damp.dia.ref
new file mode 100755
index 000000000..0f3947aee
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/damp.dia.ref
@@ -0,0 +1,100 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2001 - INRIA - Serge Steer
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//Vector of complex numbers
+R=[2 1+%i 2-3*%i];
+[wn,zeta]=damp(R);
+assert_checkequal (wn,abs(R));
+assert_checkequal (zeta,-real(R)./wn);
+dt=1;
+[wn,zeta]=damp(R,dt);
+Rd=log(R)/dt;
+assert_checkequal (wn,abs(Rd));
+assert_checkequal (zeta,-real(Rd)./wn);
+R=0;
+[wn,zeta]=damp(R);
+assert_checkequal (wn,0);
+assert_checkequal (zeta,-1);
+R=0;dt=1;
+[wn,zeta]=damp(R,dt);
+assert_checkequal (wn,%inf);
+assert_checkequal (zeta,%nan);
+R=1;dt=1;
+[wn,zeta]=damp(R,dt);
+assert_checkequal (wn,0);
+assert_checkequal (zeta,-1);
+R=1;
+[wn,zeta]=damp(R);
+assert_checkequal (wn,1);
+assert_checkequal (zeta,-1);
+//Polynomial and Polynomial array
+P=real([poly([2 1+%i 1-%i 2-3*%i 2+3*%i],'s'),poly(0,'s'),poly(1,'s')]);
+[wn,zeta]=damp(P);
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta,zetaref);
+[wn,zeta]=damp(prod(P));
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta,zetaref);
+dt=1;
+[wn,zeta]=damp(P,dt);
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[-1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+dt=1;
+[wn,zeta]=damp(prod(P),dt);
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn,wnref, 0, 1D-14);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+//transfer function
+[wn,zeta]=damp(syslin('c',ones(1,3),P));
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref, 0, 1D-14);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+dt=1;
+[wn,zeta]=damp(syslin(dt,ones(1,3),P));
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn,wnref,0, 1D-14);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+//state-space
+[wn,zeta]=damp(tf2ss(syslin('c',1,prod(P))));
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+dt=1;
+[wn,zeta]=damp(tf2ss(syslin(dt,1,prod(P))));
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn, wnref, 0, 1D-14) ;
+assert_checkalmostequal (zeta(2:$),zetaref(2:$)) ;
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+//invalid calls
+assert_checkfalse(execstr("[wn,zeta]=damp()","errcatch")==0);
+assert_checkfalse(execstr("[wn,zeta]=damp(%t)","errcatch")==0);
+assert_checkfalse(execstr("[wn,zeta]=damp(P,1:3)","errcatch")==0);
+assert_checkfalse(execstr("[wn,zeta]=damp(P,%t)","errcatch")==0);
diff --git a/modules/cacsd/tests/unit_tests/damp.tst b/modules/cacsd/tests/unit_tests/damp.tst
new file mode 100755
index 000000000..197a4bf88
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/damp.tst
@@ -0,0 +1,115 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2001 - INRIA - Serge Steer
+// Copyright (C) 2012 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//Vector of complex numbers
+
+R=[2 1+%i 2-3*%i];
+[wn,zeta]=damp(R);
+assert_checkequal (wn,abs(R));
+assert_checkequal (zeta,-real(R)./wn);
+
+dt=1;
+[wn,zeta]=damp(R,dt);
+Rd=log(R)/dt;
+assert_checkequal (wn,abs(Rd));
+assert_checkequal (zeta,-real(Rd)./wn);
+
+R=0;
+[wn,zeta]=damp(R);
+assert_checkequal (wn,0);
+assert_checkequal (zeta,-1);
+
+R=0;dt=1;
+[wn,zeta]=damp(R,dt);
+assert_checkequal (wn,%inf);
+assert_checkequal (zeta,%nan);
+
+R=1;dt=1;
+[wn,zeta]=damp(R,dt);
+assert_checkequal (wn,0);
+assert_checkequal (zeta,-1);
+
+R=1;
+[wn,zeta]=damp(R);
+assert_checkequal (wn,1);
+assert_checkequal (zeta,-1);
+
+//Polynomial and Polynomial array
+P=real([poly([2 1+%i 1-%i 2-3*%i 2+3*%i],'s'),poly(0,'s'),poly(1,'s')]);
+[wn,zeta]=damp(P);
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta,zetaref);
+
+[wn,zeta]=damp(prod(P));
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta,zetaref);
+
+dt=1;
+[wn,zeta]=damp(P,dt);
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[-1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
+dt=1;
+[wn,zeta]=damp(prod(P),dt);
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn,wnref, 0, 1D-14);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
+//transfer function
+[wn,zeta]=damp(syslin('c',ones(1,3),P));
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref, 0, 1D-14);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
+dt=1;
+[wn,zeta]=damp(syslin(dt,ones(1,3),P));
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn,wnref,0, 1D-14);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
+//state-space
+[wn,zeta]=damp(tf2ss(syslin('c',1,prod(P))));
+wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
+zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
+assert_checkalmostequal (wn,wnref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
+dt=1;
+[wn,zeta]=damp(tf2ss(syslin(dt,1,prod(P))));
+t1=log(1+%i)/dt;
+t2=log(2-3*%i)/dt;
+wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
+zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
+assert_checkalmostequal (wn, wnref, 0, 1D-14) ;
+assert_checkalmostequal (zeta(2:$),zetaref(2:$)) ;
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
+//invalid calls
+assert_checkfalse(execstr("[wn,zeta]=damp()","errcatch")==0);
+assert_checkfalse(execstr("[wn,zeta]=damp(%t)","errcatch")==0);
+assert_checkfalse(execstr("[wn,zeta]=damp(P,1:3)","errcatch")==0);
+assert_checkfalse(execstr("[wn,zeta]=damp(P,%t)","errcatch")==0);
diff --git a/modules/cacsd/tests/unit_tests/dhinf.dia.ref b/modules/cacsd/tests/unit_tests/dhinf.dia.ref
new file mode 100755
index 000000000..53dc7ffc1
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/dhinf.dia.ref
@@ -0,0 +1,58 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+A=[-0.7 0 0.3 0 -0.5 -0.1
+ -0.6 0.2 -0.4 -0.3 0 0
+ -0.5 0.7 -0.1 0 0 -0.8
+ -0.7 0 0 -0.5 -1 0
+ 0 0.3 0.6 -0.9 0.1 -0.4
+ 0.5 -0.8 0 0 0.2 -0.9];
+B=[-1 -2 -2 1 0
+ 1 0 1 -2 1
+ -3 -4 0 2 -2
+ 1 -2 1 0 -1
+ 0 1 -2 0 3
+ 1 0 3 -1 -2];
+C=[ 1 -1 2 -2 0 -3
+ -3 0 1 -1 1 0
+ 0 2 0 -4 0 -2
+ 1 -3 0 0 3 1
+ 0 1 -2 1 0 -2];
+D=[1 -1 -2 0 0
+ 0 1 0 1 0
+ 2 -1 -3 0 1
+ 0 1 0 1 -1
+ 0 0 1 2 1];
+ncon=2
+ ncon =
+
+ 2.
+nmeas=2
+ nmeas =
+
+ 2.
+gam=111.30;
+[AK,BK,CK,DK] = dhinf(A,B,C,D,ncon,nmeas,gam);
+DK_ref=[9.0643622,7.5621326;
+-3.4130376,-2.8323139];
+CK_ref=[-9.2274286,27.617295,13.786069,-0.3641854,-21.675515,9.6380172;
+3.661606,-10.657654,-5.2960847,0.2432695,8.1401006,-3.6427294];
+BK_ref=[17.040893,14.216801;
+-18.990171,-15.73011;
+25.296356,21.361546;
+20.185869,16.893822;
+1.4151937,1.2079724;
+5.3371104,4.5307879];
+AK_ref=[-18.066348,52.229142,26.177583,-0.4276594,-41.049028,18.153152;
+18.890371,-57.836295,-29.19831,0.5876879,45.493269,-19.939051;
+-26.692988,78.252232,39.17635,-1.4029006,-60.329721,26.790618;
+-21.491455,62.399041,30.862738,-0.9208084,-48.796168,21.915137;
+-0.8960266,4.2934499,2.3358869,-0.2424272,-3.0488883,1.2220794;
+-5.347976,16.254159,8.5113556,-0.2490600,-12.279774,5.1796586];
+assert_checkalmostequal(AK,AK_ref, 1.e-6 );
+assert_checkalmostequal(BK,BK_ref, 1.e-6 );
+assert_checkalmostequal(CK,CK_ref, 1.e-6 );
+assert_checkalmostequal(DK,DK_ref, 1.e-6 );
diff --git a/modules/cacsd/tests/unit_tests/dhinf.tst b/modules/cacsd/tests/unit_tests/dhinf.tst
new file mode 100755
index 000000000..c7991ca3b
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/dhinf.tst
@@ -0,0 +1,59 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+A=[-0.7 0 0.3 0 -0.5 -0.1
+ -0.6 0.2 -0.4 -0.3 0 0
+ -0.5 0.7 -0.1 0 0 -0.8
+ -0.7 0 0 -0.5 -1 0
+ 0 0.3 0.6 -0.9 0.1 -0.4
+ 0.5 -0.8 0 0 0.2 -0.9];
+B=[-1 -2 -2 1 0
+ 1 0 1 -2 1
+ -3 -4 0 2 -2
+ 1 -2 1 0 -1
+ 0 1 -2 0 3
+ 1 0 3 -1 -2];
+C=[ 1 -1 2 -2 0 -3
+ -3 0 1 -1 1 0
+ 0 2 0 -4 0 -2
+ 1 -3 0 0 3 1
+ 0 1 -2 1 0 -2];
+D=[1 -1 -2 0 0
+ 0 1 0 1 0
+ 2 -1 -3 0 1
+ 0 1 0 1 -1
+ 0 0 1 2 1];
+
+ncon=2
+nmeas=2
+gam=111.30;
+[AK,BK,CK,DK] = dhinf(A,B,C,D,ncon,nmeas,gam);
+
+DK_ref=[9.0643622,7.5621326;
+-3.4130376,-2.8323139];
+
+CK_ref=[-9.2274286,27.617295,13.786069,-0.3641854,-21.675515,9.6380172;
+3.661606,-10.657654,-5.2960847,0.2432695,8.1401006,-3.6427294];
+
+BK_ref=[17.040893,14.216801;
+-18.990171,-15.73011;
+25.296356,21.361546;
+20.185869,16.893822;
+1.4151937,1.2079724;
+5.3371104,4.5307879];
+
+AK_ref=[-18.066348,52.229142,26.177583,-0.4276594,-41.049028,18.153152;
+18.890371,-57.836295,-29.19831,0.5876879,45.493269,-19.939051;
+-26.692988,78.252232,39.17635,-1.4029006,-60.329721,26.790618;
+-21.491455,62.399041,30.862738,-0.9208084,-48.796168,21.915137;
+-0.8960266,4.2934499,2.3358869,-0.2424272,-3.0488883,1.2220794;
+-5.347976,16.254159,8.5113556,-0.2490600,-12.279774,5.1796586];
+
+assert_checkalmostequal(AK,AK_ref, 1.e-6 );
+assert_checkalmostequal(BK,BK_ref, 1.e-6 );
+assert_checkalmostequal(CK,CK_ref, 1.e-6 );
+assert_checkalmostequal(DK,DK_ref, 1.e-6 );
diff --git a/modules/cacsd/tests/unit_tests/dscr.dia.ref b/modules/cacsd/tests/unit_tests/dscr.dia.ref
new file mode 100755
index 000000000..1911c3197
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/dscr.dia.ref
@@ -0,0 +1,44 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+// Copyright (C) 2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// Case #1
+a=-1/3;
+b=1;
+c=1;
+sl=syslin('c',a,b,c);
+sld=dscr(sl,0.1);
+assert_checkalmostequal ( sld.dt , 0.1 , %eps );
+computed = sld.A;
+expected = exp(sl.A*0.1);
+assert_checkalmostequal ( computed , expected , %eps );
+computed = sld.B;
+expected = sl.A\(sld.A-eye())*sl.B;
+assert_checkalmostequal ( computed , expected , %eps );
+// Case #2
+a=[0.9,0,0.6,-1.4,-4.2;
+ 0.2,0.1,-0.2,0.5,0.6;
+ -4.3,0,2.2,0,2.4;
+ -3.7,-0.5,2.4,-0.6,2.7;
+ 6.4,0.1,-4,-0.5,-4];
+b=[-0.1,-0.1,0;
+ 0,0,0.1;
+ -0.1,0.2,-0.1;
+ 0.2,0.2,-0.6;
+ 0.2,-0.1,0.1];
+c=[2,7,-2,5,1
+ 0,-1,3,0,2];
+d=[1,0,0
+ 0,0,0];
+sl=syslin('c',a,b,c,d);
+sld=dscr(sl,0.1);
+assert_checkalmostequal ( sld.dt , 0.1 , %eps );
+computed = sld.A;
+expected = expm(sl.A*0.1);
+assert_checkalmostequal ( computed , expected , 1.e3 * %eps );
+computed = sld.B;
+expected = sl.A\(sld.A-eye())*sl.B;
+assert_checkalmostequal ( computed , expected , 2.e5 * %eps );
diff --git a/modules/cacsd/tests/unit_tests/dscr.tst b/modules/cacsd/tests/unit_tests/dscr.tst
new file mode 100755
index 000000000..5b56695d8
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/dscr.tst
@@ -0,0 +1,52 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Serge Steer
+// Copyright (C) 2011 - DIGITEO - Michael Baudin
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+
+
+// Case #1
+a=-1/3;
+b=1;
+c=1;
+sl=syslin('c',a,b,c);
+sld=dscr(sl,0.1);
+assert_checkalmostequal ( sld.dt , 0.1 , %eps );
+computed = sld.A;
+expected = exp(sl.A*0.1);
+assert_checkalmostequal ( computed , expected , %eps );
+computed = sld.B;
+expected = sl.A\(sld.A-eye())*sl.B;
+assert_checkalmostequal ( computed , expected , %eps );
+
+// Case #2
+a=[0.9,0,0.6,-1.4,-4.2;
+ 0.2,0.1,-0.2,0.5,0.6;
+ -4.3,0,2.2,0,2.4;
+ -3.7,-0.5,2.4,-0.6,2.7;
+ 6.4,0.1,-4,-0.5,-4];
+
+b=[-0.1,-0.1,0;
+ 0,0,0.1;
+ -0.1,0.2,-0.1;
+ 0.2,0.2,-0.6;
+ 0.2,-0.1,0.1];
+
+c=[2,7,-2,5,1
+ 0,-1,3,0,2];
+d=[1,0,0
+ 0,0,0];
+
+sl=syslin('c',a,b,c,d);
+sld=dscr(sl,0.1);
+assert_checkalmostequal ( sld.dt , 0.1 , %eps );
+computed = sld.A;
+expected = expm(sl.A*0.1);
+assert_checkalmostequal ( computed , expected , 1.e3 * %eps );
+computed = sld.B;
+expected = sl.A\(sld.A-eye())*sl.B;
+assert_checkalmostequal ( computed , expected , 2.e5 * %eps );
+
diff --git a/modules/cacsd/tests/unit_tests/flts.dia.ref b/modules/cacsd/tests/unit_tests/flts.dia.ref
new file mode 100755
index 000000000..d8968df02
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/flts.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+a=0.9;b=1;c=1;
+sl=syslin('d',a,b,c);
+h=ss2tf(sl);
+y=flts([1 0 0 0 ],sl);
+if norm(y-[0 a.^(0:2)])>1d-15 then bugmes();quit;end
+[y,x]=flts([1 0 0 0 ],sl);
+if norm(y-[0 a.^(0:2)])>1d-15 then bugmes();quit;end
+if abs(x-a^3)>1d-15 then bugmes();quit;end
+y=flts([1 0 0 0 ],sl,1);
+if norm(y-([0 a.^(0:2)]+a.^(0:3)))>1d-15 then bugmes();quit;end
+[y,x]=flts([1 0 0 0 ],sl,1);
+if norm(y-([0 a.^(0:2)]+a.^(0:3)))>1d-15 then bugmes();quit;end
+if abs(x-(a^4+a^3))>1d-15 then bugmes();quit;end
+y=flts([1 0 0 0 ],h);
+if norm(y-[0 a.^(0:2)])>1d-15 then bugmes();quit;end
+if execstr("[y,x]=flts([1 0 0 0 ],h);","errcatch")==0 then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/flts.tst b/modules/cacsd/tests/unit_tests/flts.tst
new file mode 100755
index 000000000..27f1c434c
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/flts.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+a=0.9;b=1;c=1;
+sl=syslin('d',a,b,c);
+h=ss2tf(sl);
+y=flts([1 0 0 0 ],sl);
+if norm(y-[0 a.^(0:2)])>1d-15 then pause,end
+
+[y,x]=flts([1 0 0 0 ],sl);
+if norm(y-[0 a.^(0:2)])>1d-15 then pause,end
+if abs(x-a^3)>1d-15 then pause,end
+
+
+y=flts([1 0 0 0 ],sl,1);
+if norm(y-([0 a.^(0:2)]+a.^(0:3)))>1d-15 then pause,end
+[y,x]=flts([1 0 0 0 ],sl,1);
+if norm(y-([0 a.^(0:2)]+a.^(0:3)))>1d-15 then pause,end
+if abs(x-(a^4+a^3))>1d-15 then pause,end
+
+y=flts([1 0 0 0 ],h);
+if norm(y-[0 a.^(0:2)])>1d-15 then pause,end
+if execstr("[y,x]=flts([1 0 0 0 ],h);","errcatch")==0 then pause,end
diff --git a/modules/cacsd/tests/unit_tests/freq.dia.ref b/modules/cacsd/tests/unit_tests/freq.dia.ref
new file mode 100755
index 000000000..c257505e2
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/freq.dia.ref
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+h=syslin('c',1/%s)
+ h =
+
+ 1
+ -
+ s
+if norm(freq(h.num,h.den,1:3)-[1 1/2 1/3])>1d-15 then bugmes();quit;end
+if norm(freq(h.num,h.den,%i*(1:3))+%i*[1 1/2 1/3])>1d-15 then bugmes();quit;end
+sl=tf2ss(h);
+if norm(freq(sl.A,sl.B,sl.C,1:3)-[1 1/2 1/3])>1d-15 then bugmes();quit;end
+if norm(freq(sl.A,sl.B,sl.C,%i*(1:3))+%i*[1 1/2 1/3])>1d-15 then bugmes();quit;end
+if norm(freq(sl.A,sl.B,sl.C,0,1:3)-[1 1/2 1/3])>1d-15 then bugmes();quit;end
+if norm(freq(sl.A,sl.B,sl.C,0,%i*(1:3))+%i*[1 1/2 1/3])>1d-15 then bugmes();quit;end
+A=[1 2;3 4];H=A/%s;
+if norm(freq(H.num,H.den,1:3)-[1 1/2 1/3].*.A,1)>1d-15 then bugmes();quit;end
+if norm(freq(H.num,H.den,%i*(1:3))+%i*[1 1/2 1/3].*.A,1)>1d-15 then bugmes();quit;end
+A=[1 2;3 4];H=A/%s;sl=tf2ss(H);
+if norm(freq(sl.A,sl.B,sl.C,1:3)-[1 1/2 1/3].*.A,1)>3d-15 then bugmes();quit;end
+if norm(freq(sl.A,sl.B,sl.C,%i*(1:3))+%i*[1 1/2 1/3].*.A,1)>3d-15 then bugmes();quit;end
+if norm(freq(sl.A,sl.B,sl.C,sl.D,1:3)-[1 1/2 1/3].*.A,1)>3d-15 then bugmes();quit;end
+if norm(freq(sl.A,sl.B,sl.C,sl.D,%i*(1:3))+%i*[1 1/2 1/3].*.A,1)>3d-15 then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/freq.tst b/modules/cacsd/tests/unit_tests/freq.tst
new file mode 100755
index 000000000..f3a483e10
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/freq.tst
@@ -0,0 +1,30 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+h=syslin('c',1/%s)
+
+if norm(freq(h.num,h.den,1:3)-[1 1/2 1/3])>1d-15 then pause,end
+if norm(freq(h.num,h.den,%i*(1:3))+%i*[1 1/2 1/3])>1d-15 then pause,end
+
+
+sl=tf2ss(h);
+if norm(freq(sl.A,sl.B,sl.C,1:3)-[1 1/2 1/3])>1d-15 then pause,end
+if norm(freq(sl.A,sl.B,sl.C,%i*(1:3))+%i*[1 1/2 1/3])>1d-15 then pause,end
+if norm(freq(sl.A,sl.B,sl.C,0,1:3)-[1 1/2 1/3])>1d-15 then pause,end
+if norm(freq(sl.A,sl.B,sl.C,0,%i*(1:3))+%i*[1 1/2 1/3])>1d-15 then pause,end
+
+
+A=[1 2;3 4];H=A/%s;
+if norm(freq(H.num,H.den,1:3)-[1 1/2 1/3].*.A,1)>1d-15 then pause,end
+if norm(freq(H.num,H.den,%i*(1:3))+%i*[1 1/2 1/3].*.A,1)>1d-15 then pause,end
+
+A=[1 2;3 4];H=A/%s;sl=tf2ss(H);
+if norm(freq(sl.A,sl.B,sl.C,1:3)-[1 1/2 1/3].*.A,1)>3d-15 then pause,end
+if norm(freq(sl.A,sl.B,sl.C,%i*(1:3))+%i*[1 1/2 1/3].*.A,1)>3d-15 then pause,end
+
+if norm(freq(sl.A,sl.B,sl.C,sl.D,1:3)-[1 1/2 1/3].*.A,1)>3d-15 then pause,end
+if norm(freq(sl.A,sl.B,sl.C,sl.D,%i*(1:3))+%i*[1 1/2 1/3].*.A,1)>3d-15 then pause,end
+
diff --git a/modules/cacsd/tests/unit_tests/freqplots.dia.ref b/modules/cacsd/tests/unit_tests/freqplots.dia.ref
new file mode 100755
index 000000000..ad9f6bbbb
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/freqplots.dia.ref
@@ -0,0 +1,51 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+plots=['bode','black','nyquist','gainplot'];
+s=poly(0,'s');
+h=syslin('c',(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+h1=h*syslin('c',(s^2+2*0.1*15.1*s+228.01)/(s^2+2*0.9*15*s+225));
+hd=dscr(h,0.01);
+hd1=dscr(h1,0.01);
+[frq,repf]=repfreq([h;h1],0.01,100);
+[phi,db]=phasemag(repf);
+Args=list(..
+ list(h),..
+ list(h,0.01,100),..
+ list(h,0.01,100,'h'),..
+ list([h;h1]),..
+ list([h;h1],0.01,100),..
+ list([h;h1],0.01,100,['h';'h1']),..
+ list(hd),..
+ list(hd,0.01,100),..
+ list(hd,0.01,100,'hd'),..
+ list([hd;hd1]),..
+ list([hd;hd1],0.01,100),..
+ list([hd;hd1],0.01,100,['hd';'hd1']),..
+ list(frq,repf(1,:)),..
+ list(frq,repf(1,:),'h'),..
+ list(frq,repf),..
+ list(frq,repf,['h';'h1']),..
+ list([frq;frq],repf,['h';'h1']),..
+ list(frq,db(1,:),phi(1,:)),..
+ list(frq,db(1,:),phi(1,:),'h'),..
+ list(frq,db,phi),..
+ list(frq,db,phi,['h';'h1']),..
+ list([frq;frq],db,phi,['h';'h1']));
+warning('off');
+for p=plots
+ mprintf("-------- %s ---------------\n",p)
+ for args=Args
+ clf()
+ if execstr(p+'(args(:))','errcatch')<>0 then bugmes();quit;end
+ end
+end
+-------- bode ---------------
+-------- black ---------------
+-------- nyquist ---------------
+-------- gainplot ---------------
+warning('on');
diff --git a/modules/cacsd/tests/unit_tests/freqplots.tst b/modules/cacsd/tests/unit_tests/freqplots.tst
new file mode 100755
index 000000000..41fc2bb5a
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/freqplots.tst
@@ -0,0 +1,50 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+
+plots=['bode','black','nyquist','gainplot'];
+s=poly(0,'s');
+h=syslin('c',(s^2+2*0.9*10*s+100)/(s^2+2*0.3*10.1*s+102.01));
+h1=h*syslin('c',(s^2+2*0.1*15.1*s+228.01)/(s^2+2*0.9*15*s+225));
+hd=dscr(h,0.01);
+hd1=dscr(h1,0.01);
+[frq,repf]=repfreq([h;h1],0.01,100);
+[phi,db]=phasemag(repf);
+
+Args=list(..
+ list(h),..
+ list(h,0.01,100),..
+ list(h,0.01,100,'h'),..
+ list([h;h1]),..
+ list([h;h1],0.01,100),..
+ list([h;h1],0.01,100,['h';'h1']),..
+ list(hd),..
+ list(hd,0.01,100),..
+ list(hd,0.01,100,'hd'),..
+ list([hd;hd1]),..
+ list([hd;hd1],0.01,100),..
+ list([hd;hd1],0.01,100,['hd';'hd1']),..
+ list(frq,repf(1,:)),..
+ list(frq,repf(1,:),'h'),..
+ list(frq,repf),..
+ list(frq,repf,['h';'h1']),..
+ list([frq;frq],repf,['h';'h1']),..
+ list(frq,db(1,:),phi(1,:)),..
+ list(frq,db(1,:),phi(1,:),'h'),..
+ list(frq,db,phi),..
+ list(frq,db,phi,['h';'h1']),..
+ list([frq;frq],db,phi,['h';'h1']));
+
+warning('off');
+for p=plots
+ mprintf("-------- %s ---------------\n",p)
+ for args=Args
+ clf()
+ if execstr(p+'(args(:))','errcatch')<>0 then pause,end
+ end
+end
+warning('on'); \ No newline at end of file
diff --git a/modules/cacsd/tests/unit_tests/hinf.dia.ref b/modules/cacsd/tests/unit_tests/hinf.dia.ref
new file mode 100755
index 000000000..b0f625a2e
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/hinf.dia.ref
@@ -0,0 +1,47 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+A=[-1 0 4 5 -3 -2
+ -2 4 -7 -2 0 3
+ -6 9 -5 0 2 -1
+ -8 4 7 -1 -3 0
+ 2 5 8 -9 1 -4
+ 3 -5 8 0 2 -6];
+B=[-3 -4 -2 1 0
+ 2 0 1 -5 2
+ -5 -7 0 7 -2
+ 4 -6 1 1 -2
+ -3 9 -8 0 5
+ 1 -2 3 -6 -2];
+C=[ 1 -1 2 -4 0 -3
+ -3 0 5 -1 1 1
+ -7 5 0 -8 2 -2
+ 9 -3 4 0 3 7
+ 0 1 -2 1 -6 -2];
+D=[ 1 -2 -3 0 0
+ 0 4 0 1 0
+ 5 -3 -4 0 1
+ 0 1 0 1 -3
+ 0 0 1 7 1];
+Gamma=10.18425636157899;
+[AK,BK,CK,DK] = hinf(A,B,C,D,2,2,Gamma);
+assert_checkalmostequal(DK,[0.0551858,0.1333855; -0.3195369,0.0333464], 1.e-6 );
+CK_Ref = [-1694955,9282226.3,7644816,3695418.1,4551537.9,3956434.1;-35560237,1.947D+08,1.604D+08,77530062,95491495,83006200];
+assert_checkalmostequal(CK,CK_Ref, 1.e-3 );
+AK_Ref = [-6.112D+08,3.347D+09,2.757D+09,1.333D+09,1.641D+09,1.427D+09;
+-2.162D+08,1.184D+09,9.749D+08,4.713D+08,5.805D+08,5.046D+08;
+-6.636D+08,3.634D+09,2.993D+09,1.447D+09,1.782D+09,1.549D+09;
+-2.619D+08,1.434D+09,1.181D+09,5.711D+08,7.034D+08,6.114D+08;
+-9.297D+08,5.092D+09,4.193D+09,2.027D+09,2.497D+09,2.170D+09;
+2.313D+08,-1.267D+09,-1.043D+09,-5.043D+08,-6.211D+08,-5.399D+08];
+assert_checkalmostequal(AK,AK_Ref, 1.e-3 );
+BK_Ref=[-0.2224538,-0.1084738;
+-0.8518108,-0.6521262;
+0.8172727,0.5793501;
+0.0843421,0.0100477;
+-0.5631929,-0.2478528;
+0.0067885,-0.7619229];
+assert_checkalmostequal(BK,BK_Ref, 1.e-5 );
diff --git a/modules/cacsd/tests/unit_tests/hinf.tst b/modules/cacsd/tests/unit_tests/hinf.tst
new file mode 100755
index 000000000..af2d485de
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/hinf.tst
@@ -0,0 +1,56 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+
+A=[-1 0 4 5 -3 -2
+ -2 4 -7 -2 0 3
+ -6 9 -5 0 2 -1
+ -8 4 7 -1 -3 0
+ 2 5 8 -9 1 -4
+ 3 -5 8 0 2 -6];
+
+B=[-3 -4 -2 1 0
+ 2 0 1 -5 2
+ -5 -7 0 7 -2
+ 4 -6 1 1 -2
+ -3 9 -8 0 5
+ 1 -2 3 -6 -2];
+
+C=[ 1 -1 2 -4 0 -3
+ -3 0 5 -1 1 1
+ -7 5 0 -8 2 -2
+ 9 -3 4 0 3 7
+ 0 1 -2 1 -6 -2];
+
+D=[ 1 -2 -3 0 0
+ 0 4 0 1 0
+ 5 -3 -4 0 1
+ 0 1 0 1 -3
+ 0 0 1 7 1];
+Gamma=10.18425636157899;
+[AK,BK,CK,DK] = hinf(A,B,C,D,2,2,Gamma);
+
+assert_checkalmostequal(DK,[0.0551858,0.1333855; -0.3195369,0.0333464], 1.e-6 );
+
+CK_Ref = [-1694955,9282226.3,7644816,3695418.1,4551537.9,3956434.1;-35560237,1.947D+08,1.604D+08,77530062,95491495,83006200];
+assert_checkalmostequal(CK,CK_Ref, 1.e-3 );
+
+AK_Ref = [-6.112D+08,3.347D+09,2.757D+09,1.333D+09,1.641D+09,1.427D+09;
+-2.162D+08,1.184D+09,9.749D+08,4.713D+08,5.805D+08,5.046D+08;
+-6.636D+08,3.634D+09,2.993D+09,1.447D+09,1.782D+09,1.549D+09;
+-2.619D+08,1.434D+09,1.181D+09,5.711D+08,7.034D+08,6.114D+08;
+-9.297D+08,5.092D+09,4.193D+09,2.027D+09,2.497D+09,2.170D+09;
+2.313D+08,-1.267D+09,-1.043D+09,-5.043D+08,-6.211D+08,-5.399D+08];
+assert_checkalmostequal(AK,AK_Ref, 1.e-3 );
+
+BK_Ref=[-0.2224538,-0.1084738;
+-0.8518108,-0.6521262;
+0.8172727,0.5793501;
+0.0843421,0.0100477;
+-0.5631929,-0.2478528;
+0.0067885,-0.7619229];
+assert_checkalmostequal(BK,BK_Ref, 1.e-5 );
diff --git a/modules/cacsd/tests/unit_tests/linmeq.dia.ref b/modules/cacsd/tests/unit_tests/linmeq.dia.ref
new file mode 100755
index 000000000..08728dcc6
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/linmeq.dia.ref
@@ -0,0 +1,831 @@
+// =============================================================================
+// 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 linmeq
+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
+//-----------------------------------------------------------
+//---------- op(A)*X + X*op(B) = C, (1a) --------------------
+//-----------------------------------------------------------
+//Small dimension
+n=4;m=3;
+//A and B full
+A = testmat1(2.5,n);
+C = rand(n,m);
+B = testmat1(0.3,m);
+if execstr('X = linmeq(5,A,B,C)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,B)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,rand(3,3),B,C)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,rand(4,3),B,C)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,rand(3,2),C)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,B,rand(m,n))' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,B,C,[0,0,0],8)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,B,C,[0,0,0],0,4)','errcatch') == 0 then bugmes();quit;end
+flag=[0,0,0];
+X = linmeq(1,A,B,C);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+//A in Schur form
+[U,A]=schur(A);flag=[0,1,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+//A and B in schur form
+[U,B]=schur(B);flag=[0,1,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+//B in schur form
+A=testmat1(2.5,n);flag=[0,0,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+//A in hess form
+[U,A]=hess(A);flag=[0,2,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+//A and B in hess form
+[U,B]=hess(B);flag=[0,2,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+//B in hess form
+A=testmat1(2.5,n);flag=[0,0,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then bugmes();quit;end
+//Large dimension
+n=23;m=17;
+//A and B full
+A=testmat1(2.5,n);C=rand(n,m);B=testmat1(0.3,m);
+X = linmeq(1,A,B,C);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+X = linmeq(1,A,B,C,[0,1,0]);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+//A and B in schur form
+[U,B]=schur(B);
+X = linmeq(1,A,B,C,[0,1,1]);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+//B in schur form
+A=testmat1(2.5,n);
+X = linmeq(1,A,B,C,[0,0,1]);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+//A in hess form
+[U,A]=hess(A);
+X = linmeq(1,A,B,C,[0,2,0]);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+//A and B in hess form
+[U,B]=hess(B);
+X = linmeq(1,A,B,C,[0,2,2]);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+//B in hess form
+A=testmat1(2.5,n);
+X = linmeq(1,A,B,C,[0,0,2]);
+if norm(A*X+X*B-C,1)>100000*%eps then bugmes();quit;end
+//-----------------------------------------------------------
+//---------- op(A)*X*op(B) + X = C, (1b) --------------------
+//-----------------------------------------------------------
+//Small dimension
+n=4;
+m=3;
+//A and B full
+A = testmat1(2.5,n);
+C = rand(n,m);
+B = testmat1(0.3,m);
+flag = [1,0,0];
+if execstr('X = linmeq(5,A,B,C,flag)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,rand(3,3),B,C,flag)','errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,rand(4,3),B,C,flag)','errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,rand(3,2),C,flag)','errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,B,rand(m,n),flag)','errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,B,C,flag,8)','errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(1,A,B,C,flag,0,4)','errcatch') == 0 then bugmes();quit;end
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+//A and B in schur form
+[U,B]=schur(B);
+flag=[1,1,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+//B in schur form
+A=testmat1(2.5,n);
+flag=[1,0,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+//A in hess form
+[U,A]=hess(A);
+flag=[1,2,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+//A and B in hess form
+[U,B]=hess(B);
+flag=[1,2,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+//B in hess form
+A=testmat1(2.5,n);
+flag=[1,0,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then bugmes();quit;end
+//Large dimension
+n=23;m=17;
+//A and B full
+A=testmat1(2.5,n);C=rand(n,m);B=testmat1(0.3,m);
+flag=[1,0,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then bugmes();quit;end
+//A and B in schur form
+[U,B]=schur(B);
+flag=[1,1,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then bugmes();quit;end
+//B in schur form
+A=testmat1(2.5,n);
+flag=[1,0,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then bugmes();quit;end
+//A in hess form
+[U,A]=hess(A);
+flag=[1,2,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then bugmes();quit;end
+//A and B in hess form
+[U,B]=hess(B);
+flag=[1,2,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then bugmes();quit;end
+//B in hess form
+A=testmat1(2.5,n);
+flag=[1,0,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then bugmes();quit;end
+//-----------------------------------------------------------
+//---------- op(A)'*X + X*op(A) = C, (2a)--------------------
+//-----------------------------------------------------------
+//Small dimension
+n = 4;
+//A full
+A = testmat1(2.5,n);
+C = rand(n,n);
+C = C+C';
+if execstr('X = linmeq(2,A,C)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,A,C,flag)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,rand(3,3),C,flag)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,rand(4,3),C,flag)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,A,C,flag)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,A,rand(4,3),flag)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,A,rand(3,3),flag)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,A,C,flag,8)' ,'errcatch') == 0 then bugmes();quit;end
+if execstr('X = linmeq(2,A,C,flag,0,4)' ,'errcatch') == 0 then bugmes();quit;end
+function A=testmat2(a,n)
+ A=testmat1(a,n)+eye()+diag([1 1],n-2);
+endfunction
+A=testmat2(2.5,n);
+X = linmeq(2,A,C);
+if norm(A'*X+X*A-C,1)>1000*%eps then bugmes();quit;end
+flag=[0,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X+X*A-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X+X*A'-C,1)>1000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X+X*A-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X+X*A'-C,1)>1000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat2(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X+X*A-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X+X*A'-C,1)>1000*%eps then bugmes();quit;end
+//Large dimension
+n=23;
+//A full
+A=testmat2(2.5,n);C=rand(n,n);C=C+C';
+X = linmeq(2,A,C);
+if norm(A'*X+X*A-C,1)>100000*%eps then bugmes();quit;end
+flag=[0,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>100000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>100000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat2(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>100000*%eps then bugmes();quit;end
+//-----------------------------------------------------------
+//---------- op(A)'*X*op(A) - X = C, (2b)--------------------
+//-----------------------------------------------------------
+//Small dimension
+n=4;
+//A full
+A=testmat1(2.5,n);
+C=rand(n,n);
+C=C+C';
+flag=[1,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X*A-X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X*A'-X-C,1)>1000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X*A-X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X*A'-X-C,1)>1000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat1(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X*A-X-C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X*A'-X-C,1)>1000*%eps then bugmes();quit;end
+//Large dimension
+n=23;
+//A full
+A=testmat1(2.5,n);C=rand(n,n);C=C+C';
+flag=[1,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>100000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>100000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat1(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>100000*%eps then bugmes();quit;end
+//-----------------------------------------------------------
+//--- op(A)'*(op(X)'*op(X)) + (op(X)'*op(X))*op(A) = --
+//--- - op(C)'*op(C), (3a) --
+//-----------------------------------------------------------
+//Small dimension
+n=4;
+//A full
+C = rand(n,n);
+A = testmat1(2.5,n);
+flag = [0,0];
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,rand(3,3),C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,rand(4,3),C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,rand(4,3),flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,rand(3,3),flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,C,flag,8)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,C,flag,0,4)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,C)' ,'errcatch')==0 then bugmes();quit;end
+//shift poles to make all of them negative
+function A=testmat3(a,n),A=testmat1(a,n)-(2+a^2)/a*eye(),endfunction
+A=testmat3(2.5,n);
+X = linmeq(3,A,C);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then bugmes();quit;end
+flag=[0,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')+(X*X')*A'+C*C',1)>1000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')+(X*X')*A'+C*C',1)>1000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat3(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')+(X*X')*A'+C*C',1)>1000*%eps then bugmes();quit;end
+//Large dimension
+n=23;
+//A full
+A=testmat3(2.5,n);C=rand(n,n);
+X = linmeq(3,A,C);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then bugmes();quit;end
+flag=[0,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat3(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then bugmes();quit;end
+//-----------------------------------------------------------
+//--- op(A)'*(op(X)'*op(X))*op(A) - op(X)'*op(X) = --
+//--- - op(C)'*op(C), (3a) --
+//-----------------------------------------------------------
+//Small dimension
+n = 4;
+//A full
+C = rand(n,n);
+A = testmat1(2.5,n);
+flag = [1,0];
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,rand(3,3),C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,rand(4,3),C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,rand(4,3),flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,rand(3,3),flag)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,C,flag,8)' ,'errcatch')==0 then bugmes();quit;end
+if execstr('X = linmeq(3,A,C,flag,0,4)' ,'errcatch')==0 then bugmes();quit;end
+//shift poles to make all of them negative
+function A=testmat4(a,n),A=testmat1(a,n)/((2+a^2)/a),endfunction
+A=testmat4(2.5,n);
+flag=[1,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')*A'-X*X'+C*C',1)>1000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')*A'-X*X'+C*C',1)>1000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat4(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then bugmes();quit;end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')*A'-X*X'+C*C',1)>1000*%eps then bugmes();quit;end
+//Large dimension
+n=23;
+//A full
+A=testmat4(2.5,n);C=rand(n,n);
+flag=[1,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then bugmes();quit;end
+flag=[1,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then bugmes();quit;end
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then bugmes();quit;end
+//A in hess form
+A=testmat4(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/linmeq.tst b/modules/cacsd/tests/unit_tests/linmeq.tst
new file mode 100755
index 000000000..4aab90a5b
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/linmeq.tst
@@ -0,0 +1,914 @@
+// =============================================================================
+// 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 linmeq
+
+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
+
+//-----------------------------------------------------------
+//---------- op(A)*X + X*op(B) = C, (1a) --------------------
+//-----------------------------------------------------------
+
+//Small dimension
+n=4;m=3;
+//A and B full
+A = testmat1(2.5,n);
+C = rand(n,m);
+B = testmat1(0.3,m);
+
+if execstr('X = linmeq(5,A,B,C)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,B)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,rand(3,3),B,C)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,rand(4,3),B,C)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,rand(3,2),C)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,B,rand(m,n))' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,B,C,[0,0,0],8)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,B,C,[0,0,0],0,4)','errcatch') == 0 then pause,end
+
+flag=[0,0,0];
+X = linmeq(1,A,B,C);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+//A in Schur form
+[U,A]=schur(A);flag=[0,1,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+
+//A and B in schur form
+[U,B]=schur(B);flag=[0,1,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+//B in schur form
+A=testmat1(2.5,n);flag=[0,0,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+
+//A in hess form
+[U,A]=hess(A);flag=[0,2,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+//A and B in hess form
+[U,B]=hess(B);flag=[0,2,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+
+//B in hess form
+A=testmat1(2.5,n);flag=[0,0,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B'-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X+X*B-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X+X*B'-C,1)>1000*%eps then pause,end
+
+
+//Large dimension
+n=23;m=17;
+//A and B full
+A=testmat1(2.5,n);C=rand(n,m);B=testmat1(0.3,m);
+X = linmeq(1,A,B,C);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+X = linmeq(1,A,B,C,flag);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+X = linmeq(1,A,B,C,[0,1,0]);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+//A and B in schur form
+[U,B]=schur(B);
+X = linmeq(1,A,B,C,[0,1,1]);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+//B in schur form
+A=testmat1(2.5,n);
+X = linmeq(1,A,B,C,[0,0,1]);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+
+//A in hess form
+[U,A]=hess(A);
+X = linmeq(1,A,B,C,[0,2,0]);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+//A and B in hess form
+[U,B]=hess(B);
+X = linmeq(1,A,B,C,[0,2,2]);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+//B in hess form
+A=testmat1(2.5,n);
+X = linmeq(1,A,B,C,[0,0,2]);
+if norm(A*X+X*B-C,1)>100000*%eps then pause,end
+
+
+//-----------------------------------------------------------
+//---------- op(A)*X*op(B) + X = C, (1b) --------------------
+//-----------------------------------------------------------
+
+//Small dimension
+n=4;
+m=3;
+
+//A and B full
+A = testmat1(2.5,n);
+C = rand(n,m);
+B = testmat1(0.3,m);
+flag = [1,0,0];
+
+if execstr('X = linmeq(5,A,B,C,flag)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,rand(3,3),B,C,flag)','errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,rand(4,3),B,C,flag)','errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,rand(3,2),C,flag)','errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,B,rand(m,n),flag)','errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,B,C,flag,8)','errcatch') == 0 then pause,end
+if execstr('X = linmeq(1,A,B,C,flag,0,4)','errcatch') == 0 then pause,end
+
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+
+
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+
+//A and B in schur form
+[U,B]=schur(B);
+flag=[1,1,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+
+//B in schur form
+A=testmat1(2.5,n);
+flag=[1,0,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+
+//A in hess form
+[U,A]=hess(A);
+flag=[1,2,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+
+//A and B in hess form
+[U,B]=hess(B);
+flag=[1,2,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+
+//B in hess form
+A=testmat1(2.5,n);
+flag=[1,0,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+Schur=1;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+Schur=2;
+trans_option=0;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B'+X-C,1)>1000*%eps then pause,end
+trans_option=2;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A'*X*B+X-C,1)>1000*%eps then pause,end
+trans_option=3;
+X = linmeq(1,A,B,C,flag,trans_option,Schur);
+if norm(A*X*B'+X-C,1)>1000*%eps then pause,end
+
+//Large dimension
+n=23;m=17;
+//A and B full
+A=testmat1(2.5,n);C=rand(n,m);B=testmat1(0.3,m);
+flag=[1,0,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then pause,end
+//A and B in schur form
+[U,B]=schur(B);
+flag=[1,1,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then pause,end
+//B in schur form
+A=testmat1(2.5,n);
+flag=[1,0,1];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then pause,end
+
+//A in hess form
+[U,A]=hess(A);
+flag=[1,2,0];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then pause,end
+//A and B in hess form
+[U,B]=hess(B);
+flag=[1,2,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then pause,end
+//B in hess form
+A=testmat1(2.5,n);
+flag=[1,0,2];
+X = linmeq(1,A,B,C,flag);
+if norm(A*X*B+X-C,1)>100000*%eps then pause,end
+//-----------------------------------------------------------
+//---------- op(A)'*X + X*op(A) = C, (2a)--------------------
+//-----------------------------------------------------------
+//Small dimension
+n = 4;
+
+//A full
+A = testmat1(2.5,n);
+C = rand(n,n);
+C = C+C';
+
+if execstr('X = linmeq(2,A,C)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,A,C,flag)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,rand(3,3),C,flag)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,rand(4,3),C,flag)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,A,C,flag)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,A,rand(4,3),flag)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,A,rand(3,3),flag)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,A,C,flag,8)' ,'errcatch') == 0 then pause,end
+if execstr('X = linmeq(2,A,C,flag,0,4)' ,'errcatch') == 0 then pause,end
+
+function A=testmat2(a,n)
+ A=testmat1(a,n)+eye()+diag([1 1],n-2);
+endfunction
+
+A=testmat2(2.5,n);
+X = linmeq(2,A,C);
+if norm(A'*X+X*A-C,1)>1000*%eps then pause,end
+flag=[0,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>1000*%eps then pause,end
+
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X+X*A-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X+X*A'-C,1)>1000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>1000*%eps then pause,end
+
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X+X*A-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X+X*A'-C,1)>1000*%eps then pause,end
+
+
+//A in hess form
+A=testmat2(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>1000*%eps then pause,end
+
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X+X*A-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X+X*A'-C,1)>1000*%eps then pause,end
+
+//Large dimension
+n=23;
+//A full
+A=testmat2(2.5,n);C=rand(n,n);C=C+C';
+X = linmeq(2,A,C);
+if norm(A'*X+X*A-C,1)>100000*%eps then pause,end
+flag=[0,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>100000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>100000*%eps then pause,end
+
+//A in hess form
+A=testmat2(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X+X*A-C,1)>100000*%eps then pause,end
+
+//-----------------------------------------------------------
+//---------- op(A)'*X*op(A) - X = C, (2b)--------------------
+//-----------------------------------------------------------
+//Small dimension
+n=4;
+//A full
+A=testmat1(2.5,n);
+C=rand(n,n);
+C=C+C';
+flag=[1,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>1000*%eps then pause,end
+
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X*A-X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X*A'-X-C,1)>1000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>1000*%eps then pause,end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X*A-X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X*A'-X-C,1)>1000*%eps then pause,end
+
+//A in hess form
+A=testmat1(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>1000*%eps then pause,end
+trans_option=0;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A'*X*A-X-C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(2,A,C,flag,trans_option);
+if norm(A*X*A'-X-C,1)>1000*%eps then pause,end
+
+//Large dimension
+n=23;
+//A full
+A=testmat1(2.5,n);C=rand(n,n);C=C+C';
+flag=[1,0];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>100000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>100000*%eps then pause,end
+
+//A in hess form
+A=testmat1(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(2,A,C,flag);
+if norm(A'*X*A-X-C,1)>100000*%eps then pause,end
+//-----------------------------------------------------------
+//--- op(A)'*(op(X)'*op(X)) + (op(X)'*op(X))*op(A) = --
+//--- - op(C)'*op(C), (3a) --
+//-----------------------------------------------------------
+//Small dimension
+n=4;
+
+//A full
+C = rand(n,n);
+A = testmat1(2.5,n);
+flag = [0,0];
+
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,rand(3,3),C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,rand(4,3),C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,rand(4,3),flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,rand(3,3),flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,C,flag,8)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,C,flag,0,4)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,C)' ,'errcatch')==0 then pause,end
+
+//shift poles to make all of them negative
+function A=testmat3(a,n),A=testmat1(a,n)-(2+a^2)/a*eye(),endfunction
+A=testmat3(2.5,n);
+X = linmeq(3,A,C);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then pause,end
+flag=[0,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then pause,end
+
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')+(X*X')*A'+C*C',1)>1000*%eps then pause,end
+
+
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then pause,end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')+(X*X')*A'+C*C',1)>1000*%eps then pause,end
+
+//A in hess form
+A=testmat3(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then pause,end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')+(X*X')*A'+C*C',1)>1000*%eps then pause,end
+
+//Large dimension
+n=23;
+//A full
+A=testmat3(2.5,n);C=rand(n,n);
+X = linmeq(3,A,C);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then pause,end
+flag=[0,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+flag=[0,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then pause,end
+
+//A in hess form
+A=testmat3(2.5,n);[U,A]=hess(A);
+flag=[0,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)+(X'*X)*A+C'*C,1)>100000*%eps then pause,end
+
+//-----------------------------------------------------------
+//--- op(A)'*(op(X)'*op(X))*op(A) - op(X)'*op(X) = --
+//--- - op(C)'*op(C), (3a) --
+//-----------------------------------------------------------
+
+//Small dimension
+n = 4;
+
+//A full
+C = rand(n,n);
+A = testmat1(2.5,n);
+flag = [1,0];
+
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,rand(3,3),C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,rand(4,3),C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,C,flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,rand(4,3),flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,rand(3,3),flag)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,C,flag,8)' ,'errcatch')==0 then pause,end
+if execstr('X = linmeq(3,A,C,flag,0,4)' ,'errcatch')==0 then pause,end
+
+//shift poles to make all of them negative
+function A=testmat4(a,n),A=testmat1(a,n)/((2+a^2)/a),endfunction
+A=testmat4(2.5,n);
+flag=[1,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then pause,end
+
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')*A'-X*X'+C*C',1)>1000*%eps then pause,end
+
+
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then pause,end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')*A'-X*X'+C*C',1)>1000*%eps then pause,end
+
+//A in hess form
+A=testmat4(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then pause,end
+trans_option=0;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>1000*%eps then pause,end
+trans_option=1;
+X = linmeq(3,A,C,flag,trans_option);
+if norm(A*(X*X')*A'-X*X'+C*C',1)>1000*%eps then pause,end
+
+//Large dimension
+n=23;
+//A full
+A=testmat4(2.5,n);C=rand(n,n);
+flag=[1,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then pause,end
+flag=[1,0];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then pause,end
+
+//A in schur form
+[U,A]=schur(A);
+flag=[1,1];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then pause,end
+
+//A in hess form
+A=testmat4(2.5,n);[U,A]=hess(A);
+flag=[1,2];
+X = linmeq(3,A,C,flag);
+if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then pause,end
diff --git a/modules/cacsd/tests/unit_tests/margins.dia.ref b/modules/cacsd/tests/unit_tests/margins.dia.ref
new file mode 100755
index 000000000..5e4cc23b3
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/margins.dia.ref
@@ -0,0 +1,123 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- ENGLISH IMPOSED -->
+//gain margin
+//-----------
+function ok=check_gmargin(h,fref,gref)
+ eps=1e-10
+ [g,f]=g_margin(h)
+ if fref==0 then
+ ok=abs(f - fref)<eps
+ else
+ ok=abs(f - fref)/abs(fref)<eps
+ end
+ if gref==0 then
+ ok=ok&abs(g - gref)<eps
+ else
+ ok=ok&abs(g - gref)/abs(gref)<eps
+ end
+endfunction
+//discrete time case
+z=poly(0,'z');
+//the references solutions are computed using the following Maple instructions
+//Digits:=50:
+//z:=exp(I*w):
+//assume(w, 'real', w > 0)
+//h:= rational fraction in z
+//M := solve(Im(h) = 0, w)
+//evalf(M/(2*Pi))
+//evalf(eval(20*log10(1/abs(h)), w = M[k]))
+h = syslin(0.1,((29/625)+(2399/50000)*z)/((1131/1250)+(-181/100)*z+z^2));
+f_ref=atan(sqrt(9003479136639)/4963519)/(0.1*2*%pi);
+g_ref=6.242379356591869534116;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+h=syslin(0.1,((43/500)+(-161/1000)*z+(39/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+f_ref=atan((1/215)*sqrt(1136805-8330*sqrt(5970))/(833/43+(1/215)*sqrt(5970)))/(0.1*2*%pi);
+g_ref=12.3470513198103944037870;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+h=syslin(0.1,((129/500)+(-483/1000)*z+(117/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+f_ref=atan((1/215)*sqrt(1136805-8330*sqrt(5970))/(833/43+(1/215)*sqrt(5970)))/(0.1*2*%pi);
+g_ref=2.8046262254171456578864840;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+h=syslin(1,((21/500)+(-3933/100000)*z+(-15407/100000)*z^2+(9259/50000)*z^3+(6939/(10^12))*z^4)/((-21/500)+(11/125)*z+(57/500)*z^2+(-9/25)*z^3+(1/5)*z^4));
+f_ref=1/2;
+g_ref=6.48227782514616029706190;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+//continuuous time case
+s=poly(0,'s');
+//the reference solutions are computed using the following Maple instructions
+//s:=I*w:
+//assume(w, 'real', w > 0)
+//h:= rational fraction in z
+//M := solve(Im(h) = 0, w)
+//evalf(M/(2*Pi))
+//evalf(eval(20*log10(1/abs(h)), w = M[k]))
+h=syslin('c',(-1+s)/(3+2*s+s^2));
+f_ref=0;
+g_ref=9.5424250943932487459005580;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+h = syslin('c',((1/5)+(4/5)*s+(0/1)*s^2+(3/10)*s^3)/((409/10000)+(1827/10000)*s+(5129/4000)*s^2+(31909/10000)*s^3+(64/25)*s^4 +s^5));
+f_ref=0.0714555258202006740373134;
+g_ref=-4.91687406933815400242335;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+h=syslin('c',485000/(10000*s+200*s^2+s^3));
+f_ref=100/(2*%pi);
+g_ref=12.305765141234350772862319;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+h = syslin('c',1/(s+2*s^2+s^3));
+f_ref=1/(2*%pi);
+g_ref=6.0205999132796239042747779;
+if ~check_gmargin(h,f_ref,g_ref) then bugmes();quit;end
+//phase margin
+//-----------
+function ok=check_pmargin(h,f_ref,p_ref)
+ eps=1e-9
+ [p,f]=p_margin(h)
+ if f_ref==0 then
+ ok=abs(f - f_ref)<eps
+ else
+ ok=abs(f - f_ref)/abs(f_ref)<eps
+ end
+ if p_ref==0 then
+ ok=ok&abs(p - p_ref)<eps
+ else
+ ok=ok&abs(p - p_ref)/abs(p_ref)<eps
+ end
+endfunction
+//discrete time case
+//the reference solutions are computed using the following Maple instructions
+//z:=exp(I*w):
+//assume(w, 'real', w > 0)
+//P := solve(abs(h) = 1, w)
+//evalf(-(eval(180-180*argument(h)/Pi, w = Re(P[k]))))+360
+h = syslin(0.1,((29/625)+(2399/50000)*z)/((1131/1250)+(-181/100)*z+z^2));
+f_ref=0.693016600315284442350578876;
+p_ref=13.57115563612946355428439468;
+if ~check_pmargin(h,f_ref,p_ref) then bugmes();quit;end
+h=syslin(0.1,((43/500)+(-161/1000)*z+(39/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+[p ,f]=p_margin(h);
+if p<>%inf then bugmes();quit;end
+if f<>[] then bugmes();quit;end
+h=syslin(0.1,3*(0.086-0.161*%z+0.078*%z^2),-0.67+2.286*%z-2.61*%z^2+%z^3);
+h=syslin(0.1,((129/500)+(-483/1000)*z+(117/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+f_ref=0.212336488950669705771059018;
+p_ref=52.94967415965772478856630911;
+if ~check_pmargin(h,f_ref,p_ref) then bugmes();quit;end
+//continuous case
+//the reference solutions are computed using the following Maple instructions
+//z:=I*w:
+//assume(w, 'real', w > 0)
+//P := solve(abs(h) = 1, w)
+//evalf(-(eval(180-180*argument(h)/Pi, w = Re(P[k]))))+360
+h=syslin('c',((11/10)+(12/5)*s+(7/10)*s^2)/(3+2*s+s^2));
+f_ref=(1/51)*sqrt(15861-204*sqrt(3562))/(2*%pi);
+p_ref=-148.547076202317410601324666;
+if ~check_pmargin(h,f_ref,p_ref) then bugmes();quit;end
+h = syslin('c',((1/5)+(4/5)*s+(3/10)*s^3)/((409/10000)+(1827/10000)*s+(5129/4000)*s^2+(31909/10000)*s^3+(64/25)*s^4+s^5));
+f_ref=0.09144216563554157543991;
+p_ref=-13.1128497150069802772313;
+if ~check_pmargin(h,f_ref,p_ref) then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/margins.tst b/modules/cacsd/tests/unit_tests/margins.tst
new file mode 100755
index 000000000..286120c49
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/margins.tst
@@ -0,0 +1,151 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- ENGLISH IMPOSED -->
+
+//gain margin
+//-----------
+function ok=check_gmargin(h,fref,gref)
+ eps=1e-10
+ [g,f]=g_margin(h)
+ if fref==0 then
+ ok=abs(f - fref)<eps
+ else
+ ok=abs(f - fref)/abs(fref)<eps
+ end
+ if gref==0 then
+ ok=ok&abs(g - gref)<eps
+ else
+ ok=ok&abs(g - gref)/abs(gref)<eps
+ end
+endfunction
+
+//discrete time case
+z=poly(0,'z');
+//the references solutions are computed using the following Maple instructions
+//Digits:=50:
+//z:=exp(I*w):
+//assume(w, 'real', w > 0)
+//h:= rational fraction in z
+//M := solve(Im(h) = 0, w)
+//evalf(M/(2*Pi))
+//evalf(eval(20*log10(1/abs(h)), w = M[k]))
+
+h = syslin(0.1,((29/625)+(2399/50000)*z)/((1131/1250)+(-181/100)*z+z^2));
+f_ref=atan(sqrt(9003479136639)/4963519)/(0.1*2*%pi);
+g_ref=6.242379356591869534116;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+
+
+h=syslin(0.1,((43/500)+(-161/1000)*z+(39/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+f_ref=atan((1/215)*sqrt(1136805-8330*sqrt(5970))/(833/43+(1/215)*sqrt(5970)))/(0.1*2*%pi);
+g_ref=12.3470513198103944037870;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+h=syslin(0.1,((129/500)+(-483/1000)*z+(117/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+f_ref=atan((1/215)*sqrt(1136805-8330*sqrt(5970))/(833/43+(1/215)*sqrt(5970)))/(0.1*2*%pi);
+g_ref=2.8046262254171456578864840;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+
+h=syslin(1,((21/500)+(-3933/100000)*z+(-15407/100000)*z^2+(9259/50000)*z^3+(6939/(10^12))*z^4)/((-21/500)+(11/125)*z+(57/500)*z^2+(-9/25)*z^3+(1/5)*z^4));
+f_ref=1/2;
+g_ref=6.48227782514616029706190;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+//continuuous time case
+s=poly(0,'s');
+//the reference solutions are computed using the following Maple instructions
+//s:=I*w:
+//assume(w, 'real', w > 0)
+//h:= rational fraction in z
+//M := solve(Im(h) = 0, w)
+//evalf(M/(2*Pi))
+//evalf(eval(20*log10(1/abs(h)), w = M[k]))
+
+h=syslin('c',(-1+s)/(3+2*s+s^2));
+f_ref=0;
+g_ref=9.5424250943932487459005580;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+
+h = syslin('c',((1/5)+(4/5)*s+(0/1)*s^2+(3/10)*s^3)/((409/10000)+(1827/10000)*s+(5129/4000)*s^2+(31909/10000)*s^3+(64/25)*s^4 +s^5));
+f_ref=0.0714555258202006740373134;
+g_ref=-4.91687406933815400242335;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+
+h=syslin('c',485000/(10000*s+200*s^2+s^3));
+f_ref=100/(2*%pi);
+g_ref=12.305765141234350772862319;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+
+h = syslin('c',1/(s+2*s^2+s^3));
+f_ref=1/(2*%pi);
+g_ref=6.0205999132796239042747779;
+if ~check_gmargin(h,f_ref,g_ref) then pause,end
+
+//phase margin
+//-----------
+function ok=check_pmargin(h,f_ref,p_ref)
+ eps=1e-9
+ [p,f]=p_margin(h)
+ if f_ref==0 then
+ ok=abs(f - f_ref)<eps
+ else
+ ok=abs(f - f_ref)/abs(f_ref)<eps
+ end
+ if p_ref==0 then
+ ok=ok&abs(p - p_ref)<eps
+ else
+ ok=ok&abs(p - p_ref)/abs(p_ref)<eps
+ end
+endfunction
+
+//discrete time case
+//the reference solutions are computed using the following Maple instructions
+//z:=exp(I*w):
+//assume(w, 'real', w > 0)
+//P := solve(abs(h) = 1, w)
+//evalf(-(eval(180-180*argument(h)/Pi, w = Re(P[k]))))+360
+
+h = syslin(0.1,((29/625)+(2399/50000)*z)/((1131/1250)+(-181/100)*z+z^2));
+f_ref=0.693016600315284442350578876;
+p_ref=13.57115563612946355428439468;
+if ~check_pmargin(h,f_ref,p_ref) then pause,end
+
+
+h=syslin(0.1,((43/500)+(-161/1000)*z+(39/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+[p ,f]=p_margin(h);
+if p<>%inf then pause,end
+if f<>[] then pause,end
+
+h=syslin(0.1,3*(0.086-0.161*%z+0.078*%z^2),-0.67+2.286*%z-2.61*%z^2+%z^3);
+h=syslin(0.1,((129/500)+(-483/1000)*z+(117/500)*z^2)/((-67/100)+(1143/500)*z+(-261/100)*z^2+z^3));
+f_ref=0.212336488950669705771059018;
+p_ref=52.94967415965772478856630911;
+if ~check_pmargin(h,f_ref,p_ref) then pause,end
+
+//continuous case
+//the reference solutions are computed using the following Maple instructions
+//z:=I*w:
+//assume(w, 'real', w > 0)
+//P := solve(abs(h) = 1, w)
+//evalf(-(eval(180-180*argument(h)/Pi, w = Re(P[k]))))+360
+
+h=syslin('c',((11/10)+(12/5)*s+(7/10)*s^2)/(3+2*s+s^2));
+f_ref=(1/51)*sqrt(15861-204*sqrt(3562))/(2*%pi);
+p_ref=-148.547076202317410601324666;
+if ~check_pmargin(h,f_ref,p_ref) then pause,end
+
+
+h = syslin('c',((1/5)+(4/5)*s+(3/10)*s^3)/((409/10000)+(1827/10000)*s+(5129/4000)*s^2+(31909/10000)*s^3+(64/25)*s^4+s^5));
+f_ref=0.09144216563554157543991;
+p_ref=-13.1128497150069802772313;
+if ~check_pmargin(h,f_ref,p_ref) then pause,end
diff --git a/modules/cacsd/tests/unit_tests/nyquist.dia.ref b/modules/cacsd/tests/unit_tests/nyquist.dia.ref
new file mode 100755
index 000000000..2e6e1b538
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/nyquist.dia.ref
@@ -0,0 +1,154 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- ENGLISH IMPOSED -->
+function r=checknyquist(Args,leg)
+ if size(Args)==1 then Args($+1)=1d-3; Args($+1)=1d+3;end
+ [frq,rf,splitf]=repfreq(Args(:));repi=imag(rf);repf=real(rf);
+ [mn,n]=size(rf);
+ splitf($+1)=n+1;
+ ksplit=1;sel=splitf(ksplit):splitf(ksplit+1)-1;
+ R=[repf(:,sel)]; I=[repi(:,sel)];
+ for ksplit=2:size(splitf,'*')-1
+ sel=splitf(ksplit):splitf(ksplit+1)-1
+ R=[R %nan(ones(mn,1)) repf(:,sel)];
+ I=[I %nan(ones(mn,1)) repi(:,sel)];
+ end
+ //use symetry
+ R=[R R(:,$:-1:1)];
+ I=[I -I(:,$:-1:1)];
+ l=find(~isnan(R(1,:)))
+ fig=gcf();
+ r=0
+ a=fig.children;
+ if a.log_flags<>'nnn' then r=1;return,end
+ if or(a.axes_visible<>["on","on","on"]) then r=2;return,end
+ n=size(Args(1),1)
+ n1=size(a.children,'*')
+ if (argn(2)==1&(n<>n1))|(argn(2)==2&(n+1<>n1)) then r=3;return,end
+ for k=1:n;
+ if a.children($+1-k).type<>'Compound' then r=4;return,end
+ if size(a.children($+1-k).children,'*')<>2 then r=5;return,end
+ if a.children($+1-k).children(1).type<>'Compound' then r=6;return, end
+ if a.children($+1-k).children(2).type<>'Polyline' then r=7;return, end
+ if %f then //temporarily removed for 5.0
+ if a.children($+1-k).children(1).children(1).type<>'Segs' then r=8;return, end
+ ns=size(a.children($+1-k).children(1).children(1).data,1);
+ if size(a.children($+1-k).children(1).children,'*')-2<>(ns/2) then r=9;return, end
+ if or(a.children($+1-k).children(1).children(2:$).type<>'Text') then r=10;return, end
+ end
+ if or(l<>find(~isnan(a.children($+1-k).children(2).data(:,1)))) then r=11;return, end
+ if norm(a.children($+1-k).children(2).data(l,:)-[R(k,l)' I(k,l)'])> 1d-14 then r=12;return, end
+ s= a.children($+1-k).children(1).children(1);
+ end
+ if argn(2)==2 then //test the legend
+ if size(a.children,'*')<=n then r=13;return,end
+ if a.children(1).type<>'Legend' then r=14;return,end
+ if size(a.children(1).links,'*')<>n then r=15;return,end
+ if or(a.children(1).text<>leg(:)) then r=16;return,end
+ end
+endfunction
+s=poly(0,'s');
+n=1+s;d=1+2*s;
+h=syslin('c',n,d);
+sl=tf2ss(h);
+sld=dscr(sl,0.01);
+hd=ss2tf(sld);
+[w,rf]=repfreq(h,0.01,100);
+//continuous time
+clf();nyquist(h);
+if checknyquist(list(h)) then bugmes();quit;end
+clf();nyquist(h,'h');
+if checknyquist(list(h),'h') then bugmes();quit;end
+clf();nyquist(h,0.01,100);
+if checknyquist(list(h,0.01,100)) then bugmes();quit;end
+clf();nyquist(h,0.01,100,'h');
+if checknyquist(list(h,0.01,100),'h') then bugmes();quit;end
+clf();nyquist(h,0.01,100,0.01)
+if checknyquist(list(h,0.01,100,0.01)) then bugmes();quit;end
+clf();nyquist(sl,0.01,100);
+if checknyquist(list(sl,0.01,100)) then bugmes();quit;end
+clf();nyquist(sl,0.01,100,0.01)
+if checknyquist(list(sl,0.01,100,0.01)) then bugmes();quit;end
+//continuous time SIMO
+h=[h;h+1];sl=[sl;sl+1];
+clf();nyquist(h);
+if checknyquist(list(h)) then bugmes();quit;end
+clf();nyquist(h,['h';'h+1']);
+if checknyquist(list(h),['h';'h+1']) then bugmes();quit;end
+clf();nyquist(h,0.01,100);
+if checknyquist(list(h,0.01,100)) then bugmes();quit;end
+clf();nyquist(h,0.01,100,['h';'h+1']);
+if checknyquist(list(h,0.01,100),['h';'h+1']) then bugmes();quit;end
+clf();nyquist(h,0.01,100,0.01)
+if checknyquist(list(h,0.01,100,0.01)) then bugmes();quit;end
+clf();nyquist(sl,0.01,100);
+if checknyquist(list(sl,0.01,100)) then bugmes();quit;end
+clf();nyquist(sl,0.01,100,0.01)
+if checknyquist(list(sl,0.01,100,0.01)) then bugmes();quit;end
+//discrete case
+clf();nyquist(hd);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd)) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,'h');
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd),'h') then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd,0.01,100)) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,0.01,100,'h');
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd,0.01,100),'h') then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,0.01,100,0.01)
+if checknyquist(list(hd,0.01,100,0.01)) then bugmes();quit;end
+clf();nyquist(sld,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(sld,0.01,100)) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(sld,0.01,100,0.01)
+if checknyquist(list(sld,0.01,100,0.01)) then bugmes();quit;end
+//discrete case SIMO
+hd=[hd;hd+1];sld=[sld;sld+1];
+clf();nyquist(hd);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd)) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,['h';'h+1']);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd),['h';'h+1']) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd,0.01,100)) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,0.01,100,['h';'h+1']);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(hd,0.01,100),['h';'h+1']) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(hd,0.01,100,0.01)
+if checknyquist(list(hd,0.01,100,0.01)) then bugmes();quit;end
+clf();nyquist(sld,0.01,100);
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+if checknyquist(list(sld,0.01,100)) then bugmes();quit;end
+WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
+clf();nyquist(sld,0.01,100,0.01)
+if checknyquist(list(sld,0.01,100,0.01)) then bugmes();quit;end
+//nyquist given by precmputed freqency response
+clf(); nyquist(w,rf)
+clf(); nyquist(w,20*log(abs(rf))/log(10),(180/%pi)*atan(imag(rf),real(rf)))
+// check legend color
+clf();
+F1=syslin('c',(2.5*0.8)/((0.25*%s+1)*(0.8*%s+1)));
+F2=syslin('c',(0.88*2.5*0.8)/((0.25*%s+1)*(0.8*%s+1)));
+F3=syslin('c',(100*2.5*0.8)/((0.25*%s+1)*(0.8*%s+1)));
+nyquist ([F1;F2;F3],0.0 ,1000,["F1(Kr=1)";"F2(Kr=0,88)";"F3(Kr=10)"],%f)
+a=gca();
+assert_checkequal(a.children(1).links.foreground, [3, 2, 1]); // [green blue black]
diff --git a/modules/cacsd/tests/unit_tests/nyquist.tst b/modules/cacsd/tests/unit_tests/nyquist.tst
new file mode 100755
index 000000000..5da957195
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/nyquist.tst
@@ -0,0 +1,158 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2010 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+// <-- ENGLISH IMPOSED -->
+
+function r=checknyquist(Args,leg)
+ if size(Args)==1 then Args($+1)=1d-3; Args($+1)=1d+3;end
+ [frq,rf,splitf]=repfreq(Args(:));repi=imag(rf);repf=real(rf);
+ [mn,n]=size(rf);
+ splitf($+1)=n+1;
+
+ ksplit=1;sel=splitf(ksplit):splitf(ksplit+1)-1;
+ R=[repf(:,sel)]; I=[repi(:,sel)];
+ for ksplit=2:size(splitf,'*')-1
+ sel=splitf(ksplit):splitf(ksplit+1)-1
+ R=[R %nan(ones(mn,1)) repf(:,sel)];
+ I=[I %nan(ones(mn,1)) repi(:,sel)];
+ end
+ //use symetry
+ R=[R R(:,$:-1:1)];
+ I=[I -I(:,$:-1:1)];
+
+ l=find(~isnan(R(1,:)))
+ fig=gcf();
+ r=0
+ a=fig.children;
+
+ if a.log_flags<>'nnn' then r=1;return,end
+ if or(a.axes_visible<>["on","on","on"]) then r=2;return,end
+
+ n=size(Args(1),1)
+ n1=size(a.children,'*')
+ if (argn(2)==1&(n<>n1))|(argn(2)==2&(n+1<>n1)) then r=3;return,end
+ for k=1:n;
+ if a.children($+1-k).type<>'Compound' then r=4;return,end
+ if size(a.children($+1-k).children,'*')<>2 then r=5;return,end
+ if a.children($+1-k).children(1).type<>'Compound' then r=6;return, end
+ if a.children($+1-k).children(2).type<>'Polyline' then r=7;return, end
+ if %f then //temporarily removed for 5.0
+ if a.children($+1-k).children(1).children(1).type<>'Segs' then r=8;return, end
+ ns=size(a.children($+1-k).children(1).children(1).data,1);
+ if size(a.children($+1-k).children(1).children,'*')-2<>(ns/2) then r=9;return, end
+ if or(a.children($+1-k).children(1).children(2:$).type<>'Text') then r=10;return, end
+ end
+ if or(l<>find(~isnan(a.children($+1-k).children(2).data(:,1)))) then r=11;return, end
+ if norm(a.children($+1-k).children(2).data(l,:)-[R(k,l)' I(k,l)'])> 1d-14 then r=12;return, end
+ s= a.children($+1-k).children(1).children(1);
+ end
+ if argn(2)==2 then //test the legend
+ if size(a.children,'*')<=n then r=13;return,end
+ if a.children(1).type<>'Legend' then r=14;return,end
+ if size(a.children(1).links,'*')<>n then r=15;return,end
+ if or(a.children(1).text<>leg(:)) then r=16;return,end
+ end
+endfunction
+
+
+s=poly(0,'s');
+n=1+s;d=1+2*s;
+h=syslin('c',n,d);
+sl=tf2ss(h);
+sld=dscr(sl,0.01);
+hd=ss2tf(sld);
+
+[w,rf]=repfreq(h,0.01,100);
+
+//continuous time
+clf();nyquist(h);
+if checknyquist(list(h)) then pause,end
+clf();nyquist(h,'h');
+if checknyquist(list(h),'h') then pause,end
+
+clf();nyquist(h,0.01,100);
+if checknyquist(list(h,0.01,100)) then pause,end
+clf();nyquist(h,0.01,100,'h');
+if checknyquist(list(h,0.01,100),'h') then pause,end
+
+clf();nyquist(h,0.01,100,0.01)
+if checknyquist(list(h,0.01,100,0.01)) then pause,end
+clf();nyquist(sl,0.01,100);
+if checknyquist(list(sl,0.01,100)) then pause,end
+clf();nyquist(sl,0.01,100,0.01)
+if checknyquist(list(sl,0.01,100,0.01)) then pause,end
+
+//continuous time SIMO
+h=[h;h+1];sl=[sl;sl+1];
+clf();nyquist(h);
+if checknyquist(list(h)) then pause,end
+clf();nyquist(h,['h';'h+1']);
+if checknyquist(list(h),['h';'h+1']) then pause,end
+
+clf();nyquist(h,0.01,100);
+if checknyquist(list(h,0.01,100)) then pause,end
+clf();nyquist(h,0.01,100,['h';'h+1']);
+if checknyquist(list(h,0.01,100),['h';'h+1']) then pause,end
+
+clf();nyquist(h,0.01,100,0.01)
+if checknyquist(list(h,0.01,100,0.01)) then pause,end
+clf();nyquist(sl,0.01,100);
+if checknyquist(list(sl,0.01,100)) then pause,end
+clf();nyquist(sl,0.01,100,0.01)
+if checknyquist(list(sl,0.01,100,0.01)) then pause,end
+
+//discrete case
+clf();nyquist(hd);
+if checknyquist(list(hd)) then pause,end
+clf();nyquist(hd,'h');
+if checknyquist(list(hd),'h') then pause,end
+
+clf();nyquist(hd,0.01,100);
+if checknyquist(list(hd,0.01,100)) then pause,end
+clf();nyquist(hd,0.01,100,'h');
+if checknyquist(list(hd,0.01,100),'h') then pause,end
+
+clf();nyquist(hd,0.01,100,0.01)
+if checknyquist(list(hd,0.01,100,0.01)) then pause,end
+clf();nyquist(sld,0.01,100);
+if checknyquist(list(sld,0.01,100)) then pause,end
+clf();nyquist(sld,0.01,100,0.01)
+if checknyquist(list(sld,0.01,100,0.01)) then pause,end
+
+//discrete case SIMO
+hd=[hd;hd+1];sld=[sld;sld+1];
+clf();nyquist(hd);
+if checknyquist(list(hd)) then pause,end
+clf();nyquist(hd,['h';'h+1']);
+if checknyquist(list(hd),['h';'h+1']) then pause,end
+
+clf();nyquist(hd,0.01,100);
+if checknyquist(list(hd,0.01,100)) then pause,end
+clf();nyquist(hd,0.01,100,['h';'h+1']);
+if checknyquist(list(hd,0.01,100),['h';'h+1']) then pause,end
+
+clf();nyquist(hd,0.01,100,0.01)
+if checknyquist(list(hd,0.01,100,0.01)) then pause,end
+clf();nyquist(sld,0.01,100);
+if checknyquist(list(sld,0.01,100)) then pause,end
+clf();nyquist(sld,0.01,100,0.01)
+if checknyquist(list(sld,0.01,100,0.01)) then pause,end
+
+//nyquist given by precmputed freqency response
+
+clf(); nyquist(w,rf)
+clf(); nyquist(w,20*log(abs(rf))/log(10),(180/%pi)*atan(imag(rf),real(rf)))
+
+// check legend color
+clf();
+F1=syslin('c',(2.5*0.8)/((0.25*%s+1)*(0.8*%s+1)));
+F2=syslin('c',(0.88*2.5*0.8)/((0.25*%s+1)*(0.8*%s+1)));
+F3=syslin('c',(100*2.5*0.8)/((0.25*%s+1)*(0.8*%s+1)));
+nyquist ([F1;F2;F3],0.0 ,1000,["F1(Kr=1)";"F2(Kr=0,88)";"F3(Kr=10)"],%f)
+a=gca();
+assert_checkequal(a.children(1).links.foreground, [3, 2, 1]); // [green blue black]
diff --git a/modules/cacsd/tests/unit_tests/odedi.dia.ref b/modules/cacsd/tests/unit_tests/odedi.dia.ref
new file mode 100755
index 000000000..105c61ad3
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/odedi.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// 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.
+// =============================================================================
+// simple tests for arsimul and odedi
+// x_{n+1}=n*x_{n}, x_{1}=1;
+deff('[xnp1]=ttt(n,xn)','xnp1=(xn**2);');
+// use y=ode('discret',y1,1,2:n,macro);y=[y1,y]
+// to get y=[y1,y2,....,y_n];
+//!
+ero_n=0;
+y=ode('discrete',2,1,2:4,ttt);y=[2,y];
+if y <> [2,4,16,256] then bugmes();quit;end
+// arsimul tests
+y=arsimul([1],[1],[0],0,1:10);
+if y <> (1:10) then bugmes();quit;end
+y=arsimul([1],[0,1],[0],0,1:10);
+if y <> [0,1:9] then bugmes();quit;end
+y=arsimul([1],[0,1],[0],0,1:10,[-5]);
+if y <> [-5,1:9] then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/odedi.tst b/modules/cacsd/tests/unit_tests/odedi.tst
new file mode 100755
index 000000000..8d50b5b68
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/odedi.tst
@@ -0,0 +1,28 @@
+// =============================================================================
+// 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.
+// =============================================================================
+
+// simple tests for arsimul and odedi
+// x_{n+1}=n*x_{n}, x_{1}=1;
+deff('[xnp1]=ttt(n,xn)','xnp1=(xn**2);');
+// use y=ode('discret',y1,1,2:n,macro);y=[y1,y]
+// to get y=[y1,y2,....,y_n];
+//!
+ero_n=0;
+y=ode('discrete',2,1,2:4,ttt);y=[2,y];
+if y <> [2,4,16,256] then pause,end
+// arsimul tests
+y=arsimul([1],[1],[0],0,1:10);
+if y <> (1:10) then pause,end
+y=arsimul([1],[0,1],[0],0,1:10);
+if y <> [0,1:9] then pause,end
+y=arsimul([1],[0,1],[0],0,1:10,[-5]);
+if y <> [-5,1:9] then pause,end
+
+
+
+
+
diff --git a/modules/cacsd/tests/unit_tests/plzr.dia.ref b/modules/cacsd/tests/unit_tests/plzr.dia.ref
new file mode 100755
index 000000000..f5b739ed5
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/plzr.dia.ref
@@ -0,0 +1,126 @@
+// =============================================================================
+// 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.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+//
+// Unit tests for plzr()
+function checkplzr(h,zrs,pls)
+ if typeof(h)=="rational" then
+ plzr(h);
+ h=tf2ss(h);
+ [a,b,c,d]=h(2:5);
+ dt=h.dt;
+ elseif typeof(h)=="state-space" then
+ plzr(h);
+ [a,b,c,d]=h(2:5)
+ dt=h.dt;
+ else
+ plzr(h(1),h(2),h(3),h(4));
+ a=h(1);
+ b=h(2);
+ c=h(3);
+ d=h(4);
+ dt=[];
+ end
+ fig=gcf();
+ ax=fig.children;
+ dr=spec(a)
+ [al,be]=tr_zer(a,b,c,d)
+ nr=al./be;
+ nr=real(nr);
+ dr=real(dr);
+ //nb_child=size
+ assert_checkequal(ax.type, "Axes");
+ // Check axis name
+ assert_checkequal(ax.x_label.text, _("Real axis"));
+ assert_checkequal(ax.y_label.text, _("Imaginary axis"));
+ // Check legend
+ assert_checkequal(ax.children(1).type,"Legend");
+ // Check stability
+ if dt == "d" then
+ assert_checkequal(ax.children(2).type,"Arc");
+ else
+ assert_checkequal(ax.children(2).type,"Segs");
+ end
+ // Check zeros
+ if size(nr,"*") <> 0 & size(dr,"*") == 0 then
+ assert_checkequal(ax.children(1).text, _("Zeros"));
+ assert_checkequal(ax.children(3).type, "Polyline");
+ assert_checktrue(ax.children(3).data-zrs<1d-5);
+ end
+ // Check poles
+ if size(dr,"*") <> 0 & size(nr,"*") == 0 then
+ assert_checkequal(ax.children(1).text, _("Poles"));
+ assert_checkequal(ax.children(3).type, "Polyline");
+ assert_checktrue(ax.children(3).data-pls<1d-5);
+ end
+ // Check zeros and poles
+ if size(nr,"*")<> 0 & size(dr,"*") <> 0 then
+ assert_checkequal(ax.children(1).text,[_("Poles");_("Zeros")]);
+ assert_checkequal(ax.children(3).type,"Polyline");
+ assert_checkequal(ax.children(4).type,"Polyline");
+ assert_checktrue(ax.children(3).data-zrs<1d-5);
+ assert_checktrue(ax.children(4).data-pls<1d-5);
+ end
+ close
+endfunction
+// With zeros and poles
+s=poly(0,"s");
+n=1+s;
+d=1+3*s;
+// continuous transfert fct
+hc=syslin("c",n./d);
+checkplzr(hc,[-1/3 0],[-1 0]);
+// discete transfert fct
+hd=syslin("d",n./d);
+checkplzr(hd,[-1/3 0],[-1 0]);
+// undifined time domain transfert fct
+h=syslin([],n./d);
+checkplzr(h,[-1/3 0],[-1 0]);
+// continuous state-space
+ssc=tf2ss(hc);
+checkplzr(ssc,[-1/3 0],[-1 0]);
+checkplzr([ssc(2),ssc(3),ssc(4),ssc(5)],[-1/3 0],[-1 0]);
+// discrete state-space
+ssd=tf2ss(hd);
+checkplzr(ssd,[-1/3 0],[-1 0]);
+// undifined time domain state-space
+ss=tf2ss(h);
+checkplzr(ss,[-1/3 0],[-1 0]);
+checkplzr([ss(2),ss(3),ss(4),ss(5)],[-1/3 0],[-1 0]);
+// With poles
+s=poly(0,"s");
+n=[1+s 2+3*s+4*s^2];
+d=[1+3*s 5-s^3];
+// continuous transfert fct
+hc=syslin("c",n./d);
+checkplzr(hc,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// discete transfert fct
+hd=syslin("d",n./d);
+checkplzr(hd,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// undifined time domain transfert fct
+h=syslin([],n./d);
+checkplzr(h,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// continuous state-space
+ssc=tf2ss(hc);
+checkplzr(ssc,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// discrete state-space
+ssd=tf2ss(hd);
+checkplzr(ssd,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// undifined time domain state-space
+ss=tf2ss(h);
+checkplzr(ss,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// error messages
+errmsg1=msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"plzr",4);
+assert_checkerror("plzr(1)",errmsg1);
+errmsg2=msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"plzr",1);
+assert_checkerror("plzr(h,1)",errmsg2);
+errmsg3=msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"plzr",1);
+assert_checkerror("plzr(ss,1)",errmsg3);
+errmsg4=msprintf(gettext("%s: Wrong type for input argument #%d: Linear dynamical system expected.\n"),"plzr",1);
+assert_checkerror("plzr(n)",errmsg4);
+errmsg5=msprintf(gettext("%s: Wrong type of input argument #%d: Array of floating point numbers expected.\n"),"plzr",1);
+assert_checkerror("plzr(""s"",""d"")",errmsg5);
diff --git a/modules/cacsd/tests/unit_tests/plzr.tst b/modules/cacsd/tests/unit_tests/plzr.tst
new file mode 100755
index 000000000..23313d76b
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/plzr.tst
@@ -0,0 +1,137 @@
+// =============================================================================
+// 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.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+//
+// Unit tests for plzr()
+
+function checkplzr(h,zrs,pls)
+
+ if typeof(h)=="rational" then
+ plzr(h);
+ h=tf2ss(h);
+ [a,b,c,d]=h(2:5);
+ dt=h.dt;
+ elseif typeof(h)=="state-space" then
+ plzr(h);
+ [a,b,c,d]=h(2:5)
+ dt=h.dt;
+ else
+ plzr(h(1),h(2),h(3),h(4));
+ a=h(1);
+ b=h(2);
+ c=h(3);
+ d=h(4);
+ dt=[];
+ end
+ fig=gcf();
+ ax=fig.children;
+ dr=spec(a)
+ [al,be]=tr_zer(a,b,c,d)
+ nr=al./be;
+ nr=real(nr);
+ dr=real(dr);
+
+ //nb_child=size
+ assert_checkequal(ax.type, "Axes");
+
+ // Check axis name
+ assert_checkequal(ax.x_label.text, _("Real axis"));
+ assert_checkequal(ax.y_label.text, _("Imaginary axis"));
+
+ // Check legend
+ assert_checkequal(ax.children(1).type,"Legend");
+
+ // Check stability
+ if dt == "d" then
+ assert_checkequal(ax.children(2).type,"Arc");
+ else
+ assert_checkequal(ax.children(2).type,"Segs");
+ end
+
+ // Check zeros
+ if size(nr,"*") <> 0 & size(dr,"*") == 0 then
+ assert_checkequal(ax.children(1).text, _("Zeros"));
+ assert_checkequal(ax.children(3).type, "Polyline");
+ assert_checktrue(ax.children(3).data-zrs<1d-5);
+ end
+ // Check poles
+ if size(dr,"*") <> 0 & size(nr,"*") == 0 then
+ assert_checkequal(ax.children(1).text, _("Poles"));
+ assert_checkequal(ax.children(3).type, "Polyline");
+ assert_checktrue(ax.children(3).data-pls<1d-5);
+ end
+ // Check zeros and poles
+ if size(nr,"*")<> 0 & size(dr,"*") <> 0 then
+ assert_checkequal(ax.children(1).text,[_("Poles");_("Zeros")]);
+ assert_checkequal(ax.children(3).type,"Polyline");
+ assert_checkequal(ax.children(4).type,"Polyline");
+ assert_checktrue(ax.children(3).data-zrs<1d-5);
+ assert_checktrue(ax.children(4).data-pls<1d-5);
+ end
+ close
+endfunction
+
+// With zeros and poles
+s=poly(0,"s");
+n=1+s;
+d=1+3*s;
+// continuous transfert fct
+hc=syslin("c",n./d);
+checkplzr(hc,[-1/3 0],[-1 0]);
+// discete transfert fct
+hd=syslin("d",n./d);
+checkplzr(hd,[-1/3 0],[-1 0]);
+// undifined time domain transfert fct
+h=syslin([],n./d);
+checkplzr(h,[-1/3 0],[-1 0]);
+// continuous state-space
+ssc=tf2ss(hc);
+checkplzr(ssc,[-1/3 0],[-1 0]);
+checkplzr([ssc(2),ssc(3),ssc(4),ssc(5)],[-1/3 0],[-1 0]);
+// discrete state-space
+ssd=tf2ss(hd);
+checkplzr(ssd,[-1/3 0],[-1 0]);
+// undifined time domain state-space
+ss=tf2ss(h);
+checkplzr(ss,[-1/3 0],[-1 0]);
+checkplzr([ss(2),ss(3),ss(4),ss(5)],[-1/3 0],[-1 0]);
+
+// With poles
+s=poly(0,"s");
+n=[1+s 2+3*s+4*s^2];
+d=[1+3*s 5-s^3];
+// continuous transfert fct
+hc=syslin("c",n./d);
+checkplzr(hc,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// discete transfert fct
+hd=syslin("d",n./d);
+checkplzr(hd,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// undifined time domain transfert fct
+h=syslin([],n./d);
+checkplzr(h,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// continuous state-space
+ssc=tf2ss(hc);
+checkplzr(ssc,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// discrete state-space
+ssd=tf2ss(hd);
+checkplzr(ssd,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+// undifined time domain state-space
+ss=tf2ss(h);
+checkplzr(ss,[],[1.7099759,0;-0.8549880,1.4808826;-0.8549880,-1.4808826;-1/3 0]);
+
+// error messages
+errmsg1=msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"plzr",4);
+assert_checkerror("plzr(1)",errmsg1);
+errmsg2=msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"plzr",1);
+assert_checkerror("plzr(h,1)",errmsg2);
+errmsg3=msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"plzr",1);
+assert_checkerror("plzr(ss,1)",errmsg3);
+errmsg4=msprintf(gettext("%s: Wrong type for input argument #%d: Linear dynamical system expected.\n"),"plzr",1);
+assert_checkerror("plzr(n)",errmsg4);
+errmsg5=msprintf(gettext("%s: Wrong type of input argument #%d: Array of floating point numbers expected.\n"),"plzr",1);
+assert_checkerror("plzr(""s"",""d"")",errmsg5);
diff --git a/modules/cacsd/tests/unit_tests/rankqr.dia.ref b/modules/cacsd/tests/unit_tests/rankqr.dia.ref
new file mode 100755
index 000000000..05798b2b7
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/rankqr.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+A=testmatrix("magi",5);
+[Q,R,JPVT,RANK,SVAL]=rankqr(A,%eps);
+assert_checkequal(RANK, 5);
+assert_checkequal(JPVT, [3,1,4,2,5]);
+assert_checkalmostequal(SVAL, [64.612618,13.836178,13.836178], 1e-6);
+R_ref=[-34.71311,-20.021254,-23.478161,-23.478161,-20.021254;
+0,-25.576344,-11.727155,-15.441525,-17.170139;
+0,0,-20.4022,3.0540446,-9.4882354;
+0,0,0,17.493086,3.6461334;
+0,0,0,0,16.000463];
+assert_checkalmostequal(R, R_ref, 1e-6);
+Q_ref=[-0.0288076,-0.6421260,0.0101293,0.7647199,0.0441038;
+-0.2016529,-0.7414138,-0.0279815,-0.6343960,0.0800023;
+-0.3744983,0.1367641,-0.6279383,0.0707175,0.6646346;
+-0.5473436,0.0374763,-0.4209775,0.0579516,-0.7200208;
+-0.720189,0.1336816,0.6539005,0.0662258,0.1774410];
+assert_checkalmostequal(Q, Q_ref, 1e-5);
diff --git a/modules/cacsd/tests/unit_tests/rankqr.tst b/modules/cacsd/tests/unit_tests/rankqr.tst
new file mode 100755
index 000000000..8297f1fe0
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/rankqr.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+A=testmatrix("magi",5);
+[Q,R,JPVT,RANK,SVAL]=rankqr(A,%eps);
+assert_checkequal(RANK, 5);
+assert_checkequal(JPVT, [3,1,4,2,5]);
+assert_checkalmostequal(SVAL, [64.612618,13.836178,13.836178], 1e-6);
+
+R_ref=[-34.71311,-20.021254,-23.478161,-23.478161,-20.021254;
+0,-25.576344,-11.727155,-15.441525,-17.170139;
+0,0,-20.4022,3.0540446,-9.4882354;
+0,0,0,17.493086,3.6461334;
+0,0,0,0,16.000463];
+assert_checkalmostequal(R, R_ref, 1e-6);
+
+Q_ref=[-0.0288076,-0.6421260,0.0101293,0.7647199,0.0441038;
+-0.2016529,-0.7414138,-0.0279815,-0.6343960,0.0800023;
+-0.3744983,0.1367641,-0.6279383,0.0707175,0.6646346;
+-0.5473436,0.0374763,-0.4209775,0.0579516,-0.7200208;
+-0.720189,0.1336816,0.6539005,0.0662258,0.1774410];
+assert_checkalmostequal(Q, Q_ref, 1e-5);
diff --git a/modules/cacsd/tests/unit_tests/ricc.dia.ref b/modules/cacsd/tests/unit_tests/ricc.dia.ref
new file mode 100755
index 000000000..2d303617b
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/ricc.dia.ref
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+A = [8,8,9;1,8,6;2,5,9];
+B = [0,6;7,8;4,0];
+C = [8,5,5;9,8,1;5,0,7];
+C=C*C';
+R=[2,9; 5,7];
+R=R*R'+eye();
+B=B*inv(R)*B';
+X=ricc(A,B,C,'cont');
+X_ref=[44.84688,2.304207,66.647924;2.304207,27.392655,10.625534;66.647924,10.625534,118.86653];
+assert_checkalmostequal(X, X_ref, 1e-6);
diff --git a/modules/cacsd/tests/unit_tests/ricc.tst b/modules/cacsd/tests/unit_tests/ricc.tst
new file mode 100755
index 000000000..95e29834b
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/ricc.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - SE - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+A = [8,8,9;1,8,6;2,5,9];
+B = [0,6;7,8;4,0];
+C = [8,5,5;9,8,1;5,0,7];
+
+C=C*C';
+R=[2,9; 5,7];
+
+R=R*R'+eye();
+B=B*inv(R)*B';
+X=ricc(A,B,C,'cont');
+X_ref=[44.84688,2.304207,66.647924;2.304207,27.392655,10.625534;66.647924,10.625534,118.86653];
+assert_checkalmostequal(X, X_ref, 1e-6);
diff --git a/modules/cacsd/tests/unit_tests/riccati.dia.ref b/modules/cacsd/tests/unit_tests/riccati.dia.ref
new file mode 100755
index 000000000..3cabbea26
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/riccati.dia.ref
@@ -0,0 +1,31 @@
+// ============================================================================
+// Tests for riccati() function
+// Added : 25/06/2007
+// Thanks to Sabine GAUZERE
+// ============================================================================
+n = 10;
+A = rand(n,n);
+B = rand(n,n);
+C = rand(n,n);
+C = C*C';
+R = rand(n,n);
+R = R*R'+eye();
+B = B*inv(R)*B';
+// Test de l'équation en temps continu
+X = riccati(A,B,C,'c','eigen');
+// Vérification
+C_cont = A'*X+X*A-X*B*X;
+// Test de l'équation en temps discret
+F = A;
+B = rand(n,n);
+G1 = B;
+G2 = R;
+G = G1/G2*G1';
+H = C;
+[X1,X2]= riccati(F,G,H,'d','schur');
+// Vérification
+X = X1/X2;
+C_disc = F'*X*F-(F'*X*G1/(G2+G1'*X*G1))*(G1'*X*F)-X;
+// Comparaison des différents résultats obtenus
+if norm(C_cont+C,1) > (10000*%eps) then bugmes();quit;end
+if norm(C_disc+H,1) > (10000*%eps) then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/riccati.tst b/modules/cacsd/tests/unit_tests/riccati.tst
new file mode 100755
index 000000000..02aca429e
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/riccati.tst
@@ -0,0 +1,44 @@
+// =============================================================================
+// 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.
+// =============================================================================
+
+// ============================================================================
+// Tests for riccati() function
+// Added : 25/06/2007
+// Thanks to Sabine GAUZERE
+// ============================================================================
+
+n = 10;
+A = rand(n,n);
+B = rand(n,n);
+C = rand(n,n);
+C = C*C';
+R = rand(n,n);
+R = R*R'+eye();
+B = B*inv(R)*B';
+
+// Test de l'équation en temps continu
+X = riccati(A,B,C,'c','eigen');
+
+// Vérification
+C_cont = A'*X+X*A-X*B*X;
+
+// Test de l'équation en temps discret
+F = A;
+B = rand(n,n);
+G1 = B;
+G2 = R;
+G = G1/G2*G1';
+H = C;
+[X1,X2]= riccati(F,G,H,'d','schur');
+
+// Vérification
+X = X1/X2;
+C_disc = F'*X*F-(F'*X*G1/(G2+G1'*X*G1))*(G1'*X*F)-X;
+
+// Comparaison des différents résultats obtenus
+if norm(C_cont+C,1) > (10000*%eps) then pause,end
+if norm(C_disc+H,1) > (10000*%eps) then pause,end
diff --git a/modules/cacsd/tests/unit_tests/routh_t.dia.ref b/modules/cacsd/tests/unit_tests/routh_t.dia.ref
new file mode 100755
index 000000000..c629767ba
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/routh_t.dia.ref
@@ -0,0 +1,45 @@
+// =============================================================================
+// 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 -->
+// unit tests for routh_t() function
+// =============================================================================
+s=poly(0,'s');
+k=poly(0,'k');
+//Test with a polynomial
+P1=s*(s+7)*(s+11);
+assert_checkequal(routh_t(P1), [1 77; 18 0; 77 0; 0 0]);
+[r, num] = routh_t(P1);
+assert_checkequal(r, [1 77; 18 0; 77 0; 0 0]);
+assert_checkequal(num, 0);
+//Test with a transfert function
+h=1/P1;
+ref1=[1 77; 18 k;(1386-k)/18 0; k 0];
+numref1=numer(ref1);
+numref1(3)=1386 - k;
+denref1=denom(ref1);
+denref1(3)=18;
+assert_checkequal(numer(routh_t(h,k))/horner(denom(routh_t(h,k)),1),numref1/denref1);
+assert_checkequal(numer(routh_t(h,k,%t))/horner(denom(routh_t(h,k,%t)),1),numref1/denref1);
+assert_checkequal(routh_t(h,k,%f),[1 77; 18 k; 1386-k 0; 1386*k-k*k 0]);
+// One of the coefficients in the polynomial equals zero
+P2=2*s^2-24;
+assert_checkequal(routh_t(P2), [2 -24; 4 0; -24 0]);
+[r, num] = routh_t(P2);
+assert_checkequal(r, [2 -24; 4 0; -24 0]);
+assert_checkequal(num, 1);
+// A row full of zeros
+P3=s^4-6*s^3+10*s^2-6*s+9;
+assert_checkequal(routh_t(P3),[1 10 9; -6 -6 0; 9 9 0; 18 0 0; 9 0 0]);
+[r, num] = routh_t(P3);
+assert_checkequal(r,[1 10 9; -6 -6 0; 9 9 0; 18 0 0; 9 0 0]);
+assert_checkequal(num, 2);
+//Error messages
+assert_checkfalse(execstr("routh_t(P,%t)","errcatch")==0);
+assert_checkfalse(execstr("routh_t(P,k)","errcatch")==0);
+assert_checkfalse(execstr("routh_t()","errcatch")==0);
+assert_checkfalse(execstr("routh_t(h)","errcatch")==0);
+assert_checkfalse(execstr("routh_t(h,k,%t,%t)","errcatch")==0);
diff --git a/modules/cacsd/tests/unit_tests/routh_t.tst b/modules/cacsd/tests/unit_tests/routh_t.tst
new file mode 100755
index 000000000..427d08bcb
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/routh_t.tst
@@ -0,0 +1,53 @@
+// =============================================================================
+// 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 -->
+
+// unit tests for routh_t() function
+// =============================================================================
+
+s=poly(0,'s');
+k=poly(0,'k');
+
+//Test with a polynomial
+P1=s*(s+7)*(s+11);
+assert_checkequal(routh_t(P1), [1 77; 18 0; 77 0; 0 0]);
+[r, num] = routh_t(P1);
+assert_checkequal(r, [1 77; 18 0; 77 0; 0 0]);
+assert_checkequal(num, 0);
+
+//Test with a transfert function
+h=1/P1;
+ref1=[1 77; 18 k;(1386-k)/18 0; k 0];
+numref1=numer(ref1);
+numref1(3)=1386 - k;
+denref1=denom(ref1);
+denref1(3)=18;
+assert_checkequal(numer(routh_t(h,k))/horner(denom(routh_t(h,k)),1),numref1/denref1);
+assert_checkequal(numer(routh_t(h,k,%t))/horner(denom(routh_t(h,k,%t)),1),numref1/denref1);
+assert_checkequal(routh_t(h,k,%f),[1 77; 18 k; 1386-k 0; 1386*k-k*k 0]);
+
+// One of the coefficients in the polynomial equals zero
+P2=2*s^2-24;
+assert_checkequal(routh_t(P2), [2 -24; 4 0; -24 0]);
+[r, num] = routh_t(P2);
+assert_checkequal(r, [2 -24; 4 0; -24 0]);
+assert_checkequal(num, 1);
+
+// A row full of zeros
+P3=s^4-6*s^3+10*s^2-6*s+9;
+assert_checkequal(routh_t(P3),[1 10 9; -6 -6 0; 9 9 0; 18 0 0; 9 0 0]);
+[r, num] = routh_t(P3);
+assert_checkequal(r,[1 10 9; -6 -6 0; 9 9 0; 18 0 0; 9 0 0]);
+assert_checkequal(num, 2);
+
+//Error messages
+assert_checkfalse(execstr("routh_t(P,%t)","errcatch")==0);
+assert_checkfalse(execstr("routh_t(P,k)","errcatch")==0);
+assert_checkfalse(execstr("routh_t()","errcatch")==0);
+assert_checkfalse(execstr("routh_t(h)","errcatch")==0);
+assert_checkfalse(execstr("routh_t(h,k,%t,%t)","errcatch")==0);
diff --git a/modules/cacsd/tests/unit_tests/ss2tf.dia.ref b/modules/cacsd/tests/unit_tests/ss2tf.dia.ref
new file mode 100755
index 000000000..39e2edf5f
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/ss2tf.dia.ref
@@ -0,0 +1,84 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+a=0.5;b=1;c=2;
+sl=syslin('c',a,b,c);
+h1=ss2tf(sl);
+if h1.num<>2 then bugmes();quit;end
+if h1.den<>poly([-0.5 1],'s','c') then bugmes();quit;end
+d=1;
+sl=syslin('c',a,b,c,d);
+h2=ss2tf(sl);
+if h2<>h1+1 then bugmes();quit;end
+b=[b b];
+sl=syslin('c',a,b,c);
+h2=ss2tf(sl);
+if or(h2<>[h1 h1]) then bugmes();quit;end
+a=[0.9,0,0.6,-1.4,-4.2;
+ 0.2,0.1,-0.2,0.5,0.6;
+ -4.3,0,2.2,0,2.4;
+ -3.7,-0.5,2.4,-0.6,2.7;
+ 6.4,0.1,-4,-0.5,-4];
+b=[-0.1,-0.1,0;
+ 0,0,0.1;
+ -0.1,0.2,-0.1;
+ 0.2,0.2,-0.6;
+ 0.2,-0.1,0.1];
+c=[2,7,-2,5,1
+ 0,-1,3,0,2];
+d=[1,0,0
+ 0,0,0];
+sl=syslin('c',a,b,c,d);
+h=ss2tf(sl)
+ h =
+
+
+ column 1
+
+ 2 3 4 5
+ 1.3986 + 41.9012s + 64.737s + 26.3s + 2.6s + s
+ ----------------------------------------------
+ 2 3 4 5
+ - 0.6296 + 15.4568s + 35.104s + 25.39s + 1.4s + s
+
+ 2 3 4
+ 0.38308 - 8.1212s + 2.283s - 0.29s + 0.1s
+ -----------------------------------------------
+ 2 3 4 5
+ - 0.6296 + 15.4568s + 35.104s + 25.39s + 1.4s + s
+
+ column 2
+
+ 2 3 4
+ 3.9545 + 14.2365s + 8.024s + 0.52s + 0.3s
+ -----------------------------------------------
+ 2 3 4 5
+ - 0.6296 + 15.4568s + 35.104s + 25.39s + 1.4s + s
+
+ 2 3 4
+ - 0.09758 + 5.4601s + 9.735s + 0.19s + 0.4s
+ -----------------------------------------------
+ 2 3 4 5
+ - 0.6296 + 15.4568s + 35.104s + 25.39s + 1.4s + s
+
+ column 3
+
+ 2 3 4
+ 0.7293 - 40.8154s - 49.552s - 1.58s - 2s
+ ----------------------------------------------
+ 2 3 4 5
+ - 0.6296 + 15.4568s + 35.104s + 25.39s + 1.4s + s
+
+ 2 3 4
+ - 0.58334 + 15.1342s - 4.929s + 0.61s - 0.2s
+ ----------------------------------------------
+ 2 3 4 5
+ - 0.6296 + 15.4568s + 35.104s + 25.39s + 1.4s + s
+if or(degree(h.den)<>5) then bugmes();quit;end
+if or(degree(h.num)<>[5,4,4;4,4,4]) then bugmes();quit;end
+r1=spec(a);R1=gsort([real(r1) imag(r1)],'lr','i');
+r2=roots(h.den(1,1));R2=gsort([real(r2) imag(r2)],'lr','i');
+if norm(R2-R1,'inf')>1d-14 then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/ss2tf.tst b/modules/cacsd/tests/unit_tests/ss2tf.tst
new file mode 100755
index 000000000..3747fe8f6
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/ss2tf.tst
@@ -0,0 +1,50 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+a=0.5;b=1;c=2;
+sl=syslin('c',a,b,c);
+h1=ss2tf(sl);
+if h1.num<>2 then pause,end
+if h1.den<>poly([-0.5 1],'s','c') then pause,end
+d=1;
+sl=syslin('c',a,b,c,d);
+h2=ss2tf(sl);
+if h2<>h1+1 then pause,end
+
+b=[b b];
+sl=syslin('c',a,b,c);
+h2=ss2tf(sl);
+if or(h2<>[h1 h1]) then pause,end
+
+
+a=[0.9,0,0.6,-1.4,-4.2;
+ 0.2,0.1,-0.2,0.5,0.6;
+ -4.3,0,2.2,0,2.4;
+ -3.7,-0.5,2.4,-0.6,2.7;
+ 6.4,0.1,-4,-0.5,-4];
+
+b=[-0.1,-0.1,0;
+ 0,0,0.1;
+ -0.1,0.2,-0.1;
+ 0.2,0.2,-0.6;
+ 0.2,-0.1,0.1];
+
+c=[2,7,-2,5,1
+ 0,-1,3,0,2];
+d=[1,0,0
+ 0,0,0];
+
+sl=syslin('c',a,b,c,d);
+
+h=ss2tf(sl)
+if or(degree(h.den)<>5) then pause,end
+if or(degree(h.num)<>[5,4,4;4,4,4]) then pause,end
+
+r1=spec(a);R1=gsort([real(r1) imag(r1)],'lr','i');
+r2=roots(h.den(1,1));R2=gsort([real(r2) imag(r2)],'lr','i');
+if norm(R2-R1,'inf')>1d-14 then pause,end
+
+
diff --git a/modules/cacsd/tests/unit_tests/sylv.dia.ref b/modules/cacsd/tests/unit_tests/sylv.dia.ref
new file mode 100755
index 000000000..dc28ac3a6
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/sylv.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- ENGLISH IMPOSED -->
+// Run with test_run('cacsd', 'sylv', ['no_check_error_output']);
+A = rand(4, 4); C = rand(4, 3); B = rand(3, 3);
+// Solve continuous-time Sylvester equation: A*X+X*B = C
+X = sylv(A, B, C, "c");
+expected_norm = 1.D-16;
+if norm(A*X+X*B-C)-expected_norm > 1.D-15 then bugmes();quit;end
+// Solve modified discrete-time Sylvester equation: A*X*B+X = C
+X = sylv(A, B, C, "d");
+if norm(A*X*B+X-C)-expected_norm > 1.D-15 then bugmes();quit;end
+// Solve real discrete-time Sylvester equation: A*X*B+X = C
+X = -sylv(-A, B, C, "d");
+if norm(A*X*B-X-C)-expected_norm > 1.D-15 then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/sylv.tst b/modules/cacsd/tests/unit_tests/sylv.tst
new file mode 100755
index 000000000..c89fcd072
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/sylv.tst
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- ENGLISH IMPOSED -->
+
+// Run with test_run('cacsd', 'sylv', ['no_check_error_output']);
+
+A = rand(4, 4); C = rand(4, 3); B = rand(3, 3);
+
+// Solve continuous-time Sylvester equation: A*X+X*B = C
+X = sylv(A, B, C, "c");
+
+expected_norm = 1.D-16;
+
+if norm(A*X+X*B-C)-expected_norm > 1.D-15 then pause,end
+
+// Solve modified discrete-time Sylvester equation: A*X*B+X = C
+X = sylv(A, B, C, "d");
+
+if norm(A*X*B+X-C)-expected_norm > 1.D-15 then pause,end
+
+// Solve real discrete-time Sylvester equation: A*X*B+X = C
+X = -sylv(-A, B, C, "d");
+
+if norm(A*X*B-X-C)-expected_norm > 1.D-15 then pause,end
diff --git a/modules/cacsd/tests/unit_tests/syslin.dia.ref b/modules/cacsd/tests/unit_tests/syslin.dia.ref
new file mode 100755
index 000000000..395480079
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/syslin.dia.ref
@@ -0,0 +1,73 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//state space
+a=[1 2;0 4];b=[1;1];c=[1 2];
+sl=syslin('c',a,b,c);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>0)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('d',a,b,c);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>0)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin(0.1,a,b,c);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>0)|or(sl.dt<>0.1) then bugmes();quit;end
+sl=syslin('c',a,b,c,1);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('d',a,b,c,1);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin(0.1,a,b,c,1);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1)|or(sl.dt<>0.1) then bugmes();quit;end
+sl=syslin('c',a,b,c,1+%s);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1+%s)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('d',a,b,c,1+%s);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1+%s)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin(0.1,a,b,c,1+%s);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1+%s)|or(sl.dt<>0.1) then bugmes();quit;end
+b=eye(2,2);d=zeros(1,2);
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then bugmes();quit;end
+c=[];d=[]
+ d =
+
+ []
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then bugmes();quit;end
+c=[1 2];d=[];b=[];
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then bugmes();quit;end
+a=[];b=[];c=[];d=1;
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then bugmes();quit;end
+//transfer functions
+num=1+%s;den=1-%s+3*%s^2;simp_mode(%f);
+sl=syslin('c',num,den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then bugmes();quit;end
+sl=syslin('c',num./den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then bugmes();quit;end
+num=1+%z;den=1-%z+3*%z^2;simp_mode(%f);
+sl=syslin('d',num,den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'d') then bugmes();quit;end
+sl=syslin('d',num./den);
+num=[1+%s %s^2];den=(1-%s+3*%s^2)*ones(num);simp_mode(%f);
+sl=syslin('c',num,den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then bugmes();quit;end
+num=[1+%z 2];den=(1-%z+3*%z^2)*ones(num);simp_mode(%f);
+sl=syslin('c',num./den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/syslin.tst b/modules/cacsd/tests/unit_tests/syslin.tst
new file mode 100755
index 000000000..6f05926ca
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/syslin.tst
@@ -0,0 +1,83 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//state space
+a=[1 2;0 4];b=[1;1];c=[1 2];
+sl=syslin('c',a,b,c);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>0)|or(sl.dt<>'c') then pause,end
+sl=syslin('d',a,b,c);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>0)|or(sl.dt<>'d') then pause,end
+sl=syslin(0.1,a,b,c);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>0)|or(sl.dt<>0.1) then pause,end
+
+sl=syslin('c',a,b,c,1);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1)|or(sl.dt<>'c') then pause,end
+sl=syslin('d',a,b,c,1);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1)|or(sl.dt<>'d') then pause,end
+sl=syslin(0.1,a,b,c,1);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1)|or(sl.dt<>0.1) then pause,end
+
+sl=syslin('c',a,b,c,1+%s);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1+%s)|or(sl.dt<>'c') then pause,end
+sl=syslin('d',a,b,c,1+%s);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1+%s)|or(sl.dt<>'d') then pause,end
+sl=syslin(0.1,a,b,c,1+%s);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>1+%s)|or(sl.dt<>0.1) then pause,end
+
+b=eye(2,2);d=zeros(1,2);
+
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then pause,end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then pause,end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then pause,end
+
+c=[];d=[]
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then pause,end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then pause,end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then pause,end
+
+c=[1 2];d=[];b=[];
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then pause,end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then pause,end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then pause,end
+
+a=[];b=[];c=[];d=1;
+sl=syslin('c',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'c') then pause,end
+sl=syslin('d',a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>'d') then pause,end
+sl=syslin(0.1,a,b,c,d);
+if or(sl.A<>a)|or(sl.B<>b)|or(sl.C<>c)|or(sl.D<>d)|or(sl.dt<>0.1) then pause,end
+
+
+//transfer functions
+num=1+%s;den=1-%s+3*%s^2;simp_mode(%f);
+sl=syslin('c',num,den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then pause,end
+
+sl=syslin('c',num./den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then pause,end
+
+num=1+%z;den=1-%z+3*%z^2;simp_mode(%f);
+sl=syslin('d',num,den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'d') then pause,end
+sl=syslin('d',num./den);
+
+num=[1+%s %s^2];den=(1-%s+3*%s^2)*ones(num);simp_mode(%f);
+sl=syslin('c',num,den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then pause,end
+
+num=[1+%z 2];den=(1-%z+3*%z^2)*ones(num);simp_mode(%f);
+sl=syslin('c',num./den);
+if or(sl.num<>num)|or(sl.den<>den)|or(sl.dt<>'c') then pause,end
diff --git a/modules/cacsd/tests/unit_tests/tf2ss.dia.ref b/modules/cacsd/tests/unit_tests/tf2ss.dia.ref
new file mode 100755
index 000000000..4ab1f02e1
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/tf2ss.dia.ref
@@ -0,0 +1,47 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+s=%s;
+n=1;d=1+3*s;
+h=syslin('c',n./d);
+sl=tf2ss(h);
+if sl.A<>-1/3 then bugmes();quit;end
+if sl.B*sl.C<>1/3 then bugmes();quit;end
+if sl.D<>0 then bugmes();quit;end
+if sl.X0<>0 then bugmes();quit;end
+if sl.dt<>'c' then bugmes();quit;end
+h=syslin('d',n./d);
+sl=tf2ss(h);
+if sl.A<>-1/3 then bugmes();quit;end
+if sl.B*sl.C<>1/3 then bugmes();quit;end
+if sl.D<>0 then bugmes();quit;end
+if sl.X0<>0 then bugmes();quit;end
+if sl.dt<>'d' then bugmes();quit;end
+h1=[h h];
+sl1=tf2ss(h1);
+if abs(sl1.A+1/3)>1d-15 then bugmes();quit;end
+if norm(sl1.B*sl1.C-1/3,1)>1d-15 then bugmes();quit;end
+if or(sl1.D<>[0 0]) then bugmes();quit;end
+if sl1.X0<>0 then bugmes();quit;end
+if sl1.dt<>'d' then bugmes();quit;end
+n=[1+s 2+3*s+4*s^2 5; 0 1-s s];
+d=[1+3*s 5-s^3 s+1;1+s 1+s+s^2 3*s-1];
+h=syslin('c',n./d);
+sl=tf2ss(h);
+cden=lcm(d);cden=cden/coeff(cden,degree(cden))
+ cden =
+
+ 2 3 4
+ 0.5555556 + 1.1111111s - 3.8888889s - 9.5555556s - 10.222222s
+ 5 6 7 8
+ - 4.2222222s + 1.8888889s + 2s + s
+if norm(coeff(cden-poly(sl.A,'s')),1)>1d-10 then bugmes();quit;end
+e=h-ss2tf(sl);
+if norm(coeff(e.num))>>1d-10 then bugmes();quit;end
+n=(1+s);d=(1+3*s)*(0.9999+s);
+h=syslin('c',n./d);
+sl=tf2ss(h,0.01);
+if size(sl.A,'*')<>1 then bugmes();quit;end
diff --git a/modules/cacsd/tests/unit_tests/tf2ss.tst b/modules/cacsd/tests/unit_tests/tf2ss.tst
new file mode 100755
index 000000000..5218876a7
--- /dev/null
+++ b/modules/cacsd/tests/unit_tests/tf2ss.tst
@@ -0,0 +1,53 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA - Serge Steer
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+
+
+s=%s;
+n=1;d=1+3*s;
+h=syslin('c',n./d);
+sl=tf2ss(h);
+if sl.A<>-1/3 then pause,end
+if sl.B*sl.C<>1/3 then pause,end
+if sl.D<>0 then pause,end
+if sl.X0<>0 then pause,end
+if sl.dt<>'c' then pause,end
+
+h=syslin('d',n./d);
+sl=tf2ss(h);
+if sl.A<>-1/3 then pause,end
+if sl.B*sl.C<>1/3 then pause,end
+if sl.D<>0 then pause,end
+if sl.X0<>0 then pause,end
+if sl.dt<>'d' then pause,end
+
+h1=[h h];
+sl1=tf2ss(h1);
+if abs(sl1.A+1/3)>1d-15 then pause,end
+if norm(sl1.B*sl1.C-1/3,1)>1d-15 then pause,end
+if or(sl1.D<>[0 0]) then pause,end
+if sl1.X0<>0 then pause,end
+if sl1.dt<>'d' then pause,end
+
+
+n=[1+s 2+3*s+4*s^2 5; 0 1-s s];
+d=[1+3*s 5-s^3 s+1;1+s 1+s+s^2 3*s-1];
+
+h=syslin('c',n./d);
+sl=tf2ss(h);
+cden=lcm(d);cden=cden/coeff(cden,degree(cden))
+if norm(coeff(cden-poly(sl.A,'s')),1)>1d-10 then pause,end
+
+
+
+e=h-ss2tf(sl);
+if norm(coeff(e.num))>>1d-10 then pause,end
+
+n=(1+s);d=(1+3*s)*(0.9999+s);
+h=syslin('c',n./d);
+sl=tf2ss(h,0.01);
+if size(sl.A,'*')<>1 then pause,end