Changeset 887 for trunk/psLib/test/dataManip/tst_psStats04.c
- Timestamp:
- Jun 6, 2004, 2:31:55 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psStats04.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psStats04.c
r779 r887 1 1 /***************************************************************************** 2 2 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. 4 7 *****************************************************************************/ 5 8 #include <stdio.h> … … 12 15 { 13 16 psStats *myStats = NULL; 14 psStats *myStats2 = NULL;15 17 int testStatus = true; 16 18 int i = 0; … … 18 20 psVector *maskVector= NULL; 19 21 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 /*************************************************************************/ 20 48 printPositiveTestHeader(stdout, 21 49 "psStats functions", 22 50 "PS_STAT_NVALUES"); 23 51 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); 29 53 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"); 42 55 printf("The expected nvalues was %d. The calculated nvalues was %d.\n", 43 N, myStats 2->nValues);44 if (myStats 2->nValues == N) {56 N, myStats->nValues); 57 if (myStats->nValues == N) { 45 58 testStatus = true; 46 59 } else { … … 48 61 } 49 62 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"); 52 68 printf("The expected nvalues was %d. The calculated nvalues was %d.\n", 53 N/2, myStats 2->nValues);54 if (myStats 2->nValues == N/2) {69 N/2, myStats->nValues); 70 if (myStats->nValues == N/2) { 55 71 testStatus = true; 56 72 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
