IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2004, 2:31:55 PM (22 years ago)
Author:
gusciora
Message:

Most of these tests work.

File:
1 edited

Legend:

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

    r779 r887  
    11/*****************************************************************************
    22    This routine must ensure that PS_STAT_NVALUES is correctly computed
    3     by the procedure psArrayStats().
     3    by the procedure psVectorStats().
     4 
     5    Note: The NVALUES stat was removed from the IfA requirements spec.  So,
     6    this test is no longer in use.
    47 *****************************************************************************/
    58#include <stdio.h>
     
    1215{
    1316    psStats *myStats    = NULL;
    14     psStats *myStats2   = NULL;
    1517    int testStatus      = true;
    1618    int i               = 0;
     
    1820    psVector *maskVector= NULL;
    1921
     22    /*************************************************************************/
     23    /*  Allocate and initialize data structures                      */
     24    /*************************************************************************/
     25    myStats = psStatsAlloc(PS_STAT_NVALUES);
     26    myVector = psVectorAlloc(N, PS_TYPE_F32);
     27    myVector->n = N;
     28    maskVector = psVectorAlloc(N, PS_TYPE_U8);
     29    maskVector->n = N;
     30
     31    // Set the appropriate values for the vector data.
     32    for (i=0;i<N;i++) {
     33        myVector->data.F32[i] = (float) i;
     34    }
     35
     36    // Set the mask vector and calculate the expected maximum.
     37    for (i=0;i<N;i++) {
     38        if (i < (N/2)) {
     39            maskVector->data.U8[i] = 0;
     40        } else {
     41            maskVector->data.U8[i] = 1;
     42        }
     43    }
     44
     45    /*************************************************************************/
     46    /*  Call psVectorStats() with no vector mask.                    */
     47    /*************************************************************************/
    2048    printPositiveTestHeader(stdout,
    2149                            "psStats functions",
    2250                            "PS_STAT_NVALUES");
    2351
    24     myStats = psStatsAlloc(PS_STAT_NVALUES);
    25     myVector = psVectorAlloc(PS_TYPE_FLOAT, N);
    26     myVector->n = N;
    27     maskVector = psVectorAlloc(PS_TYPE_UINT8, N);
    28     maskVector->n = N;
     52    myStats = psVectorStats(myStats, myVector, NULL, 0);
    2953
    30     for (i=0;i<N;i++) {
    31         myVector->vec.f[i] = (float) i;
    32         if (i < (N/2)) {
    33             maskVector->vec.ui8[i] = 0;
    34         } else {
    35             maskVector->vec.ui8[i] = 1;
    36         }
    37     }
    38 
    39     myStats2 = psArrayStats(myVector, NULL, 0, myStats);
    40 
    41     printf("Called psArrayStats() on a vector with no elements masked.\n");
     54    printf("Called psVectorStats() on a vector with no elements masked.\n");
    4255    printf("The expected nvalues was %d.  The calculated nvalues was %d.\n",
    43            N, myStats2->nValues);
    44     if (myStats2->nValues == N) {
     56           N, myStats->nValues);
     57    if (myStats->nValues == N) {
    4558        testStatus = true;
    4659    } else {
     
    4861    }
    4962
    50     myStats2 = psArrayStats(myVector, maskVector, 1, myStats);
    51     printf("Called psArrayStats() on a vector with last N/2 elements masked.\n");
     63    /*************************************************************************/
     64    /*  Call psVectorStats() with vector mask.                       */
     65    /*************************************************************************/
     66    myStats = psVectorStats(myStats, myVector, maskVector, 1);
     67    printf("Called psVectorStats() on a vector with last N/2 elements masked.\n");
    5268    printf("The expected nvalues was %d.  The calculated nvalues was %d.\n",
    53            N/2, myStats2->nValues);
    54     if (myStats2->nValues == N/2) {
     69           N/2, myStats->nValues);
     70    if (myStats->nValues == N/2) {
    5571        testStatus = true;
    5672    } else {
Note: See TracChangeset for help on using the changeset viewer.