From cb6d500415f8db3078cc95ece2a4bfabb4e50489 Mon Sep 17 00:00:00 2001 From: nutricato Date: Thu, 9 Jul 2009 09:10:40 +0000 Subject: --- src/c/operations/interfaces/int_OpDotSlash.h | 17 ++--- .../scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 1 + .../test002_Symbols/scilabcode/mainfunction.sci | 1 + .../test003_VerySimple/scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 43 ++++++++++++ .../test088_SimpleFor/scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 1 + .../test200_malloc/scilabcode/mainfunction.sci | 1 + .../test200_malloc/scilabcode/myinit.sci | 1 + .../test200_malloc/scilabcode/myzeros.sci | 1 + .../test301_cchirp/scilabcode/mainfunction.sci | 59 ++++++++++++++++ .../test301_cchirp/scilabcode/myconvol.sci | 31 +++++++++ .../test305_Moebius/scilabcode/XYgrid.sci | 32 +++++++++ .../test305_Moebius/scilabcode/mainfunction.sci | 66 ++++++++++++++++++ .../scilabcode/mainfunction.sci | 1 + .../scilabcode/mainfunction.sci | 80 ++++++++++++---------- 21 files changed, 294 insertions(+), 48 deletions(-) create mode 100644 tests/unit_tests/test064_OpMinusFloatComplex/scilabcode/mainfunction.sci create mode 100644 tests/unit_tests/test301_cchirp/scilabcode/mainfunction.sci create mode 100644 tests/unit_tests/test301_cchirp/scilabcode/myconvol.sci create mode 100644 tests/unit_tests/test305_Moebius/scilabcode/XYgrid.sci create mode 100644 tests/unit_tests/test305_Moebius/scilabcode/mainfunction.sci diff --git a/src/c/operations/interfaces/int_OpDotSlash.h b/src/c/operations/interfaces/int_OpDotSlash.h index a0f097de..a6c57051 100644 --- a/src/c/operations/interfaces/int_OpDotSlash.h +++ b/src/c/operations/interfaces/int_OpDotSlash.h @@ -38,25 +38,19 @@ #define s0s2OpDotSlashs2(in1,in2,size,out) {int i=0;\ - sinverma(in2,out,size[0]);\ - for (i=0;i MOREA: commentare meglio lo scopo di questa funzione +//---> NUTRICATO: annotare anche le funzioni di plot facendole puntare a funzioni dummy che non fanno nulla. +//---> NUTRICATO: la convoluzione e' stata stostituita con una custom in quanto non ancora implementata da INRIA. + + +// sampling parameters +fs = 1000; //Hz +Tmax = .01; //----> NUTRICATO: VALORE VERO 1 +t = 0 : 1 ./ fs : Tmax; + +// chirp parameters +fo = 10 +k = 150 + +tau=0.7 + +c=exp(2*%i*%pi*(fo*t+k./2*t.^2));//chirp signal in complex form +// figure +// subplot(2,2,1) +// plot(t(1:250),real(c(1:250))); +//title('chirp(t)') + +cr=exp(2*%i*%pi*(fo*(t-tau)+k./2*(t-tau).^2));//chirp signal delayed in complex form +// subplot(2,2,2) + +// plot(t(1:250),real(c(1:250)),'r',t(1:250),real(cr(1:250)),'g'); +// title('chirp(t) e chirp(t-tau)') + +// filter response +// subplot(2,2,3) +h=conj(exp(2*%i*%pi*(fo*(-t)+k./2*(-t).^2))); + + +// plot(t(1:250),real(h(1:250))); +// title('conj(chirp(-t))') +//---> NUTRICATO: la convoluzione e' stata commentata in quanto non ancora implementata. +y=myconvol(h,cr); + + +tch=0:1 ./ fs:2*Tmax; +// subplot(2,2,4) +// plot(tch,abs(y)) +// title(' y(t)') + +disp('t') +disp(t) +disp('c') +disp(c) +disp('cr') +disp(cr) +disp('h') +disp(h) +disp('y') +disp(y) +endfunction + + diff --git a/tests/unit_tests/test301_cchirp/scilabcode/myconvol.sci b/tests/unit_tests/test301_cchirp/scilabcode/myconvol.sci new file mode 100644 index 00000000..6640c372 --- /dev/null +++ b/tests/unit_tests/test301_cchirp/scilabcode/myconvol.sci @@ -0,0 +1,31 @@ +//SCI2C: NIN= 2 +//SCI2C: NOUT= 1 +//SCI2C: OUT(1).TP= FA_TP_MAX(IN(1).TP,IN(2).TP) +//SCI2C: OUT(1).SZ(1)= '1' +//SCI2C: OUT(1).SZ(2)= FA_SUB(FA_ADD(IN(1).SZ(2),IN(2).SZ(2)),'1') +//SCI2C: DEFAULT_PRECISION= DOUBLE + +function y = myconvol(h,x) +hlen = length(h); +xlen = length(x); +//y = zeros(1,hlen+xlen-1); + +for cnt1 = 1:xlen + y(cnt1) = 0+%i*0; + for cnt2 = 1:cnt1 + if ((cnt1-cnt2+1) <= hlen) + y(cnt1) = y(cnt1) + h(cnt1-cnt2+1)*x(cnt2); + else + y(cnt1) = y(cnt1) + 0; + end + end +end + +for cnt1 = xlen+1:xlen+hlen-1 + y(cnt1) = 0+%i*0; + for cnt2 = cnt1-hlen+1:xlen + y(cnt1) = y(cnt1) + h(cnt1-cnt2+1)*x(cnt2); + end +end + +endfunction diff --git a/tests/unit_tests/test305_Moebius/scilabcode/XYgrid.sci b/tests/unit_tests/test305_Moebius/scilabcode/XYgrid.sci new file mode 100644 index 00000000..0957237d --- /dev/null +++ b/tests/unit_tests/test305_Moebius/scilabcode/XYgrid.sci @@ -0,0 +1,32 @@ +//SCI2C: NIN= 2 +//SCI2C: NOUT= 2 +//SCI2C: OUT(1).TP= IN(1).TP +//SCI2C: OUT(1).SZ(1)= IN(2).SZ(2) +//SCI2C: OUT(1).SZ(2)= IN(1).SZ(2) +//SCI2C: OUT(2).TP= IN(1).TP +//SCI2C: OUT(2).SZ(1)= IN(2).SZ(2) +//SCI2C: OUT(2).SZ(2)= IN(1).SZ(2) +//SCI2C: DEFAULT_PRECISION= DOUBLE + +// ------------------------------------ +// this script emulate the matlab meshgrid +// only for bidimensional mesh. +// ------------------------------------ + +function [X,Y] = XYgrid(x,y) + +n = length(x); +m = length(y); + +X=zeros(m,n); +Y=zeros(m,n); + +for k=1:m + X(k,1:n)=x; +end + +for h=1:n + Y(1:m,h)=y'; +end + +endfunction diff --git a/tests/unit_tests/test305_Moebius/scilabcode/mainfunction.sci b/tests/unit_tests/test305_Moebius/scilabcode/mainfunction.sci new file mode 100644 index 00000000..4e79667b --- /dev/null +++ b/tests/unit_tests/test305_Moebius/scilabcode/mainfunction.sci @@ -0,0 +1,66 @@ +//SCI2C: DEFAULT_PRECISION= DOUBLE + +function mainfunction() + +//the program construct moebius +// and klein bottle surface from +//http://www.metlin.org/mathematics/ +// topological-constructs/non-orientable-surfaces/ + + +// --------------------- +// --- Moebius strip --- +// --------------------- +num_points = 20; +R = 20; +a = -0.4; +b = 0.4; + +step=(b-a)./(num_points-1); +step1=(2*%pi)./num_points; +s=a:step:b; +t=0:step1:2*%pi; + +[S, T] = XYgrid(s, t); +x = [R + (S.*cos(T./2))].*cos(T); +y = [R + (S.*cos(T./2))].*sin(T); +z = S.*sin(T./2); + +disp('x(1:10)') +disp(x(1:10)) +disp('y(1:10)') +disp(y(1:10)) +disp('z(1:10)') +disp(z(1:10)) + +// ENABLE/DISABLE PLOT +// scf(0); surf(x, y, z); + +// ----------------------- +// --- Klein Bottle II --- +// ----------------------- +num_points = 50; + +//u = linspace (0, 2*(%pi), num_points); +//v = linspace (0, 2*(%pi), num_points); +step_u = (2*%pi)./num_points +u = 0:step_u:2*%pi; +v = u; + +[U,V] = XYgrid(u,v); + +x1 = cos(U).*(cos(U./2).*(sqrt(2)+cos(V))+(sin(U./2).*sin(V).*cos(V))); +y1 = sin(U).*(cos(U./2).*(sqrt(2)+cos(V))+(sin(U./2).*sin(V).*cos(V))); +z1 = -1.*sin(U./2).*(sqrt(2)+cos(V))+cos(U./2).*sin(V).*cos(V); + +disp('x1(1:10)'); +disp(x1(1:10)); +disp('y1(1:10)') +disp(y1(1:10)) +disp('z1(1:10)') +disp(z1(1:10)) +// ENABLE/DISABLE PLOT +// scf(1) ;surf(x1, y1, z1) + +endfunction + diff --git a/tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci b/tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci index e32d8d3a..8455ac70 100644 --- a/tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci +++ b/tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci @@ -14,3 +14,4 @@ disp('s1(i0)'); disp(s1(i0)); endfunction + diff --git a/tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci b/tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci index 5e2a7728..5719fc08 100644 --- a/tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci +++ b/tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci @@ -1,49 +1,59 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE function mainfunction() - -// --------------------------------------- -// --- Initialization of the parameters. --- -// --------------------------------------- +//---> MOREA: commentare meglio lo scopo di questa funzione +//---> NUTRICATO: annotare anche le funzioni di plot facendole puntare a funzioni dummy che non fanno nulla. +//---> NUTRICATO: la convoluzione e' stata stostituita con una custom in quanto non ancora implementata da INRIA. -// --------------------------------------- -// --- Set number of point for quadrature . -// --- interval for quadrature [a,b] -// --------------------------------------- +// sampling parameters +fs = 1000; //Hz +Tmax = .01; //----> NUTRICATO: VALORE VERO 1 +t = 0 : 1 ./ fs : Tmax; +// chirp parameters +fo = 10 +k = 150 +tau=0.7 -Np =10 // number of point for quadrature -a=1 -b=5 - +c=exp(2*%i*%pi*(fo*t+k./2*t.^2));//chirp signal in complex form +// figure +// subplot(2,2,1) +// plot(t(1:250),real(c(1:250))); +//title('chirp(t)') -// --------------------------------------- -// --- Compute Legendre-Gauss-Lobatto nodes, weights -//. ---In standard [-1 1] interval -// --------------------------------------- +cr=exp(2*%i*%pi*(fo*(t-tau)+k./2*(t-tau).^2));//chirp signal delayed in complex form +// subplot(2,2,2) -[x,w]=lglnodes(Np); -disp('x'); -disp(x); -disp('w'); -disp(w); -// --------------------------------------- -// --- Compute the nodes -//. ---In [a,b] pick a t points in the -// --- desired interval -// ------------------------------------- +// plot(t(1:250),real(c(1:250)),'r',t(1:250),real(cr(1:250)),'g'); +// title('chirp(t) e chirp(t-tau)') -t=((b-a)./2)*x+(b+a)./2; +// filter response +// subplot(2,2,3) +h=conj(exp(2*%i*%pi*(fo*(-t)+k./2*(-t).^2))); +// plot(t(1:250),real(h(1:250))); +// title('conj(chirp(-t))') +//---> NUTRICATO: la convoluzione e' stata commentata in quanto non ancora implementata. +y=myconvol(h,cr); + + +tch=0:1 ./ fs:2*Tmax; +// subplot(2,2,4) +// plot(tch,abs(y)) +// title(' y(t)') + +disp('t') +disp(t) +disp('c') +disp(c) +disp('cr') +disp(cr) +disp('h') +disp(h) +disp('y') +disp(y) +endfunction -Iab=((b-a)./2)*mysum(w.*Fint(t),11); -disp('Number of nodes for quadrature '); -disp(Np) -disp('Integral value in [a b] with Np points'); -disp(Iab) - - -endfunction -- cgit