IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2004, 5:14:39 PM (22 years ago)
Author:
gusciora
Message:

...

File:
1 edited

Legend:

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

    r887 r893  
    1111{
    1212    psStats *myStats    = NULL;
     13    psStats *myStats2    = NULL;
    1314    int testStatus      = true;
    1415    int globalTestStatus = true;
     
    5152        }
    5253    }
     54
     55
    5356    realMeanNoMask /= (float) N;
    5457    realMeanWithMask /= (float) count;
     
    7881
    7982    /*************************************************************************/
    80     /*  Call psVectorStats() with vector mask.                       */
    81     /*************************************************************************/
    82     printPositiveTestHeader(stdout,
    83                             "psStats functions",
    84                             "PS_STAT_SAMPLE_MEAN: with vector mask");
     83    /*  Call psVectorStats() with vector mask=1.                             */
     84    /*************************************************************************/
     85    printPositiveTestHeader(stdout,
     86                            "psStats functions",
     87                            "PS_STAT_SAMPLE_MEAN: with vector mask=1");
    8588
    8689    myStats = psVectorStats(myStats, myVector, maskVector, 1);
     
    97100    printFooter(stdout,
    98101                "psVector functions",
    99                 "PS_STAT_SAMPLE_MEAN: with vector mask",
    100                 testStatus);
    101 
    102     /*************************************************************************/
    103     /*  Deallocate data structures                                   */
     102                "PS_STAT_SAMPLE_MEAN: with vector mask=1",
     103                testStatus);
     104
     105    /*************************************************************************/
     106    /*  Call psVectorStats() with vector mask=2.                             */
     107    /*************************************************************************/
     108    printPositiveTestHeader(stdout,
     109                            "psStats functions",
     110                            "PS_STAT_SAMPLE_MEAN: with vector mask=2");
     111
     112    // Set the mask vector and calculate the expected maximum.
     113    // Set the mask vector.
     114    for (i=0;i<N;i++) {
     115        if (maskVector->data.U8[i] == 1) {
     116            maskVector->data.U8[i] = 2;
     117        }
     118    }
     119
     120    myStats = psVectorStats(myStats, myVector, maskVector, 2);
     121    mean = myStats->sampleMean;
     122    printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
     123    printf("The expected mean was %f; the calculated mean was %f\n", realMeanWithMask, mean);
     124    if (mean == realMeanWithMask) {
     125        testStatus = true;
     126    } else {
     127        testStatus = false;
     128        globalTestStatus = false;
     129    }
     130
     131    printFooter(stdout,
     132                "psVector functions",
     133                "PS_STAT_SAMPLE_MEAN: with vector mask=2",
     134                testStatus);
     135
     136    /*************************************************************************/
     137    /*  Call psVectorStats() with vector mask=3.                             */
     138    /*************************************************************************/
     139    printPositiveTestHeader(stdout,
     140                            "psStats functions",
     141                            "PS_STAT_SAMPLE_MEAN: with vector mask=3");
     142
     143    // Set the mask vector and calculate the expected maximum.
     144    // Set the mask vector.
     145    for (i=0;i<N;i++) {
     146        if (maskVector->data.U8[i] == 2) {
     147            maskVector->data.U8[i] = 3;
     148        }
     149    }
     150
     151    myStats = psVectorStats(myStats, myVector, maskVector, 3);
     152    mean = myStats->sampleMean;
     153    printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
     154    printf("The expected mean was %f; the calculated mean was %f\n", realMeanWithMask, mean);
     155    if (mean == realMeanWithMask) {
     156        testStatus = true;
     157    } else {
     158        testStatus = false;
     159        globalTestStatus = false;
     160    }
     161
     162    printFooter(stdout,
     163                "psVector functions",
     164                "PS_STAT_SAMPLE_MEAN: with vector mask=3",
     165                testStatus);
     166    /*************************************************************************/
     167    /*  Call psVectorStats() with NULL inputs.                               */
     168    /*************************************************************************/
     169    printPositiveTestHeader(stdout,
     170                            "psStats functions",
     171                            "PS_STAT_SAMPLE_MEAN: NULL inputs");
     172
     173    myStats = psVectorStats(myStats, NULL, NULL, 0);
     174    myStats2 = psVectorStats(NULL, myVector, NULL, 0);
     175
     176    printFooter(stdout,
     177                "psVector functions",
     178                "PS_STAT_SAMPLE_MEAN: NULL inputs",
     179                testStatus);
     180
     181    /*************************************************************************/
     182    /*  Deallocate data structures                                           */
    104183    /*************************************************************************/
    105184    printPositiveTestHeader(stdout,
Note: See TracChangeset for help on using the changeset viewer.