Changeset 1985
- Timestamp:
- Oct 6, 2004, 12:27:06 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 5 edited
-
src/dataManip/psFunctions.c (modified) (4 diffs)
-
src/math/psPolynomial.c (modified) (4 diffs)
-
src/math/psSpline.c (modified) (4 diffs)
-
test/dataManip/tst_psFunc00.c (modified) (18 diffs)
-
test/dataManip/tst_psFunc07.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFunctions.c
r1982 r1985 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 0$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-10-06 2 1:30:53$9 * @version $Revision: 1.51 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-06 22:27:06 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 2065 2065 2066 2066 XXX: SDR is silent about data types. PS_TYPE_F32 is implemented. 2067 2068 XXX: The spline eval functions require input and output to be F32. however 2069 the spline fit functions require F32 and F64. 2067 2070 *****************************************************************************/ 2068 2071 float psSpline1DEval(const psSpline1D *spline, … … 2090 2093 } 2091 2094 2095 // XXX: The spline eval functions require input and output to be F32. 2096 // however the spline fit functions require F32 and F64. 2092 2097 psVector *psSpline1DEvalVector(const psVector *x, 2093 2098 const psSpline1D *spline) … … 2097 2102 2098 2103 tmpVector = psVectorAlloc(x->n, PS_TYPE_F32); 2099 for (i=0;i<x->n;i++) { 2100 tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]); 2104 if (x->type.type == PS_TYPE_F32) { 2105 for (i=0;i<x->n;i++) { 2106 tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]); 2107 } 2108 } else if (x->type.type == PS_TYPE_F64) { 2109 for (i=0;i<x->n;i++) { 2110 tmpVector->data.F32[i] = psSpline1DEval(spline, (float) x->data.F64[i]); 2111 } 2112 } else { 2113 psError(__func__, "Unknown data type.\n"); 2114 return(NULL); 2101 2115 } 2102 2116 -
trunk/psLib/src/math/psPolynomial.c
r1982 r1985 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 0$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-10-06 2 1:30:53$9 * @version $Revision: 1.51 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-06 22:27:06 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 2065 2065 2066 2066 XXX: SDR is silent about data types. PS_TYPE_F32 is implemented. 2067 2068 XXX: The spline eval functions require input and output to be F32. however 2069 the spline fit functions require F32 and F64. 2067 2070 *****************************************************************************/ 2068 2071 float psSpline1DEval(const psSpline1D *spline, … … 2090 2093 } 2091 2094 2095 // XXX: The spline eval functions require input and output to be F32. 2096 // however the spline fit functions require F32 and F64. 2092 2097 psVector *psSpline1DEvalVector(const psVector *x, 2093 2098 const psSpline1D *spline) … … 2097 2102 2098 2103 tmpVector = psVectorAlloc(x->n, PS_TYPE_F32); 2099 for (i=0;i<x->n;i++) { 2100 tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]); 2104 if (x->type.type == PS_TYPE_F32) { 2105 for (i=0;i<x->n;i++) { 2106 tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]); 2107 } 2108 } else if (x->type.type == PS_TYPE_F64) { 2109 for (i=0;i<x->n;i++) { 2110 tmpVector->data.F32[i] = psSpline1DEval(spline, (float) x->data.F64[i]); 2111 } 2112 } else { 2113 psError(__func__, "Unknown data type.\n"); 2114 return(NULL); 2101 2115 } 2102 2116 -
trunk/psLib/src/math/psSpline.c
r1982 r1985 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 0$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-10-06 2 1:30:53$9 * @version $Revision: 1.51 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-06 22:27:06 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 2065 2065 2066 2066 XXX: SDR is silent about data types. PS_TYPE_F32 is implemented. 2067 2068 XXX: The spline eval functions require input and output to be F32. however 2069 the spline fit functions require F32 and F64. 2067 2070 *****************************************************************************/ 2068 2071 float psSpline1DEval(const psSpline1D *spline, … … 2090 2093 } 2091 2094 2095 // XXX: The spline eval functions require input and output to be F32. 2096 // however the spline fit functions require F32 and F64. 2092 2097 psVector *psSpline1DEvalVector(const psVector *x, 2093 2098 const psSpline1D *spline) … … 2097 2102 2098 2103 tmpVector = psVectorAlloc(x->n, PS_TYPE_F32); 2099 for (i=0;i<x->n;i++) { 2100 tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]); 2104 if (x->type.type == PS_TYPE_F32) { 2105 for (i=0;i<x->n;i++) { 2106 tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]); 2107 } 2108 } else if (x->type.type == PS_TYPE_F64) { 2109 for (i=0;i<x->n;i++) { 2110 tmpVector->data.F32[i] = psSpline1DEval(spline, (float) x->data.F64[i]); 2111 } 2112 } else { 2113 psError(__func__, "Unknown data type.\n"); 2114 return(NULL); 2101 2115 } 2102 2116 -
trunk/psLib/test/dataManip/tst_psFunc00.c
r1811 r1985 3 3 allocated and deallocated by the psPolynomialXXXlloc() procedures. 4 4 It also calls the various psPolynomialXXXEval() procedures. 5 6 The F32 and F64 polynomials are tested for all orders (1 - 4) and for 7 both ordinary and chebyshev polynomials. 8 9 NOTE: This test code requries the stdout file to verify that the results 10 are good. 5 11 *****************************************************************************/ 6 12 #include <stdio.h> … … 12 18 #define MISC_X_VALUE 5.0 13 19 #define MISC_INT_NUMBER 35 14 #define NUM_BINS 20015 20 #define AN 2 16 21 #define BN 4 … … 60 65 } 61 66 printFooter(stdout, 62 "ps Stats functions",67 "psFunctions functions", 63 68 "Allocate/Deallocate the psPolynomial1D structure.", 64 69 testStatus); … … 90 95 } 91 96 printFooter(stdout, 92 "ps Stats functions",97 "psFunctions functions", 93 98 "Allocate/Deallocate the psPolynomial2D structure.", 94 99 testStatus); … … 121 126 } 122 127 printFooter(stdout, 123 "ps Stats functions",128 "psFunctions functions", 124 129 "Allocate/Deallocate the psPolynomial3D structure.", 125 130 testStatus); … … 155 160 } 156 161 printFooter(stdout, 157 "ps Stats functions",162 "psFunctions functions", 158 163 "Allocate/Deallocate the psPolynomial4D structure.", 159 164 testStatus); … … 185 190 } 186 191 printFooter(stdout, 187 "ps Stats functions",192 "psFunctions functions", 188 193 "Allocate/Deallocate the psDPolynomial1D structure.", 189 194 testStatus); … … 211 216 } 212 217 printFooter(stdout, 213 "ps Stats functions",218 "psFunctions functions", 214 219 "Allocate/Deallocate the psDPolynomial2D structure.", 215 220 testStatus); … … 242 247 } 243 248 printFooter(stdout, 244 "ps Stats functions",249 "psFunctions functions", 245 250 "Allocate/Deallocate the psDPolynomial3D structure.", 246 251 testStatus); … … 276 281 } 277 282 printFooter(stdout, 278 "ps Stats functions",283 "psFunctions functions", 279 284 "Allocate/Deallocate the psDPolynomial4D structure.", 280 285 testStatus); … … 306 311 } 307 312 printFooter(stdout, 308 "ps Stats functions",313 "psFunctions functions", 309 314 "Allocate/Deallocate the psPolynomial1D structure (CHEBYSHEV).", 310 315 testStatus); … … 335 340 } 336 341 printFooter(stdout, 337 "ps Stats functions",342 "psFunctions functions", 338 343 "Allocate/Deallocate the psPolynomial2D structure (CHEBYSHEV).", 339 344 testStatus); … … 366 371 } 367 372 printFooter(stdout, 368 "ps Stats functions",373 "psFunctions functions", 369 374 "Allocate/Deallocate the psPolynomial3D structure (CHEBYSHEV).", 370 375 testStatus); … … 400 405 } 401 406 printFooter(stdout, 402 "ps Stats functions",407 "psFunctions functions", 403 408 "Allocate/Deallocate the psPolynomial4D structure (CHEBYSHEV).", 404 409 testStatus); … … 430 435 } 431 436 printFooter(stdout, 432 "ps Stats functions",437 "psFunctions functions", 433 438 "Allocate/Deallocate the psDPolynomial1D structure (CHEBYSHEV).", 434 439 testStatus); … … 456 461 } 457 462 printFooter(stdout, 458 "ps Stats functions",463 "psFunctions functions", 459 464 "Allocate/Deallocate the psDPolynomial2D structure (CHEBYSHEV).", 460 465 testStatus); … … 487 492 } 488 493 printFooter(stdout, 489 "ps Stats functions",494 "psFunctions functions", 490 495 "Allocate/Deallocate the psDPolynomial3D structure (CHEBYSHEV).", 491 496 testStatus); … … 521 526 } 522 527 printFooter(stdout, 523 "ps Stats functions",528 "psFunctions functions", 524 529 "Allocate/Deallocate the psDPolynomial4D structure (CHEBYSHEV).", 525 530 testStatus); -
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.
