From octave-sources-request at bevo dot che dot wisc dot edu Tue Jun 13 06:17:09 2000 Subject: More signal test From: "Billinghurst, David (CRTS)" To: octave-sources at bevo dot che dot wisc dot edu Cc: "'bsapp at nua dot lampf dot lanl dot gov'" Date: Tue, 13 Jun 2000 11:15:15 -0000 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01BFD528.A62E6610 Content-Type: text/plain Here are some more signal tests, to supplement http://www.che.wisc.edu/octave/mailing-lists/octave-sources/2000/72 There are a couple more to go, but may not get to them for a while. +++++++++++++++++++++++++++++++++++++++++ (Mr) David Billinghurst Comalco Research Centre PO Box 316, Thomastown, Vic, Australia, 3074 Phone: +61 3 9469 0642 FAX: +61 3 9462 2700 Email: David dot Billinghurst at riotinto dot com dot au <> <> <> <> ------_=_NextPart_000_01BFD528.A62E6610 Content-Type: application/octet-stream; name="fftfilt-1.m" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fftfilt-1.m" ## fftfilt-1.m=0A= ##=0A= ## Author: David Billinghurst (David dot Billinghurst at riotinto dot com dot au)=0A= ## Comalco Research and Technology=0A= ## 02 May 2000=0A= =0A= # 3 point moving average FIR filter=0A= N =3D 1024;=0A= c =3D 1 + 0.5*i;=0A= =0A= b =3D [1,1,1]/3;=0A= x =3D ones(1,N);=0A= y1 =3D fftfilt(b,x);=0A= y0 =3D [ 1./3., 2./3., ones(1,N-2)];=0A= =0A= ans_1 =3D (all (abs (y1 - y0) < 2*sqrt(N)*eps));=0A= if ( !ans_1 ) =0A= printf("Test 1 failed\n");=0A= endif=0A= =0A= y2 =3D fftfilt(b,x,8);=0A= ans_2 =3D (all (abs (y2 - y0) < 2*sqrt(N)*eps));=0A= if ( !ans_2 ) =0A= printf("Test 2 failed\n");=0A= endif=0A= =0A= z =3D c * x;=0A= y3 =3D fftfilt(b,z);=0A= ans_3 =3D (all (abs (y3 - c*y0) < 2*sqrt(N)*eps));=0A= if ( !ans_3 ) =0A= printf("Test 3 failed\n");=0A= endif=0A= =0A= ans_1 && ans_2 && ans_3=0A= ------_=_NextPart_000_01BFD528.A62E6610 Content-Type: application/octet-stream; name="filter-1.m" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="filter-1.m" ## filter-1.m=0A= ##=0A= ## Author: David Billinghurst (David dot Billinghurst at riotinto dot com dot au)=0A= ## Comalco Research and Technology=0A= ## 02 May 2000=0A= =0A= # 3 point moving average FIR filter=0A= N =3D 32=0A= =0A= b =3D [1,1,1]/3;=0A= x =3D ones(1,N);=0A= y =3D filter(b,a,x);=0A= y0 =3D [ 1./3., 2./3., ones(1,N-2)];=0A= =0A= ans_1 =3D (all (abs (y - y0) < 8*eps));=0A= if ( !ans_1 ) =0A= printf("Test 1 failed\n");=0A= endif=0A= =0A= # Saving final state=0A= [y,yf] =3D filter(b,a,x);=0A= yf0 =3D [ 2, 1 ]/3';=0A= ans_2 =3D (all (abs (y - y0) < 8*eps)) && (all (abs (yf - yf0) < = 8*eps));=0A= if ( !ans_2 ) =0A= printf("Test 2 failed\n");=0A= endif=0A= =0A= # Using previous final state as new initial state=0A= yi =3D yf;=0A= [y,yf] =3D filter(b,a,x,yi);=0A= ans_3 =3D (all (abs (y - x) < 8*eps));=0A= if ( !ans_3 ) =0A= printf("Test 3 failed\n");=0A= endif=0A= =0A= ans_1 && ans_2 && ans_3=0A= =0A= ------_=_NextPart_000_01BFD528.A62E6610 Content-Type: application/octet-stream; name="sinc-1.m" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sinc-1.m" ## sinc-1.m=0A= ##=0A= ## Author: David Billinghurst (David dot Billinghurst at riotinto dot com dot au)=0A= ## Comalco Research and Technology=0A= ## 02 May 2000=0A= =0A= function r=3DTaylor_sinc(x)=0A= # Taylor series expansion of sinc(x)=0A= # Exact in IEEE-754 double precision for -0.1 < x < 0.1=0A= p =3D (pi*x)*(pi*x);=0A= = r=3D((((((p/(15*14)+1)*p/(13*12)-1)*p/(11*10)+1)*p/(9*8)-1)*p/(7*6)+1)*p= /(5*4)-1)*p/(3*2)+1;=0A= endfunction=0A= =0A= x=3D[1e-1,1e-3,1e-5,1e-7,1e-9,eps,realmin,0,-realmin,-eps,-1e-9,-1e-7,-1= e-5,-1e-3,-1e-1]; =0A= a =3D zeros(size(x));=0A= =0A= for i =3D 1:length(x)=0A= a(i) =3D Taylor_sinc(x(i));=0A= endfor=0A= =0A= y =3D sinc(x);=0A= =0A= all( abs(y-a) < eps )=0A= ------_=_NextPart_000_01BFD528.A62E6610 Content-Type: application/octet-stream; name="signal.exp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="signal.exp" ## The following functions need to have tests written for them:=0A= =0A= # detrend=0A= =0A= set test detrend-1=0A= set prog_output "ans =3D 1"=0A= do_test detrend-1.m=0A= =0A= set test detrend-2=0A= set prog_output "ans =3D 1"=0A= do_test detrend-2.m=0A= =0A= set test detrend-3=0A= set prog_output "ans =3D 1"=0A= do_test detrend-3.m=0A= =0A= # fft=0A= set test fft-1=0A= set prog_output "ans =3D 1"=0A= do_test fft-1.m=0A= =0A= # ifft=0A= set test ifft-1=0A= set prog_output "ans =3D 1"=0A= do_test ifft-1.m=0A= =0A= # fft2=0A= set test fft2-1=0A= set prog_output "ans =3D 1"=0A= do_test fft2-1.m=0A= =0A= # ifft2=0A= set test ifft2-1=0A= set prog_output "ans =3D 1"=0A= do_test ifft2-1.m=0A= =0A= # fftconv=0A= =0A= # fftfilt=0A= set test fftfilt-1=0A= set prog_output "ans =3D 1"=0A= do_test fftfilt-1.m=0A= =0A= # filter=0A= set test filter-1=0A= set prog_output "ans =3D 1"=0A= do_test filter-1.m=0A= =0A= # freqz=0A= # sinc=0A= =0A= set test sinc-1=0A= set prog_output "ans =3D 1"=0A= do_test sinc-1.m=0A= =0A= =0A= ------_=_NextPart_000_01BFD528.A62E6610-- ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------