IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psVectorFFT.c

    r1406 r2204  
    66*  @author Robert DeSonia, MHPCC
    77*
    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 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020#define GENIMAGE(img,c,r,TYP, valueFcn) \
    2121img = psImageAlloc(c,r,PS_TYPE_##TYP); \
    22 for (unsigned int row=0;row<r;row++) { \
     22for (psU32 row=0;row<r;row++) { \
    2323    ps##TYP* imgRow = img->data.TYP[row]; \
    24     for (unsigned int col=0;col<c;col++) { \
     24    for (psU32 col=0;col<c;col++) { \
    2525        imgRow[col] = (ps##TYP)(valueFcn); \
    2626    } \
    2727}
    2828
    29 static int testVectorFFT( void );
    30 static int testVectorRealImaginary( void );
    31 static int testVectorComplex( void );
    32 static int testVectorConjugate( void );
    33 static int testVectorPowerSpectrum( void );
     29static psS32 testVectorFFT( void );
     30static psS32 testVectorRealImaginary( void );
     31static psS32 testVectorComplex( void );
     32static psS32 testVectorConjugate( void );
     33static psS32 testVectorPowerSpectrum( void );
    3434
    3535testDescription tests[] = {
     
    5454                          };
    5555
    56 int main( int argc, char* argv[] )
     56psS32 main( psS32 argc, char* argv[] )
    5757{
    5858    psLogSetLevel( PS_LOG_INFO );
     
    6161}
    6262
    63 int testVectorFFT( void )
     63psS32 testVectorFFT( void )
    6464{
    6565    psVector * vec = NULL;
     
    7878    vec = psVectorAlloc( 100, PS_TYPE_F32 );
    7979    vec->n = vec->nalloc;
    80     for ( unsigned int n = 0; n < 100; n++ ) {
     80    for ( psU32 n = 0; n < 100; n++ ) {
    8181        vec->data.F32[ n ] = sinf( ( psF32 ) n / 50.0f * M_PI );
    8282    }
     
    9191
    9292    // 3. verify that the only significant component cooresponds to the freqency of the input in step 1.
    93     for ( unsigned int n = 0; n < 100; n++ ) {
     93    for ( psU32 n = 0; n < 100; n++ ) {
    9494        if ( n == 1 || n == 99 ) {
    9595            if ( fabsf( cabsf( vec2->data.C32[ n ] ) - 50.0f ) > 0.1f ) {
     
    111111        return 4;
    112112    }
    113     for ( unsigned int n = 0; n < 100; n++ ) {
     113    for ( psU32 n = 0; n < 100; n++ ) {
    114114        psF32 val = sinf( ( psF32 ) n / 50.0f * M_PI );
    115115        psF32 vecVal = crealf( vec3->data.C32[ n ] ) / 100;
     
    128128}
    129129
    130 int testVectorRealImaginary( void )
     130psS32 testVectorRealImaginary( void )
    131131{
    132132    psVector * vec = NULL;
     
    143143    vec = psVectorAlloc( 100, PS_TYPE_C32 );
    144144    vec->n = vec->nalloc;
    145     for ( unsigned int n = 0; n < 100; n++ ) {
     145    for ( psU32 n = 0; n < 100; n++ ) {
    146146        vec->data.C32[ n ] = n + I * ( n * 2 );
    147147    }
     
    171171
    172172    // 3. compare results to the real/imaginary components of input
    173     for ( unsigned int n = 0; n < 100; n++ ) {
     173    for ( psU32 n = 0; n < 100; n++ ) {
    174174        psF32 r = n;
    175175        psF32 i = ( n * 2 );
     
    193193}
    194194
    195 int testVectorComplex( void )
     195psS32 testVectorComplex( void )
    196196{
    197197    psVector * vec = NULL;
     
    220220    vec->n = vec->nalloc;
    221221    vec2->n = vec2->nalloc;
    222     for ( unsigned int n = 0; n < 100; n++ ) {
     222    for ( psU32 n = 0; n < 100; n++ ) {
    223223        vec->data.F32[ n ] = n;
    224224        vec2->data.F32[ n ] = ( n * 2 );
     
    237237    // 4. call psVectorReal and psVectorImaginary on step 2 results (not needed, just use crealf/cimagf)
    238238    // 5. compare step 4 results to input.
    239     for ( unsigned int n = 0; n < 100; n++ ) {
     239    for ( psU32 n = 0; n < 100; n++ ) {
    240240        if ( fabsf( crealf( vec3->data.C32[ n ] ) - n ) > FLT_EPSILON ||
    241241                fabsf( cimagf( vec3->data.C32[ n ] ) - ( n * 2 ) ) > FLT_EPSILON ) {
     
    278278}
    279279
    280 int testVectorConjugate( void )
     280psS32 testVectorConjugate( void )
    281281{
    282282    psVector * vec = NULL;
     
    293293    vec = psVectorAlloc( 100, PS_TYPE_C32 );
    294294    vec->n = vec->nalloc;
    295     for ( unsigned int n = 0; n < 100; n++ ) {
     295    for ( psU32 n = 0; n < 100; n++ ) {
    296296        vec->data.C32[ n ] = n + I * ( n * 2 );
    297297    }
     
    307307
    308308    // 4. verify each value is conjugate of input (a+bi -> a-bi)
    309     for ( unsigned int n = 0; n < 100; n++ ) {
     309    for ( psU32 n = 0; n < 100; n++ ) {
    310310        if ( fabsf( crealf( vec->data.C32[ n ] ) - crealf( vec2->data.C32[ n ] ) ) > FLT_EPSILON ||
    311311                fabsf( cimagf( vec->data.C32[ n ] ) + cimagf( vec2->data.C32[ n ] ) ) > FLT_EPSILON ) {
     
    322322}
    323323
    324 int testVectorPowerSpectrum( void )
     324psS32 testVectorPowerSpectrum( void )
    325325{
    326326    psVector * vec = NULL;
     
    338338    vec = psVectorAlloc( 100, PS_TYPE_C32 );
    339339    vec->n = vec->nalloc;
    340     for ( unsigned int n = 0; n < 100; n++ ) {
     340    for ( psU32 n = 0; n < 100; n++ ) {
    341341        vec->data.C32[ n ] = n + I * sinf( ( ( psF32 ) n ) / 50.f * M_PI );
    342342    }
     
    365365    };
    366366
    367     for ( unsigned int n = 1; n < 50; n++ ) {
     367    for ( psU32 n = 1; n < 50; n++ ) {
    368368        val = ( cabsf( vec->data.C32[ n ] ) * cabsf( vec->data.C32[ n ] ) +
    369369                cabsf( vec->data.C32[ 100 - n ] ) * cabsf( vec->data.C32[ 100 - n ] ) ) / 100 / 100;
Note: See TracChangeset for help on using the changeset viewer.