diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/signal_processing/tests | |
download | scilab_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/signal_processing/tests')
95 files changed, 2759 insertions, 0 deletions
diff --git a/modules/signal_processing/tests/nonreg_tests/bug_10856.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_10856.dia.ref new file mode 100755 index 000000000..26d199211 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_10856.dia.ref @@ -0,0 +1,28 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 10856 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10856 +// +// <-- Short Description --> +// analpf did not return the right result. +fr=10:10:1000000; +for i = 3:6 + hs=analpf(i,'butt',[.1 0],2800); + // Check the degree of denominator + assert_checkequal(degree(hs(3)),i); + // Check that numerator degree is 0 + assert_checkequal(degree(hs(2)),0); + // Check that first term of denominator is equal to numerator + assert_checkalmostequal(horner(hs(3),0),horner(hs(2),0)); + // At low frequencies, amplitudes are almost 0 + assert_checktrue(horner(hs,5)<1); + // Check that the slope at high frequencies has the right value + assert_checktrue(20*log10(horner(hs,10e7))-20*log10(horner(hs,10e6))-20*i<0.1); +end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_10856.tst b/modules/signal_processing/tests/nonreg_tests/bug_10856.tst new file mode 100755 index 000000000..33f95d2cc --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_10856.tst @@ -0,0 +1,31 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 10856 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10856 +// +// <-- Short Description --> +// analpf did not return the right result. + +fr=10:10:1000000; +for i = 3:6 + hs=analpf(i,'butt',[.1 0],2800); + // Check the degree of denominator + assert_checkequal(degree(hs(3)),i); + // Check that numerator degree is 0 + assert_checkequal(degree(hs(2)),0); + // Check that first term of denominator is equal to numerator + assert_checkalmostequal(horner(hs(3),0),horner(hs(2),0)); + // At low frequencies, amplitudes are almost 0 + assert_checktrue(horner(hs,5)<1); + // Check that the slope at high frequencies has the right value + assert_checktrue(20*log10(horner(hs,10e7))-20*log10(horner(hs,10e6))-20*i<0.1); +end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_11802.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_11802.dia.ref new file mode 100755 index 000000000..ad819845f --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_11802.dia.ref @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 11802 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11802 +// +// <-- Short Description --> +// mrfit function redefines the diff function (making nyquist function fail when called just after). +a = [10 20 30 40 50]; +b = [1 2 3 4 5]; +tt = mrfit(a,b,2); +assert_checktrue(execstr("nyquist(tt)", "errcatch")==0); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_11802.tst b/modules/signal_processing/tests/nonreg_tests/bug_11802.tst new file mode 100755 index 000000000..64f77a6d6 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_11802.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 11802 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11802 +// +// <-- Short Description --> +// mrfit function redefines the diff function (making nyquist function fail when called just after). + +a = [10 20 30 40 50]; +b = [1 2 3 4 5]; +tt = mrfit(a,b,2); + +assert_checktrue(execstr("nyquist(tt)", "errcatch")==0);
\ No newline at end of file diff --git a/modules/signal_processing/tests/nonreg_tests/bug_12715.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_12715.dia.ref new file mode 100755 index 000000000..3f63aa3e0 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_12715.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 12715 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12715 +// +// <-- Short Description --> +// cross function is redefined when using systems. +a=[0 0 0 0 0 0 6 6]; +assert_checkequal(real(pspect(2,4,'re',a,a)), [0 6 0 6]); +assert_checkequal(imag(pspect(2,4,'re',a,a)), [0 0 0 0]); +assert_checktrue(real(cspect(2,4,'re',a,a)) - [12.9375 0 -0.5626 0] < 1d-3); +assert_checktrue(imag(cspect(2,4,'re',a,a)) - [0 -6.75 0 6.75] < 1d-6); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_12715.tst b/modules/signal_processing/tests/nonreg_tests/bug_12715.tst new file mode 100755 index 000000000..d7755242b --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_12715.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 12715 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12715 +// +// <-- Short Description --> +// cross function is redefined when using systems. + +a=[0 0 0 0 0 0 6 6]; +assert_checkequal(real(pspect(2,4,'re',a,a)), [0 6 0 6]); +assert_checkequal(imag(pspect(2,4,'re',a,a)), [0 0 0 0]); +assert_checktrue(real(cspect(2,4,'re',a,a)) - [12.9375 0 -0.5626 0] < 1d-3); +assert_checktrue(imag(cspect(2,4,'re',a,a)) - [0 -6.75 0 6.75] < 1d-6); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13205.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_13205.dia.ref new file mode 100755 index 000000000..f8d1d67ce --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13205.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. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 13205 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13205 +// +// <-- Short Description --> +// group accepted continuous transfer functions. +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A discrete system expected.\n"), "group", 2); +s = poly(0, "s"); +h = s/(s-.5); +assert_checkerror("group(100, h)", refMsg); +// Working example +h = ss2tf(cls2dls(tf2ss(syslin("c",1/s)),0.1)); +[tg, fr] = group(100, h); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13205.tst b/modules/signal_processing/tests/nonreg_tests/bug_13205.tst new file mode 100755 index 000000000..4a82f17f2 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13205.tst @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Paul Bignier +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 13205 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13205 +// +// <-- Short Description --> +// group accepted continuous transfer functions. + +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A discrete system expected.\n"), "group", 2); +s = poly(0, "s"); +h = s/(s-.5); +assert_checkerror("group(100, h)", refMsg); + +// Working example +h = ss2tf(cls2dls(tf2ss(syslin("c",1/s)),0.1)); +[tg, fr] = group(100, h); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13346.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_13346.dia.ref new file mode 100755 index 000000000..86da94a78 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13346.dia.ref @@ -0,0 +1,20 @@ +// ============================================================================= +// 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. +// ============================================================================= +//<-- CLI SHELL MODE --> +// <-- Non-regression test for bug 13346 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13346 +// +// <-- Short Description --> +// Filter did not work on a simple delay +X = [1, zeros(1,9)]; +delayed_X = zeros(1,10); delayed_X(3) = 1; +A = 1; +B = [0 0 1]; +res = filter(B, A, X); +assert_checkalmostequal(res, delayed_X); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13346.tst b/modules/signal_processing/tests/nonreg_tests/bug_13346.tst new file mode 100755 index 000000000..1039b3c0e --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13346.tst @@ -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. +// ============================================================================= + +//<-- CLI SHELL MODE --> +// <-- Non-regression test for bug 13346 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13346 +// +// <-- Short Description --> +// Filter did not work on a simple delay + +X = [1, zeros(1,9)]; +delayed_X = zeros(1,10); delayed_X(3) = 1; + +A = 1; +B = [0 0 1]; + +res = filter(B, A, X); +assert_checkalmostequal(res, delayed_X); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13527.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_13527.dia.ref new file mode 100755 index 000000000..8f00d40c7 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13527.dia.ref @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Vladislav TRUBKIN +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 13527 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13527 +// +// <-- Short Description --> +// hilb must be called only with an odd integer number of points +// +lstr = gettext("%s: Wrong type for input argument #%d: An odd integer expected.\n"); +errmsg = msprintf (lstr, "hilb", 1); +// KO +assert_checkerror("hilb(2)", errmsg); +assert_checkerror("hilb(14)", errmsg); +assert_checkerror("hilb(26)", errmsg); +assert_checkerror("hilb(26.5)", errmsg); +assert_checkerror("hilb(27.5)", errmsg); +// OK +assert_checkequal(execstr("hilb(3)", "errcatch"), 0); +assert_checkequal(execstr("hilb(7)", "errcatch"), 0); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13527.tst b/modules/signal_processing/tests/nonreg_tests/bug_13527.tst new file mode 100755 index 000000000..8f00d40c7 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13527.tst @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Vladislav TRUBKIN +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 13527 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13527 +// +// <-- Short Description --> +// hilb must be called only with an odd integer number of points +// +lstr = gettext("%s: Wrong type for input argument #%d: An odd integer expected.\n"); +errmsg = msprintf (lstr, "hilb", 1); +// KO +assert_checkerror("hilb(2)", errmsg); +assert_checkerror("hilb(14)", errmsg); +assert_checkerror("hilb(26)", errmsg); +assert_checkerror("hilb(26.5)", errmsg); +assert_checkerror("hilb(27.5)", errmsg); +// OK +assert_checkequal(execstr("hilb(3)", "errcatch"), 0); +assert_checkequal(execstr("hilb(7)", "errcatch"), 0); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13692.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_13692.dia.ref new file mode 100755 index 000000000..71fbf39c7 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13692.dia.ref @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 13692 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13205 +// +// <-- Short Description --> +// group returned an error for a discrete dynamical system with a specified +// sample time. +S = syslin(0.5, 1/%z); +[tg, fr] = group(10, S); +assert_checkequal(tg, ones(1, 10)); +assert_checkequal(fr, [0:0.05:0.45]); +// An expected error +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A discrete system expected.\n"), "group", 2); +S = syslin("c", (1+%s)/(1+0.5*%s+%s^2)); +assert_checkerror("group(10, S)", refMsg); +S = syslin([], (1+%s)/(1+0.5*%s+%s^2)); +assert_checkerror("group(10, S)", refMsg); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_13692.tst b/modules/signal_processing/tests/nonreg_tests/bug_13692.tst new file mode 100755 index 000000000..4f6d3b4f7 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_13692.tst @@ -0,0 +1,30 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 13692 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13205 +// +// <-- Short Description --> +// group returned an error for a discrete dynamical system with a specified +// sample time. + +S = syslin(0.5, 1/%z); +[tg, fr] = group(10, S); +assert_checkequal(tg, ones(1, 10)); +assert_checkequal(fr, [0:0.05:0.45]); + +// An expected error +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A discrete system expected.\n"), "group", 2); +S = syslin("c", (1+%s)/(1+0.5*%s+%s^2)); +assert_checkerror("group(10, S)", refMsg); + +S = syslin([], (1+%s)/(1+0.5*%s+%s^2)); +assert_checkerror("group(10, S)", refMsg); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_1635.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_1635.dia.ref new file mode 100755 index 000000000..33c82c53b --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_1635.dia.ref @@ -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 --> +// +// <-- Non-regression test for bug 1635 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1635 +// +// <-- Short Description --> +// iir filter frequency response may be wrong +fl=0.0004535; +fu=0.0009070; +[Poles,Zeros,Gain]=iir(4,'bp','butt',[fl fu],[0 0]); +frq=linspace(fl,fu,400); +//evaluation of frequency response in the pass zone +//based on pole zero gain representation +frqz=exp(2*%i*%pi*frq); +z=ones(frq); +for i=1:size(Zeros,'*') + z=z.*(Zeros(i)-frqz); +end +p=ones(frq); +for i=1:size(Zeros,'*') + p=p.*(Poles(i)-frqz); +end +repf=Gain*(z./p); +db=20*log10(abs(repf)); +assert_checkalmostequal(db(1),-3,0.01); +assert_checkalmostequal(db($),-3,0.01); +assert_checktrue(max(abs(db(100:250)))<0.005) + ans = + + T diff --git a/modules/signal_processing/tests/nonreg_tests/bug_1635.tst b/modules/signal_processing/tests/nonreg_tests/bug_1635.tst new file mode 100755 index 000000000..034b7cfaf --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_1635.tst @@ -0,0 +1,42 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 1635 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1635 +// +// <-- Short Description --> +// iir filter frequency response may be wrong + +fl=0.0004535; +fu=0.0009070; + +[Poles,Zeros,Gain]=iir(4,'bp','butt',[fl fu],[0 0]); + +frq=linspace(fl,fu,400); +//evaluation of frequency response in the pass zone +//based on pole zero gain representation +frqz=exp(2*%i*%pi*frq); + +z=ones(frq); +for i=1:size(Zeros,'*') + z=z.*(Zeros(i)-frqz); +end + +p=ones(frq); +for i=1:size(Zeros,'*') + p=p.*(Poles(i)-frqz); +end +repf=Gain*(z./p); +db=20*log10(abs(repf)); +assert_checkalmostequal(db(1),-3,0.01); +assert_checkalmostequal(db($),-3,0.01); + +assert_checktrue(max(abs(db(100:250)))<0.005) diff --git a/modules/signal_processing/tests/nonreg_tests/bug_2076.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_2076.dia.ref new file mode 100755 index 000000000..b4b6dad88 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_2076.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// 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 2076 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2076 +// +// <-- Short Description --> +// pspect does not use the last data window +a=[0 0 0 0 0 0 6 6]; +p=pspect(2,4,"re",a,a); +if or(p<>[0 6 0 6]) then bugmes();quit;end +p=pspect(2,4,"re", a); +if or(p<>[0 6 0 6]) then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_2076.tst b/modules/signal_processing/tests/nonreg_tests/bug_2076.tst new file mode 100755 index 000000000..5957baca2 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_2076.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 2076 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2076 +// +// <-- Short Description --> +// pspect does not use the last data window + + +a=[0 0 0 0 0 0 6 6]; +p=pspect(2,4,"re",a,a); +if or(p<>[0 6 0 6]) then pause,end + +p=pspect(2,4,"re", a); +if or(p<>[0 6 0 6]) then pause,end + diff --git a/modules/signal_processing/tests/nonreg_tests/bug_279.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_279.dia.ref new file mode 100755 index 000000000..86f8f51cc --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_279.dia.ref @@ -0,0 +1,30 @@ +// ============================================================================= +// 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 279 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=279 +// +// <-- Short Description --> +// Wrong zeros values +format(20); +Fs= 44100.0; // Sample Freq in Hz +om1= 1765.0; // lower stop corner Hz +om2= 2205.0; // lower pass corner Hz +om3= 4410.0; // higher pass corner Hz +om4= 5427.6; // higher stop corner Hz +gripple= 0.2; // passband ripple in dB +gstop = -40.0; // stop band attenuation in dB +a1= 2*%pi*om1/Fs; +a2= 2*%pi*om2/Fs; +a3= 2*%pi*om3/Fs; +a4= 2*%pi*om4/Fs; +om=[a1, a2, a3, a4 ]; +deltap= 1.0 - 10.00**(-0.05*gripple); +deltas= 10.00**(0.05* gstop) ; +[cells,fact,zers,pols]=eqiir('bp','el',om,deltap,deltas); +if zers($)==0 | zers($-1)==0 then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_279.tst b/modules/signal_processing/tests/nonreg_tests/bug_279.tst new file mode 100755 index 000000000..936d74aa4 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_279.tst @@ -0,0 +1,42 @@ +// ============================================================================= +// 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 279 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=279 +// +// <-- Short Description --> +// Wrong zeros values + + + +format(20); + +Fs= 44100.0; // Sample Freq in Hz +om1= 1765.0; // lower stop corner Hz +om2= 2205.0; // lower pass corner Hz +om3= 4410.0; // higher pass corner Hz +om4= 5427.6; // higher stop corner Hz + +gripple= 0.2; // passband ripple in dB +gstop = -40.0; // stop band attenuation in dB + + +a1= 2*%pi*om1/Fs; +a2= 2*%pi*om2/Fs; +a3= 2*%pi*om3/Fs; +a4= 2*%pi*om4/Fs; + +om=[a1, a2, a3, a4 ]; + +deltap= 1.0 - 10.00**(-0.05*gripple); +deltas= 10.00**(0.05* gstop) ; + +[cells,fact,zers,pols]=eqiir('bp','el',om,deltap,deltas); + +if zers($)==0 | zers($-1)==0 then pause,end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_3546.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_3546.dia.ref new file mode 100755 index 000000000..796cd4db2 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_3546.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// 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 3546 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3546 +// +// <-- Short Description --> +// frmag broken in scilab 5.0 +[hm1,fr1]=frmag([0.4 -1 -1],[1 0.85 -1],256); +[hm2,fr2]=frmag(poly([0.4 -1 -1],'z','c'),poly([1 0.85 -1],'z','c'),256); +if or(hm1<>hm2)|or(fr1<>fr2) then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_3546.tst b/modules/signal_processing/tests/nonreg_tests/bug_3546.tst new file mode 100755 index 000000000..8cff71eee --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_3546.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// 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 3546 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3546 +// +// <-- Short Description --> +// frmag broken in scilab 5.0 +[hm1,fr1]=frmag([0.4 -1 -1],[1 0.85 -1],256); +[hm2,fr2]=frmag(poly([0.4 -1 -1],'z','c'),poly([1 0.85 -1],'z','c'),256); +if or(hm1<>hm2)|or(fr1<>fr2) then pause,end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4065.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_4065.dia.ref new file mode 100755 index 000000000..fb7f0532c --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4065.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// 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 4065 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4065 +// +// <-- Short Description --> +// When filter is used with polynomials as arguments num and den, the degree 0 monomial is ignored. +Num=1;Den=1+%z;u=[1,2,3,4,5]; +if or(filter(Num,Den,u)<>filter([0 1],[1 1],u)) then bugmes();quit;end +if or(filter(%z,Den,u)<>filter(1,[1 1],u)) then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4065.tst b/modules/signal_processing/tests/nonreg_tests/bug_4065.tst new file mode 100755 index 000000000..e26c8bbb5 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4065.tst @@ -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 4065 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4065 +// +// <-- Short Description --> +// When filter is used with polynomials as arguments num and den, the degree 0 monomial is ignored. +Num=1;Den=1+%z;u=[1,2,3,4,5]; +if or(filter(Num,Den,u)<>filter([0 1],[1 1],u)) then pause,end +if or(filter(%z,Den,u)<>filter(1,[1 1],u)) then pause,end + diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4120.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_4120.dia.ref new file mode 100755 index 000000000..0fb6c2dd6 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4120.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// 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 4120 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4120 +// +// <-- Short Description --> +// IIR filter desing demo fails under Windows 64 (XP and Vista). +y = amell(1.1503675,0.5653572); +if y == 0 then bugmes();quit;end +ref = 1.0883305; +if abs(y - ref)> 10e-8 then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4120.tst b/modules/signal_processing/tests/nonreg_tests/bug_4120.tst new file mode 100755 index 000000000..7376c0fc7 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4120.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// 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 4120 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4120 +// +// <-- Short Description --> +// IIR filter desing demo fails under Windows 64 (XP and Vista). + +y = amell(1.1503675,0.5653572); +if y == 0 then pause,end + +ref = 1.0883305; +if abs(y - ref)> 10e-8 then pause,end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4229.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_4229.dia.ref new file mode 100755 index 000000000..fa18c7ec6 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4229.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 4229 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4229 +// +// <-- Short Description --> +// delip does not return an error message if one element of first input +// argument is negative +errmsg = msprintf(_("Incompatible input argument.\n")); +assert_checkerror("delip([-2 2], 0.5)", errmsg); +assert_checkerror("delip([2 -2], 0.5)", errmsg); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4229.tst b/modules/signal_processing/tests/nonreg_tests/bug_4229.tst new file mode 100755 index 000000000..a578ed15b --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4229.tst @@ -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 4229 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4229 +// +// <-- Short Description --> +// delip does not return an error message if one element of first input +// argument is negative + +errmsg = msprintf(_("Incompatible input argument.\n")); +assert_checkerror("delip([-2 2], 0.5)", errmsg); +assert_checkerror("delip([2 -2], 0.5)", errmsg); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4249.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_4249.dia.ref new file mode 100755 index 000000000..a492e8082 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4249.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// 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 4249 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4249 +// +// <-- Short Description --> +// The filter function does not work when the transfer function is a perfect pass all hz = 1/1. +Num=1;Den=1+%z;u=[1,2,3,4,5]; +if or(filter(1,1,u)<>u) then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4249.tst b/modules/signal_processing/tests/nonreg_tests/bug_4249.tst new file mode 100755 index 000000000..52bd0e309 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4249.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// 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 4249 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4249 +// +// <-- Short Description --> +// The filter function does not work when the transfer function is a perfect pass all hz = 1/1. +Num=1;Den=1+%z;u=[1,2,3,4,5]; +if or(filter(1,1,u)<>u) then pause,end + diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4481.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_4481.dia.ref new file mode 100755 index 000000000..3b17d441f --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4481.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 4481 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4481 +// +// <-- Short Description --> +// iir should be able to handle a scalar for frq +hz_ref = iir(4, 'lp' , 'ellip' , [0.25 0.25], [0.05 0.02]); +hz = iir(4, 'lp' , 'ellip' , 0.25, [0.05 0.02]); +assert_checkequal(hz,hz_ref); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4481.tst b/modules/signal_processing/tests/nonreg_tests/bug_4481.tst new file mode 100755 index 000000000..beb646cf4 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4481.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 4481 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4481 +// +// <-- Short Description --> +// iir should be able to handle a scalar for frq + +hz_ref = iir(4, 'lp' , 'ellip' , [0.25 0.25], [0.05 0.02]); +hz = iir(4, 'lp' , 'ellip' , 0.25, [0.05 0.02]); +assert_checkequal(hz,hz_ref); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4504.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_4504.dia.ref new file mode 100755 index 000000000..fd70aaf27 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4504.dia.ref @@ -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. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 4504 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4504 +// +// <-- Short Description --> +// Function sskf does not act as the documentation says: +// Only xe = sskf(y,f,h,q,r,x0) works (not [xe pe] = sskf(y,f,h,q,r,x0)) +rand("seed",5); +rand("normal"); +q=[.03 0.01;.01 0.03]; +u=rand(2,11); +f=[1.1 0.1;0 0.8]; +g=(chol(q))'; +m0=[10 10]'; +p0=[2 0;0 2]; +x0=m0+(chol(p0))'*rand(2,1); +x=ltitr(f,g,u,x0); +r=[2 0;0 2]; +v=(chol(r))'*rand(2,11); +y=x+v; +h=eye(2,2); +assert_checktrue(execstr("[xe pe]=sskf(y,f,h,q,r,m0)","errcatch")==0); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4504.tst b/modules/signal_processing/tests/nonreg_tests/bug_4504.tst new file mode 100755 index 000000000..da31b1281 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4504.tst @@ -0,0 +1,33 @@ +// ============================================================================= +// 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 4504 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4504 +// +// <-- Short Description --> +// Function sskf does not act as the documentation says: +// Only xe = sskf(y,f,h,q,r,x0) works (not [xe pe] = sskf(y,f,h,q,r,x0)) + +rand("seed",5); +rand("normal"); +q=[.03 0.01;.01 0.03]; +u=rand(2,11); +f=[1.1 0.1;0 0.8]; +g=(chol(q))'; +m0=[10 10]'; +p0=[2 0;0 2]; +x0=m0+(chol(p0))'*rand(2,1); +x=ltitr(f,g,u,x0); +r=[2 0;0 2]; +v=(chol(r))'*rand(2,11); +y=x+v; +h=eye(2,2); +assert_checktrue(execstr("[xe pe]=sskf(y,f,h,q,r,m0)","errcatch")==0); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4618.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_4618.dia.ref new file mode 100755 index 000000000..79b14bc91 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4618.dia.ref @@ -0,0 +1,14 @@ +// ============================================================================= +// 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 4618 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4618 +// +// <-- Short Description --> +// buttmag produces a warning because of redefining symbol sample. +if buttmag(3,1000,1)<>1 then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_4618.tst b/modules/signal_processing/tests/nonreg_tests/bug_4618.tst new file mode 100755 index 000000000..3fb92708c --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_4618.tst @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4618 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4618 +// +// <-- Short Description --> +// buttmag produces a warning because of redefining symbol sample. + +if buttmag(3,1000,1)<>1 then pause,end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_6512.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_6512.dia.ref new file mode 100755 index 000000000..39ca8d552 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_6512.dia.ref @@ -0,0 +1,61 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 6512 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6512 +// +// <-- Short Description --> +// Check that findm is still ok +res = findm(1); +assert_checktrue(%k(1-res)/%k(res)-1<1e-8); +res = findm(0.1); +assert_checktrue(%k(1-res)/%k(res)-0.1<1e-8); +res = findm(0.5); +assert_checktrue(%k(1-res)/%k(res)-0.5<1e-8); +// Check that zpell is still ok +gain_ref=0.4818507; +po_ref=[-68.292059+161.54792*%i -68.292059-161.54792*%i]; +ze_ref=[250.20121*%i, -250.20121*%i]; +[ze,po,gain]=zpell(0.2,2,100,200); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); +gain_ref=0.3553711; +po_ref=[-157.37848+228.46667*%i,-157.37848-228.46667*%i]; +ze_ref=[464.22153*%i -464.22153*%i]; +[ze,po,gain]=zpell(0.1,3,150,300); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); +gain_ref=0.1880517; +po_ref=[-74.045505+159.77986*%i,-74.045505-159.77986*%i]; +ze_ref=[384.0618*%i -384.0618*%i]; +[ze,po,gain]=zpell(0.5,5,150,300); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); +gain_ref=0.1656341; +po_ref=[-43.753882+156.42721*%i -43.753882-156.42721*%i]; +ze_ref=[344.09218*%i -344.09218*%i]; +[ze,po,gain]=zpell(0.9,5,150,300); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); +// Check example in ell1mag help page +deff('[alpha,BeTa]=alpha_beta(n,m,m1)',... +'if 2*int(n/2)==n then, BeTa=K1; else, BeTa=0;end;... +alpha=%k(1-m1)/%k(1-m);') +epsilon=0.1;A=10; +m1=(epsilon*epsilon)/(A*A-1);n=5;omegac=6; +m=find_freq(epsilon,A,n);omegar = omegac/sqrt(m); +[alpha,Beta]=alpha_beta(n,m,m1); +assert_checktrue(abs(alpha*delip(1,sqrt(m))-n*%k(m1)-3.553e-15)<1e-6); +// Check example in %k help page +ref=1.7775194; +assert_checktrue(abs(delip(1,sqrt(0.4))-ref)<1e-5); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_6512.tst b/modules/signal_processing/tests/nonreg_tests/bug_6512.tst new file mode 100755 index 000000000..78c5a6b59 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_6512.tst @@ -0,0 +1,67 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 6512 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6512 +// +// <-- Short Description --> +// Check that findm is still ok + +res = findm(1); +assert_checktrue(%k(1-res)/%k(res)-1<1e-8); +res = findm(0.1); +assert_checktrue(%k(1-res)/%k(res)-0.1<1e-8); +res = findm(0.5); +assert_checktrue(%k(1-res)/%k(res)-0.5<1e-8); + +// Check that zpell is still ok +gain_ref=0.4818507; +po_ref=[-68.292059+161.54792*%i -68.292059-161.54792*%i]; +ze_ref=[250.20121*%i, -250.20121*%i]; +[ze,po,gain]=zpell(0.2,2,100,200); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); +gain_ref=0.3553711; +po_ref=[-157.37848+228.46667*%i,-157.37848-228.46667*%i]; +ze_ref=[464.22153*%i -464.22153*%i]; +[ze,po,gain]=zpell(0.1,3,150,300); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); +gain_ref=0.1880517; +po_ref=[-74.045505+159.77986*%i,-74.045505-159.77986*%i]; +ze_ref=[384.0618*%i -384.0618*%i]; +[ze,po,gain]=zpell(0.5,5,150,300); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); +gain_ref=0.1656341; +po_ref=[-43.753882+156.42721*%i -43.753882-156.42721*%i]; +ze_ref=[344.09218*%i -344.09218*%i]; +[ze,po,gain]=zpell(0.9,5,150,300); +assert_checktrue(abs(ze-ze_ref)<1e-5); +assert_checktrue(abs(po-po_ref)<1e-5); +assert_checktrue(abs(gain-gain_ref)<1e-5); + +// Check example in ell1mag help page +deff('[alpha,BeTa]=alpha_beta(n,m,m1)',... +'if 2*int(n/2)==n then, BeTa=K1; else, BeTa=0;end;... +alpha=%k(1-m1)/%k(1-m);') +epsilon=0.1;A=10; +m1=(epsilon*epsilon)/(A*A-1);n=5;omegac=6; +m=find_freq(epsilon,A,n);omegar = omegac/sqrt(m); +[alpha,Beta]=alpha_beta(n,m,m1); +assert_checktrue(abs(alpha*delip(1,sqrt(m))-n*%k(m1)-3.553e-15)<1e-6); + +// Check example in %k help page +ref=1.7775194; +assert_checktrue(abs(delip(1,sqrt(0.4))-ref)<1e-5); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_6861.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_6861.dia.ref new file mode 100755 index 000000000..c48021b25 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_6861.dia.ref @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 6861 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6861 +// +// <-- Short Description --> +// yulewalk example failed on Windows +f = [0, 0.4, 0.4, 0.6, 0.6, 1]; +H = [0, 0, 1, 1, 0, 0]; +ierr = execstr("Hz = yulewalk(8, f, H);","errcatch"); +if ierr <> 0 then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_6861.tst b/modules/signal_processing/tests/nonreg_tests/bug_6861.tst new file mode 100755 index 000000000..9a3efe23b --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_6861.tst @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 6861 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6861 +// +// <-- Short Description --> +// yulewalk example failed on Windows + +f = [0, 0.4, 0.4, 0.6, 0.6, 1]; +H = [0, 0, 1, 1, 0, 0]; +ierr = execstr("Hz = yulewalk(8, f, H);","errcatch"); +if ierr <> 0 then pause,end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_768.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_768.dia.ref new file mode 100755 index 000000000..1b95f4a04 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_768.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> +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 768 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=768 +// +// <-- Short Description --> +// as on Scilab 2.7.2, the "window" function still has a bug +// when choosing the "chebychev" type with its corresponding +// parameter vector. SAys the parameters are out of bounds +// whereas it is wrong +msgerr = msprintf(gettext("%s: Wrong value for input argument #%d: incorrect element #%d\n"), "window", 3, 2); +assert_checkerror ( "window(''ch'',128,[0.25 0.1])" , msgerr); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_768.tst b/modules/signal_processing/tests/nonreg_tests/bug_768.tst new file mode 100755 index 000000000..b83656d37 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_768.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> +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 768 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=768 +// +// <-- Short Description --> +// as on Scilab 2.7.2, the "window" function still has a bug +// when choosing the "chebychev" type with its corresponding +// parameter vector. SAys the parameters are out of bounds +// whereas it is wrong + +msgerr = msprintf(gettext("%s: Wrong value for input argument #%d: incorrect element #%d\n"), "window", 3, 2); +assert_checkerror ( "window(''ch'',128,[0.25 0.1])" , msgerr);
\ No newline at end of file diff --git a/modules/signal_processing/tests/nonreg_tests/bug_7849.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_7849.dia.ref new file mode 100755 index 000000000..4f99fa6b4 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_7849.dia.ref @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 7849 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7849 +// +// <-- Short Description --> +// eqfir crashs Scilab on MacOS platform +if execstr("hn = eqfir(33, [0 .2; .25 .35; .4 .5], [0 1 0], [1 1 1]);", "errcatch") <> 0 then bugmes();quit;end +if or(size(hn) <> [1 33]) then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_7849.tst b/modules/signal_processing/tests/nonreg_tests/bug_7849.tst new file mode 100755 index 000000000..fe0b23ee6 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_7849.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 7849 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7849 +// +// <-- Short Description --> +// eqfir crashs Scilab on MacOS platform + +if execstr("hn = eqfir(33, [0 .2; .25 .35; .4 .5], [0 1 0], [1 1 1]);", "errcatch") <> 0 then pause, end +if or(size(hn) <> [1 33]) then pause, end + diff --git a/modules/signal_processing/tests/nonreg_tests/bug_7881.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_7881.dia.ref new file mode 100755 index 000000000..6e0be7e19 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_7881.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 7881 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7881 +// +// <-- Short Description --> +// In the lattn function, the second argument is a scalar +// ============================================================================= +c = rand(1:50); +assert_checkfalse(execstr("lattn(10,[1 2], c)", "errcatch") == 0); +refMsg = msprintf(_("%s: Wrong size for input argument #%d: A scalar expected.\n"), "lattn", 2); +assert_checkerror("lattn(10,[1 2], c)", refMsg); +c1 = rand(10,3); +assert_checkfalse(execstr("lattn(2, 1, c1)", "errcatch") == 0); +refMsg = msprintf(_("%s: Wrong values for input arguments #%d and #%d.\n"), "lattn", 1,2); +assert_checkerror("lattn(2, 1, c1)", refMsg); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_7881.tst b/modules/signal_processing/tests/nonreg_tests/bug_7881.tst new file mode 100755 index 000000000..d2ba33cdc --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_7881.tst @@ -0,0 +1,32 @@ +// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 7881 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7881
+//
+// <-- Short Description -->
+// In the lattn function, the second argument is a scalar
+// =============================================================================
+
+c = rand(1:50);
+assert_checkfalse(execstr("lattn(10,[1 2], c)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong size for input argument #%d: A scalar expected.\n"), "lattn", 2);
+assert_checkerror("lattn(10,[1 2], c)", refMsg);
+
+c1 = rand(10,3);
+assert_checkfalse(execstr("lattn(2, 1, c1)", "errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong values for input arguments #%d and #%d.\n"), "lattn", 1,2);
+assert_checkerror("lattn(2, 1, c1)", refMsg);
+
+
+
+
+
diff --git a/modules/signal_processing/tests/nonreg_tests/bug_7895.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_7895.dia.ref new file mode 100755 index 000000000..714c770ec --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_7895.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- Non-regression test for bug 7895 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7895 +// +// <-- Short Description --> +// fft2() was broken on Windows +assert_checkequal(execstr("m = rand(10, 4);r = fft2(m);", "errcatch"), 0); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_7895.tst b/modules/signal_processing/tests/nonreg_tests/bug_7895.tst new file mode 100755 index 000000000..ceae8ecfe --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_7895.tst @@ -0,0 +1,18 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- Non-regression test for bug 7895 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7895 +// +// <-- Short Description --> +// fft2() was broken on Windows + +assert_checkequal(execstr("m = rand(10, 4);r = fft2(m);", "errcatch"), 0); + + diff --git a/modules/signal_processing/tests/nonreg_tests/bug_8684.tst b/modules/signal_processing/tests/nonreg_tests/bug_8684.tst new file mode 100755 index 000000000..b0cae6b41 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_8684.tst @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Vincent COUVERT <vincent.couvert@scilab.org> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- INTERACTIVE TEST --> +// +// <-- Non-regression test for bug 8684 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8684 +// +// <-- Short Description --> +// 'wfir' function produced an error message when used interactively. + +// 1. type wfir() in Scilab Console +// 2. choose low pass filter type +// 3. set cut-off frequency to e.g. 0.03 +// 4. set filter length to e.g. 64 +// 5. choose Chebyshev window type +// ==> Check that a message box is opened and no error message displayed
\ No newline at end of file diff --git a/modules/signal_processing/tests/nonreg_tests/bug_9675.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_9675.dia.ref new file mode 100755 index 000000000..32c21cf07 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_9675.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9675 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9675 +// +// <-- Short Description --> +// iir returns wrong value with Scilab-5.3.1 and Scilab-5.3.2 under Windows_64 +hz=iir(3,'bp','cheb1',[.15 .25],[.08 .03]); +z=poly(0,'z'); +num=-0.013202009223+0.039606027668*z^2-0.039606027668*z^4+... + 0.013202009223*z^6; +den=0.500720867559-1.032666480454*z+2.407044124849*z^2... + -2.614123854577*z^3+3.000398199872*z^4-1.647252234036*z^5+z^6; +if ~assert_checkalmostequal (coeff(hz.num) , coeff(num) , 1d-10) then bugmes();quit;end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_9675.tst b/modules/signal_processing/tests/nonreg_tests/bug_9675.tst new file mode 100755 index 000000000..89b43c10e --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_9675.tst @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9675 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9675 +// +// <-- Short Description --> +// iir returns wrong value with Scilab-5.3.1 and Scilab-5.3.2 under Windows_64 + +hz=iir(3,'bp','cheb1',[.15 .25],[.08 .03]); +z=poly(0,'z'); +num=-0.013202009223+0.039606027668*z^2-0.039606027668*z^4+... + 0.013202009223*z^6; +den=0.500720867559-1.032666480454*z+2.407044124849*z^2... + -2.614123854577*z^3+3.000398199872*z^4-1.647252234036*z^5+z^6; +if ~assert_checkalmostequal (coeff(hz.num) , coeff(num) , 1d-10) then pause,end diff --git a/modules/signal_processing/tests/nonreg_tests/bug_9851.dia.ref b/modules/signal_processing/tests/nonreg_tests/bug_9851.dia.ref new file mode 100755 index 000000000..9d0d80762 --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_9851.dia.ref @@ -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 9851 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9851 +// +// <-- Short Description --> +// Error message occurs because of a cut-off frequency of 0.25Hz with irr +hz=iir(2,'lp','butt',[0.25 0.25],[0 0]); +z=poly(0,'z'); +num=0.292893218813+0.585786437627*z+0.292893218813*z^2; +den=0.171572875254+5.55111512d-17*z+z^2; +assert_checkalmostequal(coeff(numer(hz)), coeff(num), 1d-9); +assert_checkalmostequal(coeff(denom(hz)), coeff(den), 1d-9); diff --git a/modules/signal_processing/tests/nonreg_tests/bug_9851.tst b/modules/signal_processing/tests/nonreg_tests/bug_9851.tst new file mode 100755 index 000000000..fba8c8f5f --- /dev/null +++ b/modules/signal_processing/tests/nonreg_tests/bug_9851.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 9851 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9851 +// +// <-- Short Description --> +// Error message occurs because of a cut-off frequency of 0.25Hz with irr + +hz=iir(2,'lp','butt',[0.25 0.25],[0 0]); +z=poly(0,'z'); +num=0.292893218813+0.585786437627*z+0.292893218813*z^2; +den=0.171572875254+5.55111512d-17*z+z^2; +assert_checkalmostequal(coeff(numer(hz)), coeff(num), 1d-9); +assert_checkalmostequal(coeff(denom(hz)), coeff(den), 1d-9); diff --git a/modules/signal_processing/tests/unit_tests/amell.dia.ref b/modules/signal_processing/tests/unit_tests/amell.dia.ref new file mode 100755 index 000000000..723ba7e2e --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/amell.dia.ref @@ -0,0 +1,9 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +if amell(10,[1:10])<> 0 then bugmes();quit;end +if or(size(amell([1:10],[1:10])) <> [1 10]) then bugmes();quit;end +if or(amell([1:10],[1:10])<> 0) then bugmes();quit;end diff --git a/modules/signal_processing/tests/unit_tests/amell.tst b/modules/signal_processing/tests/unit_tests/amell.tst new file mode 100755 index 000000000..4e085bdd0 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/amell.tst @@ -0,0 +1,10 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +if amell(10,[1:10])<> 0 then pause,end +if or(size(amell([1:10],[1:10])) <> [1 10]) then pause,end +if or(amell([1:10],[1:10])<> 0) then pause,end
\ No newline at end of file diff --git a/modules/signal_processing/tests/unit_tests/conv.dia.ref b/modules/signal_processing/tests/unit_tests/conv.dia.ref new file mode 100755 index 000000000..2603ff0a6 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/conv.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// 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. +// ============================================================================= +u=1:10;v=[1 -1]; +assert_checkequal(conv(u,v),[ones(1,10) -10]); +assert_checkequal(conv(u,v,"full"),[ones(1,10) -10]); +assert_checkequal(conv(u,v'),[ones(1,10) -10]); +assert_checkequal(conv(u',v),[ones(10,1); -10]); +assert_checkequal(conv(u,v,"same"),[ones(1,9) -10]); +assert_checkequal(conv(v,u,"same"),[1 1]); +assert_checkequal(conv(u,v,"valid"),ones(1,9)); +assert_checkequal(conv(v,u,"valid"),[]); +assert_checkequal(conv(u,v*%i),[ones(1,10) -10]*%i); +assert_checkequal(conv(u*%i,v*%i),-[ones(1,10) -10]+0*%i); diff --git a/modules/signal_processing/tests/unit_tests/conv.tst b/modules/signal_processing/tests/unit_tests/conv.tst new file mode 100755 index 000000000..d71cb1a90 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/conv.tst @@ -0,0 +1,18 @@ +// ============================================================================= +// 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. +// ============================================================================= +u=1:10;v=[1 -1]; +assert_checkequal(conv(u,v),[ones(1,10) -10]); +assert_checkequal(conv(u,v,"full"),[ones(1,10) -10]); +assert_checkequal(conv(u,v'),[ones(1,10) -10]); +assert_checkequal(conv(u',v),[ones(10,1); -10]); + +assert_checkequal(conv(u,v,"same"),[ones(1,9) -10]); +assert_checkequal(conv(v,u,"same"),[1 1]); +assert_checkequal(conv(u,v,"valid"),ones(1,9)); +assert_checkequal(conv(v,u,"valid"),[]); +assert_checkequal(conv(u,v*%i),[ones(1,10) -10]*%i); +assert_checkequal(conv(u*%i,v*%i),-[ones(1,10) -10]+0*%i); diff --git a/modules/signal_processing/tests/unit_tests/conv2.dia.ref b/modules/signal_processing/tests/unit_tests/conv2.dia.ref new file mode 100755 index 000000000..b8fe6c0ad --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/conv2.dia.ref @@ -0,0 +1,49 @@ +// ============================================================================= +// 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. +// ============================================================================= +s = [1 2 1; 0 0 0; -1 -2 -1]; +A = zeros(10,10); +A(3:7,3:7) = 1; +reffull=zeros(12,12); +reffull([3,4,8,9],3:9)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkequal(conv2(s,A),reffull); +assert_checkequal(conv2(A,s),reffull); +assert_checkequal(conv2(s,A,'full'),reffull); +assert_checkequal(conv2(A,s,'full'),reffull); +assert_checkequal(conv2(s,A,'same'),[0,0,0;0,0,0;-4,-4,-3]); +refsame=zeros(10,10); +refsame([2,3,7,8],2:8)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkequal(conv2(A,s,'same'),refsame); +assert_checkequal(conv2(s,A,'valid'),[]); +refvalid=zeros(8,8); +refvalid([1,2,6,7],1:7)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkequal(conv2(A,s,'valid'),refvalid); +u=[1;0;-1];v=[1 2 1]; +assert_checkequal(conv2(u,v,A),reffull); +assert_checkequal(conv2(u,v,A,'full'),reffull); +assert_checkequal(conv2(u,v,A,'same'),refsame); +assert_checkequal(conv2(u,v,A,'valid'),refvalid); +a=[1 2 3;4 5 6;7 8 9]; +assert_checkequal(conv2(a,s,'same'),[13 20 17;18 24 18;-13 -20 -17]); +assert_checkequal(conv2([3;4],[1;2]),[3;10;8]); +assert_checkequal(conv2([1;2],1,[3;4]),[3;10;8]); +assert_checkequal(conv2([1;2],%i,[3;4]),[3;10;8]*%i); +assert_checkequal(conv2([1;2]*%i,1,[3;4]),[3;10;8]*%i); +assert_checkequal(conv2([1;2],1,[3;4]*%i),[3;10;8]*%i); +assert_checkequal(conv2([1;2],%i,[3;4]*%i),-[3;10;8]+0*%i); +assert_checkequal(conv2([1;2]*%i,%i,[3;4]),-[3;10;8]+0*%i); +assert_checkequal(conv2([1;2]*%i,%i,[3;4]*%i),-[3;10;8]*%i); +assert_checkequal(conv2([1 2;3 4],[]),zeros(2,2)); +assert_checkequal(conv2([],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([1 2;3 4],[],'same'),zeros(2,2)); +assert_checkequal(conv2([],[1 2;3 4],'same'),[]); +assert_checkequal(conv2([1 2;3 4],[],'valid'),zeros(2,2)); +assert_checkequal(conv2([],[1 2;3 4],'valid'),[]); +//here we do not follow matlab +assert_checkequal(conv2([],[1,2],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([1,2],[],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([],[1;2],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([1;2],[],[1 2;3 4]),zeros(2,2)); diff --git a/modules/signal_processing/tests/unit_tests/conv2.tst b/modules/signal_processing/tests/unit_tests/conv2.tst new file mode 100755 index 000000000..1d1dd91a8 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/conv2.tst @@ -0,0 +1,59 @@ +// ============================================================================= +// 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. +// ============================================================================= +s = [1 2 1; 0 0 0; -1 -2 -1]; +A = zeros(10,10); +A(3:7,3:7) = 1; +reffull=zeros(12,12); +reffull([3,4,8,9],3:9)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkequal(conv2(s,A),reffull); +assert_checkequal(conv2(A,s),reffull); + +assert_checkequal(conv2(s,A,'full'),reffull); +assert_checkequal(conv2(A,s,'full'),reffull); + +assert_checkequal(conv2(s,A,'same'),[0,0,0;0,0,0;-4,-4,-3]); +refsame=zeros(10,10); +refsame([2,3,7,8],2:8)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkequal(conv2(A,s,'same'),refsame); + +assert_checkequal(conv2(s,A,'valid'),[]); +refvalid=zeros(8,8); +refvalid([1,2,6,7],1:7)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkequal(conv2(A,s,'valid'),refvalid); + +u=[1;0;-1];v=[1 2 1]; +assert_checkequal(conv2(u,v,A),reffull); +assert_checkequal(conv2(u,v,A,'full'),reffull); +assert_checkequal(conv2(u,v,A,'same'),refsame); +assert_checkequal(conv2(u,v,A,'valid'),refvalid); + +a=[1 2 3;4 5 6;7 8 9]; + +assert_checkequal(conv2(a,s,'same'),[13 20 17;18 24 18;-13 -20 -17]); + +assert_checkequal(conv2([3;4],[1;2]),[3;10;8]); + +assert_checkequal(conv2([1;2],1,[3;4]),[3;10;8]); +assert_checkequal(conv2([1;2],%i,[3;4]),[3;10;8]*%i); +assert_checkequal(conv2([1;2]*%i,1,[3;4]),[3;10;8]*%i); +assert_checkequal(conv2([1;2],1,[3;4]*%i),[3;10;8]*%i); +assert_checkequal(conv2([1;2],%i,[3;4]*%i),-[3;10;8]+0*%i); +assert_checkequal(conv2([1;2]*%i,%i,[3;4]),-[3;10;8]+0*%i); +assert_checkequal(conv2([1;2]*%i,%i,[3;4]*%i),-[3;10;8]*%i); + +assert_checkequal(conv2([1 2;3 4],[]),zeros(2,2)); +assert_checkequal(conv2([],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([1 2;3 4],[],'same'),zeros(2,2)); +assert_checkequal(conv2([],[1 2;3 4],'same'),[]); +assert_checkequal(conv2([1 2;3 4],[],'valid'),zeros(2,2)); +assert_checkequal(conv2([],[1 2;3 4],'valid'),[]); + +//here we do not follow matlab +assert_checkequal(conv2([],[1,2],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([1,2],[],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([],[1;2],[1 2;3 4]),zeros(2,2)); +assert_checkequal(conv2([1;2],[],[1 2;3 4]),zeros(2,2)); diff --git a/modules/signal_processing/tests/unit_tests/convol2d.dia.ref b/modules/signal_processing/tests/unit_tests/convol2d.dia.ref new file mode 100755 index 000000000..f47d29f24 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/convol2d.dia.ref @@ -0,0 +1,18 @@ +// ============================================================================= +// 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. +// ============================================================================= +s = [1 2 1; 0 0 0; -1 -2 -1]; +A = zeros(10,10); +A(3:7,3:7) = 1; +reffull=zeros(12,12); +reffull([3,4,8,9],3:9)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkalmostequal(convol2d(s,A),reffull,100*%eps,100*%eps); +assert_checkalmostequal(convol2d(A,s),reffull,100*%eps,100*%eps); +assert_checkequal(convol2d([3;4],[1;2]),[3;10;8]); +assert_checkequal(convol2d([3;4],[1;2]*%i),[3;10;8]*%i); +assert_checkequal(convol2d([3;4]*%i,[1;2]*%i),-[3;10;8]); +assert_checkequal(convol2d([1 2;3 4],[]),zeros(2,2)); +assert_checkequal(convol2d([],[1 2;3 4]),zeros(2,2)); diff --git a/modules/signal_processing/tests/unit_tests/convol2d.tst b/modules/signal_processing/tests/unit_tests/convol2d.tst new file mode 100755 index 000000000..f5d3c3f43 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/convol2d.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// 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. +// ============================================================================= +s = [1 2 1; 0 0 0; -1 -2 -1]; +A = zeros(10,10); +A(3:7,3:7) = 1; +reffull=zeros(12,12); +reffull([3,4,8,9],3:9)=[1;1;-1;-1]*[1 3 4 4 4 3 1]; +assert_checkalmostequal(convol2d(s,A),reffull,100*%eps,100*%eps); +assert_checkalmostequal(convol2d(A,s),reffull,100*%eps,100*%eps); + + +assert_checkequal(convol2d([3;4],[1;2]),[3;10;8]); +assert_checkequal(convol2d([3;4],[1;2]*%i),[3;10;8]*%i); +assert_checkequal(convol2d([3;4]*%i,[1;2]*%i),-[3;10;8]); + + +assert_checkequal(convol2d([1 2;3 4],[]),zeros(2,2)); +assert_checkequal(convol2d([],[1 2;3 4]),zeros(2,2)); diff --git a/modules/signal_processing/tests/unit_tests/corr.dia.ref b/modules/signal_processing/tests/unit_tests/corr.dia.ref new file mode 100755 index 000000000..3fae6c9f8 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/corr.dia.ref @@ -0,0 +1,33 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +rand('normal'); +x=rand(1,256); +y=-x; +deff('[z]=xx(inc,is)','z=x(is:is+inc-1)'); +deff('[z]=yy(inc,is)','z=y(is:is+inc-1)'); +[c, mxy]=corr(x,y,32); +if or(size(c)<>[1 32]) then bugmes();quit;end +if or(size(mxy)<>[1 2]) then bugmes();quit;end +x=x-mxy(1)*ones(x); +y=y-mxy(2)*ones(y); +c1=corr(x,y,32); +c2=corr(x,32); +assert_checkalmostequal(c1, -c2, [], 10*%eps); +[c3,m3]=corr('fft',xx,yy,256,32); +assert_checkalmostequal(c1, c3, [], 10*%eps); +[c4,m4]=corr('fft',xx,256,32); +assert_checkalmostequal(c1, -c2, [], 10*%eps) + ans = + + T +assert_checkequal(size(c4), [1 32]); +assert_checkequal(size(m4), [1 1]); +assert_checkalmostequal(norm(m3, 1), %eps, [], %eps); +assert_checkalmostequal(norm(m4,1), %eps, [], %eps); +assert_checkalmostequal(c3, c1, [], 10*%eps); +assert_checkalmostequal(c4, c2, [], 10*%eps); diff --git a/modules/signal_processing/tests/unit_tests/corr.tst b/modules/signal_processing/tests/unit_tests/corr.tst new file mode 100755 index 000000000..1d624efad --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/corr.tst @@ -0,0 +1,36 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + + +rand('normal'); +x=rand(1,256); +y=-x; +deff('[z]=xx(inc,is)','z=x(is:is+inc-1)'); +deff('[z]=yy(inc,is)','z=y(is:is+inc-1)'); +[c, mxy]=corr(x,y,32); +if or(size(c)<>[1 32]) then pause,end +if or(size(mxy)<>[1 2]) then pause,end + +x=x-mxy(1)*ones(x); +y=y-mxy(2)*ones(y); +c1=corr(x,y,32); +c2=corr(x,32); +assert_checkalmostequal(c1, -c2, [], 10*%eps); + +[c3,m3]=corr('fft',xx,yy,256,32); +assert_checkalmostequal(c1, c3, [], 10*%eps); + +[c4,m4]=corr('fft',xx,256,32); +assert_checkalmostequal(c1, -c2, [], 10*%eps) +assert_checkequal(size(c4), [1 32]); +assert_checkequal(size(m4), [1 1]); + +assert_checkalmostequal(norm(m3, 1), %eps, [], %eps); +assert_checkalmostequal(norm(m4,1), %eps, [], %eps); +assert_checkalmostequal(c3, c1, [], 10*%eps); +assert_checkalmostequal(c4, c2, [], 10*%eps); diff --git a/modules/signal_processing/tests/unit_tests/delip.dia.ref b/modules/signal_processing/tests/unit_tests/delip.dia.ref new file mode 100755 index 000000000..6dab3d649 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/delip.dia.ref @@ -0,0 +1,11 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +ck=0.5; +r = delip([1,2],ck); +ref = [1.6857504 1.6857504 + 2.1565156*%i]; +if or(size(r)<> [1 2]) then bugmes();quit;end +if norm(ref-r) > 1e9 *%eps then bugmes();quit;end diff --git a/modules/signal_processing/tests/unit_tests/delip.tst b/modules/signal_processing/tests/unit_tests/delip.tst new file mode 100755 index 000000000..403c1e68e --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/delip.tst @@ -0,0 +1,12 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +ck=0.5; +r = delip([1,2],ck); +ref = [1.6857504 1.6857504 + 2.1565156*%i]; +if or(size(r)<> [1 2]) then pause,end +if norm(ref-r) > 1e9 *%eps then pause,end diff --git a/modules/signal_processing/tests/unit_tests/fft.dia.ref b/modules/signal_processing/tests/unit_tests/fft.dia.ref new file mode 100755 index 000000000..fdd4ca0b6 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/fft.dia.ref @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +a = [1;2;3]; +n=size(a,'*'); +r1 = norm(1/n*exp(2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*a -fft(a,1)); +if r1 > 10 *%eps then bugmes();quit;end +r2 = norm(exp(-2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*a -fft(a,-1)); +if r2 > 100 *%eps then bugmes();quit;end +sample_rate = 1000; +t = 0:1/sample_rate:0.6; +N = size(t,'*'); +s = sin(2*%pi*50*t)+sin(2*%pi*70*t+%pi/4)+grand(1,N,'nor',0,1); +y = fft(s); +if or(size(y) <> [1 601]) then bugmes();quit;end diff --git a/modules/signal_processing/tests/unit_tests/fft.tst b/modules/signal_processing/tests/unit_tests/fft.tst new file mode 100755 index 000000000..53105f1e2 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/fft.tst @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +a = [1;2;3]; +n=size(a,'*'); +r1 = norm(1/n*exp(2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*a -fft(a,1)); +if r1 > 10 *%eps then pause,end + +r2 = norm(exp(-2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*a -fft(a,-1)); +if r2 > 100 *%eps then pause,end + +sample_rate = 1000; +t = 0:1/sample_rate:0.6; +N = size(t,'*'); +s = sin(2*%pi*50*t)+sin(2*%pi*70*t+%pi/4)+grand(1,N,'nor',0,1); +y = fft(s); +if or(size(y) <> [1 601]) then pause,end + +
\ No newline at end of file diff --git a/modules/signal_processing/tests/unit_tests/filter.dia.ref b/modules/signal_processing/tests/unit_tests/filter.dia.ref new file mode 100755 index 000000000..eed21848a --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/filter.dia.ref @@ -0,0 +1,129 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- unit tests for function filter --> +// +// <-- CLI SHELL MODE --> +//============================================================================== +// Error handling tests +//============================================================================== +fname = "filter"; +func_call = "filter(B, A, x)"; +// Type checks +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 1); +B = "test"; +A = [0 1]; +x = [1, zeros(1,99)]; +assert_checkerror(func_call, err_msg); +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 2); +B = [0 0 1]; +A = "test"; +assert_checkerror(func_call, err_msg); +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 3); +B = [0 0 1]; +A = [1 0 1]; +x = "test"; +assert_checkerror(func_call, err_msg); +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 4); +x = [1, zeros(1,99)]; +z = "test"; +func_call = "filter(B, A, x, z)"; +assert_checkerror(func_call, err_msg); +// Values are real +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 1); +z = 0; +B = %i; +assert_checkerror(func_call, err_msg); +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 2); +A = 2 * %i; +B = [0 0 1]; +assert_checkerror(func_call, err_msg); +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 3); +A = [1 0 1]; +x = [%i 1 3 4]; +assert_checkerror(func_call, err_msg); +x = [1 zeros(1, 99)]; +z = %i; +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 4); +assert_checkerror(func_call, err_msg); +// Check vector values +A = [A; A]; +z = 0; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 1); +assert_checkerror(func_call, err_msg); +A = A(1, :); +B = [B; B]; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 2); +assert_checkerror(func_call, err_msg); +B = B(1, :); +x = [x; x]; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 3); +assert_checkerror(func_call, err_msg); +x = x(1, :); +z = [1 2; 3 4]; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 4); +assert_checkerror(func_call, err_msg); +// User mixes polynomial and vector notation +z = 0; +B = %s^3 + %s + 1; +A = [1 0]; +err_msg = msprintf(_("%s: Incompatible input arguments #%d and #%d: a polynomial and 1-by-1 matrix or two polynomials expected.\n"), fname, 1, 2); +assert_checkerror(func_call, err_msg); +A = B; +B = [1 1]; +err_msg = msprintf(_("%s: Incompatible input arguments #%d and #%d: a polynomial and 1-by-1 matrix or two polynomials expected.\n"), fname, 1, 2); +assert_checkerror(func_call, err_msg); +// Denominator must have first coefficient not equal to 0 +A = [0 0 1]; +err_msg = msprintf(_("%s: Wrong value for input argument #%d: First element must not be %s.\n"), fname, 2, "0"); +assert_checkerror(func_call, err_msg); +B = %s^3 + %s + 1; +A = %s; +err_msg = msprintf(_("%s: Wrong value for input argument #%d: First element must not be %s.\n"), fname, 2, "0"); +assert_checkerror(func_call, err_msg); +//============================================================================== +// Nominal behaviour +//============================================================================== +// Integrator y(n) = y(n - 1) + x(n) +// Filter is 1/(1 - 1 * z**-1) +B = 1; +A = [1 -1]; +x = [1 1 1 1 1]; +y = [1 2 3 4 5]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); +// Same behaviour with a polynomial +B = %s; +A = %s - 1; +res = filter(B, A, x); +assert_checkalmostequal(res, y); +// Integrator with delay y(n) = y(n-1) + x(n-1) +// Filter is z**-1 / (1 + z**-1) +B = 1; +y = [0 1 2 3 4]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); +B = [0 1]; +A = [1 -1]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); +// Derivator y(n) = x(n) - x(n-1) +// Filter is 1 - z**-1 +B = [1 -1]; +A = 1; +x = [1 3 5 3 1]; +y = [1 2 2 -2 -2]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); +// Complex filter y(n) = 2 * y(n-1) - 3 * y(n-2) + x(n-2) - 2 * x(n-1) + x(n) +// Filter is (1 - 2z**-1 + z**-2) / (1 - 2z**-1 + 3z**-2) +B = [1 -2 1]; +A = [1 -2 3]; +x = [1 2 -1 1 -1]; +y = [1 2 -3 -7 -9]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); diff --git a/modules/signal_processing/tests/unit_tests/filter.tst b/modules/signal_processing/tests/unit_tests/filter.tst new file mode 100755 index 000000000..f3a18520c --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/filter.tst @@ -0,0 +1,155 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- unit tests for function filter --> +// +// <-- CLI SHELL MODE --> + +//============================================================================== +// Error handling tests +//============================================================================== + +fname = "filter"; +func_call = "filter(B, A, x)"; + +// Type checks +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 1); +B = "test"; +A = [0 1]; +x = [1, zeros(1,99)]; +assert_checkerror(func_call, err_msg); + +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 2); +B = [0 0 1]; +A = "test"; +assert_checkerror(func_call, err_msg); + +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 3); +B = [0 0 1]; +A = [1 0 1]; +x = "test"; +assert_checkerror(func_call, err_msg); + +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 4); +x = [1, zeros(1,99)]; +z = "test"; +func_call = "filter(B, A, x, z)"; +assert_checkerror(func_call, err_msg); + +// Values are real +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 1); +z = 0; +B = %i; +assert_checkerror(func_call, err_msg); + +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix or polynomial expected.\n"), fname, 2); +A = 2 * %i; +B = [0 0 1]; +assert_checkerror(func_call, err_msg); + +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 3); +A = [1 0 1]; +x = [%i 1 3 4]; +assert_checkerror(func_call, err_msg); + +x = [1 zeros(1, 99)]; +z = %i; +err_msg = msprintf(_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 4); +assert_checkerror(func_call, err_msg); + +// Check vector values +A = [A; A]; +z = 0; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 1); +assert_checkerror(func_call, err_msg); + +A = A(1, :); +B = [B; B]; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 2); +assert_checkerror(func_call, err_msg); + +B = B(1, :); +x = [x; x]; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 3); +assert_checkerror(func_call, err_msg); + +x = x(1, :); +z = [1 2; 3 4]; +err_msg = msprintf(_("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, 4); +assert_checkerror(func_call, err_msg); + +// User mixes polynomial and vector notation +z = 0; +B = %s^3 + %s + 1; +A = [1 0]; +err_msg = msprintf(_("%s: Incompatible input arguments #%d and #%d: a polynomial and 1-by-1 matrix or two polynomials expected.\n"), fname, 1, 2); +assert_checkerror(func_call, err_msg); + +A = B; +B = [1 1]; +err_msg = msprintf(_("%s: Incompatible input arguments #%d and #%d: a polynomial and 1-by-1 matrix or two polynomials expected.\n"), fname, 1, 2); +assert_checkerror(func_call, err_msg); + +// Denominator must have first coefficient not equal to 0 +A = [0 0 1]; +err_msg = msprintf(_("%s: Wrong value for input argument #%d: First element must not be %s.\n"), fname, 2, "0"); +assert_checkerror(func_call, err_msg); + +B = %s^3 + %s + 1; +A = %s; +err_msg = msprintf(_("%s: Wrong value for input argument #%d: First element must not be %s.\n"), fname, 2, "0"); +assert_checkerror(func_call, err_msg); + +//============================================================================== +// Nominal behaviour +//============================================================================== + +// Integrator y(n) = y(n - 1) + x(n) +// Filter is 1/(1 - 1 * z**-1) +B = 1; +A = [1 -1]; +x = [1 1 1 1 1]; + +y = [1 2 3 4 5]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); + +// Same behaviour with a polynomial +B = %s; +A = %s - 1; +res = filter(B, A, x); +assert_checkalmostequal(res, y); + +// Integrator with delay y(n) = y(n-1) + x(n-1) +// Filter is z**-1 / (1 + z**-1) +B = 1; +y = [0 1 2 3 4]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); + +B = [0 1]; +A = [1 -1]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); + +// Derivator y(n) = x(n) - x(n-1) +// Filter is 1 - z**-1 +B = [1 -1]; +A = 1; +x = [1 3 5 3 1]; +y = [1 2 2 -2 -2]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); + +// Complex filter y(n) = 2 * y(n-1) - 3 * y(n-2) + x(n-2) - 2 * x(n-1) + x(n) +// Filter is (1 - 2z**-1 + z**-2) / (1 - 2z**-1 + 3z**-2) +B = [1 -2 1]; +A = [1 -2 3]; +x = [1 2 -1 1 -1]; +y = [1 2 -3 -7 -9]; +res = filter(B, A, x); +assert_checkalmostequal(res, y); diff --git a/modules/signal_processing/tests/unit_tests/hank.dia.ref b/modules/signal_processing/tests/unit_tests/hank.dia.ref new file mode 100755 index 000000000..b4a498abc --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/hank.dia.ref @@ -0,0 +1,9 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Scilab Enterprises +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +a = [1:10;-(1:10)]; +ha = [1:6;-(1:6);3:8;-(3:8)]; +assert_checkequal(hank(2,3,a), ha); diff --git a/modules/signal_processing/tests/unit_tests/hank.tst b/modules/signal_processing/tests/unit_tests/hank.tst new file mode 100755 index 000000000..f2ee0715f --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/hank.tst @@ -0,0 +1,10 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Scilab Enterprises +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +a = [1:10;-(1:10)]; +ha = [1:6;-(1:6);3:8;-(3:8)]; +assert_checkequal(hank(2,3,a), ha);
\ No newline at end of file diff --git a/modules/signal_processing/tests/unit_tests/ifftshift.dia.ref b/modules/signal_processing/tests/unit_tests/ifftshift.dia.ref new file mode 100755 index 000000000..82e4f2306 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/ifftshift.dia.ref @@ -0,0 +1,30 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- CLLI SHELL MODE --> +vec = 1:60; +res = ifftshift(vec); +assert_checkequal(res(1:30), 31:60); +assert_checkequal(res(31:60), 1:30); +mat = matrix(vec, [10 6]); +refRES = (1:5)'; +refRES = [refRES refRES+10 refRES+20]; +res = ifftshift(mat); +assert_checkequal(res(1:5, 1:3), refRES+35); +assert_checkequal(res(1:5, 4:6), refRES+5); +assert_checkequal(res(6:10, 1:3), refRES+30); +assert_checkequal(res(6:10, 4:6), refRES); +// Check that ifftshift(fftshift(x)) = x +// Make a signal +t = 0:0.1:1000; +x = 3*sin(t)+8*sin(3*t)+0.5*sin(5*t)+3*rand(t); +// Compute the fft +y = fft(x, -1); +// Invert the result +invShift = ifftshift(fftshift(y)); +// Check that we recreated the original result +assert_checkequal(invShift, y); diff --git a/modules/signal_processing/tests/unit_tests/ifftshift.tst b/modules/signal_processing/tests/unit_tests/ifftshift.tst new file mode 100755 index 000000000..a9f3c0fb0 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/ifftshift.tst @@ -0,0 +1,39 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- CLLI SHELL MODE --> + +vec = 1:60; + +res = ifftshift(vec); + +assert_checkequal(res(1:30), 31:60); +assert_checkequal(res(31:60), 1:30); + +mat = matrix(vec, [10 6]); +refRES = (1:5)'; +refRES = [refRES refRES+10 refRES+20]; + +res = ifftshift(mat); + +assert_checkequal(res(1:5, 1:3), refRES+35); +assert_checkequal(res(1:5, 4:6), refRES+5); +assert_checkequal(res(6:10, 1:3), refRES+30); +assert_checkequal(res(6:10, 4:6), refRES); + + +// Check that ifftshift(fftshift(x)) = x + +// Make a signal +t = 0:0.1:1000; +x = 3*sin(t)+8*sin(3*t)+0.5*sin(5*t)+3*rand(t); +// Compute the fft +y = fft(x, -1); +// Invert the result +invShift = ifftshift(fftshift(y)); +// Check that we recreated the original result +assert_checkequal(invShift, y); diff --git a/modules/signal_processing/tests/unit_tests/kalm.dia.ref b/modules/signal_processing/tests/unit_tests/kalm.dia.ref new file mode 100755 index 000000000..7da23a476 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/kalm.dia.ref @@ -0,0 +1,42 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +w=%pi/4; // angular frequency +T=0.1; // period +t=0:T:5; +signal=cos(w*t); +// Sinusoid with noise +v=0:1:50; +y=signal+v; +// System +n=2; // system order +f=[cos(w*T) -sin(w*T); sin(w*T) cos(w*T)]; +g=0; +h=[1 0]; +p0=[1000 0; 0 0]; +R=1; +Q=0; +x0=zeros(n,1); +// Initialize for loop +x1=x0; +p1=p0; +// Kalman filter +xsum=0; +x1sum=0; +psum=0; +p1sum=0; +for i=1:length(t)-1 + [x1(:,i+1),p1,x,p]=kalm(y(i),x1(:,i),p1,f,g,h,Q,R); + xsum = xsum + x; + p1sum = p1sum + p1; + psum = psum + p; + x1sum = x1sum + x1(:,i+1); +end +assert_checkalmostequal(xsum, [295.374859628719719;202.134913816696837]); +assert_checkalmostequal(p1sum, [3.88430845743643571,0.63055345519216977;0.63055345519217121,2.08824467576958606]); +assert_checkalmostequal(psum, [3.97189248710404863,0.48230715738369057;0.48230715738369184,2.0006606461019758]); +assert_checkalmostequal(x1sum, [278.60499495977632;224.686643723725581]); diff --git a/modules/signal_processing/tests/unit_tests/kalm.tst b/modules/signal_processing/tests/unit_tests/kalm.tst new file mode 100755 index 000000000..e7bce0189 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/kalm.tst @@ -0,0 +1,46 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +w=%pi/4; // angular frequency +T=0.1; // period +t=0:T:5; +signal=cos(w*t); +// Sinusoid with noise +v=0:1:50; +y=signal+v; +// System +n=2; // system order +f=[cos(w*T) -sin(w*T); sin(w*T) cos(w*T)]; +g=0; +h=[1 0]; +p0=[1000 0; 0 0]; +R=1; +Q=0; +x0=zeros(n,1); +// Initialize for loop +x1=x0; +p1=p0; +// Kalman filter +xsum=0; +x1sum=0; +psum=0; +p1sum=0; +for i=1:length(t)-1 + [x1(:,i+1),p1,x,p]=kalm(y(i),x1(:,i),p1,f,g,h,Q,R); + xsum = xsum + x; + p1sum = p1sum + p1; + psum = psum + p; + x1sum = x1sum + x1(:,i+1); +end +assert_checkalmostequal(xsum, [295.374859628719719;202.134913816696837]); + +assert_checkalmostequal(p1sum, [3.88430845743643571,0.63055345519216977;0.63055345519217121,2.08824467576958606]); + +assert_checkalmostequal(psum, [3.97189248710404863,0.48230715738369057;0.48230715738369184,2.0006606461019758]); +assert_checkalmostequal(x1sum, [278.60499495977632;224.686643723725581]); + diff --git a/modules/signal_processing/tests/unit_tests/lattn.dia.ref b/modules/signal_processing/tests/unit_tests/lattn.dia.ref new file mode 100755 index 000000000..83430766c --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lattn.dia.ref @@ -0,0 +1,81 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +//Generate the process +t1=0:0.1:100; +y1=sin(2*%pi*t1)+sin(2*%pi*2*t1); +//Covariance of y1 +nlag=128; +c1=corr(y1,nlag); +c1=c1'; +//Compute the filter with maximum order=15 and p=1 +n=5; +[la1,sig1]=lattn(n,1,c1); +poly(0,"z"); +expected = [1, 0.4429775275224619446313]; +computed = coeff(la1(1)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [1, -0.7424151347904438535963, 0.6626546432402768971315]; +computed = coeff(la1(2)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [1, -0.7483090096409563685143, 0.6686337968594154856916, -0.0048019603017336104020]; +computed = coeff(la1(3)); +assert_checkalmostequal(computed, expected, 1.e-11); +expected = [1, -2.259216884889600152064, 3.0129744887444243062191, -2.2463220443824241101538, 0.9961140979715100707281]; +computed = coeff(la1(4)); +assert_checkalmostequal(computed, expected, 1.e-13); +expected = [1, -1.8328746888034248563315, 2.0881496310317460007866, -1.0213063678721847615805, 0.0953432301271536220000, 0.3993857757876373426598]; +computed = coeff(la1(5)); +assert_checkalmostequal(computed, expected, 1.e-10); +expected = [-1.7888543819998343753497, 1]; +computed = coeff(sig1(1)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [1.2273893327241232054092, -1.2451484900822573642643, 1]; +computed = coeff(sig1(2)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [-1.5168020192922293531979, 2.3534861083273810322680, -2.2502643910424811046767, 1]; +computed = coeff(sig1(3)); +assert_checkalmostequal(computed, expected, 1.e-13); +expected = [1.0674946929328583689056, -2.3156179157577936322809, 3.0672491379903537023210, -2.255390458180256185727, 1]; +computed = coeff(sig1(4)); +assert_checkalmostequal(computed, expected, 1.e-12); +expected = [1.4523203295727387107661, -2.2136119179063014072995, 2.0601861867297621699890, -0.1951300338336365847169, -0.8087137031222213501280, 1]; +computed = coeff(sig1(5)); +assert_checkalmostequal(computed, expected, 1.e-10); +//Compare result of poles with p=-1 and with levin function +[la2,sig2]=lattn(n,-1,c1); +expected = [1, -1.7888543819998343753497]; +computed = coeff(la2(1)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [1, -1.2451484900822573642643, 1.2273893327241232054092]; +computed = coeff(la2(2)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [1, -2.25026439104248154877, 2.3534861083273810322680, -1.5168020192922295752425]; +computed = coeff(la2(3)); +assert_checkalmostequal(computed, expected, 1.e-13); +expected = [1, -2.2553904581802566298165, 3.0672491379903545904995, -2.3156179157577940763701, 1.0674946929328590350394]; +computed = coeff(la2(4)); +assert_checkalmostequal(computed, expected, 1.e-12); +expected = [1, -0.8087137031221993677121, -0.1951300338336872108869, 2.0601861867298310038166, -2.2136119179063538098262, 1.4523203295727622474942]; +computed = coeff(la2(5)); +assert_checkalmostequal(computed, expected, 1.e-10); +expected = [0.4429775275224624442316, 1]; +computed = coeff(sig2(1)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [0.6626546432402768971315, -0.7424151347904438535963, 1]; +computed = coeff(sig2(2)); +assert_checkalmostequal(computed, expected, 1.e-14); +expected = [-0.0048019603017336104020, 0.6686337968594154856916, -0.7483090096409563685143, 1]; +computed = coeff(sig2(3)); +assert_checkalmostequal(computed, expected, 1.e-11); +expected = [0.9961140979715094045943, -2.2463220443824232219754, 3.0129744887444229739515, -2.2592168848895997079751, 1]; +computed = coeff(sig2(4)); +assert_checkalmostequal(computed, expected, 1.e-13); +expected = [0.3993857757876351222137, 0.0953432301271577298252, -1.0213063678721903126956, 2.0881496310317495535003, -1.8328746888034264106437, 1]; +computed = coeff(sig2(5)); +assert_checkalmostequal(computed, expected, 1.e-10); diff --git a/modules/signal_processing/tests/unit_tests/lattn.tst b/modules/signal_processing/tests/unit_tests/lattn.tst new file mode 100755 index 000000000..2679d8b9e --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lattn.tst @@ -0,0 +1,104 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//Generate the process +t1=0:0.1:100; +y1=sin(2*%pi*t1)+sin(2*%pi*2*t1); + +//Covariance of y1 +nlag=128; +c1=corr(y1,nlag); +c1=c1'; + +//Compute the filter with maximum order=15 and p=1 +n=5; +[la1,sig1]=lattn(n,1,c1); +poly(0,"z"); + +expected = [1, 0.4429775275224619446313]; +computed = coeff(la1(1)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [1, -0.7424151347904438535963, 0.6626546432402768971315]; +computed = coeff(la1(2)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [1, -0.7483090096409563685143, 0.6686337968594154856916, -0.0048019603017336104020]; +computed = coeff(la1(3)); +assert_checkalmostequal(computed, expected, 1.e-11); + +expected = [1, -2.259216884889600152064, 3.0129744887444243062191, -2.2463220443824241101538, 0.9961140979715100707281]; +computed = coeff(la1(4)); +assert_checkalmostequal(computed, expected, 1.e-13); + +expected = [1, -1.8328746888034248563315, 2.0881496310317460007866, -1.0213063678721847615805, 0.0953432301271536220000, 0.3993857757876373426598]; +computed = coeff(la1(5)); +assert_checkalmostequal(computed, expected, 1.e-10); + +expected = [-1.7888543819998343753497, 1]; +computed = coeff(sig1(1)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [1.2273893327241232054092, -1.2451484900822573642643, 1]; +computed = coeff(sig1(2)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [-1.5168020192922293531979, 2.3534861083273810322680, -2.2502643910424811046767, 1]; +computed = coeff(sig1(3)); +assert_checkalmostequal(computed, expected, 1.e-13); + +expected = [1.0674946929328583689056, -2.3156179157577936322809, 3.0672491379903537023210, -2.255390458180256185727, 1]; +computed = coeff(sig1(4)); +assert_checkalmostequal(computed, expected, 1.e-12); + +expected = [1.4523203295727387107661, -2.2136119179063014072995, 2.0601861867297621699890, -0.1951300338336365847169, -0.8087137031222213501280, 1]; +computed = coeff(sig1(5)); +assert_checkalmostequal(computed, expected, 1.e-10); + +//Compare result of poles with p=-1 and with levin function +[la2,sig2]=lattn(n,-1,c1); +expected = [1, -1.7888543819998343753497]; +computed = coeff(la2(1)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [1, -1.2451484900822573642643, 1.2273893327241232054092]; +computed = coeff(la2(2)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [1, -2.25026439104248154877, 2.3534861083273810322680, -1.5168020192922295752425]; +computed = coeff(la2(3)); +assert_checkalmostequal(computed, expected, 1.e-13); + +expected = [1, -2.2553904581802566298165, 3.0672491379903545904995, -2.3156179157577940763701, 1.0674946929328590350394]; +computed = coeff(la2(4)); +assert_checkalmostequal(computed, expected, 1.e-12); + +expected = [1, -0.8087137031221993677121, -0.1951300338336872108869, 2.0601861867298310038166, -2.2136119179063538098262, 1.4523203295727622474942]; +computed = coeff(la2(5)); +assert_checkalmostequal(computed, expected, 1.e-10); + +expected = [0.4429775275224624442316, 1]; +computed = coeff(sig2(1)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [0.6626546432402768971315, -0.7424151347904438535963, 1]; +computed = coeff(sig2(2)); +assert_checkalmostequal(computed, expected, 1.e-14); + +expected = [-0.0048019603017336104020, 0.6686337968594154856916, -0.7483090096409563685143, 1]; +computed = coeff(sig2(3)); +assert_checkalmostequal(computed, expected, 1.e-11); + +expected = [0.9961140979715094045943, -2.2463220443824232219754, 3.0129744887444229739515, -2.2592168848895997079751, 1]; +computed = coeff(sig2(4)); +assert_checkalmostequal(computed, expected, 1.e-13); + +expected = [0.3993857757876351222137, 0.0953432301271577298252, -1.0213063678721903126956, 2.0881496310317495535003, -1.8328746888034264106437, 1]; +computed = coeff(sig2(5)); +assert_checkalmostequal(computed, expected, 1.e-10); diff --git a/modules/signal_processing/tests/unit_tests/lattp.dia.ref b/modules/signal_processing/tests/unit_tests/lattp.dia.ref new file mode 100755 index 000000000..8249b6dbd --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lattp.dia.ref @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +//Generate the process +t1=0:0.1:100; +y1=sin(2*%pi*t1)+sin(2*%pi*2*t1); +//Covariance of y1 +nlag=128; +c1=corr(y1,nlag); +c1=c1'; +//Compute the filter with maximum order=15 and p=5 +n=5; p=2; +[la1,sig1]=lattp(n,p,c1); +poly(0,"z"); +assert_checkequal(la1(1), 1-1.83287468880270521*%z+2.08814963103010243*%z^2-1.02130636786998474*%z^3+0.09534323012550860*%z^4+0.39938577578836609*%z^5); +assert_checkequal(la1(2), 1+5934927594313.27051*%z-10877978567494.7891*%z^2+12393016866258.4355*%z^3-6061379344921.20703*%z^4+565855167403.415283*%z^5+2370325661503.31836*%z^6); +assert_checkequal(sig1, list()); diff --git a/modules/signal_processing/tests/unit_tests/lattp.tst b/modules/signal_processing/tests/unit_tests/lattp.tst new file mode 100755 index 000000000..d50ee1ab0 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lattp.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//Generate the process +t1=0:0.1:100; +y1=sin(2*%pi*t1)+sin(2*%pi*2*t1); + +//Covariance of y1 +nlag=128; +c1=corr(y1,nlag); +c1=c1'; + +//Compute the filter with maximum order=15 and p=5 +n=5; p=2; +[la1,sig1]=lattp(n,p,c1); +poly(0,"z"); +assert_checkequal(la1(1), 1-1.83287468880270521*%z+2.08814963103010243*%z^2-1.02130636786998474*%z^3+0.09534323012550860*%z^4+0.39938577578836609*%z^5); + +assert_checkequal(la1(2), 1+5934927594313.27051*%z-10877978567494.7891*%z^2+12393016866258.4355*%z^3-6061379344921.20703*%z^4+565855167403.415283*%z^5+2370325661503.31836*%z^6); + +assert_checkequal(sig1, list()); + diff --git a/modules/signal_processing/tests/unit_tests/lev.dia.ref b/modules/signal_processing/tests/unit_tests/lev.dia.ref new file mode 100755 index 000000000..8780c0669 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lev.dia.ref @@ -0,0 +1,14 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +b=1; //numerator +a=[1 -0.7 0.8]; //denominator +x=[1 zeros(1,99)]; //input=impulse +data=filter(b,a,x); //real data +a2=lev(data); //modelized data +a2_ref=[-2.95375652176204362;0.85443608696722761;1.16338825311255967;-0.5843638139231808;-1.29904413848756084;0.2827999960599864;1.36469413757280944;0.03400400016235194;-1.35680035182069414;-0.34897551040648700;1.27578817976193548;0.64514062356548996;-1.12602339214832625;-0.90653891102847028;0.91557685923087617;1.11908353906414315;-0.65578960909082540;-1.27132041260303486;0.36066165616501500;1.35504543992694138;-0.04609753618187262;-1.36574665368330295;-0.27095079413754847;1.30284736218693986;0.57339750321671712;-1.16973722751155518;-0.84494364531757027;0.97358959556271740;1.07095551571593028;-0.72497492227130311;-1.23925326552891701;0.43729112848768537;1.34076727749932667;-0.12604158192534731;-1.37002693044609769;-0.19200038407123965;1.32545541271529554;0.49969539059447443;-1.20945469704137598;-0.78046165955049063;1.02827609750283466;1.01916861075655008;-0.79168338429134533;-1.2029522535385402;0.51242661114848276;1.3219084311265532;-0.20555501106545992;-1.36962655869526673;-0.11239401148886496;1.34353509174246932;0.42428608635778209;-1.2450401074093944;-0.7133132541493183;1.07944953055333803;0.9638997523135744;-0.85568708805196592;-1.16254139775417586;0.58581140643039376;1.29853333138992988;-0.28436616878620091;-1.3645469062867672;-0.03240364874471358;1.35702463068550716;0.34742722372528412;-1.27637188232062804;-0.64372783926421662;1.1269350624915635;0.90533776448550585;-0.91676736716449969;-1.11815876043450668;0.65719479777787038;1.27072183849030163;-0.36220579955695353;-1.3548053276733052;0.04769741991851550;1.36587794301159882;0.26938138828071656;-1.30334297787510689;-0.57194315100185011;1.17057046067835535;0.84368272223090113;-0.97471554301766872;-1.06995597328870229;0.72633290636136172;1.23856896940847472;-0.43880796703439384;-1.34043510461302406;0.12763553203490674;1.37006478169273449;0.19041522085809687;-1.32586124827935214;-0.49820443920874441;1.21020664632028385;0.77914526781893556;-1.02933363771951836;-1.01809771943242855;0.79298952427985636;1.20218457328317552;-2.56955481312445810]; +assert_checkalmostequal(a2, a2_ref); diff --git a/modules/signal_processing/tests/unit_tests/lev.tst b/modules/signal_processing/tests/unit_tests/lev.tst new file mode 100755 index 000000000..23d2462a3 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lev.tst @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +b=1; //numerator +a=[1 -0.7 0.8]; //denominator +x=[1 zeros(1,99)]; //input=impulse +data=filter(b,a,x); //real data +a2=lev(data); //modelized data +a2_ref=[-2.95375652176204362;0.85443608696722761;1.16338825311255967;-0.5843638139231808;-1.29904413848756084;0.2827999960599864;1.36469413757280944;0.03400400016235194;-1.35680035182069414;-0.34897551040648700;1.27578817976193548;0.64514062356548996;-1.12602339214832625;-0.90653891102847028;0.91557685923087617;1.11908353906414315;-0.65578960909082540;-1.27132041260303486;0.36066165616501500;1.35504543992694138;-0.04609753618187262;-1.36574665368330295;-0.27095079413754847;1.30284736218693986;0.57339750321671712;-1.16973722751155518;-0.84494364531757027;0.97358959556271740;1.07095551571593028;-0.72497492227130311;-1.23925326552891701;0.43729112848768537;1.34076727749932667;-0.12604158192534731;-1.37002693044609769;-0.19200038407123965;1.32545541271529554;0.49969539059447443;-1.20945469704137598;-0.78046165955049063;1.02827609750283466;1.01916861075655008;-0.79168338429134533;-1.2029522535385402;0.51242661114848276;1.3219084311265532;-0.20555501106545992;-1.36962655869526673;-0.11239401148886496;1.34353509174246932;0.42428608635778209;-1.2450401074093944;-0.7133132541493183;1.07944953055333803;0.9638997523135744;-0.85568708805196592;-1.16254139775417586;0.58581140643039376;1.29853333138992988;-0.28436616878620091;-1.3645469062867672;-0.03240364874471358;1.35702463068550716;0.34742722372528412;-1.27637188232062804;-0.64372783926421662;1.1269350624915635;0.90533776448550585;-0.91676736716449969;-1.11815876043450668;0.65719479777787038;1.27072183849030163;-0.36220579955695353;-1.3548053276733052;0.04769741991851550;1.36587794301159882;0.26938138828071656;-1.30334297787510689;-0.57194315100185011;1.17057046067835535;0.84368272223090113;-0.97471554301766872;-1.06995597328870229;0.72633290636136172;1.23856896940847472;-0.43880796703439384;-1.34043510461302406;0.12763553203490674;1.37006478169273449;0.19041522085809687;-1.32586124827935214;-0.49820443920874441;1.21020664632028385;0.77914526781893556;-1.02933363771951836;-1.01809771943242855;0.79298952427985636;1.20218457328317552;-2.56955481312445810]; +assert_checkalmostequal(a2, a2_ref); + diff --git a/modules/signal_processing/tests/unit_tests/lindquist.dia.ref b/modules/signal_processing/tests/unit_tests/lindquist.dia.ref new file mode 100755 index 000000000..3a7c56f67 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lindquist.dia.ref @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +//Generate signal +x=%pi/10:%pi/10:102.4*%pi; +y=[1; 1] * sin(x) + [sin(2*x); sin(1.9*x)]; +//Compute correlations +c=[]; +for j=1:2 + for k=1:2 + c=[c;corr(y(k,:),y(j,:),64)]; + end +end +c=matrix(c,2,128); +//Find H,F,G with 6 states +hk=hank(20,20,c); +[H,F,G]=phc(hk,2,6); +//Solve Riccati equation +R0=c(1:2,1:2); +[P,R,T]=lindquist(100,H,F,G,R0); +assert_checkalmostequal(P,[52.953064387089377,-170.091664767326478;390.114441205931939,-1126.45220755477089;-2285.86604463640651,4579.41083686864113;1084.73413409944055,-1564.67420653525346;-5116.06921833499018,8743.68286689257002;-1976.40587294372335,3503.44251127613916]); +assert_checkalmostequal([-704.208398385009673,1053.5647942803439;1053.5647942827934,-1981.29618548816984], R); +assert_checkalmostequal(T, [-0.72821126450254769,-0.45461826616982365;-1.28940233637036883,-1.25076781365101763;0.25073933783035585,2.01963206598920664;3.13684440927242791,0.29283797163618436;-1.64165514197064755,1.68395444469620714;-1.61905018245414611,3.26102925315640091]); diff --git a/modules/signal_processing/tests/unit_tests/lindquist.tst b/modules/signal_processing/tests/unit_tests/lindquist.tst new file mode 100755 index 000000000..8415fe6a1 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/lindquist.tst @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//Generate signal +x=%pi/10:%pi/10:102.4*%pi; +y=[1; 1] * sin(x) + [sin(2*x); sin(1.9*x)]; + +//Compute correlations +c=[]; +for j=1:2 + for k=1:2 + c=[c;corr(y(k,:),y(j,:),64)]; + end +end +c=matrix(c,2,128); + +//Find H,F,G with 6 states +hk=hank(20,20,c); +[H,F,G]=phc(hk,2,6); + +//Solve Riccati equation +R0=c(1:2,1:2); +[P,R,T]=lindquist(100,H,F,G,R0); + +assert_checkalmostequal(P,[52.953064387089377,-170.091664767326478;390.114441205931939,-1126.45220755477089;-2285.86604463640651,4579.41083686864113;1084.73413409944055,-1564.67420653525346;-5116.06921833499018,8743.68286689257002;-1976.40587294372335,3503.44251127613916]); + +assert_checkalmostequal([-704.208398385009673,1053.5647942803439;1053.5647942827934,-1981.29618548816984], R); + +assert_checkalmostequal(T, [-0.72821126450254769,-0.45461826616982365;-1.28940233637036883,-1.25076781365101763;0.25073933783035585,2.01963206598920664;3.13684440927242791,0.29283797163618436;-1.64165514197064755,1.68395444469620714;-1.61905018245414611,3.26102925315640091]); diff --git a/modules/signal_processing/tests/unit_tests/remez.dia.ref b/modules/signal_processing/tests/unit_tests/remez.dia.ref new file mode 100755 index 000000000..99ed41795 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/remez.dia.ref @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +nc=21; +ngrid=nc*250; +fgrid=.5*(0:(ngrid-1))/(ngrid-1); +mag(1:ngrid/2)=ones(1:ngrid/2); +mag(ngrid/2+1:ngrid)=0*ones(1:ngrid/2); +weight=ones(fgrid); +guess=round(1:ngrid/nc:ngrid); +guess(nc+1)=ngrid; +guess(nc+2)=ngrid; +an=remez(guess,mag,fgrid,weight); +************ failure to converge ********** +probable cause is machine rounding error +- number of iterations = 5 +if the number of iterations exceeds 3 the design +may be correct, but should be verified with an fft diff --git a/modules/signal_processing/tests/unit_tests/remez.tst b/modules/signal_processing/tests/unit_tests/remez.tst new file mode 100755 index 000000000..1f3ef6df7 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/remez.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +nc=21; +ngrid=nc*250; +fgrid=.5*(0:(ngrid-1))/(ngrid-1); +mag(1:ngrid/2)=ones(1:ngrid/2); +mag(ngrid/2+1:ngrid)=0*ones(1:ngrid/2); +weight=ones(fgrid); +guess=round(1:ngrid/nc:ngrid); +guess(nc+1)=ngrid; +guess(nc+2)=ngrid; +an=remez(guess,mag,fgrid,weight); diff --git a/modules/signal_processing/tests/unit_tests/rpem.dia.ref b/modules/signal_processing/tests/unit_tests/rpem.dia.ref new file mode 100755 index 000000000..ab5fd6b56 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/rpem.dia.ref @@ -0,0 +1,40 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +nbPoints = 5; // Number of points computed +// Real parameters a,b,c: here, y=u +a=cat(2,1,zeros(1,nbPoints - 1)); +b=cat(2,1,zeros(1,nbPoints - 1)); +c=zeros(1,nbPoints); +// Generate input signal +t=linspace(0,50,1000); +w=%pi/4; +u=cos(w*t); +// Generate output signal +Arma=armac(a,b,c,1,1,0); +y=arsimul(Arma,u); +// Arguments of rpem +phi=zeros(1,nbPoints*3); +psi=zeros(1,nbPoints*3); +l=zeros(1,nbPoints*3); +p=1*eye(nbPoints*3,nbPoints*3); +theta=[0*a 0*b 0*c]; +w0=list(theta,p,l,phi,psi); +[w0, v]=rpem(w0,u,y); +assert_checkequal(size(w0), 5); +assert_checkequal(size(v,"*"), 1); +assert_checkalmostequal(v, 0.57451013690216091); +assert_checkequal(size(w0(1)), [1, 15]); +assert_checkequal(size(w0(2)), [15, 15]); +assert_checkequal(size(w0(3)), [1, 15]); +assert_checkequal(size(w0(4)), [1, 15]); +assert_checkequal(size(w0(5)), [1, 15]); +assert_checkalmostequal(sum(w0(1)), - 1.6187817562697728); +assert_checkalmostequal(sum(w0(2)), 925.971144340439537); +assert_checkalmostequal(sum(w0(3)), 0.06147492702030416); +assert_checkalmostequal(sum(w0(4)), 0.19515684603135780); +assert_checkalmostequal(sum(w0(5)), 0.22685582794021467); diff --git a/modules/signal_processing/tests/unit_tests/rpem.tst b/modules/signal_processing/tests/unit_tests/rpem.tst new file mode 100755 index 000000000..4af34f227 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/rpem.tst @@ -0,0 +1,47 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +nbPoints = 5; // Number of points computed + +// Real parameters a,b,c: here, y=u +a=cat(2,1,zeros(1,nbPoints - 1)); +b=cat(2,1,zeros(1,nbPoints - 1)); +c=zeros(1,nbPoints); + +// Generate input signal +t=linspace(0,50,1000); +w=%pi/4; +u=cos(w*t); + +// Generate output signal +Arma=armac(a,b,c,1,1,0); +y=arsimul(Arma,u); + +// Arguments of rpem +phi=zeros(1,nbPoints*3); +psi=zeros(1,nbPoints*3); +l=zeros(1,nbPoints*3); +p=1*eye(nbPoints*3,nbPoints*3); +theta=[0*a 0*b 0*c]; +w0=list(theta,p,l,phi,psi); +[w0, v]=rpem(w0,u,y); + +assert_checkequal(size(w0), 5); +assert_checkequal(size(v,"*"), 1); +assert_checkalmostequal(v, 0.57451013690216091); + +assert_checkequal(size(w0(1)), [1, 15]); +assert_checkequal(size(w0(2)), [15, 15]); +assert_checkequal(size(w0(3)), [1, 15]); +assert_checkequal(size(w0(4)), [1, 15]); +assert_checkequal(size(w0(5)), [1, 15]); +assert_checkalmostequal(sum(w0(1)), - 1.6187817562697728); +assert_checkalmostequal(sum(w0(2)), 925.971144340439537); +assert_checkalmostequal(sum(w0(3)), 0.06147492702030416); +assert_checkalmostequal(sum(w0(4)), 0.19515684603135780); +assert_checkalmostequal(sum(w0(5)), 0.22685582794021467); diff --git a/modules/signal_processing/tests/unit_tests/srkf.dia.ref b/modules/signal_processing/tests/unit_tests/srkf.dia.ref new file mode 100755 index 000000000..0564fa0f0 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/srkf.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +f=[0 0 1; 0 1 0; 2 3 4]; //State matrix +g=[1;-1;1]; //Input matrix +h=[1 1 0; 0 1 0; 0 0 0]; //Output matrix +Q=[3 2 1; 2 2 1; 1 1 1]; //Covariance matrix of dynamic noise +R=[2 1 1; 1 1 1; 1 1 2]; //Covariance matrix of observation noise +// Initialisation +p0=[6 3 2; 3 5 2; 2 2 4]; +x0=[1;1;1]; +y=[2 8 7]'; // Current observation output matrix +[x1,p1]=srkf(y,x0,p0,f,h,Q,R); +assert_checkalmostequal(p1, [-3.3826684796422888,0,0;-0.65452136096190749,1.43147468495118102,0;-10.588783837170105,-2.49768257747417177,-5.87595341369592727]); +assert_checkalmostequal(x1, [1.07553956834532438;4.10971223021582333;6.06654676258992787]); diff --git a/modules/signal_processing/tests/unit_tests/srkf.tst b/modules/signal_processing/tests/unit_tests/srkf.tst new file mode 100755 index 000000000..3551eada3 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/srkf.tst @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet +// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +f=[0 0 1; 0 1 0; 2 3 4]; //State matrix +g=[1;-1;1]; //Input matrix +h=[1 1 0; 0 1 0; 0 0 0]; //Output matrix +Q=[3 2 1; 2 2 1; 1 1 1]; //Covariance matrix of dynamic noise +R=[2 1 1; 1 1 1; 1 1 2]; //Covariance matrix of observation noise +// Initialisation +p0=[6 3 2; 3 5 2; 2 2 4]; +x0=[1;1;1]; +y=[2 8 7]'; // Current observation output matrix +[x1,p1]=srkf(y,x0,p0,f,h,Q,R); +assert_checkalmostequal(p1, [-3.3826684796422888,0,0;-0.65452136096190749,1.43147468495118102,0;-10.588783837170105,-2.49768257747417177,-5.87595341369592727]); +assert_checkalmostequal(x1, [1.07553956834532438;4.10971223021582333;6.06654676258992787]); + diff --git a/modules/signal_processing/tests/unit_tests/syredi.dia.ref b/modules/signal_processing/tests/unit_tests/syredi.dia.ref new file mode 100755 index 000000000..782a50493 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/syredi.dia.ref @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +[fact,b2,b1,b0,c1,c0,zzeros,zpoles]=syredi(1,4,[2*%pi/10,4*%pi/10,0,0],0.02,0.001); +ref_fact = 0.005976; +if norm(fact-ref_fact) > 0.0000037 then bugmes();quit;end +if or(b2<>[1 1 1]) then bugmes();quit;end +if or(size(b1)<>[1 3]) then bugmes();quit;end +if b1(3)<> 1 then bugmes();quit;end +if or(b0<>[1 1 0]) then bugmes();quit;end +if or(size(c1)<>[1 3]) then bugmes();quit;end +if or(size(c0)<>[1 3]) then bugmes();quit;end +if c0(3)<> 0 then bugmes();quit;end +if or(size(zzeros)<>[1 5]) then bugmes();quit;end +if or(size(zpoles)<>[1 5]) then bugmes();quit;end diff --git a/modules/signal_processing/tests/unit_tests/syredi.tst b/modules/signal_processing/tests/unit_tests/syredi.tst new file mode 100755 index 000000000..3167fa3e2 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/syredi.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + + +[fact,b2,b1,b0,c1,c0,zzeros,zpoles]=syredi(1,4,[2*%pi/10,4*%pi/10,0,0],0.02,0.001); +ref_fact = 0.005976; +if norm(fact-ref_fact) > 0.0000037 then pause,end +if or(b2<>[1 1 1]) then pause,end +if or(size(b1)<>[1 3]) then pause,end +if b1(3)<> 1 then pause,end +if or(b0<>[1 1 0]) then pause,end +if or(size(c1)<>[1 3]) then pause,end +if or(size(c0)<>[1 3]) then pause,end +if c0(3)<> 0 then pause,end +if or(size(zzeros)<>[1 5]) then pause,end +if or(size(zpoles)<>[1 5]) then pause,end diff --git a/modules/signal_processing/tests/unit_tests/xcorr.dia.ref b/modules/signal_processing/tests/unit_tests/xcorr.dia.ref new file mode 100755 index 000000000..d8074c791 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/xcorr.dia.ref @@ -0,0 +1,46 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +x=[1 2 3 4 3 2 1]; +c_ref=[1 4 10 20 31 40 44 40 31 20 10 4 1]; +assert_checkalmostequal(c_ref,xcorr(x)); +assert_checkalmostequal(c_ref,xcorr(x,"none")); +assert_checkalmostequal(c_ref/7,xcorr(x,"biased")); +assert_checkalmostequal(c_ref/44,xcorr(x,"coeff")); +[c,ind]=xcorr(x); +assert_checkalmostequal(c_ref./(7-abs(ind)),xcorr(x,"unbiased")); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,3)); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,3,"none")); +assert_checkalmostequal(c_ref(4:$-3)/7,xcorr(x,3,"biased")); +assert_checkalmostequal(c_ref(4:$-3)/44,xcorr(x,3,"coeff")); +[c,ind]=xcorr(x,3,"unbiased"); +assert_checkalmostequal(c_ref(4:$-3)./(7-abs(ind)),c); +x=[1 2*%i 3 4 3 2 1]; +c_ref=[ 1,2+%i*2,6+%i*4,14+%i*6,23+%i*8,32+%i*4,44,... + 32-%i*4,23-%i*8,14-%i*6,6-%i*4,2-%i*2,1]; +assert_checkalmostequal(c_ref,xcorr(x)); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,3)); +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1]; +c_ref=[0,0,0, 1, 4, 10, 20, 28, 32, 30, 20, 11, 4]; +c=xcorr(x,y); +assert_checktrue(isreal(c)); +assert_checkalmostequal(c_ref,c,sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref,xcorr(x,y,"none"),sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref/7,xcorr(x,y,"biased"),sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref/(norm(x)*norm(y)),xcorr(x,y,"coeff"),sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,y,3)); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,y,3,"none")); +assert_checkalmostequal(c_ref(4:$-3)/7,xcorr(x,y,3,"biased")); +assert_checkalmostequal(c_ref(4:$-3)/(norm(x)*norm(y)),xcorr(x,y,3,"coeff")); +[c,ind]=xcorr(x,y,3,"unbiased"); +assert_checkalmostequal(c_ref(4:$-3)./(7-abs(ind)),c); +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1+%i]; +c_ref=[0,0,0, 1-%i, 4-%i*2, 10-%i*3, 20-%i*4, 28-%i*3, 32-%i*2, 30-%i, 20, 11, 4]; +c=xcorr(x,y); +assert_checkalmostequal(c_ref,c,sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,y,3)); diff --git a/modules/signal_processing/tests/unit_tests/xcorr.tst b/modules/signal_processing/tests/unit_tests/xcorr.tst new file mode 100755 index 000000000..ef2e1ad1b --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/xcorr.tst @@ -0,0 +1,54 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +x=[1 2 3 4 3 2 1]; +c_ref=[1 4 10 20 31 40 44 40 31 20 10 4 1]; +assert_checkalmostequal(c_ref,xcorr(x)); +assert_checkalmostequal(c_ref,xcorr(x,"none")); +assert_checkalmostequal(c_ref/7,xcorr(x,"biased")); +assert_checkalmostequal(c_ref/44,xcorr(x,"coeff")); +[c,ind]=xcorr(x); +assert_checkalmostequal(c_ref./(7-abs(ind)),xcorr(x,"unbiased")); + +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,3)); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,3,"none")); +assert_checkalmostequal(c_ref(4:$-3)/7,xcorr(x,3,"biased")); +assert_checkalmostequal(c_ref(4:$-3)/44,xcorr(x,3,"coeff")); +[c,ind]=xcorr(x,3,"unbiased"); +assert_checkalmostequal(c_ref(4:$-3)./(7-abs(ind)),c); + +x=[1 2*%i 3 4 3 2 1]; +c_ref=[ 1,2+%i*2,6+%i*4,14+%i*6,23+%i*8,32+%i*4,44,... + 32-%i*4,23-%i*8,14-%i*6,6-%i*4,2-%i*2,1]; +assert_checkalmostequal(c_ref,xcorr(x)); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,3)); + +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1]; +c_ref=[0,0,0, 1, 4, 10, 20, 28, 32, 30, 20, 11, 4]; +c=xcorr(x,y); +assert_checktrue(isreal(c)); +assert_checkalmostequal(c_ref,c,sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref,xcorr(x,y,"none"),sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref/7,xcorr(x,y,"biased"),sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref/(norm(x)*norm(y)),xcorr(x,y,"coeff"),sqrt(%eps),20*%eps); + + +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,y,3)); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,y,3,"none")); +assert_checkalmostequal(c_ref(4:$-3)/7,xcorr(x,y,3,"biased")); +assert_checkalmostequal(c_ref(4:$-3)/(norm(x)*norm(y)),xcorr(x,y,3,"coeff")); +[c,ind]=xcorr(x,y,3,"unbiased"); +assert_checkalmostequal(c_ref(4:$-3)./(7-abs(ind)),c); + +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1+%i]; +c_ref=[0,0,0, 1-%i, 4-%i*2, 10-%i*3, 20-%i*4, 28-%i*3, 32-%i*2, 30-%i, 20, 11, 4]; + +c=xcorr(x,y); +assert_checkalmostequal(c_ref,c,sqrt(%eps),20*%eps); +assert_checkalmostequal(c_ref(4:$-3),xcorr(x,y,3)); diff --git a/modules/signal_processing/tests/unit_tests/xcov.dia.ref b/modules/signal_processing/tests/unit_tests/xcov.dia.ref new file mode 100755 index 000000000..6f34cfe3a --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/xcov.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +x=[1 2 3 4 3 2 1]; +assert_checktrue(xcorr(x-mean(x))==xcov(x)); +x=[1 2*%i 3 4 3 2 1]; +assert_checktrue(xcorr(x-mean(x))==xcov(x)); +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1]; +assert_checktrue(xcorr(x-mean(x),y-mean(y))==xcov(x,y)); +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1+%i]; +assert_checktrue(xcorr(x-mean(x),y-mean(y))==xcov(x,y)); diff --git a/modules/signal_processing/tests/unit_tests/xcov.tst b/modules/signal_processing/tests/unit_tests/xcov.tst new file mode 100755 index 000000000..be086dfe0 --- /dev/null +++ b/modules/signal_processing/tests/unit_tests/xcov.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +x=[1 2 3 4 3 2 1]; +assert_checktrue(xcorr(x-mean(x))==xcov(x)); + +x=[1 2*%i 3 4 3 2 1]; +assert_checktrue(xcorr(x-mean(x))==xcov(x)); + + +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1]; +assert_checktrue(xcorr(x-mean(x),y-mean(y))==xcov(x,y)); + +x=[1 2 3 4 3 2 1]; +y=[4 3 2 1+%i]; + +assert_checktrue(xcorr(x-mean(x),y-mean(y))==xcov(x,y)); |