diff options
author | simon | 2008-09-25 08:43:14 +0000 |
---|---|---|
committer | simon | 2008-09-25 08:43:14 +0000 |
commit | 64913210fb69211b7ed0fead0a63243561d8ec36 (patch) | |
tree | f0c2e1e5eb7397028afe03aec0e73b86bfa95288 /src/signalProcessing/fft | |
parent | ed7d2e1beb1803800ef05ef50286468f68ec9382 (diff) | |
download | scilab2c-64913210fb69211b7ed0fead0a63243561d8ec36.tar.gz scilab2c-64913210fb69211b7ed0fead0a63243561d8ec36.tar.bz2 scilab2c-64913210fb69211b7ed0fead0a63243561d8ec36.zip |
corrected r8tx fucntion, but problem with the zfftmaTest16 itself
Diffstat (limited to 'src/signalProcessing/fft')
-rw-r--r-- | src/signalProcessing/fft/fft842.c | 7 | ||||
-rw-r--r-- | src/signalProcessing/fft/r8tx.c | 25 | ||||
-rw-r--r-- | src/signalProcessing/fft/testDoubleFft.c | 44 |
3 files changed, 44 insertions, 32 deletions
diff --git a/src/signalProcessing/fft/fft842.c b/src/signalProcessing/fft/fft842.c index 0b9f1dbc..04c09b19 100644 --- a/src/signalProcessing/fft/fft842.c +++ b/src/signalProcessing/fft/fft842.c @@ -38,7 +38,7 @@ void fft842 (doubleComplex* b, int size , int in) int L[16],L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11,L12,L13,L14,L15; int j1,j2,j3,j4,j5,j6,j7,j8,j9,j10,j11,j12,j13,j14; - int i, j, ij, ji, ij1, ji1; + int i = 0, j, ij, ji, ij1, ji1; int n2pow, n8pow, nthpo, ipass, nxtlt, lengt; n2pow = fastlog2( size ); @@ -79,6 +79,11 @@ void fft842 (doubleComplex* b, int size , int in) nxtlt = 0x1 << (n2pow - 3*ipass); lengt = 8*nxtlt; printf ( "on appelle r%dtx \n" , 8); + + for (i= 0 ; i < size ; i++) + printf ( "%d - avant r8 %e %e %d\n" , i, zreals ( b[i]), zimags(b[i]), nxtlt); + + r8tx(nxtlt,nthpo,lengt, b,b+nxtlt,b+2*nxtlt, b+3*nxtlt,b+4*nxtlt,b+5*nxtlt, diff --git a/src/signalProcessing/fft/r8tx.c b/src/signalProcessing/fft/r8tx.c index dd693134..042b39a8 100644 --- a/src/signalProcessing/fft/r8tx.c +++ b/src/signalProcessing/fft/r8tx.c @@ -1,6 +1,4 @@ - - /* * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab * Copyright (C) 2008 - INRIA - Allan SIMON @@ -67,8 +65,10 @@ void r8tx ( int nxtlt,int nthpo,int lengt, scale = dblPi2/lengt; + for(j=1;j<=nxtlt;j++) { + arg = (j-1)*scale; c1 = cos(arg); s1 = sin(arg); @@ -87,7 +87,8 @@ void r8tx ( int nxtlt,int nthpo,int lengt, for(k=j;k<=nthpo;k+=lengt) { - kk = (k-1)*2; /* index by twos; re & im alternate */ + kk = k - 1;/* (k-1)*2*/ /* index by twos; re & im alternate */ + Atemp0 = zadds ( cc0[kk] , cc4[kk] ) ; Atemp1 = zadds ( cc1[kk] , cc5[kk] ) ; @@ -123,8 +124,6 @@ void r8tx ( int nxtlt,int nthpo,int lengt, ai7 = ci3[kk] - ci7[kk]; */ - - Btemp0 = zadds ( Atemp0 , Atemp2 ) ; Btemp1 = zadds ( Atemp1 , Atemp3 ) ; Btemp2 = zdiffs ( Atemp0 , Atemp2 ) ; @@ -157,6 +156,7 @@ void r8tx ( int nxtlt,int nthpo,int lengt, bi6 = ai4 - ar6; bi7 = ai5 - ar7; */ + cc0[kk] = zadds ( Btemp0 , Btemp1 ); /* cr0[kk] = br0 + br1; @@ -168,8 +168,7 @@ void r8tx ( int nxtlt,int nthpo,int lengt, if(j>1) { - printf ( "on sup j>1\n"); - cc1[kk] = DoubleComplex ( c4 * (zreals(Btemp0) - zreals(Btemp1)) - s4 * (zimags(Btemp0) - zimags(Btemp1)), + cc1[kk] = DoubleComplex ( (c4 * (zreals(Btemp0) - zreals(Btemp1))) - (s4 * (zimags(Btemp0) - zimags(Btemp1))), c4 * (zimags(Btemp0) - zimags(Btemp1)) + s4 * (zreals(Btemp0) - zreals(Btemp1))); cc2[kk] = DoubleComplex ( c2 * (zreals(Btemp2) - zimags(Btemp3)) - s2 * (zimags(Btemp2) + zreals(Btemp3)) , @@ -222,11 +221,12 @@ void r8tx ( int nxtlt,int nthpo,int lengt, ci6[kk] = c3*(bi6+ti) + s3*(br6+tr); cr7[kk] = c7*(br6-tr) - s7*(bi6-ti); ci7[kk] = c7*(bi6-ti) + s7*(br6-tr); + */ + } else { - printf ( "on oupa sup j>1\n"); cc1[kk] = zdiffs ( Btemp0 , Btemp1 ); /* cr1[kk] = br0 - br1; @@ -287,12 +287,5 @@ void r8tx ( int nxtlt,int nthpo,int lengt, } } - printf ( "plop %d \t%e \t%e\n" , 0 , zreals(cc0[kk]) , zimags(cc0[kk])); - printf ( "plop %d \t%e \t%e\n" , 1 , zreals(cc1[kk]) , zimags(cc1[kk])); - printf ( "plop %d \t%e \t%e\n" , 2 , zreals(cc2[kk]) , zimags(cc2[kk])); - printf ( "plop %d \t%e \t%e\n" , 3 , zreals(cc3[kk]) , zimags(cc3[kk])); - printf ( "plop %d \t%e \t%e\n" , 4 , zreals(cc4[kk]) , zimags(cc4[kk])); - printf ( "plop %d \t%e \t%e\n" , 5 , zreals(cc5[kk]) , zimags(cc5[kk])); - printf ( "plop %d \t%e \t%e\n" , 6 , zreals(cc6[kk]) , zimags(cc6[kk])); - printf ( "plop %d \t%e \t%e\n" , 7 , zreals(cc7[kk]) , zimags(cc7[kk])); + } diff --git a/src/signalProcessing/fft/testDoubleFft.c b/src/signalProcessing/fft/testDoubleFft.c index 05f4c28c..2fa2bac1 100644 --- a/src/signalProcessing/fft/testDoubleFft.c +++ b/src/signalProcessing/fft/testDoubleFft.c @@ -36,6 +36,7 @@ 0.30760907428339124, 0.93296162132173777, 0.21460078610107303, 0.31264199689030647,\ 0.36163610080257058, 0.2922266637906432 , 0.56642488157376647, 0.48264719732105732,\ 0.33217189135029912, 0.59350947011262178, 0.50153415976092219, 0.43685875833034515} + #define ZIMAG_IN16 {0.26931248093023896, 0.63257448654621840, 0.40519540151581168, 0.91847078315913677,\ 0.04373343335464597, 0.48185089323669672, 0.26395560009405017, 0.41481037065386772,\ 0.28064980218186975, 0.12800584640353918, 0.77831285959109664, 0.21190304495394230,\ @@ -83,6 +84,7 @@ static void zfftmaTest2 (void ) doubleComplex* Result = DoubleComplexMatrix ( tRealResult , tImagResult ,ROW*COLS2) ; + zfftma ( in , ROW , COLS2 , out ) ; /* if we don't add that test assert failed if result = 0 'cause then we have |(out - 0)|/|out| = 1*/ @@ -91,9 +93,13 @@ static void zfftmaTest2 (void ) for ( i = 0 ; i < (ROW*COLS2 ) ; i++ ) { printf ( "\t\t %d out : %e\t %e\t * i result : %e\t %e\t * i assert : : %e\t %e\t * i \n" , - i ,zreals(out[i]) , zimags(out[i]), zreals (Result[i]) , zimags (Result[i]), - fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) , - fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i]))); + i , + zreals(out[i]) , + zimags(out[i]), + zreals (Result[i]) , + zimags (Result[i]), + fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i]))); if ( zreals(out[i]) < 1e-14 && zreals (Result[i]) < 1e-18 ) assert ( 1 ) ; @@ -219,20 +225,31 @@ static void zfftmaTest16 (void ) doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS16)); doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS16 ); doubleComplex* Result = DoubleComplexMatrix ( tRealResult , tImagResult ,ROW*COLS16) ; +for ( i = 0 ; i < (ROW*COLS16 ) ; i++ ) + printf ("%ddebutdebut resultat\t %e\t %e \n",i , zreals(Result[i]) ,zimags(Result[i])); - + printf ("\n\n\n\n"); zfftma ( in , ROW , COLS16 , out ) ; + i = 0; +for ( i = 0 ; i < (ROW*COLS16 ) ; i++ ) + printf ("%ddebutdebut resultat\t %e\t %e \n",i , zreals(Result[i]) ,zimags(Result[i])); + + printf ("\n\n\n\n"); /* if we don't add that test assert failed if result = 0 'cause then we have |(out - 0)|/|out| = 1*/ - for ( i = 0 ; i < (ROW*COLS16 ) ; i++ ) + for ( i = 0 ; i < (ROW*COLS16 ) ; i++ ) { + printf ("%ddebutdebut resultat\t %e\t %e \n",i , zreals(Result[i]) ,zimags(Result[i])); printf ( "\t\t %d out : %e\t %e\t * i result : %e\t %e\t * i assert : : %e\t %e\t * i \n" , - i ,zreals(out[i]) , zimags(out[i]), zreals (Result[i]) , zimags (Result[i]), - fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) , - fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i]))); + i , + zreals(out[i]) , + zimags(out[i]), + zreals (Result[i]) , + zimags (Result[i]), + fabs( zreals(out[i]) - zreals (Result[i]) ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i]))); -/* if ( zreals(out[i]) < 1e-14 && zreals (Result[i]) < 1e-18 ) assert ( 1 ) ; else @@ -243,12 +260,9 @@ static void zfftmaTest16 (void ) assert ( 1 ) ; else assert ( fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])) < 1e-12 ) ; - */ - } - } static int testFft(void) { @@ -256,7 +270,8 @@ static int testFft(void) { printf("\n>>>> FFT Tests\n"); printf("\t>>>> Matrix Double Realt Tests\n"); /*dfftmaTest();*/ - + printf("\t>>>> Vector 16 Double Complex Tests\n"); + zfftmaTest16(); printf("\n\n\n"); printf("\t>>>> Vector 2 Double Complex Tests\n"); zfftmaTest2(); @@ -264,8 +279,7 @@ static int testFft(void) { zfftmaTest4(); printf("\t>>>> Vector 8 Double Complex Tests\n"); zfftmaTest8(); - printf("\t>>>> Vector 16 Double Complex Tests\n"); - zfftmaTest16(); + return 0; |