diff options
Diffstat (limited to 'tests')
33 files changed, 315 insertions, 0 deletions
diff --git a/tests/unit_tests/testLinearAlgebra/testfullrf/testfullrf.sci b/tests/unit_tests/testLinearAlgebra/testfullrf/testfullrf.sci new file mode 100644 index 0000000..49d3c7a --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testfullrf/testfullrf.sci @@ -0,0 +1,7 @@ +function testfullrf() + A = [1,2,3;4,5,6;7,8,9] + [Q,M,rk] = fullrf(A) + disp(Q) + disp(M) + disp(rk) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testgivens/testgivens.sci b/tests/unit_tests/testLinearAlgebra/testgivens/testgivens.sci new file mode 100644 index 0000000..3ef0d28 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testgivens/testgivens.sci @@ -0,0 +1,7 @@ +function testgivens() + a = [1] + b = [2] + [u,c] = givens(a,b) + disp(u) + disp(c) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testhess/testhess.sci b/tests/unit_tests/testLinearAlgebra/testhess/testhess.sci new file mode 100644 index 0000000..f991ae9 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testhess/testhess.sci @@ -0,0 +1,5 @@ +function testhess() + a = [0,0,0,0;0,6,7,8;9,10,11,12;13,14,15,16]; + h = hess(a) + disp(h) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testhouseholder/testhouseholder.sci b/tests/unit_tests/testLinearAlgebra/testhouseholder/testhouseholder.sci new file mode 100644 index 0000000..30b4c20 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testhouseholder/testhouseholder.sci @@ -0,0 +1,6 @@ +function testhouseholder() + A = [1;2;3;4;5] + B = [6;7;8;9;10] + u = householder(A,B) + disp(u) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testnorm/testnorm.sci b/tests/unit_tests/testLinearAlgebra/testnorm/testnorm.sci new file mode 100644 index 0000000..727a895 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testnorm/testnorm.sci @@ -0,0 +1,6 @@ +//* Function to find, norm(a,2) +function testnorm() + a = [1,2,3;4,5,6;7,8,9] // Matrix + d = norm(a,2); // Calling NORM function. + disp(d) // display output +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testqr/testQR.sci b/tests/unit_tests/testLinearAlgebra/testqr/testQR.sci new file mode 100644 index 0000000..292e1cb --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testqr/testQR.sci @@ -0,0 +1,8 @@ +function testQR() + A = [1,2,3;4,5,6] + [u,a,rk,e] = qr(A); + disp(u) + disp(a) + disp(rk) + disp(e) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testrowcomp/testrcomp.sci b/tests/unit_tests/testLinearAlgebra/testrowcomp/testrcomp.sci new file mode 100644 index 0000000..f8da948 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testrowcomp/testrcomp.sci @@ -0,0 +1,6 @@ +function testrcomp() + A = [1,2,3;4,5,6] + [u,rk] = rowcomp(A,"qr") + disp(u) + disp(rk) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testspec/testspec.sci b/tests/unit_tests/testLinearAlgebra/testspec/testspec.sci new file mode 100644 index 0000000..6e9346d --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testspec/testspec.sci @@ -0,0 +1,9 @@ +function testspec() + A = [1,2,3;4,5,6;7,8,9] + B = [10,11,12;13,14,15;16,17,18] + [R,diagevals,c,d] = spec(A,B) + disp(R) + disp(diagevals) + disp(c) + disp(d) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsqroot/testsqroot.sci b/tests/unit_tests/testLinearAlgebra/testsqroot/testsqroot.sci new file mode 100644 index 0000000..63db1f4 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsqroot/testsqroot.sci @@ -0,0 +1,5 @@ +function testsqroot() + a = [1,2,3;4,5,6;7,8,9]; + e = sqroot(a); + disp(e) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsva/testsva.sci b/tests/unit_tests/testLinearAlgebra/testsva/testsva.sci new file mode 100644 index 0000000..c710723 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsva/testsva.sci @@ -0,0 +1,7 @@ +function testsva() + a = [1,2,3,4;5,6,7,8;9,10,11,12] + [u,s,v] = sva(a) + disp(u) + disp(s) + disp(v) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsva/testsvatol.sci b/tests/unit_tests/testLinearAlgebra/testsva/testsvatol.sci new file mode 100644 index 0000000..b199ec3 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsva/testsvatol.sci @@ -0,0 +1,9 @@ +// function Singular Value Approx. + +function testsvatol() + a = [1,2,3,4;5,6,7,8;9,10,11,12] + [u,s,v] = sva(a,1) + disp(u) + disp(s) + disp(v) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsvd/testsvd.sci b/tests/unit_tests/testLinearAlgebra/testsvd/testsvd.sci new file mode 100644 index 0000000..9a3a50a --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsvd/testsvd.sci @@ -0,0 +1,6 @@ +function testsvd() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + [s = svd(A) // Calling Function Sequence + disp(s) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsvd/testsvdeconomy.sci b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdeconomy.sci new file mode 100644 index 0000000..0459c79 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdeconomy.sci @@ -0,0 +1,11 @@ +function testsvdeconomy() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + [u,s,vt] = svd(A,'e') // Calling Function Sequence + disp("U Matrix") + disp(u) // A = U*sigma*Vt + disp("Sigma Matrix") + disp(s) + disp(" V transpose ") + disp(vt) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsvd/testsvdim.sci b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdim.sci new file mode 100644 index 0000000..16633cc --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdim.sci @@ -0,0 +1,6 @@ +// Function double_complex - test data. +function svdim() + b = [ (5.91+5.69*%i),(3.15-4.08*%i),(4.89+4.20*%i),(7.09+2.72*%i);(1.89+3.27*%i),(4.10+6.70*%i),(7.78+4.06*%i),(4.57+2.07*%i);(3.28+3.84*%i),(-0.79+7.21*%i),(3.88+3.30*%i),(3.84+1.19*%i)] + s = svd(b) + disp(s) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsvd/testsvdrank.sci b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdrank.sci new file mode 100644 index 0000000..108acde --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdrank.sci @@ -0,0 +1,13 @@ +function testsvdrank() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + [u,s,vt,rk] = svd(A) // Calling Function Sequence + disp("U Matrix") + disp(u) // A = U*sigma*Vt + disp("Sigma Matrix") + disp(s) + disp(" V transpose ") + disp(vt) + disp("Rank") + disp(rk) +endfunction diff --git a/tests/unit_tests/testLinearAlgebra/testsvd/testsvdreal.sci b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdreal.sci new file mode 100644 index 0000000..0e68e00 --- /dev/null +++ b/tests/unit_tests/testLinearAlgebra/testsvd/testsvdreal.sci @@ -0,0 +1,11 @@ +function testsvdreal() + disp(" ** SVD Function (Singular Value Decomposition)** ") + A = [1,2,3,11;4,5,6,12;7,8,9,13] // Matrix - A + [u,s,vt] = svd(A) // Calling Function Sequence + disp("U Matrix") + disp(u) // A = U*sigma*Vt + disp("Sigma Matrix") + disp(s) + disp(" V transpose ") + disp(vt) +endfunction diff --git a/tests/unit_tests/test_analogFilters/scilabcode/main.sci b/tests/unit_tests/test_analogFilters/scilabcode/main.sci new file mode 100644 index 0000000..85fc494 --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/main.sci @@ -0,0 +1,33 @@ +// This is the demo function to test the analog filters +// They are of 4 types butterworth,chebyshev-1,chebyshev-2 and elliptic +// We are going to test here the butterworth, chebyshev-1 and chebyshev-2 filters +//zpbutt->butterworth filter +//zpch1 ->chebyshev type-1 filter +//zpch2 ->chebyshev type-2 filter +function main() + n=5; //n is the filter order + fl=3; //fl is the cutoff frequency + [pb,gb]=zpbutt(n,fl); + disp("poles of butterworth filter") + disp(pb); + disp("gain of butterworth filter"); + disp(gb); + + e=0.5; //e (epsilon) it is the ripples in pass band + wc=4; // wc cutoff frequency + [pc1,gc1]=zpch1(n,e,wc); + disp("poles of chebyshev-1 filter") + disp(pc1); + disp("gain of chebyshev-1 filter") + disp(gc1); + + a=4; //a is the attenuation in stop band + w=5; //w (omega) is the cutoff frequency + [zc2,pc2,gc2]=zpch2(n,a,w); + disp("zeros of chebyshev-2 filter") + disp(zc2); + disp("poles of chebyshev-2 filter") + disp(pc2); + disp("gain of chebyshev-2 filter") + disp(gc2); +endfunction diff --git a/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci b/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci new file mode 100644 index 0000000..1ea723d --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci @@ -0,0 +1,7 @@ +function zpbutttest() + n=5; + fl=3; + [p,g]=zpbutt(n,fl); + disp(p); + disp(g); +endfunction diff --git a/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci b/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci new file mode 100644 index 0000000..4f29e0d4 --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci @@ -0,0 +1,9 @@ +function zpch1test() + + N=5; //N is the filter order + e=0.5; //e (epsilon) it is the ripples in pass band + wc=4; // wc cutoff frequency + [p,g]=zpch1(N,e,wc); + disp(p); + disp(g); +endfunction diff --git a/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci b/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci new file mode 100644 index 0000000..665fb41 --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci @@ -0,0 +1,9 @@ +function zpch2test() + n=5; + a=4; + w=5; + [z,p,g]=zpch2(n,a,w); + disp(z); + disp(p); + disp(g); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci b/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci new file mode 100644 index 0000000..c7426c2 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci @@ -0,0 +1,7 @@ +function buttmagtest() + smp=[1:5]; + od=6; + frq=2.2; + oup=buttmag(od,frq,smp); + disp(oup); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci b/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci new file mode 100644 index 0000000..7d09637 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci @@ -0,0 +1,8 @@ +function cheb1magtest() + od=5; + wfc=3; + eps=0.3; + sap=[1:5]; + out=cheb1mag(od,wfc,eps,sap); + disp(out); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci b/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci new file mode 100644 index 0000000..b53c435 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci @@ -0,0 +1,7 @@ +function ell1magtest() + eps1=0.2; + m11=0.4; + z1=[1,2,3]; + [s1]=ell1mag(eps1,m11,z1); + disp(s1); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/main.sci b/tests/unit_tests/test_filterResponse/scilabcode/main.sci new file mode 100644 index 0000000..6a8cbc5 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/main.sci @@ -0,0 +1,20 @@ +function main() + + order=5; + sample1=[1:5]; + frq=2.2; + out1=buttmag(order,frq,sample1); + disp(out1); + + wfc=3; + eps=0.3; + sample2=[1:5]; + out2=cheb1mag(order,wfc,eps,sample2); + disp(out2); + + eps1=0.2; + m11=0.4; + z1=[1,2,3]; + [s1]=ell1mag(eps1,m11,z1); + disp(s1); +endfunction diff --git a/tests/unit_tests/test_jacobi/scilabcode/main.sci b/tests/unit_tests/test_jacobi/scilabcode/main.sci new file mode 100644 index 0000000..ee229eb --- /dev/null +++ b/tests/unit_tests/test_jacobi/scilabcode/main.sci @@ -0,0 +1,18 @@ +// Demo function to test %sn and %k functions +// %sn is the Jacobi's elliptic function +// %k is the Jacobi's complete integral +function main() + u=[1+2*%i 2+3*%i 3+1*%i]; // the corresponding complex vector + k=0.6; // parameter of elliptic integral + [out]=%sn(u,k); + disp(out); + m=[0.1 0.2 0.3]; // parametrt of Jacobi complete integral + s=%k(m); + disp(s); +endfunction + +//Output +//for %sn +// 1.5641568 - 0.2037920i 1.0580372 + 0.0100213i 1.1386855 - 0.4631921i +// for %k +// 1.6124413 1.6596236 1.7138894 diff --git a/tests/unit_tests/test_jacobi/scilabcode/modktest.sci b/tests/unit_tests/test_jacobi/scilabcode/modktest.sci new file mode 100644 index 0000000..613cd33 --- /dev/null +++ b/tests/unit_tests/test_jacobi/scilabcode/modktest.sci @@ -0,0 +1,5 @@ +function modktest() + m=[0.1 0.2 0.3]; + s=%k(m); + disp(s); +endfunction diff --git a/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci b/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci new file mode 100644 index 0000000..dc5d435 --- /dev/null +++ b/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci @@ -0,0 +1,6 @@ +function modsntest() + u=[1+2*%i 2+3*%i 3+1*%i]; // the corresponding complex vector + k=0.6; // parameter of elliptic integral + [out]=%sn(u,k); + disp(out); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/asciitest.sci b/tests/unit_tests/test_string/scilabcode/asciitest.sci new file mode 100644 index 0000000..aa0017d --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/asciitest.sci @@ -0,0 +1,11 @@ +//This function test the ascii function in scilab. +//Ascii function takes the input string and then gives the ascii code of the string. +// The output for the scilab will be:- +//[97. 110. 107. 105. 116. 32. 105. 115. 32. 114. 97. 106.] + +function asciitest() + y="ankit is raj"; //This is the input string for testing the function. + x=ascii(y); //calling of the function + disp(x); +endfunction + diff --git a/tests/unit_tests/test_string/scilabcode/asciitest2.sci b/tests/unit_tests/test_string/scilabcode/asciitest2.sci new file mode 100644 index 0000000..ca7dcb7 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/asciitest2.sci @@ -0,0 +1,5 @@ +function asciitest2() + d=[97 98 99 100 101]; + si=ascii(d); + disp(si); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/main.sci b/tests/unit_tests/test_string/scilabcode/main.sci new file mode 100644 index 0000000..4030ee0 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/main.sci @@ -0,0 +1,30 @@ +//This is the demo function to test a set of string functions +// ascii->converts the input char vector/array to corresponding ascii code or vice versa +// strchr-> it finds the occurence of a charcter in a given string +// strncpy->copy charcters from string +// strspn-> get span of character set in string + +function main() + strascii1="ankit is raj"; //This is the input string for testing the function. + asciiout1=ascii(strascii1); //calling of the function + disp(asciiout1); + + strascii2=[97 98 99 100 101]; //Input as the ascii code to get converted to string + asciiout2=ascii(strascii2); //calling the function + disp(asciiout2); + + str="This is a sample string"; + ch="s"; + out1=strchr(str,ch); + disp(out1); + + ss="Ankit Raj"; + nn=5; + resu=strncpy(ss,nn); + disp(resu); + + strsample2="Hello this is Ankit"; + a="Ank"; + oup2=strspn(a,strsample2); + disp(oup2) +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/strchrtest.sci b/tests/unit_tests/test_string/scilabcode/strchrtest.sci new file mode 100644 index 0000000..f8d3419 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/strchrtest.sci @@ -0,0 +1,6 @@ +function strchrtest() + s="This is a sample string"; + ch="s"; + y=strchr(s,ch); + disp(y); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/strcspntest.sci b/tests/unit_tests/test_string/scilabcode/strcspntest.sci new file mode 100644 index 0000000..9a03c57 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/strcspntest.sci @@ -0,0 +1,6 @@ +function strcspntest() + x="123243545assdsc"; + y="anki5t3"; + z=strcspn(y,x); + disp(z); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/strncpytest.sci b/tests/unit_tests/test_string/scilabcode/strncpytest.sci new file mode 100644 index 0000000..14eceb8 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/strncpytest.sci @@ -0,0 +1,6 @@ +function strncpytest() + ss="Ankit Raj"; + nn=5; + resu=strncpy(ss,nn); + disp(resu); +endfunction |