Changeset 1985 for trunk/psLib/test/dataManip/tst_psFunc07.c
- Timestamp:
- Oct 6, 2004, 12:27:06 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psFunc07.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psFunc07.c
r1982 r1985 4 4 values, sets the spline polynomials with psVectorFitSpline1D(), then calls 5 5 psSpline1DEval() on new data values and ensures that the results are correct. 6 7 F32 and F64 versions are used here. 8 9 XXX: The spline eval functions are F32 only, while the spline fit functions 10 are F32 and F64. 6 11 *****************************************************************************/ 7 12 #include <stdio.h> … … 62 67 printPositiveTestHeader(stdout, 63 68 "psFunction functions", 64 "psSpline1DAlloc() ");69 "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F32 versions"); 65 70 66 71 psVectorFitSpline1D(tmpSpline, x, y, NULL); … … 71 76 printf("ERROR[%d]: f(%f) is %f. Should be %f\n", i, 72 77 newX->data.F32[i], newY->data.F32[i], myFunc(newX->data.F32[i])); 78 testStatus = false; 73 79 } 74 80 } … … 88 94 printFooter(stdout, 89 95 "psFunctions functions", 90 "psSpline1DAlloc() ",96 "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F32 versions", 91 97 testStatus); 92 98 … … 94 100 } 95 101 96 int t00() 102 // This is the F64 version of the above test code. 103 int t01() 97 104 { 98 105 int testStatus = true; … … 110 117 /****************************************************************************/ 111 118 testStatus = true; 112 x = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F 32);113 newX = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F 32);114 y = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F 32);119 x = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F64); 120 newX = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F64); 121 y = psVectorAlloc(NUM_SPLINES+1, PS_TYPE_F64); 115 122 tmpSpline = psSpline1DAlloc(NUM_SPLINES, 3, MIN, MAX); 116 123 117 124 for (i=0;i<NUM_SPLINES+1;i++) { 118 x->data.F 32[i] = tmpSpline->domains[i];119 y->data.F 32[i] = myFunc(x->data.F32[i]);125 x->data.F64[i] = tmpSpline->domains[i]; 126 y->data.F64[i] = myFunc(x->data.F64[i]); 120 127 } 121 128 122 129 for (i=0;i<NUM_SPLINES;i++) { 123 newX->data.F 32[i]= ((x->data.F32[i] + x->data.F32[i+1])/2.0);130 newX->data.F64[i]= ((x->data.F64[i] + x->data.F64[i+1])/2.0); 124 131 } 125 newX->data.F 32[NUM_SPLINES] = x->data.F32[NUM_SPLINES];132 newX->data.F64[NUM_SPLINES] = x->data.F64[NUM_SPLINES]; 126 133 /****************************************************************************/ 127 134 /* psLib Code */ … … 129 136 printPositiveTestHeader(stdout, 130 137 "psFunction functions", 131 "psSpline1DAlloc() ");138 "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F64 versions"); 132 139 133 140 psVectorFitSpline1D(tmpSpline, x, y, NULL); … … 135 142 136 143 for (i=OFFSET;i<NUM_SPLINES-OFFSET+1;i++) { 137 if ( fabs( newY->data.F32[i] - myFunc(newX->data.F 32[i]) ) > fabs( ERROR_TOLERANCE * myFunc(newX->data.F32[i]) ) ) {144 if ( fabs( newY->data.F32[i] - myFunc(newX->data.F64[i]) ) > fabs( ERROR_TOLERANCE * myFunc((float)newX->data.F64[i]) ) ) { 138 145 printf("ERROR[%d]: f(%f) is %f. Should be %f\n", i, 139 newX->data.F32[i], newY->data.F32[i], myFunc(newX->data.F32[i])); 146 newX->data.F64[i], newY->data.F32[i], myFunc((float)newX->data.F64[i])); 147 testStatus = false; 140 148 } 141 149 } … … 155 163 printFooter(stdout, 156 164 "psFunctions functions", 157 "psSpline1DAlloc() ",165 "psSpline1DAlloc(), psVectorFitSpline1D, psSpline1DEvalVector: F64 versions", 158 166 testStatus); 159 167 … … 164 172 { 165 173 t00(); 174 t01(); 166 175 }
Note:
See TracChangeset
for help on using the changeset viewer.
