IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 11:25:59 AM (22 years ago)
Author:
gusciora
Message:

...

File:
1 edited

Legend:

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

    r1900 r2197  
    1010#include <math.h>
    1111
    12 #define N 200
     12#define N 90
    1313#define MEAN 32.0
    1414#define STDEV 2.0
    1515#define ERROR_TOLERANCE 0.10
    1616
    17 int main()
     17int t00()
    1818{
    1919    psStats * myStats = NULL;
     
    3232    float realMedianNoMask = MEAN;
    3333    float realModeNoMask = MEAN;
    34     float realStdevNoMask = STDEV * 0.33;
     34    float realStdevNoMask = STDEV * 0.20;
    3535    float realLQNoMask = MEAN - ( 0.6 * STDEV );
    3636    float realUQNoMask = MEAN + ( 0.6 * STDEV );
    3737    int realN50NoMask = N / 4;
    3838    int realNfitNoMask = N / 4;
    39     float realMeanWithMask = MEAN;
    40     float realMedianWithMask = MEAN;
    41     float realModeWithMask = MEAN;
    42     float realStdevWithMask = STDEV;
    43     float realLQWithMask = MEAN;
    44     float realUQWithMask = MEAN;
    45     int realN50WithMask = N / 4;
    46     int realNfitWithMask = N / 4;
    47 
     39
     40    psTraceSetLevel(".psLib.dataManip.psStats", 10);
    4841
    4942    /*************************************************************************/
     
    232225                 "PS_STAT_ROBUST_STATS: robust Nfit: no vector mask",
    233226                 testStatus );
    234 
    235 
    236     return ( 0 );
     227    return(testStatus);
     228
     229    /*************************************************************************/
     230    /*  Deallocate data structures                                           */
     231    /*************************************************************************/
     232    printPositiveTestHeader( stdout,
     233                             "psStats functions",
     234                             "psStats(): deallocating memory" );
     235
     236    psFree( myStats );
     237    psFree( myVector );
     238    psFree( maskVector );
     239
     240    psMemCheckCorruption( 1 );
     241    memLeaks = psMemCheckLeaks(currentId,NULL,stderr);
     242    if ( 0 != memLeaks ) {
     243        psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
     244    }
     245
     246    printFooter( stdout,
     247                 "psVector functions",
     248                 "psStats(): deallocating memory",
     249                 testStatus );
     250
     251    return ( !globalTestStatus );
     252}
     253
     254
     255int t01()
     256{
     257    psStats * myStats = NULL;
     258    int testStatus = true;
     259    int globalTestStatus = true;
     260    int i = 0;
     261    psVector *myVector = NULL;
     262    psVector *maskVector = NULL;
     263    // NOTE: These values were calculated by running the function on the data.
     264    // A: They must be changed if we adjust the number of data points.
     265    // B: We don't really know that they are correct.
     266    int count = 0;
     267    int currentId = psMemGetId();
     268    int memLeaks = 0;
     269    float realMeanWithMask = MEAN;
     270    float realMedianWithMask = MEAN;
     271    float realModeWithMask = MEAN;
     272    float realStdevWithMask = STDEV * 0.20;
     273    float realLQWithMask = MEAN;
     274    float realUQWithMask = MEAN;
     275    int realN50WithMask = N / 4;
     276    int realNfitWithMask = N / 4;
     277
     278    psTraceSetLevel(".psLib.dataManip.psStats", 10);
     279
     280    /*************************************************************************/
     281    /*  Allocate and initialize data structures                              */
     282    /*************************************************************************/
     283    myStats = psStatsAlloc( PS_STAT_ROBUST_MEAN |
     284                            PS_STAT_ROBUST_MEDIAN |
     285                            PS_STAT_ROBUST_MODE |
     286                            PS_STAT_ROBUST_STDEV |
     287                            PS_STAT_ROBUST_QUARTILE );
     288
     289    maskVector = psVectorAlloc( N, PS_TYPE_U8 );
     290    maskVector->n = N;
     291    myVector = psGaussianDev( MEAN, STDEV, N );
     292    // Set the mask vector and calculate the expected maximum.
     293    for ( i = 0;i < N;i++ ) {
     294        if ( i < ( N / 2 ) ) {
     295            maskVector->data.U8[ i ] = 0;
     296            count++;
     297        } else {
     298            maskVector->data.U8[ i ] = 1;
     299        }
     300    }
    237301
    238302    /*************************************************************************/
     
    422486    return ( !globalTestStatus );
    423487}
     488
     489int main()
     490{
     491    t00();
     492    t01();
     493}
Note: See TracChangeset for help on using the changeset viewer.