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/fftw/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/fftw/tests')
34 files changed, 3325 insertions, 0 deletions
diff --git a/modules/fftw/tests/benchmarks/bench_fft.tst b/modules/fftw/tests/benchmarks/bench_fft.tst new file mode 100755 index 000000000..4bc004833 --- /dev/null +++ b/modules/fftw/tests/benchmarks/bench_fft.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//============================================================================== +// Benchmark for fft function +//============================================================================== + +a = 0; b = 0; +stacksize(30000000); +a = rand(800000, 1, 'n'); + +// <-- BENCH START --> + b = fft(a, -1); +// <-- BENCH END --> + diff --git a/modules/fftw/tests/nonreg_tests/bug_10807.dia.ref b/modules/fftw/tests/nonreg_tests/bug_10807.dia.ref new file mode 100755 index 000000000..faf19f4a4 --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_10807.dia.ref @@ -0,0 +1,41 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10807 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10807 +// +// <-- Short Description --> +// It was not possible to overload fft and fftw for list, tlist, mlist type +// +M = mlist(['V', 'name', 'value'], ['a', 'b';'c' 'd'], [1 2; 3 4]); +if %fftw then + fname = "fftw"; + msgerr = [msprintf(gettext("Function not defined for given argument type(s),\n")); + msprintf(gettext(" check arguments or define function %s for overloading.\n"), "%V_" + fname)]; + assert_checkerror ("fft(M)", msgerr); + msgerr = [msprintf(gettext("Function not defined for given argument type(s),\n")); + msprintf(gettext(" check arguments or define function %s for overloading.\n"), "%V_" + fname)]; + assert_checkerror ("fftw(M)", msgerr); + function bOK = %V_fftw(X) + bOK = %T; + endfunction + assert_checktrue(fft(M)); + assert_checktrue(fftw(M)); +else + fname = "fft"; + msgerr = [msprintf(gettext("Function not defined for given argument type(s),\n")); + msprintf(gettext(" check arguments or define function %s for overloading.\n"), "%V_" + fname)]; + assert_checkerror ("fft(M)", msgerr); + function bOK = %V_fft(X) + bOK = %T; + endfunction + assert_checktrue(fft(M)); +end diff --git a/modules/fftw/tests/nonreg_tests/bug_10807.tst b/modules/fftw/tests/nonreg_tests/bug_10807.tst new file mode 100755 index 000000000..f1e210ca5 --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_10807.tst @@ -0,0 +1,47 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10807 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10807 +// +// <-- Short Description --> +// It was not possible to overload fft and fftw for list, tlist, mlist type +// + +M = mlist(['V', 'name', 'value'], ['a', 'b';'c' 'd'], [1 2; 3 4]); + +if %fftw then + fname = "fftw"; + msgerr = [msprintf(gettext("Function not defined for given argument type(s),\n")); + msprintf(gettext(" check arguments or define function %s for overloading.\n"), "%V_" + fname)]; + assert_checkerror ("fft(M)", msgerr); + + msgerr = [msprintf(gettext("Function not defined for given argument type(s),\n")); + msprintf(gettext(" check arguments or define function %s for overloading.\n"), "%V_" + fname)]; + assert_checkerror ("fftw(M)", msgerr); + + function bOK = %V_fftw(X) + bOK = %T; + endfunction + + assert_checktrue(fft(M)); + assert_checktrue(fftw(M)); +else + fname = "fft"; + msgerr = [msprintf(gettext("Function not defined for given argument type(s),\n")); + msprintf(gettext(" check arguments or define function %s for overloading.\n"), "%V_" + fname)]; + assert_checkerror ("fft(M)", msgerr); + + function bOK = %V_fft(X) + bOK = %T; + endfunction + assert_checktrue(fft(M)); +end diff --git a/modules/fftw/tests/nonreg_tests/bug_5081.dia.ref b/modules/fftw/tests/nonreg_tests/bug_5081.dia.ref new file mode 100755 index 000000000..e91d3e591 --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_5081.dia.ref @@ -0,0 +1,31 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 5081 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5081 +// +// <-- Short Description --> +// +// demo "Signal Processing" --> "Spectral Estimation" fails (Windows) + rand('normal'); + rand('seed',0); + x = rand(1:1024-33+1); + nf = 33; + bedge = [0 .1;.125 .5]; + des = [1 0]; + wate = [1 1]; + h = eqfir(nf,bedge,des,wate); + h1 = [h 0*ones(1:max(size(x))-1)]; + x1 = [x 0*ones(1:max(size(h))-1)]; + hf = fft(h1,-1); + xf = fft(x1,-1); + yf = hf.*xf; + y = real(fft(yf,1)); + ierr = execstr("[sm2] = cspect(100,200,''tr'',y);","errcatch"); + if ierr <> 0 then bugmes();quit;end diff --git a/modules/fftw/tests/nonreg_tests/bug_5081.tst b/modules/fftw/tests/nonreg_tests/bug_5081.tst new file mode 100755 index 000000000..eed3aa93b --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_5081.tst @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 5081 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5081 +// +// <-- Short Description --> +// +// demo "Signal Processing" --> "Spectral Estimation" fails (Windows) + + rand('normal'); + rand('seed',0); + x = rand(1:1024-33+1); + nf = 33; + bedge = [0 .1;.125 .5]; + des = [1 0]; + wate = [1 1]; + h = eqfir(nf,bedge,des,wate); + h1 = [h 0*ones(1:max(size(x))-1)]; + x1 = [x 0*ones(1:max(size(h))-1)]; + hf = fft(h1,-1); + xf = fft(x1,-1); + yf = hf.*xf; + y = real(fft(yf,1)); + ierr = execstr("[sm2] = cspect(100,200,''tr'',y);","errcatch"); + if ierr <> 0 then pause,end diff --git a/modules/fftw/tests/nonreg_tests/bug_8390.tst b/modules/fftw/tests/nonreg_tests/bug_8390.tst new file mode 100755 index 000000000..ca6a74bed --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_8390.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// 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 --> +// +// <-- INTERACTIVE TEST --> +// +// <-- Non-regression test for bug 8390 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8390 +// +// <-- Short Description --> +// a "Warning : redefining function: mputl" displayed if you did not install fftw on Windows. +// +// +// install scilab without fftw module +// check that you do not have this warning
\ No newline at end of file diff --git a/modules/fftw/tests/nonreg_tests/bug_9266.dia.ref b/modules/fftw/tests/nonreg_tests/bug_9266.dia.ref new file mode 100755 index 000000000..0344d7626 --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_9266.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9266 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9266 +// +// <-- Short Description --> +// +// fftw crashed on Windows with MKL wrapper +// (install scilab on windows with fftw support and MKL wrapper) +a = rand(3, 3); +r = fftw(a); +ref = [ 5.0053826 , -1.0513065 + 0.6838074*%i, -1.0513065 - 0.6838074*%i ; .. + -0.4155955 - 0.5198981*%i, -0.2145198-0.3890532*%i, 0.1296924-1.0547338*%i ; .. + - 0.4155955 + 0.5198981*%i, 0.1296924 + 1.0547338*%i, - 0.2145198 + 0.3890532*%i ]; +assert_checkalmostequal(r, ref, %eps * 10e8); diff --git a/modules/fftw/tests/nonreg_tests/bug_9266.tst b/modules/fftw/tests/nonreg_tests/bug_9266.tst new file mode 100755 index 000000000..8edacfac6 --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_9266.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9266 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9266 +// +// <-- Short Description --> +// +// fftw crashed on Windows with MKL wrapper +// (install scilab on windows with fftw support and MKL wrapper) + +a = rand(3, 3); +r = fftw(a); + +ref = [ 5.0053826 , -1.0513065 + 0.6838074*%i, -1.0513065 - 0.6838074*%i ; .. + -0.4155955 - 0.5198981*%i, -0.2145198-0.3890532*%i, 0.1296924-1.0547338*%i ; .. + - 0.4155955 + 0.5198981*%i, 0.1296924 + 1.0547338*%i, - 0.2145198 + 0.3890532*%i ]; + +assert_checkalmostequal(r, ref, %eps * 10e8); diff --git a/modules/fftw/tests/nonreg_tests/bug_9647.dia.ref b/modules/fftw/tests/nonreg_tests/bug_9647.dia.ref new file mode 100755 index 000000000..690669b8a --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_9647.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9647 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9647 +// +// <-- Short Description --> +// On Scilab startup, the variable fft was declared by default while it should not. +// +if %fftw then + assert_checkequal(isdef("fft"), %T); + assert_checkequal(funptr("fft"), funptr("fftw")); +else + assert_checkequal(isdef("fft"), %F); +end diff --git a/modules/fftw/tests/nonreg_tests/bug_9647.tst b/modules/fftw/tests/nonreg_tests/bug_9647.tst new file mode 100755 index 000000000..a9842b1ab --- /dev/null +++ b/modules/fftw/tests/nonreg_tests/bug_9647.tst @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9647 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9647 +// +// <-- Short Description --> +// On Scilab startup, the variable fft was declared by default while it should not. +// + +if %fftw then + assert_checkequal(isdef("fft"), %T); + assert_checkequal(funptr("fft"), funptr("fftw")); +else + assert_checkequal(isdef("fft"), %F); +end diff --git a/modules/fftw/tests/unit_tests/dct_part1.dia.ref b/modules/fftw/tests/unit_tests/dct_part1.dia.ref new file mode 100755 index 000000000..4b91d3c8c --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part1.dia.ref @@ -0,0 +1,133 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//============================================================================================ +//=================================dct(A [,isn ]) ============================================ +//============================================================================================ +//*****1-D transform ************************************************************************* +//Real case +x=1:12; +y=dct(x); +y_ref=[22.516660498395403,-11.8786642686858634,0,-1.28774657627874833,0,-0.43698525004935185,0,.. + -0.19742775076373928,0,-0.09151733141338797,0,-0.02710534350890513]; +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +x=[2;8;1;3;7;6;8;7;9;1;6;7;7;2;5;2;2;2;9;7;3]; +y_ref=[22.6946605845432074;1.10519574266518794;-2.3241759528540804;-4.85151174144696462; + 1.0125846934610252;-1.1922212636993892;1.59557416291812504;4.54344111251121419; + -2.5559634218592766;0.60407624058440501;-2.30214098713630388; 3.897143024186624; + -4.1080570985039806;-4.03538258536340688;-2.00594354950719467;-1.38969746761551849; + -1.83219922773155397;-2.95095934890382949;-1.53744081244562425;-1.30413301180655994; + 4.3041816147747296]; +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +//Complex case +x=[9+%i*4,2+%i*3,3+%i*6,4+%i*4,3+%i*9,6+%i,5+%i*5,3+%i*3,6+%i*4,5+%i*3]; +y_ref=complex(dct(real(x)),dct(imag(x))); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +//*****2-D transform ************************************************************************* +//Real case +x=matrix([1 5 -3 7 0.3 -1 23 -0.5 -0.9 2 -7 23],3,4); +y_ref=[14.1162140816863513,-8.0479004090282249,-1.9918584287042105,3.4272874122786048; + 5.26794551983977577,8.50616086908862101,-17.2887608000110866,12.1283851880283517; + 11.3288900603721974,-15.5570935550615044,-0.30618621784789912,-0.91342220197659429]; +//assert_checkalmostequal(DCTN(x,-1),y_ref); +y=dct(x); +assert_checkalmostequal(y,y_ref); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x); +x = [5,0,8,8,6,4,3,2,4; + 4,5,2,4,6,9,5,6,8; + 3,3,1,4,7,9,3,8,6; + 6,4,7,9,9,3,5,0,5; + 4,3,2,1,5,4,5,7,2; + 9,1,7,2,3,7,1,2,8]; +y_ref = [34.5650219259403997,-1.78710447324021815,-2.48169728021161573,0.16666666666666699,.. + 5.69563532864431199,-0.59272882615611178,2.21317603189356582,3.3056243529158942,.. + 0.77159656358327178; + 1.97808522199214609,-1.62888466797664266,-3.52915941330826,-1.81698729810778037,.. + -0.00057916618067070,0.72759134820032212,-0.49562009306186250,-1.52634899725477169,.. + -1.64182890117946090; + -2,2.0255789396616728,2.39977639282567701,-1.02062072615965738,-0.21623417629893263,.. + -0.33673269589600086,4.59619407771255872,3.58705650694926259,1.2017970067515158; + -1.632993161855452,4.54779009715027005,-3.28900566318474974,-2.5,-2.3230729643967232,.. + 4.37582606600885970,0.28867513459481303,-2.32803596885859054,3.9415445893237928; + 0.7698003589195008,3.99972019170555404,-1.83426711715667090,-4.12478955692152738,.. + 2.28878659482871472,0.71653818014654680,4.42268981335851574,1.16186166799936497,.. + 1.59242235450869574; + -2.92089426357420923,-3.87026979368244106,0.33153838264147889,2.68301270189221830,.. + -1.42188370601683456,1.21560492170039569,-3.67104657360480369,2.74425230353935490,.. + -2.13332925728981504]; +//assert_checkalmostequal(DCTN(x,-1),y_ref); +y=dct(x); +assert_checkalmostequal(y,y_ref,1000*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +//Complex case +x=[1+%i*4, 8+%i*4; 2+%i*9, 1+%i; 7+%i*2, 2+%i*6; 7+%i*6, 8+%i*7]; +y_ref=complex(dct(real(x)),dct(imag(x))); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +//*****N-D transform ************************************************************************* +function y=DCTN(y,flag) + for i=1:ndims(y),y=dct(y,flag,i),end +endfunction +//Real case +x=matrix([2,8,1,3,7,6,8,7,9,1,6,7,7,2,5,2,2,2,9,7,3,9,2,3,.. + 4,3,6,5,3,6,5,4,3,6,4,9,1,5,3,4,3,1,8,2,1,7,2,7],[3,4,4]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x); +x=matrix([5,1,10,2,0,8,1,10,7,2,5,8,8,1,8,3],[2 2 2 2]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +x=matrix([5,1,10,2,0,8,1,10,7,2,5,8,8,1,8,3],[1 2 2 2 2]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +x=matrix([2,8,1,3,7,6,8,7,9,1,6,7,7,2,5,2,2,2,9,7,3,9,2,3,... + 4,3,6,5,3,6,5,4,3,6,4,9,11,5,3,4,3,1,8,2,1,7,2,7,... + 8,4,4,9,1,2,6,6,7,9,5,3,4,9,9,3,4,7,3,5,3,5,5,1,... + 2,6,8,5,7,2,4,8,6,5,2,8,1,3,9,8,5,10,6,10,1,7,4,6],[3,4,2 4]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,100*%eps); +//Complex case +x=matrix([3,3+%i*8,6+%i,1+%i*9,6,7+%i*2,3+%i*5,%i*7,5+%i*9,4+%i*2,2+%i*6,5+%i*3,4+%i*4,... + 3+%i*9,1+%i*8,6+%i*8,3+%i*3,7+%i*4,5+%i*4,3+%i*7,7+%i*8,1+%i*4,4+%i*8,7+%i*5,... + 9+%i,2+%i*10,4+%i*2,10,5+%i*8,5+%i,6+%i*10,6+%i*7,5+%i*2,8+%i*5,8+%i*8,10+%i*8,... + 8+%i,4+%i*8,2+%i*3,9+%i*3,1+%i*10,5+%i*9,4+%i*2,%i*9,5+%i*7,8+%i*9,6,2+%i*2],[3,4,1,4]); +y_ref=dct(real(x))+%i*(dct(imag(x))); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); diff --git a/modules/fftw/tests/unit_tests/dct_part1.tst b/modules/fftw/tests/unit_tests/dct_part1.tst new file mode 100755 index 000000000..3a2475e70 --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part1.tst @@ -0,0 +1,151 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//============================================================================================ +//=================================dct(A [,isn ]) ============================================ +//============================================================================================ +//*****1-D transform ************************************************************************* +//Real case +x=1:12; +y=dct(x); +y_ref=[22.516660498395403,-11.8786642686858634,0,-1.28774657627874833,0,-0.43698525004935185,0,.. + -0.19742775076373928,0,-0.09151733141338797,0,-0.02710534350890513]; +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); + +x=[2;8;1;3;7;6;8;7;9;1;6;7;7;2;5;2;2;2;9;7;3]; +y_ref=[22.6946605845432074;1.10519574266518794;-2.3241759528540804;-4.85151174144696462; + 1.0125846934610252;-1.1922212636993892;1.59557416291812504;4.54344111251121419; + -2.5559634218592766;0.60407624058440501;-2.30214098713630388; 3.897143024186624; + -4.1080570985039806;-4.03538258536340688;-2.00594354950719467;-1.38969746761551849; + -1.83219922773155397;-2.95095934890382949;-1.53744081244562425;-1.30413301180655994; + 4.3041816147747296]; +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); + +//Complex case +x=[9+%i*4,2+%i*3,3+%i*6,4+%i*4,3+%i*9,6+%i,5+%i*5,3+%i*3,6+%i*4,5+%i*3]; + +y_ref=complex(dct(real(x)),dct(imag(x))); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +//*****2-D transform ************************************************************************* +//Real case +x=matrix([1 5 -3 7 0.3 -1 23 -0.5 -0.9 2 -7 23],3,4); +y_ref=[14.1162140816863513,-8.0479004090282249,-1.9918584287042105,3.4272874122786048; + 5.26794551983977577,8.50616086908862101,-17.2887608000110866,12.1283851880283517; + 11.3288900603721974,-15.5570935550615044,-0.30618621784789912,-0.91342220197659429]; + +//assert_checkalmostequal(DCTN(x,-1),y_ref); + +y=dct(x); +assert_checkalmostequal(y,y_ref); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref); +assert_checktrue(isreal(y)); + +assert_checkalmostequal(dct(y,1),x); + + +x = [5,0,8,8,6,4,3,2,4; + 4,5,2,4,6,9,5,6,8; + 3,3,1,4,7,9,3,8,6; + 6,4,7,9,9,3,5,0,5; + 4,3,2,1,5,4,5,7,2; + 9,1,7,2,3,7,1,2,8]; +y_ref = [34.5650219259403997,-1.78710447324021815,-2.48169728021161573,0.16666666666666699,.. + 5.69563532864431199,-0.59272882615611178,2.21317603189356582,3.3056243529158942,.. + 0.77159656358327178; + 1.97808522199214609,-1.62888466797664266,-3.52915941330826,-1.81698729810778037,.. + -0.00057916618067070,0.72759134820032212,-0.49562009306186250,-1.52634899725477169,.. + -1.64182890117946090; + -2,2.0255789396616728,2.39977639282567701,-1.02062072615965738,-0.21623417629893263,.. + -0.33673269589600086,4.59619407771255872,3.58705650694926259,1.2017970067515158; + -1.632993161855452,4.54779009715027005,-3.28900566318474974,-2.5,-2.3230729643967232,.. + 4.37582606600885970,0.28867513459481303,-2.32803596885859054,3.9415445893237928; + 0.7698003589195008,3.99972019170555404,-1.83426711715667090,-4.12478955692152738,.. + 2.28878659482871472,0.71653818014654680,4.42268981335851574,1.16186166799936497,.. + 1.59242235450869574; + -2.92089426357420923,-3.87026979368244106,0.33153838264147889,2.68301270189221830,.. + -1.42188370601683456,1.21560492170039569,-3.67104657360480369,2.74425230353935490,.. + -2.13332925728981504]; +//assert_checkalmostequal(DCTN(x,-1),y_ref); +y=dct(x); +assert_checkalmostequal(y,y_ref,1000*%eps); +assert_checktrue(isreal(y)); + +assert_checkalmostequal(dct(y,1),x,0,100*%eps); + +//Complex case +x=[1+%i*4, 8+%i*4; 2+%i*9, 1+%i; 7+%i*2, 2+%i*6; 7+%i*6, 8+%i*7]; +y_ref=complex(dct(real(x)),dct(imag(x))); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); +//*****N-D transform ************************************************************************* +function y=DCTN(y,flag) + for i=1:ndims(y),y=dct(y,flag,i),end +endfunction + +//Real case +x=matrix([2,8,1,3,7,6,8,7,9,1,6,7,7,2,5,2,2,2,9,7,3,9,2,3,.. + 4,3,6,5,3,6,5,4,3,6,4,9,1,5,3,4,3,1,8,2,1,7,2,7],[3,4,4]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +y=dct(x,-1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1),x); + +x=matrix([5,1,10,2,0,8,1,10,7,2,5,8,8,1,8,3],[2 2 2 2]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); + +x=matrix([5,1,10,2,0,8,1,10,7,2,5,8,8,1,8,3],[1 2 2 2 2]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); + + +x=matrix([2,8,1,3,7,6,8,7,9,1,6,7,7,2,5,2,2,2,9,7,3,9,2,3,... + 4,3,6,5,3,6,5,4,3,6,4,9,11,5,3,4,3,1,8,2,1,7,2,7,... + 8,4,4,9,1,2,6,6,7,9,5,3,4,9,9,3,4,7,3,5,3,5,5,1,... + 2,6,8,5,7,2,4,8,6,5,2,8,1,3,9,8,5,10,6,10,1,7,4,6],[3,4,2 4]); +y_ref=DCTN(x,-1); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,100*%eps); + +//Complex case +x=matrix([3,3+%i*8,6+%i,1+%i*9,6,7+%i*2,3+%i*5,%i*7,5+%i*9,4+%i*2,2+%i*6,5+%i*3,4+%i*4,... + 3+%i*9,1+%i*8,6+%i*8,3+%i*3,7+%i*4,5+%i*4,3+%i*7,7+%i*8,1+%i*4,4+%i*8,7+%i*5,... + 9+%i,2+%i*10,4+%i*2,10,5+%i*8,5+%i,6+%i*10,6+%i*7,5+%i*2,8+%i*5,8+%i*8,10+%i*8,... + 8+%i,4+%i*8,2+%i*3,9+%i*3,1+%i*10,5+%i*9,4+%i*2,%i*9,5+%i*7,8+%i*9,6,2+%i*2],[3,4,1,4]); +y_ref=dct(real(x))+%i*(dct(imag(x))); +y=dct(x); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1),x,0,100*%eps); diff --git a/modules/fftw/tests/unit_tests/dct_part2.dia.ref b/modules/fftw/tests/unit_tests/dct_part2.dia.ref new file mode 100755 index 000000000..b185f0a0f --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part2.dia.ref @@ -0,0 +1,181 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//============================================================================================ +//=================================dct(A ,isn, sel) ============================================ +//============================================================================================== +function x=DCT(y,flag,sel) + x=y; + Dims=size(y) + ind=1:ndims(y) + ind(sel)=[]; + I=list(); + for k=1:ndims(y),I(k)=:;end + select size(ind,'*') + case 1 then + for i1=1:Dims(ind) + I(ind)=i1; + x(I(:))=dct(y(I(:))); + end + case 2 then + for i1=1:Dims(ind(1)) + I(ind(1))=i1; + for i2=1:Dims(ind(2)) + I(ind(2))=i2; + x(I(:))=dct(y(I(:))); + end + end + case 3 then + for i1=1:Dims(ind(1)) + I(ind(1))=i1; + for i2=1:Dims(ind(2)) + I(ind(2))=i2; + for i3=1:Dims(ind(3)) + I(ind(3))=i3; + x(I(:))=dct(y(I(:))); + end + end + end + else + error('not handled') + end +endfunction +//*****multiple 1-D transform ****************************************************************** +//Real case +x=matrix(1:12,3,4); +y_ref=x;for i2=1:4,y_ref(:,i2)=dct(x(:,i2));end +y=dct(x,-1,1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,1),x,0,100*%eps); +y_ref=x;for i1=1:3,y_ref(i1,:)=dct(x(i1,:));end +y=dct(x,-1,2); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,2),x,0,100*%eps); +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,4,2]); +y_ref=x;for i1=1:3,for i3=1:2,y_ref(i1,:,i3)=dct(x(i1,:,i3));end;end +y=dct(x,-1,2); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,2),x,0,100*%eps); +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,1,4,2]); +y_ref=x;for i1=1:3,for i4=1:2,y_ref(i1,1,:,i4)=dct(x(i1,1,:,i4));end;end +y=dct(x,-1,3); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,3),x,0,100*%eps); +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,1,4,2]); +y_ref=x;for i1=1:3,for i3=1:4,y_ref(i1,1,i3,:)=dct(x(i1,1,i3,:));end;end +y=dct(x,-1,4); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,4),x,0,100*%eps); +//Complex case +x=matrix( [ 9+%i*9, 8+%i*4, 4+%i*6, 8+%i*8, 1+%i*8, 1+%i*6, 5+%i*4, 4+%i*7, ... + 6+%i*5, 9+%i*6, 1+%i*10, 4+%i*2, 9+%i*5,%i*2, 9+%i*6, 9+%i*4, 9, ... + 8+%i*6,%i*7,%i*9, 5+%i, 4+%i*3, 8, 5+%i*6],[3,1,4,2]); +y_ref=x;for i1=1:3,for i3=1:4,y_ref(i1,1,i3,:)=dct(x(i1,1,i3,:));end;end +y=dct(x,-1,4); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1,4),x,0,100*%eps); +//*****multiple 2-D transform ****************************************************************** +//Real case +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,4,2]); +sel=[2 3]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,1,4,2]); +sel=[1 3]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[1,3,4,2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +x=matrix([6,4,5,5,1,9,7,1,1,5,8,1,7,2,2,4,4,2,3,1,4,7,1,6,4,... + 2,2,6,9,7,3,2,2,7,6,9,6,8,1,7,6,8,8,1,2,3,5,7],[3,2,1,4,2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +//Complex case +x=matrix([6+%i,4,5,5,1,9,7,1,1,5,8,1,7,2,2,4,4,2,3,1,4,7,1,6,4,... + 2,2,6,9,7,3,2,2,7,6,9,6,8,1,7,6,8,8-%i,1,2,3,5,7],[3,2,1,4,2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +//*****multiple N-D transform ****************************************************************** +//Real case +x=matrix([2,8,1,3,7,6,8,7,9,1,6,7,7,2,5,2,2,2,9,7,3,9,2,3,... + 4,3,6,5,3,6,5,4,3,6,4,9,11,5,3,4,3,1,8,2,1,7,2,7,... + 8,4,4,9,1,2,6,6,7,9,5,3,4,9,9,3,4,7,3,5,3,5,5,1,... + 2,6,8,5,7,2,4,8,6,5,2,8,1,3,9,8,5,10,6,10,1,7,4,6],[3,4,2 4]); +sel=[1 3 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +sel=[1 2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +x=matrix([5,8,8,4,2,2,2,9,0,2,6,7,6,0,2,9,1,3,4,6,4,3,1,8,0,4,7,2,9,7,2,3,9,1,5,7,.. + 8,6,4,7,1,2,9,3,7,0,2,10,9,1,9,5,9,9,2,0,0,7,5,1,5,8,4,4,8,0,10,10,7,10,... + 8,5,2,9,0,7,2,8,4,3,6,8,9,6,6,9,6,5,7,9,7,5,9,6,4,7,3,6,0,9,10,6,6,3,10,... + 8,9,5,1,7,9,0,8,6,1,8,5,2,8,8,7,4,3,6,0,9,3,2,5,1,10,7,8,5,7,5,7,1,7,3,9,... + 8,5,4,9,0,5,2,1,10,5,2,1,9,9,6,7,2,9,8,3,2,6,2,5,6,4,1,5,1,3,9,2,2,1,7,10,... + 9,7,8,8,10,2,5,7,4,5,8,3,9,2,9,9,10,1,8,9,7,6,8,1,5,0,10,8,6,8,4,8,4,6,9,3,... + 9,4,2,4,3,5,4,3,3,0,5,7,7,3,6,7,4,2,9,9,4,4,6,7,9,3,10,1,1,7,8,8,3,5,4,3,3,... + 9,10,1,6,2,0,6,0,3,1,2,2,4,1,3,1,8,6,3,4,5,1,10,7,9,10,3,6,2,6,6,5,2,1,8,6,... + 6,7,1,1,8,6,4,3,9,10,1,4,7,2,10,7,1,4,5,5,5,8,3,9,7,2,1,3,1,3,4,2,0,4,5,1,10,... + 7,1,9,8,5,9,5,3,6,4,9,0,8,3,1,6,9,4,3,4,8,2,5,1,5,3,0,2,3,1,10,3,1,9,9,8,2],[3 2 3 4 5]); +sel=[2 3 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +x=matrix([5,8,8,4,2,2,2,9,0,2,6,7,6,0,2,9,1,3,4,6,4,3,1,8,0,4,7,2,9,7,2,3,9,1,5,7,.. + 8,6,4,7,1,2,9,3,7,0,2,10,9,1,9,5,9,9,2,0,0,7,5,1,5,8,4,4,8,0,10,10,7,10,... + 8,5,2,9,0,7,2,8,4,3,6,8,9,6,6,9,6,5,7,9,7,5,9,6,4,7,3,6,0,9,10,6,6,3,10,... + 8,9,5,1,7,9,0,8,6,1,8,5,2,8,8,7,4,3,6,0,9,3,2,5,1,10,7,8,5,7,5,7,1,7,3,9,... + 8,5,4,9,0,5,2,1,10,5,2,1,9,9,6,7,2,9,8,3,2,6,2,5,6,4,1,5,1,3,9,2,2,1,7,10,... + 9,7,8,8,10,2,5,7,4,5,8,3,9,2,9,9,10,1,8,9,7,6,8,1,5,0,10,8,6,8,4,8,4,6,9,3,... + 9,4,2,4,3,5,4,3,3,0,5,7,7,3,6,7,4,2,9,9,4,4,6,7,9,3,10,1,1,7,8,8,3,5,4,3,3,... + 9,10,1,6,2,0,6,0,3,1,2,2,4,1,3,1,8,6,3,4,5,1,10,7,9,10,3,6,2,6,6,5,2,1,8,6,... + 6,7,1,1,8,6,4,3,9,10,1,4,7,2,10,7,1,4,5,5,5,8,3,9,7,2,1,3,1,3,4,2,0,4,5,1,10,... + 7,1,9,8,5,9,5,3,6,4,9,0,8,3,1,6,9,4,3,4,8,2,5,1,5,3,0,2,3,1,10,3,1,9,9,8,2],[3 2 1 3 4 5]); +sel=[2 4 5]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); +x=matrix([9,8,8,8,6,5,5,9,8,1,1,9,4,10,8,6,0,7,2,5,6,8,2,1,7,1,1,6,8,6,4,3],[2 2 2 2 2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); diff --git a/modules/fftw/tests/unit_tests/dct_part2.tst b/modules/fftw/tests/unit_tests/dct_part2.tst new file mode 100755 index 000000000..06de11424 --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part2.tst @@ -0,0 +1,204 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//============================================================================================ +//=================================dct(A ,isn, sel) ============================================ +//============================================================================================== +function x=DCT(y,flag,sel) + x=y; + Dims=size(y) + ind=1:ndims(y) + ind(sel)=[]; + I=list(); + for k=1:ndims(y),I(k)=:;end + select size(ind,'*') + case 1 then + for i1=1:Dims(ind) + I(ind)=i1; + x(I(:))=dct(y(I(:))); + end + case 2 then + for i1=1:Dims(ind(1)) + I(ind(1))=i1; + for i2=1:Dims(ind(2)) + I(ind(2))=i2; + x(I(:))=dct(y(I(:))); + end + end + case 3 then + for i1=1:Dims(ind(1)) + I(ind(1))=i1; + for i2=1:Dims(ind(2)) + I(ind(2))=i2; + for i3=1:Dims(ind(3)) + I(ind(3))=i3; + x(I(:))=dct(y(I(:))); + end + end + end + + else + error('not handled') + end +endfunction + +//*****multiple 1-D transform ****************************************************************** +//Real case +x=matrix(1:12,3,4); +y_ref=x;for i2=1:4,y_ref(:,i2)=dct(x(:,i2));end +y=dct(x,-1,1); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,1),x,0,100*%eps); + +y_ref=x;for i1=1:3,y_ref(i1,:)=dct(x(i1,:));end +y=dct(x,-1,2); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,2),x,0,100*%eps); + +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,4,2]); +y_ref=x;for i1=1:3,for i3=1:2,y_ref(i1,:,i3)=dct(x(i1,:,i3));end;end +y=dct(x,-1,2); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,2),x,0,100*%eps); + +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,1,4,2]); +y_ref=x;for i1=1:3,for i4=1:2,y_ref(i1,1,:,i4)=dct(x(i1,1,:,i4));end;end +y=dct(x,-1,3); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,3),x,0,100*%eps); + +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,1,4,2]); +y_ref=x;for i1=1:3,for i3=1:4,y_ref(i1,1,i3,:)=dct(x(i1,1,i3,:));end;end +y=dct(x,-1,4); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,4),x,0,100*%eps); + +//Complex case +x=matrix( [ 9+%i*9, 8+%i*4, 4+%i*6, 8+%i*8, 1+%i*8, 1+%i*6, 5+%i*4, 4+%i*7, ... + 6+%i*5, 9+%i*6, 1+%i*10, 4+%i*2, 9+%i*5,%i*2, 9+%i*6, 9+%i*4, 9, ... + 8+%i*6,%i*7,%i*9, 5+%i, 4+%i*3, 8, 5+%i*6],[3,1,4,2]); +y_ref=x;for i1=1:3,for i3=1:4,y_ref(i1,1,i3,:)=dct(x(i1,1,i3,:));end;end +y=dct(x,-1,4); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1,4),x,0,100*%eps); + +//*****multiple 2-D transform ****************************************************************** +//Real case +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,4,2]); +sel=[2 3]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[3,1,4,2]); +sel=[1 3]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +x=matrix([7,1,8,3,5,6,2,8,6,3,10,9,3,1,9,7,9,4,6,7,7,4,1,5],[1,3,4,2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +x=matrix([6,4,5,5,1,9,7,1,1,5,8,1,7,2,2,4,4,2,3,1,4,7,1,6,4,... + 2,2,6,9,7,3,2,2,7,6,9,6,8,1,7,6,8,8,1,2,3,5,7],[3,2,1,4,2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +//Complex case +x=matrix([6+%i,4,5,5,1,9,7,1,1,5,8,1,7,2,2,4,4,2,3,1,4,7,1,6,4,... + 2,2,6,9,7,3,2,2,7,6,9,6,8,1,7,6,8,8-%i,1,2,3,5,7],[3,2,1,4,2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +//*****multiple N-D transform ****************************************************************** +//Real case + + +x=matrix([2,8,1,3,7,6,8,7,9,1,6,7,7,2,5,2,2,2,9,7,3,9,2,3,... + 4,3,6,5,3,6,5,4,3,6,4,9,11,5,3,4,3,1,8,2,1,7,2,7,... + 8,4,4,9,1,2,6,6,7,9,5,3,4,9,9,3,4,7,3,5,3,5,5,1,... + 2,6,8,5,7,2,4,8,6,5,2,8,1,3,9,8,5,10,6,10,1,7,4,6],[3,4,2 4]); +sel=[1 3 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +sel=[1 2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + + +x=matrix([5,8,8,4,2,2,2,9,0,2,6,7,6,0,2,9,1,3,4,6,4,3,1,8,0,4,7,2,9,7,2,3,9,1,5,7,.. + 8,6,4,7,1,2,9,3,7,0,2,10,9,1,9,5,9,9,2,0,0,7,5,1,5,8,4,4,8,0,10,10,7,10,... + 8,5,2,9,0,7,2,8,4,3,6,8,9,6,6,9,6,5,7,9,7,5,9,6,4,7,3,6,0,9,10,6,6,3,10,... + 8,9,5,1,7,9,0,8,6,1,8,5,2,8,8,7,4,3,6,0,9,3,2,5,1,10,7,8,5,7,5,7,1,7,3,9,... + 8,5,4,9,0,5,2,1,10,5,2,1,9,9,6,7,2,9,8,3,2,6,2,5,6,4,1,5,1,3,9,2,2,1,7,10,... + 9,7,8,8,10,2,5,7,4,5,8,3,9,2,9,9,10,1,8,9,7,6,8,1,5,0,10,8,6,8,4,8,4,6,9,3,... + 9,4,2,4,3,5,4,3,3,0,5,7,7,3,6,7,4,2,9,9,4,4,6,7,9,3,10,1,1,7,8,8,3,5,4,3,3,... + 9,10,1,6,2,0,6,0,3,1,2,2,4,1,3,1,8,6,3,4,5,1,10,7,9,10,3,6,2,6,6,5,2,1,8,6,... + 6,7,1,1,8,6,4,3,9,10,1,4,7,2,10,7,1,4,5,5,5,8,3,9,7,2,1,3,1,3,4,2,0,4,5,1,10,... + 7,1,9,8,5,9,5,3,6,4,9,0,8,3,1,6,9,4,3,4,8,2,5,1,5,3,0,2,3,1,10,3,1,9,9,8,2],[3 2 3 4 5]); +sel=[2 3 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +x=matrix([5,8,8,4,2,2,2,9,0,2,6,7,6,0,2,9,1,3,4,6,4,3,1,8,0,4,7,2,9,7,2,3,9,1,5,7,.. + 8,6,4,7,1,2,9,3,7,0,2,10,9,1,9,5,9,9,2,0,0,7,5,1,5,8,4,4,8,0,10,10,7,10,... + 8,5,2,9,0,7,2,8,4,3,6,8,9,6,6,9,6,5,7,9,7,5,9,6,4,7,3,6,0,9,10,6,6,3,10,... + 8,9,5,1,7,9,0,8,6,1,8,5,2,8,8,7,4,3,6,0,9,3,2,5,1,10,7,8,5,7,5,7,1,7,3,9,... + 8,5,4,9,0,5,2,1,10,5,2,1,9,9,6,7,2,9,8,3,2,6,2,5,6,4,1,5,1,3,9,2,2,1,7,10,... + 9,7,8,8,10,2,5,7,4,5,8,3,9,2,9,9,10,1,8,9,7,6,8,1,5,0,10,8,6,8,4,8,4,6,9,3,... + 9,4,2,4,3,5,4,3,3,0,5,7,7,3,6,7,4,2,9,9,4,4,6,7,9,3,10,1,1,7,8,8,3,5,4,3,3,... + 9,10,1,6,2,0,6,0,3,1,2,2,4,1,3,1,8,6,3,4,5,1,10,7,9,10,3,6,2,6,6,5,2,1,8,6,... + 6,7,1,1,8,6,4,3,9,10,1,4,7,2,10,7,1,4,5,5,5,8,3,9,7,2,1,3,1,3,4,2,0,4,5,1,10,... + 7,1,9,8,5,9,5,3,6,4,9,0,8,3,1,6,9,4,3,4,8,2,5,1,5,3,0,2,3,1,10,3,1,9,9,8,2],[3 2 1 3 4 5]); + +sel=[2 4 5]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); + +x=matrix([9,8,8,8,6,5,5,9,8,1,1,9,4,10,8,6,0,7,2,5,6,8,2,1,7,1,1,6,8,6,4,3],[2 2 2 2 2]); +sel=[2 4]; +y_ref=DCT(x,-1,sel); +y=dct(x,-1,sel); +assert_checkalmostequal(y,y_ref,0,100*%eps); +assert_checktrue(isreal(y)); +assert_checkalmostequal(dct(y,1,sel),x,0,100*%eps); diff --git a/modules/fftw/tests/unit_tests/dct_part3.dia.ref b/modules/fftw/tests/unit_tests/dct_part3.dia.ref new file mode 100755 index 000000000..ec6969825 --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part3.dia.ref @@ -0,0 +1,65 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//============================================================================================ +//=================================dct(A ,isn, dim, incr) ============================================ +//============================================================================================== +//*****multiple 1-D transform ****************************************************************** +//Real case +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 5 1 -1]; +y=matrix(dct(A(:),-1,4,1),size(A)); +assert_checkalmostequal(y,dct(A,-1,1),0,100*%eps); +y1=matrix(dct(y(:),1,4,1),size(A)); +assert_checkalmostequal(y1,dct(y,1,1),0,100*%eps); +y=matrix(dct(A(:),-1,3,4),size(A)); +assert_checkalmostequal(y,dct(A,-1,2),0,100*%eps); +y1=matrix(dct(y(:),1,3,4),size(A)); +assert_checkalmostequal(y1,dct(y,1,2),0,100*%eps); +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(dct(A,-1,20,1),[5*4 9 5 6]); +assert_checkalmostequal(y,dct(matrix(A,[5*4 9 5 6]),-1,1),0,100*%eps); +y=matrix(dct(A,-1,45,20),[5*4 9*5 6]); +assert_checkalmostequal(y,dct(matrix(A,[5*4 9*5 6]),-1,2),0,100*%eps); +y1=matrix(dct(y(:),1,45,20),size(A)); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A,0,100*%eps); +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(dct(A(:),-1,[9 5],[20 180]),[5 4 9 5 6]); +y1=dct(matrix(A,[5 4 9 5 6]),-1,[3 4]); +assert_checkalmostequal(y,y1,0,100*%eps); +y1=dct(y(:),1,[9 5],[20 180]); +assert_checkalmostequal(A(:),y1,0,100*%eps); +assert_checktrue(isreal(y1)); +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y1=dct(matrix(A,[5 4 9 5 6]),-1,[2 4]); +y=matrix(dct(A(:),-1,[4 5],[5 180]),[5 4 9 5 6]); +assert_checkalmostequal(y,y1,0,100*%eps); +y1=dct(y(:),1,[4 5],[5 180]); +assert_checkalmostequal(A(:),y1,10*%eps,100*%eps); +assert_checktrue(isreal(y1)); +//complex case +A=[%i 1 1 + 2 -1+3*%i -1; + 3 4 4; + 5*%i 1 -1]; +y=matrix(dct(A(:),-1,4,1),size(A)); +assert_checkalmostequal(y,dct(A,-1,1),0,100*%eps); +y1=matrix(dct(y(:),1,4,1),size(A)); +assert_checkalmostequal(y1,dct(y,1,1),0,100*%eps); +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims))+%i*rand(1,prod(Dims)); +y1=dct(matrix(A,[5 4 9 5 6]),-1,[2 4]); +y=matrix(dct(A(:),-1,[4 5],[5 180]),[5 4 9 5 6]); +assert_checkalmostequal(y,y1,0,100*%eps); +y1=dct(y(:),1,[4 5],[5 180]); +assert_checkalmostequal(A(:),y1,10*%eps,100*%eps); diff --git a/modules/fftw/tests/unit_tests/dct_part3.tst b/modules/fftw/tests/unit_tests/dct_part3.tst new file mode 100755 index 000000000..9139f63af --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part3.tst @@ -0,0 +1,83 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - INRIA - Serge STEER +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//============================================================================================ +//=================================dct(A ,isn, dim, incr) ============================================ +//============================================================================================== +//*****multiple 1-D transform ****************************************************************** +//Real case +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 5 1 -1]; +y=matrix(dct(A(:),-1,4,1),size(A)); +assert_checkalmostequal(y,dct(A,-1,1),0,100*%eps); +y1=matrix(dct(y(:),1,4,1),size(A)); +assert_checkalmostequal(y1,dct(y,1,1),0,100*%eps); + +y=matrix(dct(A(:),-1,3,4),size(A)); +assert_checkalmostequal(y,dct(A,-1,2),0,100*%eps); +y1=matrix(dct(y(:),1,3,4),size(A)); +assert_checkalmostequal(y1,dct(y,1,2),0,100*%eps); + +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(dct(A,-1,20,1),[5*4 9 5 6]); +assert_checkalmostequal(y,dct(matrix(A,[5*4 9 5 6]),-1,1),0,100*%eps); + +y=matrix(dct(A,-1,45,20),[5*4 9*5 6]); +assert_checkalmostequal(y,dct(matrix(A,[5*4 9*5 6]),-1,2),0,100*%eps); +y1=matrix(dct(y(:),1,45,20),size(A)); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A,0,100*%eps); + +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(dct(A(:),-1,[9 5],[20 180]),[5 4 9 5 6]); +y1=dct(matrix(A,[5 4 9 5 6]),-1,[3 4]); +assert_checkalmostequal(y,y1,0,100*%eps); + +y1=dct(y(:),1,[9 5],[20 180]); +assert_checkalmostequal(A(:),y1,0,100*%eps); +assert_checktrue(isreal(y1)); + + +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y1=dct(matrix(A,[5 4 9 5 6]),-1,[2 4]); + +y=matrix(dct(A(:),-1,[4 5],[5 180]),[5 4 9 5 6]); + +assert_checkalmostequal(y,y1,0,100*%eps); + +y1=dct(y(:),1,[4 5],[5 180]); +assert_checkalmostequal(A(:),y1,10*%eps,100*%eps); +assert_checktrue(isreal(y1)); + +//complex case +A=[%i 1 1 + 2 -1+3*%i -1; + 3 4 4; + 5*%i 1 -1]; +y=matrix(dct(A(:),-1,4,1),size(A)); +assert_checkalmostequal(y,dct(A,-1,1),0,100*%eps); +y1=matrix(dct(y(:),1,4,1),size(A)); +assert_checkalmostequal(y1,dct(y,1,1),0,100*%eps); + + +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims))+%i*rand(1,prod(Dims)); +y1=dct(matrix(A,[5 4 9 5 6]),-1,[2 4]); + +y=matrix(dct(A(:),-1,[4 5],[5 180]),[5 4 9 5 6]); + +assert_checkalmostequal(y,y1,0,100*%eps); + +y1=dct(y(:),1,[4 5],[5 180]); +assert_checkalmostequal(A(:),y1,10*%eps,100*%eps); diff --git a/modules/fftw/tests/unit_tests/dct_part4.dia.ref b/modules/fftw/tests/unit_tests/dct_part4.dia.ref new file mode 100755 index 000000000..9e359a081 --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part4.dia.ref @@ -0,0 +1,33 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +// Here only option specific cases are checked because the other parts +// are common with dct_part[1 2 3].tst +//============================================================================================ +//=================================dct(A, ..., option) ============================================ +//============================================================================================== +//DCT-II, DCT, IDCT, DCT-III +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5]; +n=15; +assert_checkequal(dct(A),dct(A,"dct")); +assert_checkequal(dct(A,1),dct(A,1,"idct")); +assert_checkalmostequal(dct(A)./dct(A,"dct2"),[0.5 ones(1,n-1)/sqrt(2)]/sqrt(n));//unnormalized +A=matrix([1 5 -3 7 0.3 -1 23 -0.5 -0.9 2 -7 23],3,4); +assert_checkequal(dct(A),dct(A,"dct")); +assert_checkequal(dct(A,1),dct(A,1,"idct")); +[m,n]=size(A); +y_ref=diag([0.5 ones(1,m-1)/sqrt(2)]/sqrt(m))*dct(A,"dct2")*diag([0.5 ones(1,n-1)/sqrt(2)]/sqrt(n)); +assert_checkalmostequal(dct(A),y_ref); +//dct-I +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5];n=15; +y_ref=A(1)+(-1).^(0:n-1)*A(n)+2*sum((A(2:n-1)'*ones(1,n)).*cos(%pi*(1:n-2)'*(0:n-1)/(n-1)),1); +assert_checkalmostequal(dct(A,"dct1"),y_ref); +//dct-IV +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5];n=15; +y_ref=2*sum((A'*ones(1,n)).*cos(%pi*(0.5:n)'*(0.5:n)/n),1); +assert_checkalmostequal(dct(A,-1,"dct4"),y_ref); +assert_checkalmostequal(dct(dct(A,-1,"dct4"),1,"dct4"),2*n*A); diff --git a/modules/fftw/tests/unit_tests/dct_part4.tst b/modules/fftw/tests/unit_tests/dct_part4.tst new file mode 100755 index 000000000..2f3ae8412 --- /dev/null +++ b/modules/fftw/tests/unit_tests/dct_part4.tst @@ -0,0 +1,40 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> +// Here only option specific cases are checked because the other parts +// are common with dct_part[1 2 3].tst +//============================================================================================ +//=================================dct(A, ..., option) ============================================ +//============================================================================================== +//DCT-II, DCT, IDCT, DCT-III +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5]; +n=15; +assert_checkequal(dct(A),dct(A,"dct")); +assert_checkequal(dct(A,1),dct(A,1,"idct")); + +assert_checkalmostequal(dct(A)./dct(A,"dct2"),[0.5 ones(1,n-1)/sqrt(2)]/sqrt(n));//unnormalized + +A=matrix([1 5 -3 7 0.3 -1 23 -0.5 -0.9 2 -7 23],3,4); +assert_checkequal(dct(A),dct(A,"dct")); +assert_checkequal(dct(A,1),dct(A,1,"idct")); + +[m,n]=size(A); +y_ref=diag([0.5 ones(1,m-1)/sqrt(2)]/sqrt(m))*dct(A,"dct2")*diag([0.5 ones(1,n-1)/sqrt(2)]/sqrt(n)); +assert_checkalmostequal(dct(A),y_ref); + +//dct-I +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5];n=15; +y_ref=A(1)+(-1).^(0:n-1)*A(n)+2*sum((A(2:n-1)'*ones(1,n)).*cos(%pi*(1:n-2)'*(0:n-1)/(n-1)),1); +assert_checkalmostequal(dct(A,"dct1"),y_ref); + + +//dct-IV +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5];n=15; +y_ref=2*sum((A'*ones(1,n)).*cos(%pi*(0.5:n)'*(0.5:n)/n),1); +assert_checkalmostequal(dct(A,-1,"dct4"),y_ref); +assert_checkalmostequal(dct(dct(A,-1,"dct4"),1,"dct4"),2*n*A); diff --git a/modules/fftw/tests/unit_tests/dst.dia.ref b/modules/fftw/tests/unit_tests/dst.dia.ref new file mode 100755 index 000000000..f0a43935d --- /dev/null +++ b/modules/fftw/tests/unit_tests/dst.dia.ref @@ -0,0 +1,48 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +// Here only 1d dst computations are checked, because the dst gateway +// is a clone of the dct one. +//real cases +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5]; +n=15; +//DST-I +y_ref=2*sum((A'*ones(1,n)).*sin(%pi*(1:n)'*(1:n)/(n+1)),1); +assert_checkalmostequal(dst(A,-1,"dst1"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst1"),1,"dst1"),2*(n+1)*A); +//DST-II +y_ref=2*sum((A'*ones(1,n)).*sin(%pi*(0.5:n)'*(1:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst2"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst2"),1,"dst3"),2*n*A); +//DST-III +y_ref=((-1).^(0:n-1))*A(n)+ 2*sum((A(1:n-1)'*ones(1,n)).*sin(%pi*(1:n-1)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,1,"dst3"),y_ref); +assert_checkalmostequal(dst(dst(A,1,"dst3"),-1,"dst2"),2*n*A); +//DST-iV +y_ref=2*sum((A'*ones(1,n)).*sin(%pi*(0.5:n)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst4"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst4"),1,"dst4"),2*n*A); +//complex cases +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5]+%i*[2 2 2 9 7 3 9 2 3 4 3 6 5 3 6]; +n=15; +//DST-I +y_ref=2*sum((A.'*ones(1,n)).*sin(%pi*(1:n)'*(1:n)/(n+1)),1); +assert_checkalmostequal(dst(A,-1,"dst1"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst1"),1,"dst1"),2*(n+1)*A); +//DST-II +y_ref=2*sum((A.'*ones(1,n)).*sin(%pi*(0.5:n)'*(1:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst2"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst2"),1,"dst3"),2*n*A); +//DST-III +y_ref=((-1).^(0:n-1))*A(n)+ 2*sum((A(1:n-1).'*ones(1,n)).*sin(%pi*(1:n-1)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,1,"dst3"),y_ref,100*%eps,104*%eps); +assert_checkalmostequal(dst(dst(A,1,"dst3"),-1,"dst2"),2*n*A); +//DST-iV +y_ref=2*sum((A.'*ones(1,n)).*sin(%pi*(0.5:n)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst4"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst4"),1,"dst4"),2*n*A); +//complex cases diff --git a/modules/fftw/tests/unit_tests/dst.tst b/modules/fftw/tests/unit_tests/dst.tst new file mode 100755 index 000000000..9064d00c0 --- /dev/null +++ b/modules/fftw/tests/unit_tests/dst.tst @@ -0,0 +1,60 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +// Here only 1d dst computations are checked, because the dst gateway +// is a clone of the dct one. +//real cases +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5]; +n=15; +//DST-I +y_ref=2*sum((A'*ones(1,n)).*sin(%pi*(1:n)'*(1:n)/(n+1)),1); +assert_checkalmostequal(dst(A,-1,"dst1"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst1"),1,"dst1"),2*(n+1)*A); + +//DST-II +y_ref=2*sum((A'*ones(1,n)).*sin(%pi*(0.5:n)'*(1:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst2"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst2"),1,"dst3"),2*n*A); + +//DST-III +y_ref=((-1).^(0:n-1))*A(n)+ 2*sum((A(1:n-1)'*ones(1,n)).*sin(%pi*(1:n-1)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,1,"dst3"),y_ref); +assert_checkalmostequal(dst(dst(A,1,"dst3"),-1,"dst2"),2*n*A); + + +//DST-iV +y_ref=2*sum((A'*ones(1,n)).*sin(%pi*(0.5:n)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst4"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst4"),1,"dst4"),2*n*A); +//complex cases + +A=[2,8,-1,3,7,6,8,7,9,1,6,7,7,2,5]+%i*[2 2 2 9 7 3 9 2 3 4 3 6 5 3 6]; +n=15; +//DST-I +y_ref=2*sum((A.'*ones(1,n)).*sin(%pi*(1:n)'*(1:n)/(n+1)),1); +assert_checkalmostequal(dst(A,-1,"dst1"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst1"),1,"dst1"),2*(n+1)*A); + +//DST-II +y_ref=2*sum((A.'*ones(1,n)).*sin(%pi*(0.5:n)'*(1:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst2"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst2"),1,"dst3"),2*n*A); + +//DST-III +y_ref=((-1).^(0:n-1))*A(n)+ 2*sum((A(1:n-1).'*ones(1,n)).*sin(%pi*(1:n-1)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,1,"dst3"),y_ref,100*%eps,104*%eps); +assert_checkalmostequal(dst(dst(A,1,"dst3"),-1,"dst2"),2*n*A); + + +//DST-iV +y_ref=2*sum((A.'*ones(1,n)).*sin(%pi*(0.5:n)'*(0.5:n)/(n)),1); +assert_checkalmostequal(dst(A,-1,"dst4"),y_ref); +assert_checkalmostequal(dst(dst(A,-1,"dst4"),1,"dst4"),2*n*A); +//complex cases + diff --git a/modules/fftw/tests/unit_tests/fftw_flag.dia.ref b/modules/fftw/tests/unit_tests/fftw_flag.dia.ref new file mode 100755 index 000000000..816865bf1 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_flag.dia.ref @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +//============================================= +ff = fftw_flags(); +assert_checkequal(double(ff),64); +//============================================= +//change flags +r = fftw_flags(["FFTW_MEASURE";"FFTW_CONSERVE_MEMORY"]); +assert_checkequal(double(r),4); +//============================================= +//change flags and display current value of fftw flags (both integer and strings) +[a,S]=fftw_flags("FFTW_PATIENT"); +assert_checkequal(double(a),32); +assert_checkequal(S,'FFTW_PATIENT'); +//============================================= diff --git a/modules/fftw/tests/unit_tests/fftw_flag.tst b/modules/fftw/tests/unit_tests/fftw_flag.tst new file mode 100755 index 000000000..818164883 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_flag.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +//============================================= +ff = fftw_flags(); +assert_checkequal(double(ff),64); +//============================================= +//change flags +r = fftw_flags(["FFTW_MEASURE";"FFTW_CONSERVE_MEMORY"]); +assert_checkequal(double(r),4); +//============================================= +//change flags and display current value of fftw flags (both integer and strings) +[a,S]=fftw_flags("FFTW_PATIENT"); +assert_checkequal(double(a),32); +assert_checkequal(S,'FFTW_PATIENT'); +//============================================= diff --git a/modules/fftw/tests/unit_tests/fftw_part1.dia.ref b/modules/fftw/tests/unit_tests/fftw_part1.dia.ref new file mode 100755 index 000000000..ca8492ec5 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part1.dia.ref @@ -0,0 +1,272 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//============================================================================================ +//=================================fft(A [,isn [,flag]]) ===================================== +//============================================================================================ +//1-D transform ****************************************************************************** +//R2C case ------------------------------------------------------------------------------------ +assert_checkequal(fft(1:4),[10,-2+%i*2,-2,-2-%i*2]); +assert_checkequal(ifft(1:4),conj(fft(1:4)/4)); +assert_checkequal(fft(1:4,-1),[10,-2+%i*2,-2,-2-%i*2]); +assert_checkequal(fft(1:4,1),conj(fft(1:4,-1)/4)); +//C2R case ------------------------------------------------------------------------------------ +// ODD case +A=[1 0 %i -%i 0]; +y=fft(A); +y_ref=[1, 2.17557050458494672, -0.902113032590307062, 2.90211303259030728, -0.17557050458494649]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,-1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1)); +// EVEN case +A=[1 0 %i 2 -%i 0]; +y=fft(A); +y_ref=[3, 0.73205080756887719, 1.2679491924311228,-1, 4.7320508075688767,-2.73205080756887719]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,-1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1),10*%eps,10*%eps); +//R2R case ------------------------------------------------------------------------------------ +// ODD case +y=fft(1); +assert_checktrue(isreal(y)); +assert_checkequal(y,1); +A=[0 1 2 2 1]; +y=fft(A); +y_ref=[6,-2.61803398874989446, -0.381966011250104875, -0.381966011250104875, -2.61803398874989446]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),10*%eps,10*%eps); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +// EVEN case +A=1:2; +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,[3 -1]); +assert_checkalmostequal(A,ifft(y),10*%eps,10*%eps); +A=[0 1 2 5 2 1]; +y=fft(A); +y_ref=[11,-6, 2,-3, 2,-6]; +assert_checktrue(isreal(y)); +assert_checkequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),10*%eps,10*%eps); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +//C2C case ------------------------------------------------------------------------------------ +A=[1+%i 2 5*%i -8+5*%i]; +y=fft(A); +y_ref=[-5+%i*11,-4-%i*14, 7+%i, 6+%i*6]; +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); +//2-D transform ******************************************************************************* +//R2R case ------------------------------------------------------------------------------------ +// ODD X EVEN case +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 2 -1 -1]; +y=fft(A); +y_ref=[ 13, 4, 4; + -9, 0, 0; + 13,-8,-8; + -9, 0, 0]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +// EVEN X EVEN case +A=[0 1 5 1 + 2 -1 6 -1 + 3 4 7 4 + 2 -1 6 -1]; +y=fft(A); +y_ref=[37, -17, 25,-17; + -11, -1, 1, -1; + 13, -1,-15, -1; + -11, -1, 1, -1]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +// ODD X ODD case +A=[0 1 1 + 2 -1 -1 + 2 -1 -1]; +y=fft(A); +y_ref=[ 2, 5, 5; + 2,-4,-4; + 2,-4,-4]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +A=[0 1 5 1 + 2 -1 6 -1 + 3 4 7 4 + 2 -1 6 -1]; +y=fft(A); +y_ref=[37, -17, 25,-17; + -11, -1, 1, -1; + 13, -1,-15, -1; + -11, -1, 1, -1]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +A=[1 2 3 3 2;4 6 9 11 8;5 7 10 10 7;4 8 11 9 6]; +y=fft(A); +y_ref=[ 126,-25.1803398874989490,-2.81966011250105097,-2.81966011250105097,-25.1803398874989490; + -28, 10.391435051850296,-1.68915303351051138, 1.21701707851093177,-1.91929909685071642; + -26, 6.2360679774997898, 1.76393202250021019, 1.76393202250021019, 6.2360679774997898; + -28,-1.91929909685071642, 1.21701707851093177,-1.68915303351051138, 10.391435051850296]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +//R2C case ------------------------------------------------------------------------------------ +A=[1 2 3;7 3 9;-1 5 4;0 8 -3]; +y=fft(A); +y_ref=[38, -8.5-%i*4.33012701892219276, -8.5+%i*4.33012701892219276; + -2-%i*14, 18.722431864335455-%i*1.76794919243112281 -10.7224318643354568-%i*5.23205080756887675; + -10, -5.5+%i*4.33012701892219276, -5.5-%i*4.33012701892219276; + -2+%i*14,-10.7224318643354568+%i*5.23205080756887675, 18.722431864335455+%i*1.76794919243112281]; +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +y=fft(A,1); +y_ref=[3.16666666666666607, -0.70833333333333326+%i*0.36084391824351614,-0.70833333333333326-%i*0.36084391824351614; + -0.16666666666666660+%i*1.16666666666666652, 1.56020265536128777+%i*0.14732909936926014,-0.89353598869462125+%i*0.43600423396407301; + -0.83333333333333337, -0.45833333333333320-%i*0.36084391824351603,-0.45833333333333320+%i*0.36084391824351603; + -0.16666666666666660-%i*1.16666666666666652,-0.89353598869462125-%i*0.43600423396407301,1.56020265536128777-%i*0.14732909936926014]; +assert_checkalmostequal(y,y_ref); +//C2R case +//------------------------------------------------------------------------------------ +// ODD X EVEN case +A=[0 %i -%i + 2+%i -1 -1 + 3 4 4 + 2-%i -1 -1]; +y=fft(A); +y_ref=[ 11, 6.7320508075688767, 3.2679491924311228; + -9, 4.7320508075688767, 1.2679491924311228; + 11,-5.26794919243112325, -8.7320508075688767; + -13, 0.73205080756887719, -2.73205080756887719]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +A=[1 2 3 3 2;4 6 9 11 8;5 7 10 10 7;4 8 11 9 6]; +y=fft(A); +y_ref=[ 126,-25.1803398874989490,-2.81966011250105097,-2.81966011250105097,-25.1803398874989490; + -28, 10.391435051850296,-1.68915303351051138, 1.21701707851093177,-1.91929909685071642; + -26, 6.2360679774997898, 1.76393202250021019, 1.76393202250021019, 6.2360679774997898; + -28,-1.91929909685071642, 1.21701707851093177,-1.68915303351051138, 10.391435051850296]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +// ODD X ODD case +A=[0 %i -%i + 2+%i -1 -1 + 2-%i -1 -1]; +y=fft(A); +y_ref=[0, 7.7320508075688767, 4.26794919243112325; + 1.73205080756887719, 0.46410161513775439, -3; + -1.73205080756887719,-2.99999999999999956, -6.46410161513775350]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +A=[1440, 32-%i*28,-102-%i*188,-102+%i*188, 32+%i*28; + 140-%i*52,-21+%i*14,-33+%i*8, 31+%i*77, 8+%i*169; + 30,-179+%i*40,-32-%i*175, 97-%i*107,-191-%i*147; + 20,-83-%i*162,-127+%i*71,-127-%i*71,-83+%i*162; + 30,-191+%i*147, 97+%i*107,-32+%i*175,-179-%i*40; + 140+%i*52, 8-%i*169, 31-%i*77,-33-%i*8,-21-%i*14]; +y=fft(A); +y_ref=[ 600, 1201.23812370118321, 2697.02967953848838, 2102.2365384314553, 2399.49565832887311; + 1800.35521029058418, 1800.85854102712074, 897.335302928384408, 598.365730980120588,2102.75200480588182; + 2097.89073857917083, 901.733860383104911, 600.566385143489583, 602.768240434540644,1796.70756549178577; + 900, 1503.68526108760511, 2698.74007483319838, 598.106629651731282, 299.468034427465; + 2.10926142082939805, 1797.22849022236483, 902.940272151356453, 1500.39858431578159,2697.65660185757633; + 2399.64478970941582, 898.55653188654594, 2102.57661444176256, 601.137293239859559,2098.41798069032438]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,1000*%eps); +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +//C2C case ------------------------------------------------------------------------------------ +A=[0 %i 3-%i + 2+%i -1 -1 + 3 4 4 + 2-3*%i -1 -1]; +y=fft(A); +y_ref=[14-%i*2, 5.23205080756887675+%i*0.59807621135331601,1.76794919243112281-%i*4.598076211353316; + -4, 5.23205080756887675+%i*2.598076211353316, 1.76794919243112281-%i*2.598076211353316; + 14+%i*2,-6.7679491924311233+%i*4.598076211353316, -10.2320508075688767-%i*0.59807621135331601; + -12, -2.76794919243112281+%i*2.598076211353316, -6.23205080756887675-%i*2.598076211353316]; +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); diff --git a/modules/fftw/tests/unit_tests/fftw_part1.tst b/modules/fftw/tests/unit_tests/fftw_part1.tst new file mode 100755 index 000000000..bf81aae80 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part1.tst @@ -0,0 +1,333 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//============================================================================================ +//=================================fft(A [,isn [,flag]]) ===================================== +//============================================================================================ + +//1-D transform ****************************************************************************** +//R2C case ------------------------------------------------------------------------------------ +assert_checkequal(fft(1:4),[10,-2+%i*2,-2,-2-%i*2]); +assert_checkequal(ifft(1:4),conj(fft(1:4)/4)); +assert_checkequal(fft(1:4,-1),[10,-2+%i*2,-2,-2-%i*2]); +assert_checkequal(fft(1:4,1),conj(fft(1:4,-1)/4)); +//C2R case ------------------------------------------------------------------------------------ +// ODD case +A=[1 0 %i -%i 0]; +y=fft(A); +y_ref=[1, 2.17557050458494672, -0.902113032590307062, 2.90211303259030728, -0.17557050458494649]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); + +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +y=fft(A,-1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1)); + +// EVEN case +A=[1 0 %i 2 -%i 0]; +y=fft(A); +y_ref=[3, 0.73205080756887719, 1.2679491924311228,-1, 4.7320508075688767,-2.73205080756887719]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,-1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1),10*%eps,10*%eps); + +//R2R case ------------------------------------------------------------------------------------ +// ODD case +y=fft(1); +assert_checktrue(isreal(y)); +assert_checkequal(y,1); + +A=[0 1 2 2 1]; +y=fft(A); +y_ref=[6,-2.61803398874989446, -0.381966011250104875, -0.381966011250104875, -2.61803398874989446]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),10*%eps,10*%eps); + +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + +// EVEN case +A=1:2; +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,[3 -1]); +assert_checkalmostequal(A,ifft(y),10*%eps,10*%eps); + +A=[0 1 2 5 2 1]; +y=fft(A); +y_ref=[11,-6, 2,-3, 2,-6]; +assert_checktrue(isreal(y)); +assert_checkequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),10*%eps,10*%eps); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +//C2C case ------------------------------------------------------------------------------------ +A=[1+%i 2 5*%i -8+5*%i]; +y=fft(A); +y_ref=[-5+%i*11,-4-%i*14, 7+%i, 6+%i*6]; +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); + +//2-D transform ******************************************************************************* + +//R2R case ------------------------------------------------------------------------------------ +// ODD X EVEN case +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 2 -1 -1]; +y=fft(A); +y_ref=[ 13, 4, 4; + -9, 0, 0; + 13,-8,-8; + -9, 0, 0]; + +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + + +// EVEN X EVEN case +A=[0 1 5 1 + 2 -1 6 -1 + 3 4 7 4 + 2 -1 6 -1]; +y=fft(A); +y_ref=[37, -17, 25,-17; + -11, -1, 1, -1; + 13, -1,-15, -1; + -11, -1, 1, -1]; + +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +// ODD X ODD case +A=[0 1 1 + 2 -1 -1 + 2 -1 -1]; +y=fft(A); +y_ref=[ 2, 5, 5; + 2,-4,-4; + 2,-4,-4]; + +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + +A=[0 1 5 1 + 2 -1 6 -1 + 3 4 7 4 + 2 -1 6 -1]; +y=fft(A); +y_ref=[37, -17, 25,-17; + -11, -1, 1, -1; + 13, -1,-15, -1; + -11, -1, 1, -1]; + +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +A=[1 2 3 3 2;4 6 9 11 8;5 7 10 10 7;4 8 11 9 6]; +y=fft(A); +y_ref=[ 126,-25.1803398874989490,-2.81966011250105097,-2.81966011250105097,-25.1803398874989490; + -28, 10.391435051850296,-1.68915303351051138, 1.21701707851093177,-1.91929909685071642; + -26, 6.2360679774997898, 1.76393202250021019, 1.76393202250021019, 6.2360679774997898; + -28,-1.91929909685071642, 1.21701707851093177,-1.68915303351051138, 10.391435051850296]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); + +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +//R2C case ------------------------------------------------------------------------------------ +A=[1 2 3;7 3 9;-1 5 4;0 8 -3]; +y=fft(A); +y_ref=[38, -8.5-%i*4.33012701892219276, -8.5+%i*4.33012701892219276; + -2-%i*14, 18.722431864335455-%i*1.76794919243112281 -10.7224318643354568-%i*5.23205080756887675; + -10, -5.5+%i*4.33012701892219276, -5.5-%i*4.33012701892219276; + -2+%i*14,-10.7224318643354568+%i*5.23205080756887675, 18.722431864335455+%i*1.76794919243112281]; +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + +y=fft(A,1); +y_ref=[3.16666666666666607, -0.70833333333333326+%i*0.36084391824351614,-0.70833333333333326-%i*0.36084391824351614; + -0.16666666666666660+%i*1.16666666666666652, 1.56020265536128777+%i*0.14732909936926014,-0.89353598869462125+%i*0.43600423396407301; + -0.83333333333333337, -0.45833333333333320-%i*0.36084391824351603,-0.45833333333333320+%i*0.36084391824351603; + -0.16666666666666660-%i*1.16666666666666652,-0.89353598869462125-%i*0.43600423396407301,1.56020265536128777-%i*0.14732909936926014]; +assert_checkalmostequal(y,y_ref); +//C2R case +//------------------------------------------------------------------------------------ +// ODD X EVEN case +A=[0 %i -%i + 2+%i -1 -1 + 3 4 4 + 2-%i -1 -1]; +y=fft(A); +y_ref=[ 11, 6.7320508075688767, 3.2679491924311228; + -9, 4.7320508075688767, 1.2679491924311228; + 11,-5.26794919243112325, -8.7320508075688767; + -13, 0.73205080756887719, -2.73205080756887719]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); +A=[1 2 3 3 2;4 6 9 11 8;5 7 10 10 7;4 8 11 9 6]; +y=fft(A); +y_ref=[ 126,-25.1803398874989490,-2.81966011250105097,-2.81966011250105097,-25.1803398874989490; + -28, 10.391435051850296,-1.68915303351051138, 1.21701707851093177,-1.91929909685071642; + -26, 6.2360679774997898, 1.76393202250021019, 1.76393202250021019, 6.2360679774997898; + -28,-1.91929909685071642, 1.21701707851093177,-1.68915303351051138, 10.391435051850296]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y)); + +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +// ODD X ODD case +A=[0 %i -%i + 2+%i -1 -1 + 2-%i -1 -1]; +y=fft(A); +y_ref=[0, 7.7320508075688767, 4.26794919243112325; + 1.73205080756887719, 0.46410161513775439, -3; + -1.73205080756887719,-2.99999999999999956, -6.46410161513775350]; + +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +A=[1440, 32-%i*28,-102-%i*188,-102+%i*188, 32+%i*28; + 140-%i*52,-21+%i*14,-33+%i*8, 31+%i*77, 8+%i*169; + 30,-179+%i*40,-32-%i*175, 97-%i*107,-191-%i*147; + 20,-83-%i*162,-127+%i*71,-127-%i*71,-83+%i*162; + 30,-191+%i*147, 97+%i*107,-32+%i*175,-179-%i*40; + 140+%i*52, 8-%i*169, 31-%i*77,-33-%i*8,-21-%i*14]; +y=fft(A); +y_ref=[ 600, 1201.23812370118321, 2697.02967953848838, 2102.2365384314553, 2399.49565832887311; + 1800.35521029058418, 1800.85854102712074, 897.335302928384408, 598.365730980120588,2102.75200480588182; + 2097.89073857917083, 901.733860383104911, 600.566385143489583, 602.768240434540644,1796.70756549178577; + 900, 1503.68526108760511, 2698.74007483319838, 598.106629651731282, 299.468034427465; + 2.10926142082939805, 1797.22849022236483, 902.940272151356453, 1500.39858431578159,2697.65660185757633; + 2399.64478970941582, 898.55653188654594, 2102.57661444176256, 601.137293239859559,2098.41798069032438]; +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,1000*%eps); + + +y=fft(A,-1,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,-1,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + + +//C2C case ------------------------------------------------------------------------------------ +A=[0 %i 3-%i + 2+%i -1 -1 + 3 4 4 + 2-3*%i -1 -1]; +y=fft(A); +y_ref=[14-%i*2, 5.23205080756887675+%i*0.59807621135331601,1.76794919243112281-%i*4.598076211353316; + -4, 5.23205080756887675+%i*2.598076211353316, 1.76794919243112281-%i*2.598076211353316; + 14+%i*2,-6.7679491924311233+%i*4.598076211353316, -10.2320508075688767-%i*0.59807621135331601; + -12, -2.76794919243112281+%i*2.598076211353316, -6.23205080756887675-%i*2.598076211353316]; +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,ifft(y),0,10*%eps); + + diff --git a/modules/fftw/tests/unit_tests/fftw_part2.dia.ref b/modules/fftw/tests/unit_tests/fftw_part2.dia.ref new file mode 100755 index 000000000..8d75478d4 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part2.dia.ref @@ -0,0 +1,386 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//3-D transform ******************************************************************************* +//R2R case ------------------------------------------------------------------------------------ +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 2 -1 -1]; +A(:,:,2)=A+1; +A(:,:,3)=A(:,:,2); +y_ref=matrix([63;-27;39;-27;12;0;-24;0;12;0;-24;0;-12; + 0;0;0;0;0;0;0;0;0;0;0; + -12;0;0;0;0;0;0;0;0;0;0;0],[4 3 3]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1),0,10*%eps); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1,"symmetric"),0,10*%eps); +y=fft(A,"nonsymmetric"); //use R2C +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1,"nonsymmetric"),0,10*%eps); +A=matrix([4750;-163;138;138;-163;-100;-2;9;-148;42;10;-301;246;246;-301;-100;42;-148;9;-2;-12;157; + -110;224;37;-101;-94;260;258;345;-49;175;227;110;161;65;-40;-182;161;-390;412;101;168; + 138;35;21;-95;-81;236;1;219;-215;120;284;-232;-35;-23;215;-191;122;412;35;138;168;101; + -35;122;-191;215;-23;219;-232;284;120;-215;21;1;236;-81;-95;-12;37;224;-110;157;65;-390; + 161;-182;-40;-49;161;110;227;175;-101;345;258;260;-94],[5,4,5]); +y_ref=matrix([ 9006; 1997.01835368650836; 7499.98164631349118; 7499.98164631349118; + 1997.01835368650836; 5500; 8003.03595972396761; 4499.30203473224719; + 3496.74144394796622; 4500.92056159581989; 7994; 4500.41996658886728; + 7002.58003341113272; 7002.58003341113272; 4500.41996658886728; 5500; + 4500.92056159581989; 3496.74144394796622; 4499.30203473224719; 8003.03595972396761; + 3003.23606797749972; 4503.21094298379558; 2498.80193260011856; 4500.56038652002371; + 3002.80933008143711; 1502.48409399493175; 4997.98726249178435; 6998.63971425121235; + 4503.41908441918713; 5499.99740938413652; 4000.79645449752343; 3004.49048964150825; + 3499; 4495.40709100495314; 4504.89210254386671; 5498.03152064027927; + 3999.73866895309675; 1500.9206722688125; 7001.49266501579041; 3003.15588613093223; + 2998.76393202250028; 5001.43961347997629; 5493.78905701620442; 6994.19066991856289; + 5003.19806739988144; 4499.2782026543191; 4996.34845842043978; 3004.96649100621744; + 7499.64517406068444; 5505.14335301404844; 4497.20354550247703; 3502.59290899504595; + 8498.50951035849175; 6998.10789745613329; 3499; 7000.20618271046988; + 5998.73979214458359; 3497.30757754890101; 2497.2015304242459; 3495.29626046592784; + 2998.76393202250028; 5003.19806739988144; 6994.19066991856289; 5493.78905701620442; + 5001.43961347997629; 7000.20618271046988; 3495.29626046592784; 2497.2015304242459; + 3497.30757754890101; 5998.73979214458359; 4497.20354550247703; 3499; + 6998.10789745613329; 8498.50951035849175; 3502.59290899504595; 4499.2782026543191; + 5505.14335301404844; 7499.64517406068444; 3004.96649100621744; 4996.34845842043978; + 3003.23606797749972; 3002.80933008143711; 4500.56038652002371; 2498.80193260011856; + 4503.21094298379558; 5498.03152064027927; 3003.15588613093223; 7001.49266501579041; + 1500.9206722688125; 3999.73866895309675; 4000.79645449752343; 4504.89210254386671; + 4495.40709100495314; 3499; 3004.49048964150825; 1502.48409399493175; + 5499.99740938413652; 4503.41908441918713; 6998.63971425121235; 4997.98726249178435],[5,4,5]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +//R2C case ------------------------------------------------------------------------------------ +A=matrix([5;4;3;6;4;9;0;5;3;4;3;1;8;2;1;7;2;7;8;4;4;9; + 1;2;6;6;7;9;5;3;4;9;9;3;4;7;3;5;3;5;5;1;2;6; + 8;0;7;2;4;8;6;5;2;8;1;3;9;8;5;10],[4,3,5]); +y_ref=matrix([ 290; 22+%i*4;-26; 22-%i*4; 9.5+%i*9.52627944162882301; + -1.1339745962155614+%i*17.1602540378443891;-3.5+%i*25.1147367097487191; + -2.8660254037844384+%i*0.16025403784438552; 9.5-%i*9.52627944162882301; + -2.8660254037844384-%i*0.16025403784438552;-3.5-%i*25.1147367097487191; + -1.1339745962155614-%i*17.1602540378443891;-10.9549150281252636-%i*1.37984007917967944; + 5.35973404130009712-%i*26.1183685942109989;-23.4614928368734752-%i*1.14281435514402396; + -3.59580201879988692+%i*23.0406850570357449;-21.3658553026453930-%i*8.84359942677465227; + 20.7330326917071268-%i*8.81688081018132586; 3.64531223802112692-%i*9.52499614355328994; + 7.43941996380932657-%i*16.867370295570808; 17.5396173813961269+%i*3.3290181678526012; + 15.0849628274577707+%i*11.593028238175755; 25.597333548226878-%i*1.41840966171390725; + -18.8967357079763296-%i*30.6614339614318183;-16.5450849718747364+%i*32.005406439473461; + -2.0005198567285527+%i*10.4427980896260522; 8.9614928368734752-%i*15.1639036975864734; + 8.23658783422834162-%i*9.7162555616206916;-4.97109202629695890-%i*8.30757202395887973; + 0.92910806515476718-%i*30.3790246133370161;-5.43718181239582421+%i*23.1017112524799586; + -14.884673669748171-%i*11.3804574337330209; 16.7973299475462241+%i*19.3569789554980396; + -0.44355669881229343+%i*5.1399061460535682;-7.8054639738521807-%i*7.52153572775482537; + -5.96155747159219818-%i*1.55370934855336351;-16.5450849718747364-%i*32.005406439473461; + 8.23658783422834162+%i*9.7162555616206916; 8.9614928368734752+%i*15.1639036975864734; + -2.0005198567285527-%i*10.4427980896260522; 16.7973299475462241-%i*19.3569789554980396; + -5.96155747159219818+%i*1.55370934855336351;-7.8054639738521807+%i*7.52153572775482537; + -0.44355669881229343-%i*5.1399061460535682;-4.97109202629695890+%i*8.30757202395887973; + -14.884673669748171+%i*11.3804574337330209;-5.43718181239582421-%i*23.1017112524799586; + 0.92910806515476718+%i*30.3790246133370161;-10.9549150281252636+%i*1.37984007917967944; + -3.59580201879988692-%i*23.0406850570357449;-23.4614928368734752+%i*1.14281435514402396; + 5.35973404130009712+%i*26.1183685942109989; 17.5396173813961269-%i*3.3290181678526012; + -18.8967357079763296+%i*30.6614339614318183; 25.597333548226878+%i*1.41840966171390725; + 15.0849628274577707-%i*11.593028238175755;-21.3658553026453930+%i*8.84359942677465227; + 7.43941996380932657+%i*16.867370295570808; 3.64531223802112692+%i*9.52499614355328994; + 20.7330326917071268+%i*8.81688081018132586],[4,3,5]); +y=fft(A); +assert_checkalmostequal(y,y_ref); +//C2R case ------------------------------------------------------------------------------------ +A=matrix([ 2900; 220+%i*40;-260; 220-%i*40; 95+%i*95;-11+%i*172;-35+%i*251;-29+%i*2; 95-%i*95; + -29-%i*2;-35-%i*251;-11-%i*172;-110-%i*14; 54-%i*261;-235-%i*11;-36+%i*230;-214-%i*88; + 207-%i*88; 36-%i*95; 74-%i*169; 175+%i*33; 151+%i*116; 256-%i*14;-189-%i*307; + -165+%i*320;-20+%i*104; 90-%i*152; 82-%i*97;-50-%i*83; 9-%i*304;-54+%i*231;-149-%i*114; + 168+%i*194;-4+%i*51;-78-%i*75;-60-%i*16;-165-%i*320; 82+%i*97; 90+%i*152;-20-%i*104; + 168-%i*194;-60+%i*16;-78+%i*75;-4-%i*51;-50+%i*83;-149+%i*114;-54-%i*231; 9+%i*304; + -110+%i*14;-36-%i*230;-235+%i*11; 54+%i*261; 175-%i*33;-189+%i*307; 256+%i*14; + 151-%i*116;-214+%i*88; 74+%i*169; 36+%i*95; 207+%i*88],[4,3,5]); +y_ref=matrix([ 2996; 3600; 1800; 2396; 1804.08726109815325; 601.420841162336728; 1797.20231832067839; + 2402.0440006453523; 2399.91273890184675; 2998.57915883766327; 2.79768167932161305; + 5401.95599935464725; 2396.96074950014463; 2999.02579525054898; 3601.07865923712325; + 4800.47728151174852; 5402.68357811465103; 5996.71587420499782; 2994.98775825329631; + 4800.7569165971172; 1194.78718041472757; 1801.42138987713292; 597.945126438306488; + 4795.69787130615623; 1806.28063851446973; 2996.33933739403255; 1802.22357633135243; + 2999.61398771896711; 4800.14227629597099; 1194.58106615498582; 4200.9816123952096; + -1.643335439786938; 3000.6599157117771; 3602.13659702117502; 1207.26152998727684; + 601.910475422587638; 3601.29217048561441; 5398.45474462091079; 4205.6200225335615; + 3606.49125722100416; 5397.78905489267254; 4200.45827894945342; 2396.05617461713109; + 1802.27482470993255; 3000.2119789042963; 5400.98960279924631; 2403.91117288032501; + 1800.15817472797062; 4799.46644149977146; 4206.18012273450677; 591.077741897962369; + 1197.41747354827976; 2398.62992927763071; 1199.93973694330134; 600.335830922918376; + 5401.45253626486101; 1201.09608638827149; 2403.75745404970803; 4798.52079450553538; + 4195.39253641116193],[4,3,5]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +//C2C case +//------------------------------------------------------------------------------------ +A=[0 %i 3-%i + 2+%i -1 -1 + 3 4 4 + 2-3*%i -1 -1]; +A(:,:,2)=A+1; +A(:,:,3)=A(:,:,2).*A(:,:,2); +y=fft(A); +y_ref=matrix([ 130-%i*22;-34-%i*14; 102+%i*10;-98+%i*2; 11.624355652982139+%i*5.18653347947321031; + 45.6243556529821319+%i*13.1865334794732103;-28.375644347017861+%i*37.1865334794732121; + -18.375644347017861+%i*29.1865334794732121;-12.624355652982139-%i*31.1865334794732121; + 21.3756443470178574-%i*23.1865334794732121;-52.6243556529821319+%i*0.81346652052678969; + -42.624355652982139-%i*7.18653347947321031;-30.1435935394489825+%i*63.4256258422040702; + 23.124355652982139-%i*12.0525588832576496;-33.464101615137757+%i*49.9615242270663131; + 29.2679491924311215-%i*54.6935750346351952;-0.90192378864668221-%i*5.2224318643354568; + -19.633974596215559+%i*23.2224318643354550;-16.2224318643354550-%i*18.6865334794732121; + -13.4903810567665765-%i*19.4185842870420871; 24.026279441628823-%i*6.83012701892219098; + 5.29422863405994804+%i*21.6147367097487226; 8.7057713659400484-%i*20.2942286340599445; + 11.4378221735089287-%i*21.026279441628823;-57.8564064605510140-%i*47.4256258422040702; + -1.1243556529821408+%i*26.0525588832576496;-26.5358983848622465-%i*53.9615242270663131; + 32.732050807568875+%i*52.6935750346351952; 4.97372055837117344+%i*1.83012701892219409; + -10.2942286340599463-%i*28.614736709748719; 24.2942286340599480-%i*4.705771365940052; + 23.5621778264910695-%i*1.9737205583711752;-6.09807621135331601+%i*24.2224318643354550; + -21.3660254037844375-%i*6.2224318643354586; 13.2224318643354550+%i*17.6865334794732085; + 12.4903810567665818+%i*20.4185842870420871],[4,3,3]); +assert_checkalmostequal(y,y_ref); +//N-D transform ******************************************************************************* +//R2R case ------------------------------------------------------------------------------------ +A=matrix([7090;265;265;180;-42;-198;30;15;15;180;-198;-42;160;235;-245;-335;135;182;240;-75;75; + -265;465;148;160;-245;235;-265;148;465;240;75;-75;-335;182;135;-410;446;204;-280;-253; + 353;-450;-198;-372;140;351;229;-48;236;-312;456;181;-279;262;-540;-50;363;385;-99;368; + 242;-6;-236;-71;-321;158;20;-90;397;109;195;-110;265;265;-120;-370;-110;-650;55;55;-120; + -110;-370;-20;-125;-245;91;-153;34;-80;85;-5;-151;-447;416;-20;-245;-125;-151;416;-447; + -80;-5;85;91;34;-153;-410;204;446;140;229;351;-450;-372;-198;-280;353;-253;368;-6;242; + 397;195;109;158;-90;20;-236;-321;-71;-48;-312;236;363;-99;385;262;-50;-540;456;-279;181],[3,4,3,4]); +y_ref=matrix([ 8640; 6480; 6480; 11520; 5760.26656797432588; 5039.73343202567412; 4320; 7200; 7200; + 11520; 5039.73343202567412; 5760.26656797432588; 4320; 2160; 2880; 9369.32603294810724; + 4323.73066958946401; 5040.79842187187296; 7200; 2160.00000000000045; 2880; + 12230.6739670518928; 3596.2693304105369; 12239.2015781281261; 4320; 2880; 2160; + 12230.6739670518928; 12239.2015781281261; 3596.2693304105369; 7200; 2880; + 2160.00000000000045; 9369.32603294810724; 5040.79842187187296; 4323.73066958946401; + 11520; 4318.1340241797152; 9361.8659758202848; 12240; 5046.12849930729499; + 7193.87150069270501; 7200; 10079.7334320256741; 10800.2665679743259; 2160; + 2164.52909146133834; 8635.47090853866212; 7923.73066958946401; 7196.80246635918866; + 8641.59812579485151; 7921.06627189730625; 6480.53313594865176; 10801.5994078459589; + 10079.2015781281261; 6482.39782971783188; 7198.66844217947437; 5759.73343202567321; + 9362.39911176893838; 5038.66716012836696; 7196.26933041053599; 13678.4018742051485; + 6483.19753364081134; 5038.93372810269375; 6478.40059215404108; 5039.46686405134824; + 2880.79842187187342; 1441.33155782052563; 9357.60217028216903; 6480.26656797432679; + 8641.33283987163304; 2877.60088823106116; 4320; 4320; 4320; 3600; 8639.20029607702054; + 10800.7997039229795; 12960; 8640; 8640; 3600; 10800.7997039229795; 8639.20029607702054; + 7920; 12960; 10800; 9365.06350946109706; 7196.00276243620829; 8637.60217028216721; + 10800; 720.000000000000455; 7920; 5034.93649053890294; 8643.99723756379171; + 5762.39782971783279; 7920; 10800; 12960; 5034.93649053890294; 5762.39782971783279; + 8643.99723756379171; 10800; 7920; 720.000000000000455; 9365.06350946109706; + 8637.60217028216721; 7196.00276243620829; 11520; 9361.8659758202848; 4318.1340241797152; + 2160; 8635.47090853866212; 2164.52909146133834; 7200; 10800.2665679743259; + 10079.7334320256741; 12240; 7193.87150069270501; 5046.12849930729499; + 7196.26933041053599; 6483.19753364081134; 13678.4018742051485; 6480.26656797432679; + 2877.60088823106116; 8641.33283987163304; 2880.79842187187342; 9357.60217028216903; + 1441.33155782052563; 5038.93372810269375; 5039.46686405134824; 6478.40059215404108; + 7923.73066958946401; 8641.59812579485151; 7196.80246635918866; 5759.73343202567321; + 5038.66716012836696; 9362.39911176893838; 10079.2015781281261; 7198.66844217947437; + 6482.39782971783188; 7921.06627189730625; 10801.5994078459589; 6480.53313594865176],[3,4,3,4]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +A=matrix([ 2900; 220+%i*40;-260; 220-%i*40; 95+%i*95;-11+%i*172;-35+%i*251;-29+%i*2; 95-%i*95; + -29-%i*2;-35-%i*251;-11-%i*172;-110-%i*14; 54-%i*261;-235-%i*11;-36+%i*230;-214-%i*88; + 207-%i*88; 36-%i*95; 74-%i*169; 175+%i*33; 151+%i*116; 256-%i*14;-189-%i*307; + -165+%i*320;-20+%i*104; 90-%i*152; 82-%i*97;-50-%i*83; 9-%i*304;-54+%i*231;-149-%i*114; + 168+%i*194;-4+%i*51;-78-%i*75;-60-%i*16;-165-%i*320; 82+%i*97; 90+%i*152;-20-%i*104; + 168-%i*194;-60+%i*16;-78+%i*75;-4-%i*51;-50+%i*83;-149+%i*114;-54-%i*231; 9+%i*304; + -110+%i*14;-36-%i*230;-235+%i*11; 54+%i*261; 175-%i*33;-189+%i*307; 256+%i*14; + 151-%i*116;-214+%i*88; 74+%i*169; 36+%i*95; 207+%i*88],[4,3,5]); +y_ref=matrix([ 2996; 3600; 1800; 2396; 1804.08726109815325; 601.420841162336728; 1797.20231832067839; + 2402.0440006453523; 2399.91273890184675; 2998.57915883766327; 2.79768167932161305; + 5401.95599935464725; 2396.96074950014463; 2999.02579525054898; 3601.07865923712325; + 4800.47728151174852; 5402.68357811465103; 5996.71587420499782; 2994.98775825329631; + 4800.7569165971172; 1194.78718041472757; 1801.42138987713292; 597.945126438306488; + 4795.69787130615623; 1806.28063851446973; 2996.33933739403255; 1802.22357633135243; + 2999.61398771896711; 4800.14227629597099; 1194.58106615498582; 4200.9816123952096; + -1.643335439786938; 3000.6599157117771; 3602.13659702117502; 1207.26152998727684; + 601.910475422587638; 3601.29217048561441; 5398.45474462091079; 4205.6200225335615; + 3606.49125722100416; 5397.78905489267254; 4200.45827894945342; 2396.05617461713109; + 1802.27482470993255; 3000.2119789042963; 5400.98960279924631; 2403.91117288032501; + 1800.15817472797062; 4799.46644149977146; 4206.18012273450677; 591.077741897962369; + 1197.41747354827976; 2398.62992927763071; 1199.93973694330134; 600.335830922918376; + 5401.45253626486101; 1201.09608638827149; 2403.75745404970803; 4798.52079450553538; + 4195.39253641116193],[4,3,5]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +//============================================================================================ +//=================================fft(A ,isn, sel [,flag]) ================================== +//============================================================================================ +//R2C and C2R case --------------------------------------------------------------------------- +// Multiple 1D transforms +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 5 1 -1]; +y_ref = [ 10, 5, 3; + -3+%i*3,-3+%i*2,-3; + -4, 5, 7; + -3-%i*3,-3-%i*2,-3]; +y=fft(A,-1,1); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,1,1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); +y_ref = [ 2.5, 1.25, 0.75; + -0.75-%i*0.75,-0.75-%i*0.5,-0.75; + -1, 1.25, 1.75; + -0.75+%i*0.75,-0.75+%i*0.5,-0.75]; +y=fft(A,1,1); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,-1,1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); +y_ref = [ 2,-1,-1; + 0, 3, 3; + 11,-1,-1; + 5, 5-%i*1.7320508, 5+%i*1.7320508]; +y=fft(A,-1,2); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,1,2); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); +y_ref = [ 0.66666666666666663,-0.33333333333333331,-0.33333333333333331; + 0, 1, 1; + 3.66666666666666652,-0.33333333333333326,-0.33333333333333326; + 1.66666666666666652, 1.66666666666666652+%i*0.57735026918962573,.. + 1.66666666666666652-%i*0.57735026918962573]; +y=fft(A,1,2); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,-1,2); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); +// Multiple 1D and 2D transforms of ND arrays +Dims=[5 3 4]; +A=matrix(1:60,Dims); +Sel=2; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end +Sel=3; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(2) + ind=list(i,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(2) + ind=list(i,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end +Sel=[1 2]; +y=fft(A,-1,Sel); +for j=1:Dims(3) + ind=list(:,:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(3) + ind=list(:,:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:))); +end +Sel=[1 3]; +y=fft(A,-1,Sel); +for j=1:Dims(2) + ind=list(:,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); +end +Dims=[5 3 4 7]; +A=matrix(1:prod(Dims),Dims); +Sel=[1 3 4]; +y=fft(A,-1,Sel); +for j=1:Dims(2) + ind=list(:,j,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j,:,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); +end +Sel=[2 4]; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end +Sel=3; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(2) + for k=1:Dims(4) + ind=list(i,j,:,k); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(2) + for k=1:Dims(4) + ind=list(i,j,:,k); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end + end +end diff --git a/modules/fftw/tests/unit_tests/fftw_part2.tst b/modules/fftw/tests/unit_tests/fftw_part2.tst new file mode 100755 index 000000000..afc9d67bd --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part2.tst @@ -0,0 +1,421 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//3-D transform ******************************************************************************* + +//R2R case ------------------------------------------------------------------------------------ +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 2 -1 -1]; +A(:,:,2)=A+1; +A(:,:,3)=A(:,:,2); +y_ref=matrix([63;-27;39;-27;12;0;-24;0;12;0;-24;0;-12; + 0;0;0;0;0;0;0;0;0;0;0; + -12;0;0;0;0;0;0;0;0;0;0;0],[4 3 3]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1),0,10*%eps); + +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1,"symmetric"),0,10*%eps); + +y=fft(A,"nonsymmetric"); //use R2C +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); +assert_checkalmostequal(A,fft(y,1,"nonsymmetric"),0,10*%eps); + + +A=matrix([4750;-163;138;138;-163;-100;-2;9;-148;42;10;-301;246;246;-301;-100;42;-148;9;-2;-12;157; + -110;224;37;-101;-94;260;258;345;-49;175;227;110;161;65;-40;-182;161;-390;412;101;168; + 138;35;21;-95;-81;236;1;219;-215;120;284;-232;-35;-23;215;-191;122;412;35;138;168;101; + -35;122;-191;215;-23;219;-232;284;120;-215;21;1;236;-81;-95;-12;37;224;-110;157;65;-390; + 161;-182;-40;-49;161;110;227;175;-101;345;258;260;-94],[5,4,5]); +y_ref=matrix([ 9006; 1997.01835368650836; 7499.98164631349118; 7499.98164631349118; + 1997.01835368650836; 5500; 8003.03595972396761; 4499.30203473224719; + 3496.74144394796622; 4500.92056159581989; 7994; 4500.41996658886728; + 7002.58003341113272; 7002.58003341113272; 4500.41996658886728; 5500; + 4500.92056159581989; 3496.74144394796622; 4499.30203473224719; 8003.03595972396761; + 3003.23606797749972; 4503.21094298379558; 2498.80193260011856; 4500.56038652002371; + 3002.80933008143711; 1502.48409399493175; 4997.98726249178435; 6998.63971425121235; + 4503.41908441918713; 5499.99740938413652; 4000.79645449752343; 3004.49048964150825; + 3499; 4495.40709100495314; 4504.89210254386671; 5498.03152064027927; + 3999.73866895309675; 1500.9206722688125; 7001.49266501579041; 3003.15588613093223; + 2998.76393202250028; 5001.43961347997629; 5493.78905701620442; 6994.19066991856289; + 5003.19806739988144; 4499.2782026543191; 4996.34845842043978; 3004.96649100621744; + 7499.64517406068444; 5505.14335301404844; 4497.20354550247703; 3502.59290899504595; + 8498.50951035849175; 6998.10789745613329; 3499; 7000.20618271046988; + 5998.73979214458359; 3497.30757754890101; 2497.2015304242459; 3495.29626046592784; + 2998.76393202250028; 5003.19806739988144; 6994.19066991856289; 5493.78905701620442; + 5001.43961347997629; 7000.20618271046988; 3495.29626046592784; 2497.2015304242459; + 3497.30757754890101; 5998.73979214458359; 4497.20354550247703; 3499; + 6998.10789745613329; 8498.50951035849175; 3502.59290899504595; 4499.2782026543191; + 5505.14335301404844; 7499.64517406068444; 3004.96649100621744; 4996.34845842043978; + 3003.23606797749972; 3002.80933008143711; 4500.56038652002371; 2498.80193260011856; + 4503.21094298379558; 5498.03152064027927; 3003.15588613093223; 7001.49266501579041; + 1500.9206722688125; 3999.73866895309675; 4000.79645449752343; 4504.89210254386671; + 4495.40709100495314; 3499; 3004.49048964150825; 1502.48409399493175; + 5499.99740938413652; 4503.41908441918713; 6998.63971425121235; 4997.98726249178435],[5,4,5]); + +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + + +//R2C case ------------------------------------------------------------------------------------ +A=matrix([5;4;3;6;4;9;0;5;3;4;3;1;8;2;1;7;2;7;8;4;4;9; + 1;2;6;6;7;9;5;3;4;9;9;3;4;7;3;5;3;5;5;1;2;6; + 8;0;7;2;4;8;6;5;2;8;1;3;9;8;5;10],[4,3,5]); +y_ref=matrix([ 290; 22+%i*4;-26; 22-%i*4; 9.5+%i*9.52627944162882301; + -1.1339745962155614+%i*17.1602540378443891;-3.5+%i*25.1147367097487191; + -2.8660254037844384+%i*0.16025403784438552; 9.5-%i*9.52627944162882301; + -2.8660254037844384-%i*0.16025403784438552;-3.5-%i*25.1147367097487191; + -1.1339745962155614-%i*17.1602540378443891;-10.9549150281252636-%i*1.37984007917967944; + 5.35973404130009712-%i*26.1183685942109989;-23.4614928368734752-%i*1.14281435514402396; + -3.59580201879988692+%i*23.0406850570357449;-21.3658553026453930-%i*8.84359942677465227; + 20.7330326917071268-%i*8.81688081018132586; 3.64531223802112692-%i*9.52499614355328994; + 7.43941996380932657-%i*16.867370295570808; 17.5396173813961269+%i*3.3290181678526012; + 15.0849628274577707+%i*11.593028238175755; 25.597333548226878-%i*1.41840966171390725; + -18.8967357079763296-%i*30.6614339614318183;-16.5450849718747364+%i*32.005406439473461; + -2.0005198567285527+%i*10.4427980896260522; 8.9614928368734752-%i*15.1639036975864734; + 8.23658783422834162-%i*9.7162555616206916;-4.97109202629695890-%i*8.30757202395887973; + 0.92910806515476718-%i*30.3790246133370161;-5.43718181239582421+%i*23.1017112524799586; + -14.884673669748171-%i*11.3804574337330209; 16.7973299475462241+%i*19.3569789554980396; + -0.44355669881229343+%i*5.1399061460535682;-7.8054639738521807-%i*7.52153572775482537; + -5.96155747159219818-%i*1.55370934855336351;-16.5450849718747364-%i*32.005406439473461; + 8.23658783422834162+%i*9.7162555616206916; 8.9614928368734752+%i*15.1639036975864734; + -2.0005198567285527-%i*10.4427980896260522; 16.7973299475462241-%i*19.3569789554980396; + -5.96155747159219818+%i*1.55370934855336351;-7.8054639738521807+%i*7.52153572775482537; + -0.44355669881229343-%i*5.1399061460535682;-4.97109202629695890+%i*8.30757202395887973; + -14.884673669748171+%i*11.3804574337330209;-5.43718181239582421-%i*23.1017112524799586; + 0.92910806515476718+%i*30.3790246133370161;-10.9549150281252636+%i*1.37984007917967944; + -3.59580201879988692-%i*23.0406850570357449;-23.4614928368734752+%i*1.14281435514402396; + 5.35973404130009712+%i*26.1183685942109989; 17.5396173813961269-%i*3.3290181678526012; + -18.8967357079763296+%i*30.6614339614318183; 25.597333548226878+%i*1.41840966171390725; + 15.0849628274577707-%i*11.593028238175755;-21.3658553026453930+%i*8.84359942677465227; + 7.43941996380932657+%i*16.867370295570808; 3.64531223802112692+%i*9.52499614355328994; + 20.7330326917071268+%i*8.81688081018132586],[4,3,5]); +y=fft(A); +assert_checkalmostequal(y,y_ref); + +//C2R case ------------------------------------------------------------------------------------ +A=matrix([ 2900; 220+%i*40;-260; 220-%i*40; 95+%i*95;-11+%i*172;-35+%i*251;-29+%i*2; 95-%i*95; + -29-%i*2;-35-%i*251;-11-%i*172;-110-%i*14; 54-%i*261;-235-%i*11;-36+%i*230;-214-%i*88; + 207-%i*88; 36-%i*95; 74-%i*169; 175+%i*33; 151+%i*116; 256-%i*14;-189-%i*307; + -165+%i*320;-20+%i*104; 90-%i*152; 82-%i*97;-50-%i*83; 9-%i*304;-54+%i*231;-149-%i*114; + 168+%i*194;-4+%i*51;-78-%i*75;-60-%i*16;-165-%i*320; 82+%i*97; 90+%i*152;-20-%i*104; + 168-%i*194;-60+%i*16;-78+%i*75;-4-%i*51;-50+%i*83;-149+%i*114;-54-%i*231; 9+%i*304; + -110+%i*14;-36-%i*230;-235+%i*11; 54+%i*261; 175-%i*33;-189+%i*307; 256+%i*14; + 151-%i*116;-214+%i*88; 74+%i*169; 36+%i*95; 207+%i*88],[4,3,5]); +y_ref=matrix([ 2996; 3600; 1800; 2396; 1804.08726109815325; 601.420841162336728; 1797.20231832067839; + 2402.0440006453523; 2399.91273890184675; 2998.57915883766327; 2.79768167932161305; + 5401.95599935464725; 2396.96074950014463; 2999.02579525054898; 3601.07865923712325; + 4800.47728151174852; 5402.68357811465103; 5996.71587420499782; 2994.98775825329631; + 4800.7569165971172; 1194.78718041472757; 1801.42138987713292; 597.945126438306488; + 4795.69787130615623; 1806.28063851446973; 2996.33933739403255; 1802.22357633135243; + 2999.61398771896711; 4800.14227629597099; 1194.58106615498582; 4200.9816123952096; + -1.643335439786938; 3000.6599157117771; 3602.13659702117502; 1207.26152998727684; + 601.910475422587638; 3601.29217048561441; 5398.45474462091079; 4205.6200225335615; + 3606.49125722100416; 5397.78905489267254; 4200.45827894945342; 2396.05617461713109; + 1802.27482470993255; 3000.2119789042963; 5400.98960279924631; 2403.91117288032501; + 1800.15817472797062; 4799.46644149977146; 4206.18012273450677; 591.077741897962369; + 1197.41747354827976; 2398.62992927763071; 1199.93973694330134; 600.335830922918376; + 5401.45253626486101; 1201.09608638827149; 2403.75745404970803; 4798.52079450553538; + 4195.39253641116193],[4,3,5]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + +//C2C case +//------------------------------------------------------------------------------------ +A=[0 %i 3-%i + 2+%i -1 -1 + 3 4 4 + 2-3*%i -1 -1]; +A(:,:,2)=A+1; +A(:,:,3)=A(:,:,2).*A(:,:,2); +y=fft(A); +y_ref=matrix([ 130-%i*22;-34-%i*14; 102+%i*10;-98+%i*2; 11.624355652982139+%i*5.18653347947321031; + 45.6243556529821319+%i*13.1865334794732103;-28.375644347017861+%i*37.1865334794732121; + -18.375644347017861+%i*29.1865334794732121;-12.624355652982139-%i*31.1865334794732121; + 21.3756443470178574-%i*23.1865334794732121;-52.6243556529821319+%i*0.81346652052678969; + -42.624355652982139-%i*7.18653347947321031;-30.1435935394489825+%i*63.4256258422040702; + 23.124355652982139-%i*12.0525588832576496;-33.464101615137757+%i*49.9615242270663131; + 29.2679491924311215-%i*54.6935750346351952;-0.90192378864668221-%i*5.2224318643354568; + -19.633974596215559+%i*23.2224318643354550;-16.2224318643354550-%i*18.6865334794732121; + -13.4903810567665765-%i*19.4185842870420871; 24.026279441628823-%i*6.83012701892219098; + 5.29422863405994804+%i*21.6147367097487226; 8.7057713659400484-%i*20.2942286340599445; + 11.4378221735089287-%i*21.026279441628823;-57.8564064605510140-%i*47.4256258422040702; + -1.1243556529821408+%i*26.0525588832576496;-26.5358983848622465-%i*53.9615242270663131; + 32.732050807568875+%i*52.6935750346351952; 4.97372055837117344+%i*1.83012701892219409; + -10.2942286340599463-%i*28.614736709748719; 24.2942286340599480-%i*4.705771365940052; + 23.5621778264910695-%i*1.9737205583711752;-6.09807621135331601+%i*24.2224318643354550; + -21.3660254037844375-%i*6.2224318643354586; 13.2224318643354550+%i*17.6865334794732085; + 12.4903810567665818+%i*20.4185842870420871],[4,3,3]); +assert_checkalmostequal(y,y_ref); + +//N-D transform ******************************************************************************* +//R2R case ------------------------------------------------------------------------------------ + +A=matrix([7090;265;265;180;-42;-198;30;15;15;180;-198;-42;160;235;-245;-335;135;182;240;-75;75; + -265;465;148;160;-245;235;-265;148;465;240;75;-75;-335;182;135;-410;446;204;-280;-253; + 353;-450;-198;-372;140;351;229;-48;236;-312;456;181;-279;262;-540;-50;363;385;-99;368; + 242;-6;-236;-71;-321;158;20;-90;397;109;195;-110;265;265;-120;-370;-110;-650;55;55;-120; + -110;-370;-20;-125;-245;91;-153;34;-80;85;-5;-151;-447;416;-20;-245;-125;-151;416;-447; + -80;-5;85;91;34;-153;-410;204;446;140;229;351;-450;-372;-198;-280;353;-253;368;-6;242; + 397;195;109;158;-90;20;-236;-321;-71;-48;-312;236;363;-99;385;262;-50;-540;456;-279;181],[3,4,3,4]); + +y_ref=matrix([ 8640; 6480; 6480; 11520; 5760.26656797432588; 5039.73343202567412; 4320; 7200; 7200; + 11520; 5039.73343202567412; 5760.26656797432588; 4320; 2160; 2880; 9369.32603294810724; + 4323.73066958946401; 5040.79842187187296; 7200; 2160.00000000000045; 2880; + 12230.6739670518928; 3596.2693304105369; 12239.2015781281261; 4320; 2880; 2160; + 12230.6739670518928; 12239.2015781281261; 3596.2693304105369; 7200; 2880; + 2160.00000000000045; 9369.32603294810724; 5040.79842187187296; 4323.73066958946401; + 11520; 4318.1340241797152; 9361.8659758202848; 12240; 5046.12849930729499; + 7193.87150069270501; 7200; 10079.7334320256741; 10800.2665679743259; 2160; + 2164.52909146133834; 8635.47090853866212; 7923.73066958946401; 7196.80246635918866; + 8641.59812579485151; 7921.06627189730625; 6480.53313594865176; 10801.5994078459589; + 10079.2015781281261; 6482.39782971783188; 7198.66844217947437; 5759.73343202567321; + 9362.39911176893838; 5038.66716012836696; 7196.26933041053599; 13678.4018742051485; + 6483.19753364081134; 5038.93372810269375; 6478.40059215404108; 5039.46686405134824; + 2880.79842187187342; 1441.33155782052563; 9357.60217028216903; 6480.26656797432679; + 8641.33283987163304; 2877.60088823106116; 4320; 4320; 4320; 3600; 8639.20029607702054; + 10800.7997039229795; 12960; 8640; 8640; 3600; 10800.7997039229795; 8639.20029607702054; + 7920; 12960; 10800; 9365.06350946109706; 7196.00276243620829; 8637.60217028216721; + 10800; 720.000000000000455; 7920; 5034.93649053890294; 8643.99723756379171; + 5762.39782971783279; 7920; 10800; 12960; 5034.93649053890294; 5762.39782971783279; + 8643.99723756379171; 10800; 7920; 720.000000000000455; 9365.06350946109706; + 8637.60217028216721; 7196.00276243620829; 11520; 9361.8659758202848; 4318.1340241797152; + 2160; 8635.47090853866212; 2164.52909146133834; 7200; 10800.2665679743259; + 10079.7334320256741; 12240; 7193.87150069270501; 5046.12849930729499; + 7196.26933041053599; 6483.19753364081134; 13678.4018742051485; 6480.26656797432679; + 2877.60088823106116; 8641.33283987163304; 2880.79842187187342; 9357.60217028216903; + 1441.33155782052563; 5038.93372810269375; 5039.46686405134824; 6478.40059215404108; + 7923.73066958946401; 8641.59812579485151; 7196.80246635918866; 5759.73343202567321; + 5038.66716012836696; 9362.39911176893838; 10079.2015781281261; 7198.66844217947437; + 6482.39782971783188; 7921.06627189730625; 10801.5994078459589; 6480.53313594865176],[3,4,3,4]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +A=matrix([ 2900; 220+%i*40;-260; 220-%i*40; 95+%i*95;-11+%i*172;-35+%i*251;-29+%i*2; 95-%i*95; + -29-%i*2;-35-%i*251;-11-%i*172;-110-%i*14; 54-%i*261;-235-%i*11;-36+%i*230;-214-%i*88; + 207-%i*88; 36-%i*95; 74-%i*169; 175+%i*33; 151+%i*116; 256-%i*14;-189-%i*307; + -165+%i*320;-20+%i*104; 90-%i*152; 82-%i*97;-50-%i*83; 9-%i*304;-54+%i*231;-149-%i*114; + 168+%i*194;-4+%i*51;-78-%i*75;-60-%i*16;-165-%i*320; 82+%i*97; 90+%i*152;-20-%i*104; + 168-%i*194;-60+%i*16;-78+%i*75;-4-%i*51;-50+%i*83;-149+%i*114;-54-%i*231; 9+%i*304; + -110+%i*14;-36-%i*230;-235+%i*11; 54+%i*261; 175-%i*33;-189+%i*307; 256+%i*14; + 151-%i*116;-214+%i*88; 74+%i*169; 36+%i*95; 207+%i*88],[4,3,5]); +y_ref=matrix([ 2996; 3600; 1800; 2396; 1804.08726109815325; 601.420841162336728; 1797.20231832067839; + 2402.0440006453523; 2399.91273890184675; 2998.57915883766327; 2.79768167932161305; + 5401.95599935464725; 2396.96074950014463; 2999.02579525054898; 3601.07865923712325; + 4800.47728151174852; 5402.68357811465103; 5996.71587420499782; 2994.98775825329631; + 4800.7569165971172; 1194.78718041472757; 1801.42138987713292; 597.945126438306488; + 4795.69787130615623; 1806.28063851446973; 2996.33933739403255; 1802.22357633135243; + 2999.61398771896711; 4800.14227629597099; 1194.58106615498582; 4200.9816123952096; + -1.643335439786938; 3000.6599157117771; 3602.13659702117502; 1207.26152998727684; + 601.910475422587638; 3601.29217048561441; 5398.45474462091079; 4205.6200225335615; + 3606.49125722100416; 5397.78905489267254; 4200.45827894945342; 2396.05617461713109; + 1802.27482470993255; 3000.2119789042963; 5400.98960279924631; 2403.91117288032501; + 1800.15817472797062; 4799.46644149977146; 4206.18012273450677; 591.077741897962369; + 1197.41747354827976; 2398.62992927763071; 1199.93973694330134; 600.335830922918376; + 5401.45253626486101; 1201.09608638827149; 2403.75745404970803; 4798.52079450553538; + 4195.39253641116193],[4,3,5]); +y=fft(A); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); +y=fft(A,"symmetric"); +assert_checktrue(isreal(y)); +assert_checkalmostequal(y,y_ref); + +y=fft(A,"nonsymmetric"); +assert_checktrue(~isreal(y)); +assert_checkalmostequal(y,y_ref); + +//============================================================================================ +//=================================fft(A ,isn, sel [,flag]) ================================== +//============================================================================================ +//R2C and C2R case --------------------------------------------------------------------------- +// Multiple 1D transforms +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 5 1 -1]; + +y_ref = [ 10, 5, 3; + -3+%i*3,-3+%i*2,-3; + -4, 5, 7; + -3-%i*3,-3-%i*2,-3]; +y=fft(A,-1,1); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,1,1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); + +y_ref = [ 2.5, 1.25, 0.75; + -0.75-%i*0.75,-0.75-%i*0.5,-0.75; + -1, 1.25, 1.75; + -0.75+%i*0.75,-0.75+%i*0.5,-0.75]; +y=fft(A,1,1); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,-1,1); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); + +y_ref = [ 2,-1,-1; + 0, 3, 3; + 11,-1,-1; + 5, 5-%i*1.7320508, 5+%i*1.7320508]; + +y=fft(A,-1,2); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,1,2); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); + +y_ref = [ 0.66666666666666663,-0.33333333333333331,-0.33333333333333331; + 0, 1, 1; + 3.66666666666666652,-0.33333333333333326,-0.33333333333333326; + 1.66666666666666652, 1.66666666666666652+%i*0.57735026918962573,.. + 1.66666666666666652-%i*0.57735026918962573]; +y=fft(A,1,2); +assert_checkalmostequal(y,y_ref); +y=fft(y_ref,-1,2); +assert_checktrue(isreal(y)); +assert_checkalmostequal(A,y); + +// Multiple 1D and 2D transforms of ND arrays +Dims=[5 3 4]; +A=matrix(1:60,Dims); +Sel=2; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end + +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end + + +Sel=3; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(2) + ind=list(i,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(2) + ind=list(i,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end + +Sel=[1 2]; +y=fft(A,-1,Sel); +for j=1:Dims(3) + ind=list(:,:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(3) + ind=list(:,:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:))); +end + +Sel=[1 3]; +y=fft(A,-1,Sel); +for j=1:Dims(2) + ind=list(:,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); +end + +Dims=[5 3 4 7]; +A=matrix(1:prod(Dims),Dims); +Sel=[1 3 4]; +y=fft(A,-1,Sel); +for j=1:Dims(2) + ind=list(:,j,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end + +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j,:,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); +end + +Sel=[2 4]; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end + +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(3) + ind=list(i,:,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end + +Sel=3; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(2) + for k=1:Dims(4) + ind=list(i,j,:,k); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end +end + +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + for j=1:Dims(2) + for k=1:Dims(4) + ind=list(i,j,:,k); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end + end +end diff --git a/modules/fftw/tests/unit_tests/fftw_part3.dia.ref b/modules/fftw/tests/unit_tests/fftw_part3.dia.ref new file mode 100755 index 000000000..9ee0c4d35 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part3.dia.ref @@ -0,0 +1,53 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//C2C case ------------------------------------------------------------------------------------ +Dims=[5 3 4]; +A=[10 %i 3-%i 5 + 2+%i -1 -1 7-%i + 3 4 4 -11 + 2-3*%i -1 -1 0.3+%i + -3 -2 -1 8]; +Sel=1; +y=fft(A,-1,Sel); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end +Sel=2; +y=fft(A,-1,Sel); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end +Dims=[5 3 4 7 5]; +A=matrix(rand(1,prod(Dims))+%i*rand(1,prod(Dims)),Dims); +Sel= [2 3 5]; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(4) + ind=list(i,:,:,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y=fft(y,1,Sel); +for i=1:Dims(1) + for j=1:Dims(4) + ind=list(i,:,:,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end diff --git a/modules/fftw/tests/unit_tests/fftw_part3.tst b/modules/fftw/tests/unit_tests/fftw_part3.tst new file mode 100755 index 000000000..72323cc43 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part3.tst @@ -0,0 +1,61 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//C2C case ------------------------------------------------------------------------------------ +Dims=[5 3 4]; +A=[10 %i 3-%i 5 + 2+%i -1 -1 7-%i + 3 4 4 -11 + 2-3*%i -1 -1 0.3+%i + -3 -2 -1 8]; + +Sel=1; +y=fft(A,-1,Sel); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end + +Sel=2; +y=fft(A,-1,Sel); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end + + +Dims=[5 3 4 7 5]; +A=matrix(rand(1,prod(Dims))+%i*rand(1,prod(Dims)),Dims); +Sel= [2 3 5]; +y=fft(A,-1,Sel); +for i=1:Dims(1) + for j=1:Dims(4) + ind=list(i,:,:,j,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end + +y=fft(y,1,Sel); +for i=1:Dims(1) + for j=1:Dims(4) + ind=list(i,:,:,j,:); + assert_checkalmostequal(y(ind(:)),A(ind(:))); + end +end + diff --git a/modules/fftw/tests/unit_tests/fftw_part4.dia.ref b/modules/fftw/tests/unit_tests/fftw_part4.dia.ref new file mode 100755 index 000000000..ddbd62de4 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part4.dia.ref @@ -0,0 +1,152 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//R2R case ------------------------------------------------------------------------------------ +A=[0 1 2 2 1 + 2 -1 3 3 -1 + 3 4 5 5 4 + 2 -1 3 3 -1]; +Dims=[4 5]; +Sel=1; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end +Sel=2; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end +//ND case +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 2 -1 -1]; +A(:,:,2)=A+1; +A(:,:,3)=A(:,:,2); +Dims=size(A); +Sel=1; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + for k=1:Dims(3) + ind=list(:,j,k); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + for k=1:Dims(3) + ind=list(:,j,k); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); + end +end +Sel=1:2; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for k=1:Dims(3) + ind=list(:,:,k); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for k=1:Dims(3) + ind=list(:,:,k); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end +Sel=2:3; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:,:); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end +Dims=[5 4 9 5 6]; +A=matrix(rand(1,prod(Dims)),Dims); +y=fft(A,-1,[2 4]); +for i1=1:Dims(1) + for i3=1:Dims(3) + for i5=1:Dims(5) + ind=list(i1,:,i3,:,i5);; + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end +end +y1=fft(y,1,[2 4]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); +y=fft(A,-1,[2 4 5]); +for i1=1:Dims(1) + for i3=1:Dims(3) + ind=list(i1,:,i3,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y1=fft(y,1,[2 4 5]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); +Dims=[5 4 7 5 6 3]; +A=matrix(rand(1,prod(Dims)),Dims); +y=fft(A,-1,[2 5]); +for i1=1:Dims(1) + for i3=1:Dims(3) + for i4=1:Dims(4) + for i6=1:Dims(6) + ind=list(i1,:,i3,i4,:,i6); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end + end +end +y1=fft(y,1,[2 5]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); +y=fft(A,-1,[2 4 6]); +for i1=1:Dims(1) + for i3=1:Dims(3) + for i5=1:Dims(5) + ind=list(i1,:,i3,:,i5,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end +end +y1=fft(y,1,[2 4 6]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); +y=fft(A,-1,[2 4 5 6]); +for i1=1:Dims(1) + for i3=1:Dims(3) + ind=list(i1,:,i3,:,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y1=fft(y,1,[2 4 5 6]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); diff --git a/modules/fftw/tests/unit_tests/fftw_part4.tst b/modules/fftw/tests/unit_tests/fftw_part4.tst new file mode 100755 index 000000000..fb81ce425 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part4.tst @@ -0,0 +1,171 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//R2R case ------------------------------------------------------------------------------------ +A=[0 1 2 2 1 + 2 -1 3 3 -1 + 3 4 5 5 4 + 2 -1 3 3 -1]; + +Dims=[4 5]; +Sel=1; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + ind=list(:,j); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end + +Sel=2; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end + +//ND case +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 2 -1 -1]; +A(:,:,2)=A+1; +A(:,:,3)=A(:,:,2); + +Dims=size(A); +Sel=1; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + for k=1:Dims(3) + ind=list(:,j,k); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end + +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for j=1:Dims(2) + for k=1:Dims(3) + ind=list(:,j,k); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); + end +end + +Sel=1:2; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for k=1:Dims(3) + ind=list(:,:,k); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end + +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for k=1:Dims(3) + ind=list(:,:,k); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end + +Sel=2:3; +y=fft(A,-1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); +end +y=fft(y,1,Sel); +assert_checktrue(isreal(y)); +for i=1:Dims(1) + ind=list(i,:,:); + assert_checkalmostequal(y(ind(:)),A(ind(:)),0,10*%eps); +end + +Dims=[5 4 9 5 6]; +A=matrix(rand(1,prod(Dims)),Dims); +y=fft(A,-1,[2 4]); +for i1=1:Dims(1) + for i3=1:Dims(3) + for i5=1:Dims(5) + ind=list(i1,:,i3,:,i5);; + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end +end +y1=fft(y,1,[2 4]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); + + +y=fft(A,-1,[2 4 5]); +for i1=1:Dims(1) + for i3=1:Dims(3) + ind=list(i1,:,i3,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y1=fft(y,1,[2 4 5]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); + + +Dims=[5 4 7 5 6 3]; +A=matrix(rand(1,prod(Dims)),Dims); +y=fft(A,-1,[2 5]); +for i1=1:Dims(1) + for i3=1:Dims(3) + for i4=1:Dims(4) + for i6=1:Dims(6) + ind=list(i1,:,i3,i4,:,i6); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end + end +end + +y1=fft(y,1,[2 5]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); + + +y=fft(A,-1,[2 4 6]); +for i1=1:Dims(1) + for i3=1:Dims(3) + for i5=1:Dims(5) + ind=list(i1,:,i3,:,i5,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end + end +end +y1=fft(y,1,[2 4 6]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); + +y=fft(A,-1,[2 4 5 6]); +for i1=1:Dims(1) + for i3=1:Dims(3) + ind=list(i1,:,i3,:,:,:); + assert_checkalmostequal(y(ind(:)),fft(A(ind(:)),-1)); + end +end +y1=fft(y,1,[2 4 5 6]); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); diff --git a/modules/fftw/tests/unit_tests/fftw_part5.dia.ref b/modules/fftw/tests/unit_tests/fftw_part5.dia.ref new file mode 100755 index 000000000..bdd805fc7 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part5.dia.ref @@ -0,0 +1,45 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- JVM NOT MANDATORY --> +//=================================fft(A ,isn, dim, incr [,flag]) ============================= +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 5 1 -1]; +y=matrix(fft(A(:),-1,4,1),size(A)); +assert_checkalmostequal(y,fft(A,-1,1)); +y1=matrix(fft(y(:),1,4,1),size(A)); +assert_checkalmostequal(y1,fft(y,1,1)); +y=matrix(fft(A(:),-1,3,4),size(A)); +assert_checkalmostequal(y,fft(A,-1,2)); +y1=matrix(fft(y(:),1,3,4),size(A)); +assert_checkalmostequal(y1,fft(y,1,2)); +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(fft(A,-1,20,1),[5*4 9 5 6]); +assert_checkalmostequal(y,fft(matrix(A,[5*4 9 5 6]),-1,1)); +y=matrix(fft(A,-1,45,20),[5*4 9*5 6]); +assert_checkalmostequal(y,fft(matrix(A,[5*4 9*5 6]),-1,2)); +y1=matrix(fft(y(:),1,45,20),size(A)); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(fft(A(:),-1,[9 5],[20 180]),[5 4 9 5 6]); +y1=fft(matrix(A,[5 4 9 5 6]),-1,[3 4]); +assert_checkalmostequal(y,y1); +y1=fft(y(:),1,[9 5],[20 180]); +assert_checkalmostequal(A(:),y1); +assert_checktrue(isreal(y1)); +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y1=fft(matrix(A,[5 4 9 5 6]),-1,[2 4]); +y=matrix(fft(A(:),-1,[4 5],[5 180]),[5 4 9 5 6]); +assert_checkalmostequal(y,y1); +y1=fft(y(:),1,[4 5],[5 180]); +assert_checkalmostequal(A(:),y1); +assert_checktrue(isreal(y1)); diff --git a/modules/fftw/tests/unit_tests/fftw_part5.tst b/modules/fftw/tests/unit_tests/fftw_part5.tst new file mode 100755 index 000000000..3a509cd30 --- /dev/null +++ b/modules/fftw/tests/unit_tests/fftw_part5.tst @@ -0,0 +1,57 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- JVM NOT MANDATORY --> + +//=================================fft(A ,isn, dim, incr [,flag]) ============================= +A=[0 1 1 + 2 -1 -1 + 3 4 4 + 5 1 -1]; +y=matrix(fft(A(:),-1,4,1),size(A)); +assert_checkalmostequal(y,fft(A,-1,1)); +y1=matrix(fft(y(:),1,4,1),size(A)); +assert_checkalmostequal(y1,fft(y,1,1)); + +y=matrix(fft(A(:),-1,3,4),size(A)); +assert_checkalmostequal(y,fft(A,-1,2)); +y1=matrix(fft(y(:),1,3,4),size(A)); +assert_checkalmostequal(y1,fft(y,1,2)); + +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(fft(A,-1,20,1),[5*4 9 5 6]); +assert_checkalmostequal(y,fft(matrix(A,[5*4 9 5 6]),-1,1)); + +y=matrix(fft(A,-1,45,20),[5*4 9*5 6]); +assert_checkalmostequal(y,fft(matrix(A,[5*4 9*5 6]),-1,2)); +y1=matrix(fft(y(:),1,45,20),size(A)); +assert_checktrue(isreal(y1)); +assert_checkalmostequal(y1,A); + +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y=matrix(fft(A(:),-1,[9 5],[20 180]),[5 4 9 5 6]); +y1=fft(matrix(A,[5 4 9 5 6]),-1,[3 4]); +assert_checkalmostequal(y,y1); + +y1=fft(y(:),1,[9 5],[20 180]); +assert_checkalmostequal(A(:),y1); +assert_checktrue(isreal(y1)); + + +Dims=[5 4 9 5 6]; +A=rand(1,prod(Dims)); +y1=fft(matrix(A,[5 4 9 5 6]),-1,[2 4]); + +y=matrix(fft(A(:),-1,[4 5],[5 180]),[5 4 9 5 6]); + +assert_checkalmostequal(y,y1); + +y1=fft(y(:),1,[4 5],[5 180]); +assert_checkalmostequal(A(:),y1); +assert_checktrue(isreal(y1)); diff --git a/modules/fftw/tests/unit_tests/setget_fftw_wisdom.dia.ref b/modules/fftw/tests/unit_tests/setget_fftw_wisdom.dia.ref new file mode 100755 index 000000000..048cc3af3 --- /dev/null +++ b/modules/fftw/tests/unit_tests/setget_fftw_wisdom.dia.ref @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +//================================= +//return fftw wisdom +try + txt=get_fftw_wisdom(); + assert_checkequal(size(txt),[3 1]); + //================================= + //set fftw wisdom + set_fftw_wisdom(txt); + //================================= + //reset fftw wisdom + fftw_forget_wisdom() + //================================= +end diff --git a/modules/fftw/tests/unit_tests/setget_fftw_wisdom.tst b/modules/fftw/tests/unit_tests/setget_fftw_wisdom.tst new file mode 100755 index 000000000..2e5a1bc67 --- /dev/null +++ b/modules/fftw/tests/unit_tests/setget_fftw_wisdom.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +//================================= +//return fftw wisdom +try + txt=get_fftw_wisdom(); + assert_checkequal(size(txt),[3 1]); + //================================= + //set fftw wisdom + set_fftw_wisdom(txt); + //================================= + //reset fftw wisdom + fftw_forget_wisdom() + //================================= +end |