diff options
author | simon | 2008-10-21 14:58:00 +0000 |
---|---|---|
committer | simon | 2008-10-21 14:58:00 +0000 |
commit | 153567ec32547640e50f4ad0b069b6dcabd0d8e1 (patch) | |
tree | 67447a0a1d1d363e528f9f65f7deace621718dd8 /src/signalProcessing/fft | |
parent | 8c48708aafe419c1813283e871023a8adc966bb6 (diff) | |
download | scilab2c-153567ec32547640e50f4ad0b069b6dcabd0d8e1.tar.gz scilab2c-153567ec32547640e50f4ad0b069b6dcabd0d8e1.tar.bz2 scilab2c-153567ec32547640e50f4ad0b069b6dcabd0d8e1.zip |
every current tests work now , on the road again to add them all
Diffstat (limited to 'src/signalProcessing/fft')
-rw-r--r-- | src/signalProcessing/fft/dfftmx.c | 279 | ||||
-rw-r--r-- | src/signalProcessing/fft/fft_internal.h | 4 | ||||
-rw-r--r-- | src/signalProcessing/fft/testDoubleFft.c | 427 |
3 files changed, 574 insertions, 136 deletions
diff --git a/src/signalProcessing/fft/dfftmx.c b/src/signalProcessing/fft/dfftmx.c index cf739e03..4ce3c107 100644 --- a/src/signalProcessing/fft/dfftmx.c +++ b/src/signalProcessing/fft/dfftmx.c @@ -119,11 +119,14 @@ int dfftmx ( double* _pdblA , double* _pdblB , int _iNtot, int _iN, int _iNspan, nt = inc*ntot ; ks = inc*nspan; rad = atan ( 1 ); + printf ( "rad %f\n" , rad ) ; c72 = cos (rad/0.6250); s72 = sin (rad/0.6250); s120= sqrt(0.750); + + fprintf (stderr , "\n\n" ); fprintf (stderr , "preliminary\n" ); @@ -224,13 +227,21 @@ int factorTransform (void) { int retVal = 42; + int jjjj = 0 ; + - dr = 8 * jc/kspan ; - cd = 2 * pow ( sin(0.5*dr*rad) , 2 ); + dr = 8 * (double)jc/(double)kspan ; + printf ( "dr %f = jc %d kspan %d \n" ,dr, jc , kspan ); + cd = 2 * sin(0.5*dr*rad)*sin(0.5*dr*rad); sd = sin(dr*rad) ; + printf ("debut cd %f sd %f dr %f\n\n" , cd , sd, dr) ; kk = 1 ; i++ ; + for ( jjjj = 0 ; jjjj < 10 ; jjjj ++ ) + { + printf ( " \t%d a %f b %f \n" ,jjjj, a[jjjj] , b[jjjj] ); + } fprintf (stderr , "avant switch i %d ,nfac[i-1] %d\n" , i , nfac[i-1]); @@ -265,6 +276,10 @@ switch ( nfac[i-1] ) fprintf (stderr , "\t\t k %d i %d\n" , k ,i); factorOf3Transform ( ) ; + for ( jjjj = 0 ; jjjj < 9 ; jjjj ++ ) + { + printf ( " \t apres transf%d a %f b %f \n" ,jjjj, a[jjjj] , b[jjjj] ); + } break ; case 5 : @@ -281,7 +296,7 @@ switch ( nfac[i-1] ) k = nfac[i-1] ; kspnn = kspan ; kspan = kspan / k ; - fprintf (stderr , "\t\t k %d kspan \n" , k , kspan); + fprintf (stderr , "\t\t k %d kspan %d \n" , k , kspan); fprintf (stderr , "\t\t nfac[i-1] %d jf %d\n" , nfac[i-1] , jf ) ; if ( nfac[i-1] != jf) { @@ -293,6 +308,11 @@ switch ( nfac[i-1] ) break ; } + printf ("\n\n"); + for ( jjjj = 0 ; jjjj < 15; jjjj ++ ) + { + printf ( " \t%d a %f b %f \n" ,jjjj, a[jjjj] , b[jjjj] ); + } if ( retVal == 42 ) { @@ -321,19 +341,26 @@ switch ( nfac[i-1] ) void permute_stage1 (void) { - int retVal = 0 ; + int retVal = 1 ; + printf ("\t pre_sqFactor2NormlOrder\n"); pre_sqFactor2NormlOrder ( ) ; if ( n == ntot ) /*permutation for single-variate transform (optional code)*/ - while ( retVal == 0) - retVal = single_sqFactor2NormlOrder ( ) ; + while ( retVal == 1) + { + printf ("\tsingle_sqFactor2NormlOrder\n"); + single_sqFactor2NormlOrder ( ) ; + retVal = post_sqFactor2NormlOrder () ; + } else /*permutation for multivariate transform*/ - while ( retVal == 0) + while ( retVal == 1) + { + printf ("\tmulti_sqFactor2NormlOrder\n"); retVal = multi_sqFactor2NormlOrder ( ); - + } } @@ -341,7 +368,6 @@ void permute_stage1 (void) void permute_stage2 (void) { - int retVal ; kspnn = np[kt] ; fprintf (stderr , "\t kspnn %d , kt %d\n" , kspnn , kt); @@ -354,16 +380,24 @@ void permute_stage2 (void) fprintf (stderr , "\tdetPermutCycles 2\n" ); detPermutCycles ( ); - fprintf (stderr , "\tend ploplpop 2\n" ); - retVal = end ( ) ; - fprintf (stderr , "\t on n'est plus dans le end\n "); - while ( retVal == 1) + + + j = k3 + 1; + nt -= kspnn ; + i = nt - inc + 1 ; + while ( nt >= 0 ) { - fprintf (stderr , "\reorderMatrix 2\n" ); - reorderMatrix ( ) ; - retVal = end ( ) ; + printf ( "\t\t j %d , k3 %d\n" , j , k3 ) ; + fprintf (stderr , "\treordermatrix \n" ); + + reorderMatrix ( ) ; + j = k3 + 1 ; + nt -= kspnn ; + i = nt - inc + 1 ; + printf ( "\t\t570 nt %d k3 %d j %d\n" , nt, k3 , j) ; } + } /** ************************************** @@ -376,6 +410,7 @@ Sous-Sous-Fonctions int pre_fOf2Trans (void) { + int ktemp = 0 ; kspan /= 2; k1 = kspan + 2 ; @@ -394,18 +429,23 @@ int pre_fOf2Trans (void) b[kk-1] = b[kk-1] + bk; kk = k2 + kspan ; + ktemp = kk ; if ( kk > nn ) { kk -= nn ; } - }while ( kk <= jc && kk <= nn ); + }while (ktemp <= nn ||( kk <= jc && ktemp <= nn)); + + + printf ("\t kk %d > kspan %d ?\n" , kk, kspan ); if ( kk > kspan ) return 1 ; /*goto350*/ else + return 0 ;/*goto60*/ @@ -414,81 +454,83 @@ int pre_fOf2Trans (void) } + int factorOf2Transform (void) { - -int doOnceAgain = 1 ; +int ktemp = 0 ; +printf ( "\t\t fact\n" ) ; - /*60*/ - do - { +do /*60*/ + { c1 = 1 - cd ; s1 = sd ; mm = min( k1/2 , klim); + do/* do 80 */ + { + do + { + k2 = kk + kspan; + printf ("\t\t 80 k2 %d kk %d\n" , k2 , kk); + ak = a[kk-1] - a[k2-1]; + bk = b[kk-1] - b[k2-1]; -do - { - k2 = kk + kspan ; - ak = a[kk-1] - a[k2-1] ; - bk = b[kk-1] - b[k2-1] ; + a[kk-1] = a[kk-1] + a[k2-1]; + b[kk-1] = b[kk-1] + b[k2-1]; - a[kk-1] += a[k2-1] ; - b[kk-1] += b[k2-1] ; + a[k2-1] = c1*ak - s1*bk; + b[k2-1] = s1*ak + c1*bk; + printf ("\t\t k2 %d c1 %f s1 %f ak %f bk %f\n" , k2 , c1,s1,ak,bk); - a[k2-1] = c1*ak - s1*bk ; - b[k2-1] = c1*bk + s1*ak ; + kk = k2 + kspan; + ktemp = kk ; + if (kk >= nt) + { + k2 = kk - nt; + c1 = -c1; + kk = k1 - k2; + printf ("\t\t k2 %d kk %d nt %d\n" , k2 , kk , nt); + } - kk = k2 + kspan ; + }while ( ktemp < nt || (kk > k2 && ( ktemp >= nt)) ); - if ( kk >= nt ) - { - k2 = kk - nt ; - c1 = -c1 ; - kk = k1 - k2; + kk += jc; - if ( kk <= k2) + if ( kk <= mm ) /* 70 */ { - kk += jc ; - - if ( kk <= mm ) - { - ak = c1 - ( cd*c1*sd*s1) ; - s1 += (sd*c1-cd*s1) ; - /*c the following three statements compensate for truncation - c error. if rounded arithmetic is used, substitute - c c1=ak*/ - c1 = 0.5/(ak*ak+s1*s1) + 0.5 ; - s1 *= c1 ; - c1 *= ak ; - } - else - { - if ( kk < k2 ) - { - s1 = (double) ((kk-1)/jc)*dr*rad; - c1 = cos (s1); - s1 = cos (s1); - mm = min ( (k1 >> 1 ) , mm+klim ); - } - else - { - /*on sort de la boucle */ - doOnceAgain = 1 ; - } - } + printf ( "\t 70 \n") ; + ak = c1 - ( cd*c1+sd*s1) ; + s1 += (sd*c1-cd*s1) ; + /*c the following three statements compensate for truncation + c error. if rounded arithmetic is used, substitute + c c1=ak*/ + c1 = 0.5/(ak*ak+s1*s1) + 0.5 ; + s1 *= c1 ; + c1 *= ak ; } - } - - }while ( doOnceAgain == 0 ) ; + else + { + if ( kk < k2 ) /*90*/ + { + printf ( "\t 90 \n") ; + s1 = dr*rad*((double)(kk-1)/(double)jc); + c1 = cos(s1) ; + s1 = sin(s1) ; + mm = min(k1/2,mm+klim); + } + } + printf ( "\tplop\n") ; + }while ( kk <= mm || ( kk > mm && kk < k2 )); k1 += (inc+inc) ; kk = (k1-kspan)/2 + jc; - }while ( kk <= jc+jc ); + } while ( kk <= jc*2 ); + + printf ("goto40 1\n" ) ; return 0 ; /*goto40*/ } @@ -692,6 +734,8 @@ do void factorOf5Transform (void) { + int ktemp ; + c2 = c72*c72 - s72 *s72 ; s2 = 2 * c72*s72; fprintf (stderr , "plop\n" ) ; @@ -746,13 +790,14 @@ void factorOf5Transform (void) b[k3-1] = bk - aj ; kk = k4 + kspan; + ktemp = kk ; fprintf (stderr , "ak %f \tbk %f\naj %f \tbj %f\n" , ak , bk , aj ,bj ); fprintf (stderr , "kk %d \t nn %d \t kspan %d\n", kk , nn , kspan ); if ( kk >= nn ) kk -= nn ; fprintf (stderr , "kk %d \t nn %d \t kspan %d\n", kk , nn , kspan ); - }while ( kk <= kspan && kk < nn); + }while (ktemp < nn || ( kk <= kspan && ktemp >= nn)); fprintf (stderr , "fin 5\n" ); @@ -899,6 +944,7 @@ int mulByRotationFactor (void ) { c2 = 1 - cd ; s1 = sd ; + printf ( "\t 300 c2 %f s1 %f \n" , c2 , s1 ); mm = min ( kspan , klim ) ; /*320 */ @@ -908,10 +954,10 @@ int mulByRotationFactor (void ) c1 = c2 ; s2 = s1 ; kk += kspan ; - + printf ( "\t 320 c2 %f s1 %f \n" , c2 , s1 ); do { - printf ( "\t 330 \n" ) ; + printf ( "\t 330 kk %d s2 %f c2 %f\n" , kk , s2 , c2 ) ; ak = a[kk-1] ; a[kk-1] = c2*ak - s2*b[kk-1] ; b[kk-1] = s2*ak + c2*b[kk-1] ; @@ -919,15 +965,16 @@ int mulByRotationFactor (void ) kk += kspnn ; ktemp = kk ; - + printf ("\t\t kk %d nt %d \n" , kk , nt ); if ( kk > nt ) { ak = s1*s2 ; - s2 = s1*c2 + s1*c1 ; + s2 = s1*c2 + s2*c1 ; c2 = c1*c2 - ak ; kk += (kspan - nt ) ; + printf ( "\t\t plop c2 %f s2 %f \n" , c2 , s2 ); - + printf ("\t\t kk %d kspnn %d \n" , kk , kspnn ); } }while (ktemp <= nt || ( kk <= kspnn && ktemp > nt )) ; @@ -964,7 +1011,7 @@ int mulByRotationFactor (void ) } } - }while ( kk <= mm ||( kk <= kspan && kk > nn ) ) ; + }while ( kk <= mm ||( kk <= kspan && kk > mm ) ) ; kk += (jc + inc -kspan ); @@ -1005,13 +1052,14 @@ void pre_sqFactor2NormlOrder (void) kspan = np[1] ; kk = jc + 1 ; k2 = kspan + 1 ; + j = 1; } int post_sqFactor2NormlOrder (void) { - + printf ("\tpost_sqFactor2NormlOrder\n"); do { do @@ -1019,7 +1067,8 @@ int post_sqFactor2NormlOrder (void) k2 -= np[j-1] ; j++ ; k2 += np[j] ; - } while ( k2 < np[j-1]); + printf ("\t\t380-k2 %d np[%d] = %d\n" , k2 , j-1 , np[j-1]); + } while ( k2 > np[j-1]); j = 1 ; @@ -1029,6 +1078,7 @@ int post_sqFactor2NormlOrder (void) if ( kk < k2 ) { + printf ( "\t\t return 1\n"); return 1 ; } else @@ -1040,38 +1090,33 @@ int post_sqFactor2NormlOrder (void) }while ( kk < ks ) ; - + jc = k3 ; + printf ( "\t\t return 0\n"); return 0; } /* appeler cetter fonction dans un do while valeur_retour != 1)*/ -int single_sqFactor2NormlOrder (void) +void single_sqFactor2NormlOrder (void) { do { + printf ("\t\t 370 - kk %d ks %d k2 %d\n", kk , ks , k2 ) ; ak = a[kk-1] ; a[kk-1] = a[k2-1] ; a[k2-1] = ak ; + bk = b[kk-1] ; b[kk-1] = b[k2-1] ; b[k2-1] = bk ; + kk += inc ; k2 += kspan ; } while ( k2 < ks ); /*380*/ - - if( post_sqFactor2NormlOrder ( ) == 1 ) - { - - return 1 ; - } - jc = k3 ; - - return 0; } /*idem que single_ */ @@ -1189,8 +1234,8 @@ void detPermutCycles (void) { do { - fprintf (stderr , "\t\t j %d \tnp[j-1] %d\n" , j , np[j-1]); j++ ; + fprintf (stderr , "\t\t500 j %d \tnp[j-1] %d\n" , j , np[j-1]); kk = np[j-1] ; }while ( kk < 0 ) ; @@ -1199,14 +1244,15 @@ void detPermutCycles (void) { do { - fprintf (stderr , "\t\t 2boucle kk %d\n" , kk ); + fprintf (stderr , "\t\t 490 kk %d\n" , kk ); k = kk ; kk = np[k-1] ; np[k-1] = -kk ; }while ( kk != j ) ; k3 = kk ; } - np[j-1] = -j ; + else + np[j-1] = -j ; }while ( j != nn ); maxf *= inc ; @@ -1214,34 +1260,14 @@ void detPermutCycles (void) return ; } -int end (void) -{ - - - fprintf (stderr , "\t\t\t end of the final end\n"); - /* - j = k3 + 1 ; - nt -= kspnn ; - i = nt - inc + 1 ; - - fprintf (stderr , "\t\t\t end of the final end\n"); - if ( nt >= 0 ) - - return 1 ; - else -*/ - return 0 ; - - -} - - void reorderMatrix (void) { - +do + { do { j-- ; + printf ( "\t\t\t j %d , %d \n" , j , np[j-1]); }while (np[j-1] < 0 ) ; jj = jc ; @@ -1255,26 +1281,27 @@ void reorderMatrix (void) kspan = maxf ; jj -= kspan ; - k = np [j-1]; + k = np [j-1]; kk = jc*k + i + jj ; k1 = kk + kspan ; k2 = 0 ; - do + do /*530*/ { k2 ++ ; wt[k2-1] = a[k1-1] ; - bt[k2-1] = b[k-1] ; + bt[k2-1] = b[k1-1] ; k1 -= inc ; - }while ( k1 < kk ); + }while ( k1 != kk ); do { k1 = kk + kspan ; k2 = k1 - jc * (k + np[k-1]); + k = -np[k-1]; - + fprintf (stderr , "\t\ttend ploplpop 3\n" ); do { a[k1-1] = a[k2-1] ; @@ -1286,19 +1313,25 @@ void reorderMatrix (void) }while ( k1 != kk ) ; kk = k2 ; + printf ( "\t\t k %d j %d\n" , k , j ) ; }while ( k != j ); + k1 = kk +kspan ; + k2 = 0 ; /*560*/ do { k2 ++ ; - a[k1-1] = wt[k2] ; - b[k1-1] = bt[k2] ; + a[k1-1] = wt[k2-1] ; + b[k1-1] = bt[k2-1] ; + k1 -= inc ; + fprintf (stderr , "\t\t560 k1 %d kk %d\n" , k1 , kk ); }while ( k1 != kk ) ; } while ( jj != 0 ) ; +}while ( j != 1 ) ; return ; } diff --git a/src/signalProcessing/fft/fft_internal.h b/src/signalProcessing/fft/fft_internal.h index c595b027..2bd5a597 100644 --- a/src/signalProcessing/fft/fft_internal.h +++ b/src/signalProcessing/fft/fft_internal.h @@ -61,9 +61,9 @@ int dfftmx ( double* _pdblA , double* _pdblB , int _iNtot, int _iN, int _iNspan, int factorOf4Transform (void); int mulByRotationFactor (void ); int post_sqFactor2NormlOrder (void); - int single_sqFactor2NormlOrder (void); + void single_sqFactor2NormlOrder (void); int preF2transform (void) ; int multi_sqFactor2NormlOrder (void); - int end (void) ; +/* int end (void) ;*/ #endif /* !__FFT_INTERNAL_H__ */ diff --git a/src/signalProcessing/fft/testDoubleFft.c b/src/signalProcessing/fft/testDoubleFft.c index c872c689..94912726 100644 --- a/src/signalProcessing/fft/testDoubleFft.c +++ b/src/signalProcessing/fft/testDoubleFft.c @@ -25,6 +25,11 @@ #define COLS8 8 #define COLS9 9 #define COLS10 10 +#define COLS11 11 +#define COLS12 12 +#define COLS13 13 +#define COLS14 14 +#define COLS15 15 #define COLS16 16 #define COLS32 32 @@ -60,6 +65,7 @@ #define ZIMAG_IN8 { 0.21460078610107303, 0.31264199689030647, 0.36163610080257058, 0.2922266637906432,\ 0.56642488157376647, 0.48264719732105732, 0.33217189135029912, 0.59350947011262178} + #define ZREAL_IN9 { 0.23122371966019273, 0.21646326314657927, 0.88338878145441413, 0.65251349471509457,\ 0.30760907428339124, 0.93296162132173777, 0.21460078610107303, 0.31264199689030647,\ 0.43685875833034515} @@ -68,6 +74,47 @@ 0.68568959552794695} +#define ZREAL_IN10 { 0.21646326314657927, 0.65251349471509457, 0.63257448654621840, 0.31264199689030647,\ + 0.93296162132173777, 0.31264199689030647, 0.48185089323669672, 0.48264719732105732,\ + 0.2922266637906432 , 0.48264719732105732 } +#define ZIMAG_IN10 { 0.23122371966019273, 0.21646326314657927, 0.88338878145441413, 0.65251349471509457,\ + 0.11383596854284406, 0.19983377400785685, 0.56186607433483005, 0.58961773291230202,\ + 0.23122371966019273, 0.21646326314657927} +/* +#define ZREAL_IN10 { 1,2,3,4,5,6,7,8,9,10 } + + +#define ZIMAG_IN10 { 1,2,3,4,5,6,7,8,9,10 } +*/ + + + +#define ZREAL_IN11 { 1,2,3,4,5,6,7,8,9,10,11 } + +#define ZIMAG_IN11 { 1,2,3,4,5,6,7,8,9,10,11 } + + +#define ZREAL_IN12 { 1,2,3,4,5,6,7,8,9,10,11,12 } + +#define ZIMAG_IN12 { 1,2,3,4,5,6,7,8,9,10,11,12 } + + +#define ZREAL_IN13 { 1,2,3,4,5,6,7,8,9,10,11,12,13 } + +#define ZIMAG_IN13 { 1,2,3,4,5,6,7,8,9,10,11,12,13 } + + + +#define ZREAL_IN14 { 1,2,3,4,5,6,7,8,9,10,11,12,13,14 } + +#define ZIMAG_IN14 { 1,2,3,4,5,6,7,8,9,10,11,12,13,14 } + +#define ZREAL_IN15 { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 } + +#define ZIMAG_IN15 { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 } + + + #define ZREAL_IN16 {0.23122371966019273, 0.21646326314657927, 0.88338878145441413, 0.65251349471509457,\ 0.30760907428339124, 0.93296162132173777, 0.21460078610107303, 0.31264199689030647,\ 0.36163610080257058, 0.2922266637906432 , 0.56642488157376647, 0.48264719732105732,\ @@ -96,6 +143,9 @@ 0.68539796629920602,0.89062247332185507,0.50422128057107329,0.34936154074966908,\ 0.38737787725403905,0.92228986788541079,0.94881842611357570,0.34353372454643250} + + + #define ZREAL_RESULT2 { 0.33054822636768222,- 0.33010595710948110} #define ZIMAG_RESULT2 { 1.29377289256080985, 0.03698931587859988} @@ -110,6 +160,13 @@ #define ZIMAG_RESULT5 { 2.71449548611417413,-0.31527367037930898, 0.60322341639929178,-0.89813890885693670,\ 0.69993670814631914} +#define ZREAL_RESULT6 { 2.18414165778085589,-0.26482327553354379,-0.01687604011087318, 0.67184740351513028,\ + 0.11489612058787246, 0.57635803139679309 } +#define ZIMAG_RESULT6 { +2.34103989927098155,+0.34168162147929737,-0.70971181304669773,-0.05571636231616137,\ + -0.11084573654913504,-0.51884289223184654 } + + + #define ZREAL_RESULT7 { 3.06753043923527002,-0.62032167153569062,-0.13156333379499591, 0.48353341667797933,\ 0.63567251139259018, 0.05503001802946385, 0.31991983390432432} @@ -130,6 +187,16 @@ -1.82700213292318292,-0.72130831941965079,-0.43263346921029644,-0.61611460931125561,\ 0.73968558488709069 } + +#define ZREAL_RESULT10 { 4.7991688111796975 , 0.13431735180709442, 0.69797375124916528,-0.96094309976899528,\ + -1.299412169815219 , 0.31298504490405327,-0.70524633213128674, 0.73186521665562432,\ + -0.84695776029792746,-0.69911818231641265} +#define ZIMAG_RESULT10 { +3.8964297915808856 ,-0.73143162523007543,-1.16550179795884423,-0.28088284236709465,\ + +0.91311790128897607,+0.14664673572406173,-0.38825389263472715,+0.70003588825710683,\ + -1.10050453393604197,+0.32258157187768072} + + + #define ZREAL_RESULT16 { 7.31841186061501503, 0.57213963313411265,-0.54757095809921363,-0.48628670926159856,\ -1.24745626002550125,-0.60260425121772254,-0.09566750389725764, 1.12013387649474438,\ -0.52123307064175606,-0.4866536676629296 , 1.98659065302356819,-0.8626986211125984 ,\ @@ -372,8 +439,8 @@ static void zfftmaTest6 (void ) - double tRealResult [] = ZREAL_RESULT8; - double tImagResult [] = ZIMAG_RESULT8; + double tRealResult [] = ZREAL_RESULT6; + double tImagResult [] = ZIMAG_RESULT6; @@ -398,7 +465,7 @@ static void zfftmaTest6 (void ) 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 @@ -409,7 +476,7 @@ static void zfftmaTest6 (void ) assert ( 1 ) ; else assert ( fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])) < 1e-12 ) ; -*/ + } @@ -468,8 +535,6 @@ static void zfftmaTest7 (void ) } - - static void zfftmaTest8 (void ) { int i = 0 ; @@ -515,6 +580,7 @@ static void zfftmaTest8 (void ) } + static void zfftmaTest9 (void ) { int i = 0 ; @@ -543,7 +609,7 @@ static void zfftmaTest9 (void ) 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 @@ -554,12 +620,343 @@ static void zfftmaTest9 (void ) assert ( 1 ) ; else assert ( fabs( zimags(out[i]) - zimags (Result[i]) ) / fabs (zimags (out[i])) < 1e-12 ) ; -*/ + + } + + +} + +static void zfftmaTest10 (void ) +{ + int i = 0 ; + + double tRealIn [] = ZREAL_IN10; + double tImagIn [] = ZIMAG_IN10 ; + + + + double tRealResult [] = ZREAL_RESULT10 ; + double tImagResult [] = ZIMAG_RESULT10 ; + + + + doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS10)); + doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS10 ); + + + + zfftma ( in , ROW , COLS10 , out ); + + + + + /* 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*COLS10 ) ; 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]), + tRealResult[i] , + tImagResult[i], + fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i]))); + + + if ( zreals(out[i]) < 1e-14 && tRealResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) < 1e-12 ); + + + if ( zimags(out[i]) < 1e-14 && tImagResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i])) < 1e-12 ) ; + } +} + +static void zfftmaTest11 (void ) +{ + int i = 0 ; + + double tRealIn [] = ZREAL_IN11; + double tImagIn [] = ZIMAG_IN11 ; + + + + double tRealResult [] = ZREAL_RESULT16 ; + double tImagResult [] = ZIMAG_RESULT16 ; + + + + doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS11)); + doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS11 ); + + + + zfftma ( in , ROW , COLS11 , out ); + + + + + /* 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*COLS11 ) ; 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]), + tRealResult[i] , + tImagResult[i], + fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i]))); + + + if ( zreals(out[i]) < 1e-14 && tRealResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) < 1e-12 ); + + + if ( zimags(out[i]) < 1e-14 && tImagResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i])) < 1e-12 ) ; + + } } + +static void zfftmaTest12 (void ) +{ + int i = 0 ; + + double tRealIn [] = ZREAL_IN12; + double tImagIn [] = ZIMAG_IN12 ; + + + + double tRealResult [] = ZREAL_RESULT16 ; + double tImagResult [] = ZIMAG_RESULT16 ; + + + + doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS12)); + doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS12 ); + + + + zfftma ( in , ROW , COLS12 , out ); + + + + + /* 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*COLS12 ) ; 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]), + tRealResult[i] , + tImagResult[i], + fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i]))); + + + if ( zreals(out[i]) < 1e-14 && tRealResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) < 1e-12 ); + + + if ( zimags(out[i]) < 1e-14 && tImagResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i])) < 1e-12 ) ; + + } + +} + + +static void zfftmaTest13 (void ) +{ + int i = 0 ; + + double tRealIn [] = ZREAL_IN13; + double tImagIn [] = ZIMAG_IN13 ; + + + + double tRealResult [] = ZREAL_RESULT16 ; + double tImagResult [] = ZIMAG_RESULT16 ; + + + + doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS13)); + doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS13 ); + + + + zfftma ( in , ROW , COLS13 , out ); + + + + + /* 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*COLS13 ) ; 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]), + tRealResult[i] , + tImagResult[i], + fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i]))); + + + if ( zreals(out[i]) < 1e-14 && tRealResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) < 1e-12 ); + + + if ( zimags(out[i]) < 1e-14 && tImagResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i])) < 1e-12 ) ; + + } + +} + + +static void zfftmaTest14 (void ) +{ + int i = 0 ; + + double tRealIn [] = ZREAL_IN14; + double tImagIn [] = ZIMAG_IN14 ; + + + + double tRealResult [] = ZREAL_RESULT16 ; + double tImagResult [] = ZIMAG_RESULT16 ; + + + + doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS14)); + doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS14 ); + + + + zfftma ( in , ROW , COLS14 , out ); + + + + + /* 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*COLS14 ) ; 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]), + tRealResult[i] , + tImagResult[i], + fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i]))); + + + if ( zreals(out[i]) < 1e-14 && tRealResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) < 1e-12 ); + + + if ( zimags(out[i]) < 1e-14 && tImagResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i])) < 1e-12 ) ; + + } + +} + + + +static void zfftmaTest15 (void ) +{ + int i = 0 ; + + double tRealIn [] = ZREAL_IN15; + double tImagIn [] = ZIMAG_IN15 ; + + + + double tRealResult [] = ZREAL_RESULT16 ; + double tImagResult [] = ZIMAG_RESULT16 ; + + + + doubleComplex* out = (doubleComplex*) malloc ( sizeof(doubleComplex) * (unsigned int) (ROW*COLS15)); + doubleComplex* in = DoubleComplexMatrix ( tRealIn , tImagIn , ROW*COLS15 ); + + + + zfftma ( in , ROW , COLS15 , out ); + + + + + /* 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*COLS15 ) ; 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]), + tRealResult[i] , + tImagResult[i], + fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) , + fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i]))); + + + if ( zreals(out[i]) < 1e-14 && tRealResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zreals(out[i]) - tRealResult[i] ) / fabs (zreals (out[i])) < 1e-12 ); + + + if ( zimags(out[i]) < 1e-14 && tImagResult[i] < 1e-18 ) + assert ( 1 ) ; + else + assert ( fabs( zimags(out[i]) - tImagResult[i] ) / fabs (zimags (out[i])) < 1e-12 ) ; + + } + +} + + + static void zfftmaTest16 (void ) { int i = 0 ; @@ -614,6 +1011,8 @@ static void zfftmaTest16 (void ) } + + static void zfftmaTest32 (void ) { int i = 0 ; @@ -676,7 +1075,6 @@ static int testFft(void) { printf("\n\n\n"); - printf("\t>>>> Vector 2 Double Complex Tests\n"); zfftmaTest2(); printf("\t>>>> Vector 3 Double Complex Tests\n"); @@ -685,7 +1083,8 @@ static int testFft(void) { zfftmaTest4(); printf("\t>>>> Vector 5 Double Complex Tests\n"); zfftmaTest5(); - + printf("\t>>>> Vector 6 Double Complex Tests\n"); + zfftmaTest6(); printf("\t>>>> Vector 7 Double Complex Tests\n"); zfftmaTest7(); printf("\t>>>> Vector 8 Double Complex Tests\n"); @@ -693,6 +1092,12 @@ static int testFft(void) { printf("\t>>>> Vector 9 Double Complex Tests\n"); zfftmaTest9(); + + + printf("\t>>>> Vector 10 Double Complex Tests\n"); + zfftmaTest10(); + +/* printf("\t>>>> Vector 16 Double Complex Tests\n"); zfftmaTest16(); printf("\t>>>> Vector 32 Double Complex Tests\n"); @@ -702,7 +1107,7 @@ static int testFft(void) { printf("\t>>>> Vector 6 Double Complex Tests\n"); zfftmaTest6(); - +*/ return 0; } |