Changeset 2204 for trunk/psLib/test/dataManip/tst_psVectorFFT.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psVectorFFT.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psVectorFFT.c
r1406 r2204 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2004- 08-06 22:34:06$8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 00:57:33 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #define GENIMAGE(img,c,r,TYP, valueFcn) \ 21 21 img = psImageAlloc(c,r,PS_TYPE_##TYP); \ 22 for ( unsigned introw=0;row<r;row++) { \22 for (psU32 row=0;row<r;row++) { \ 23 23 ps##TYP* imgRow = img->data.TYP[row]; \ 24 for ( unsigned intcol=0;col<c;col++) { \24 for (psU32 col=0;col<c;col++) { \ 25 25 imgRow[col] = (ps##TYP)(valueFcn); \ 26 26 } \ 27 27 } 28 28 29 static inttestVectorFFT( void );30 static inttestVectorRealImaginary( void );31 static inttestVectorComplex( void );32 static inttestVectorConjugate( void );33 static inttestVectorPowerSpectrum( void );29 static psS32 testVectorFFT( void ); 30 static psS32 testVectorRealImaginary( void ); 31 static psS32 testVectorComplex( void ); 32 static psS32 testVectorConjugate( void ); 33 static psS32 testVectorPowerSpectrum( void ); 34 34 35 35 testDescription tests[] = { … … 54 54 }; 55 55 56 int main( intargc, char* argv[] )56 psS32 main( psS32 argc, char* argv[] ) 57 57 { 58 58 psLogSetLevel( PS_LOG_INFO ); … … 61 61 } 62 62 63 inttestVectorFFT( void )63 psS32 testVectorFFT( void ) 64 64 { 65 65 psVector * vec = NULL; … … 78 78 vec = psVectorAlloc( 100, PS_TYPE_F32 ); 79 79 vec->n = vec->nalloc; 80 for ( unsigned intn = 0; n < 100; n++ ) {80 for ( psU32 n = 0; n < 100; n++ ) { 81 81 vec->data.F32[ n ] = sinf( ( psF32 ) n / 50.0f * M_PI ); 82 82 } … … 91 91 92 92 // 3. verify that the only significant component cooresponds to the freqency of the input in step 1. 93 for ( unsigned intn = 0; n < 100; n++ ) {93 for ( psU32 n = 0; n < 100; n++ ) { 94 94 if ( n == 1 || n == 99 ) { 95 95 if ( fabsf( cabsf( vec2->data.C32[ n ] ) - 50.0f ) > 0.1f ) { … … 111 111 return 4; 112 112 } 113 for ( unsigned intn = 0; n < 100; n++ ) {113 for ( psU32 n = 0; n < 100; n++ ) { 114 114 psF32 val = sinf( ( psF32 ) n / 50.0f * M_PI ); 115 115 psF32 vecVal = crealf( vec3->data.C32[ n ] ) / 100; … … 128 128 } 129 129 130 inttestVectorRealImaginary( void )130 psS32 testVectorRealImaginary( void ) 131 131 { 132 132 psVector * vec = NULL; … … 143 143 vec = psVectorAlloc( 100, PS_TYPE_C32 ); 144 144 vec->n = vec->nalloc; 145 for ( unsigned intn = 0; n < 100; n++ ) {145 for ( psU32 n = 0; n < 100; n++ ) { 146 146 vec->data.C32[ n ] = n + I * ( n * 2 ); 147 147 } … … 171 171 172 172 // 3. compare results to the real/imaginary components of input 173 for ( unsigned intn = 0; n < 100; n++ ) {173 for ( psU32 n = 0; n < 100; n++ ) { 174 174 psF32 r = n; 175 175 psF32 i = ( n * 2 ); … … 193 193 } 194 194 195 inttestVectorComplex( void )195 psS32 testVectorComplex( void ) 196 196 { 197 197 psVector * vec = NULL; … … 220 220 vec->n = vec->nalloc; 221 221 vec2->n = vec2->nalloc; 222 for ( unsigned intn = 0; n < 100; n++ ) {222 for ( psU32 n = 0; n < 100; n++ ) { 223 223 vec->data.F32[ n ] = n; 224 224 vec2->data.F32[ n ] = ( n * 2 ); … … 237 237 // 4. call psVectorReal and psVectorImaginary on step 2 results (not needed, just use crealf/cimagf) 238 238 // 5. compare step 4 results to input. 239 for ( unsigned intn = 0; n < 100; n++ ) {239 for ( psU32 n = 0; n < 100; n++ ) { 240 240 if ( fabsf( crealf( vec3->data.C32[ n ] ) - n ) > FLT_EPSILON || 241 241 fabsf( cimagf( vec3->data.C32[ n ] ) - ( n * 2 ) ) > FLT_EPSILON ) { … … 278 278 } 279 279 280 inttestVectorConjugate( void )280 psS32 testVectorConjugate( void ) 281 281 { 282 282 psVector * vec = NULL; … … 293 293 vec = psVectorAlloc( 100, PS_TYPE_C32 ); 294 294 vec->n = vec->nalloc; 295 for ( unsigned intn = 0; n < 100; n++ ) {295 for ( psU32 n = 0; n < 100; n++ ) { 296 296 vec->data.C32[ n ] = n + I * ( n * 2 ); 297 297 } … … 307 307 308 308 // 4. verify each value is conjugate of input (a+bi -> a-bi) 309 for ( unsigned intn = 0; n < 100; n++ ) {309 for ( psU32 n = 0; n < 100; n++ ) { 310 310 if ( fabsf( crealf( vec->data.C32[ n ] ) - crealf( vec2->data.C32[ n ] ) ) > FLT_EPSILON || 311 311 fabsf( cimagf( vec->data.C32[ n ] ) + cimagf( vec2->data.C32[ n ] ) ) > FLT_EPSILON ) { … … 322 322 } 323 323 324 inttestVectorPowerSpectrum( void )324 psS32 testVectorPowerSpectrum( void ) 325 325 { 326 326 psVector * vec = NULL; … … 338 338 vec = psVectorAlloc( 100, PS_TYPE_C32 ); 339 339 vec->n = vec->nalloc; 340 for ( unsigned intn = 0; n < 100; n++ ) {340 for ( psU32 n = 0; n < 100; n++ ) { 341 341 vec->data.C32[ n ] = n + I * sinf( ( ( psF32 ) n ) / 50.f * M_PI ); 342 342 } … … 365 365 }; 366 366 367 for ( unsigned intn = 1; n < 50; n++ ) {367 for ( psU32 n = 1; n < 50; n++ ) { 368 368 val = ( cabsf( vec->data.C32[ n ] ) * cabsf( vec->data.C32[ n ] ) + 369 369 cabsf( vec->data.C32[ 100 - n ] ) * cabsf( vec->data.C32[ 100 - n ] ) ) / 100 / 100;
Note:
See TracChangeset
for help on using the changeset viewer.
