Changeset 13124
- Timestamp:
- May 1, 2007, 6:20:06 PM (19 years ago)
- Location:
- trunk/psLib/test/math
- Files:
-
- 15 edited
-
tap_psFunc01.c (modified) (3 diffs)
-
tap_psMatrix01.c (modified) (4 diffs)
-
tap_psMatrix02.c (modified) (7 diffs)
-
tap_psMinimizeLMM.c (modified) (8 diffs)
-
tap_psMinimizePowell.c (modified) (6 diffs)
-
tap_psPolyFit1D.c (modified) (5 diffs)
-
tap_psPolyFit2D.c (modified) (1 diff)
-
tap_psPolyFit3D.c (modified) (1 diff)
-
tap_psPolyFit4D.c (modified) (1 diff)
-
tap_psPolynomialEval1D.c (modified) (6 diffs)
-
tap_psPolynomialEval2D.c (modified) (6 diffs)
-
tap_psPolynomialEval3D.c (modified) (6 diffs)
-
tap_psPolynomialEval4D.c (modified) (5 diffs)
-
tap_psSparse.c (modified) (21 diffs)
-
tap_psSpline1D.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tap_psFunc01.c
r10945 r13124 10 10 #include "tap.h" 11 11 #include "pstap.h" 12 12 13 #define MY_MEAN 5.0 13 14 #define MY_STDEV 2.0 … … 21 22 plan_tests(4); 22 23 24 23 25 // Test the psGaussian(): normalized version 24 26 { 25 27 psMemId id = psMemGetId(); 26 27 28 bool errorFlag = false; 28 29 for (psS32 x = 0 ; x < (int) (MY_MEAN * 2.0) ; x++) … … 37 38 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 38 39 } 40 39 41 40 42 // Test the psGaussian(): non-normalized version -
trunk/psLib/test/math/tap_psMatrix01.c
r10816 r13124 4 4 * 5 5 * This test driver contains the following tests: 6 * Create input images7 6 * Transpose input image into output image 8 7 * Transpose input image into auto allocated NULL output image 9 * Free input images10 8 * 11 9 * @author Ross Harman, MHPCC 12 10 * 13 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $14 * @date $Date: 200 6-12-20 20:02:29$11 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-05-02 04:20:06 $ 15 13 * 16 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 54 52 psS32 main( psS32 argc, char* argv[] ) 55 53 { 56 plan_tests(10); 57 // Preliminary: Create input images 54 plan_tests(14); 55 56 57 // Verify with NULL input params 58 { 59 psMemId id = psMemGetId(); 60 psImage *outImage = psMatrixTranspose(NULL, NULL); 61 ok(outImage == NULL, "psMatrixTranspose() returned NULL with NULL input params"); 62 psFree(outImage); 63 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 64 } 65 66 67 // Verify with incorrect input image type 68 { 69 psMemId id = psMemGetId(); 70 psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_S64); 71 psImage *outImage = psMatrixTranspose(NULL, inImage); 72 ok(outImage == NULL, "psMatrixTranspose() returned NULL with incorrect input image type"); 73 psFree(inImage); 74 psFree(outImage); 75 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 76 } 77 78 58 79 psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64); 59 80 psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64); … … 79 100 inImageF32->data.F32[2][2] = 9; 80 101 81 // T est A - Transpose input image into output image102 // Transpose input image into output image 82 103 { 83 104 psMemId id = psMemGetId(); … … 99 120 } 100 121 101 // Test B - Transpose input image into auto allocated NULL output image 122 123 // Transpose input image into auto allocated NULL output image 102 124 { 103 125 psMemId id = psMemGetId(); 104 psImage *outImageNull = NULL; 105 outImageNull = psMatrixTranspose(outImageNull, inImage); 126 psImage *outImageNull = psMatrixTranspose(NULL, inImage); 106 127 ok(!check_matrix(outImageNull), "Output image data set correctly"); 107 128 108 psImage *outImageNullF32 = NULL; 109 outImageNullF32 = psMatrixTranspose(outImageNullF32, inImageF32); 129 psImage *outImageNullF32 = psMatrixTranspose(NULL, inImageF32); 110 130 check_matrix(outImageNullF32); 111 131 ok(!check_matrix(outImageNullF32), "Output image data set correctly"); -
trunk/psLib/test/math/tap_psMatrix02.c
r12431 r13124 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $15 * @date $Date: 2007-0 3-14 00:39:51$14 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2007-05-02 04:20:06 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include "pstap.h" 25 25 26 psS32main(psS32 argc,27 char* argv[])26 int main(psS32 argc, 27 char* argv[]) 28 28 { 29 29 psLogSetFormat("HLNM"); 30 30 plan_tests(11); 31 31 32 // Test A - Input pointer same as output pointer 32 // Input pointer same as output pointer 33 // XXX: This results in a seg fault. It's not clear that passing this test is 34 // a requirement. However, we should probably fix the case where the input 35 // image equals the output image. 33 36 if (0) { 34 37 psMemId id = psMemGetId(); … … 40 43 } 41 44 42 // Test B - Null input psImage 45 46 // Null input psImage 47 // Merge with tap_psMatrix01.c, get rid of this test (redundant) 43 48 { 44 49 psMemId id = psMemGetId(); … … 52 57 } 53 58 54 // Test C - Incorrect type for input pointer 59 60 // Incorrect type for input pointer 61 // Merge with tap_psMatrix01.c, get rid of this test (redundant) 55 62 { 56 63 psMemId id = psMemGetId(); … … 65 72 } 66 73 67 // Test D - Incorrect type for output pointer 74 75 // Incorrect type for output pointer 68 76 { 69 77 psMemId id = psMemGetId(); … … 79 87 } 80 88 81 // Test E - Matrix not square for output pointer 89 90 // Matrix not square for output pointer 82 91 // XXX: We should probably do more here. 83 92 { … … 90 99 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 91 100 } 92 return 0;93 101 } -
trunk/psLib/test/math/tap_psMinimizeLMM.c
r10945 r13124 2 2 This routine must ensure that psMinimizeLM() works correctly. 3 3 4 XXX: This code needs a lot of additional test case work. 5 The minimization currently (always?) fails and we don't 6 attempt to check the output values. 4 XXX: This code needs a lot of additional test case work. The minimization 5 currently fails and we don't attempt to check the output values. 6 XXX: Add tests for 7 covar arg set to non-NULL 8 constraint set to non-NULL 9 Set x->vectors to NULL, or use wrong types 10 yWt (errors) vector set to incorrect size, type. 7 11 *****************************************************************************/ 8 12 #include <stdio.h> … … 19 23 float expectedParm[NUM_PARAMS]; 20 24 21 25 // y = p2 + p0 * e^( x0^2 + x1^2 / (2 * p1^2) ) 22 26 float function(const psVector *params, const psVector *x) 23 27 { … … 35 39 36 40 37 /*****************************************************************************38 fitFunc():39 sum = param[0] * x[0] * x[1] +40 param[1] * x[0] +41 param[2] * x[0]^2 +42 param[3] * x[1] +43 param[4] * x[1]^244 45 *****************************************************************************/46 41 psF32 fitFunc(psVector *deriv, 47 42 psVector *params, … … 56 51 } 57 52 53 58 54 #define NUM_ITER 10 59 55 #define TOL 20.0 … … 62 58 psLogSetFormat("HLNM"); 63 59 psLogSetLevel(PS_LOG_INFO); 64 plan_tests(2); 60 plan_tests(34); 61 62 65 63 // Test psMinimizationAlloc() 66 64 { … … 79 77 } 80 78 81 /* 82 // Test psMinConstrainAlloc() 83 { 84 psMemId id = psMemGetId(); 85 psMinConstrain *tmp = psMinConstrainAlloc(NUM_ITER, TOL); 86 ok(tmp != NULL. "psMinConstrainAlloc() returned non-NULL"); 87 skip_start(tmp == NULL, 4, "Skipping tests because psMinConstrainAlloc() failed"); 88 ok(tmp->paramMask == NULL, "psMinConstrainAlloc() properly set ->paramMask"); 89 ok(tmp->paramMax == NULL, "psMinConstrainAlloc() properly set ->paramMax"); 90 ok(tmp->paramMin == NULL, "psMinConstrainAlloc() properly set ->paramMin"); 91 ok(tmp->paramDelta == NULL, "psMinConstrainAlloc() properly set ->paramDelta"); 92 psFree(tmp); 93 skip_end(); 94 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 95 } 96 */ 97 98 // Test psMinimizeLMChi2() 79 80 // Test psMinConstraintAlloc() 81 { 82 psMemId id = psMemGetId(); 83 psMinConstraint *tmp = psMinConstraintAlloc(); 84 ok(tmp != NULL, "psMinConstraintAlloc() returned non-NULL"); 85 skip_start(tmp == NULL, 2, "Skipping tests because psMinConstraintAlloc() failed"); 86 ok(tmp->paramMask == NULL, "psMinConstraintAlloc() properly set ->paramMask"); 87 ok(tmp->checkLimits == NULL, "psMinConstraintAlloc() properly set ->checkLimits"); 88 psFree(tmp); 89 skip_end(); 90 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 91 } 92 93 94 // Test psMinimizeLMChi2(): unallowed input parameters. 95 { 96 psMemId id = psMemGetId(); 97 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 98 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 99 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); 100 psVector *coordinates = psVectorAlloc(NUM_DATA_POINTS, PS_TYPE_F32); 101 psVector *coordinatesF64 = psVectorAlloc(NUM_DATA_POINTS, PS_TYPE_F64); 102 psVector *errors = psVectorAlloc(NUM_DATA_POINTS, PS_TYPE_F32); 103 psVector *params = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); 104 psVector *paramsF64 = psVectorAlloc(NUM_PARAMS, PS_TYPE_F64); 105 psVector *trueParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); 106 107 // Test with psMinimization set to NULL 108 { 109 psMemId id = psMemGetId(); 110 bool tmpBool = psMinimizeLMChi2(NULL, NULL, params, NULL, ordinates, 111 coordinates, errors, (psMinimizeLMChi2Func)fitFunc); 112 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with NULL psMinimization"); 113 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 114 } 115 116 117 // Test with params set to NULL 118 { 119 psMemId id = psMemGetId(); 120 bool tmpBool = psMinimizeLMChi2(min, NULL, NULL, NULL, ordinates, 121 coordinates, errors, (psMinimizeLMChi2Func)fitFunc); 122 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with NULL params"); 123 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 124 } 125 126 127 // Test with params wrong type 128 { 129 psMemId id = psMemGetId(); 130 bool tmpBool = psMinimizeLMChi2(min, NULL, paramsF64, NULL, ordinates, 131 coordinates, errors, (psMinimizeLMChi2Func)fitFunc); 132 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with NULL params"); 133 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 134 } 135 136 137 // Test with ordinates (x) set to NULL 138 { 139 psMemId id = psMemGetId(); 140 bool tmpBool = psMinimizeLMChi2(min, NULL, params, NULL, NULL, 141 coordinates, errors, (psMinimizeLMChi2Func)fitFunc); 142 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with NULL ordinates (x)"); 143 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 144 } 145 146 147 // Test with coordinates (y) set to NULL 148 { 149 psMemId id = psMemGetId(); 150 bool tmpBool = psMinimizeLMChi2(min, NULL, params, NULL, ordinates, 151 NULL, errors, (psMinimizeLMChi2Func)fitFunc); 152 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with NULL coordinates (y)"); 153 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 154 } 155 156 157 // Test with coordinates (y) wrong type (F64) 158 { 159 psMemId id = psMemGetId(); 160 bool tmpBool = psMinimizeLMChi2(min, NULL, params, NULL, ordinates, 161 coordinatesF64, errors, (psMinimizeLMChi2Func)fitFunc); 162 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with coordinates (y) wrong type"); 163 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 164 } 165 166 167 // Test with ordinates and coordinates wrong size 168 { 169 psMemId id = psMemGetId(); 170 coordinates->n--; 171 bool tmpBool = psMinimizeLMChi2(min, NULL, params, NULL, ordinates, 172 coordinates, errors, (psMinimizeLMChi2Func)fitFunc); 173 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with NULL psMinimization"); 174 coordinates->n++; 175 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 176 } 177 178 179 // Test with function set to NULL 180 { 181 psMemId id = psMemGetId(); 182 bool tmpBool = psMinimizeLMChi2(min, NULL, params, NULL, ordinates, 183 coordinates, errors, NULL); 184 ok(!tmpBool, "psMinimizeLMChi2() returned FALSE with NULL fit function"); 185 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 186 } 187 188 psFree(min); 189 psFree(params); 190 psFree(paramsF64); 191 psFree(trueParams); 192 psFree(ordinates); 193 psFree(coordinates); 194 psFree(coordinatesF64); 195 psFree(errors); 196 psFree(rng); 197 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 198 } 199 200 201 // Test psMinimizeLMChi2() with legitimate input values 202 // Currently this fails, and we do not attempt to verify output 99 203 { 100 204 psMemId id = psMemGetId(); … … 158 262 } 159 263 printf("Mean relative difference is %f\n", diff/(float)NUM_DATA_POINTS); 160 264 skip_end(); 161 265 psFree(min); 162 266 psFree(params); … … 166 270 psFree(errors); 167 271 psFree(rng); 168 skip_end(); 169 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 170 } 171 } 272 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 273 } 274 } -
trunk/psLib/test/math/tap_psMinimizePowell.c
r13123 r13124 9 9 XXX: Also, the test currently fails because of memory corruption in 10 10 psMinimizePowell(). 11 XXX: The unallowed input parameter tests could be more extensive 11 12 *****************************************************************************/ 12 13 #include <stdio.h> … … 74 75 { 75 76 psLogSetFormat("HLNM"); 76 plan_tests( 1);77 plan_tests(8); 77 78 78 79 // Check for various errors on unallowed input parameters 79 80 { 80 psMemId id = psMemGetId();81 82 81 psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); 83 82 psVector *myParamMask = psVectorAlloc(NUM_PARAMS, PS_TYPE_U8); … … 85 84 psArray *myCoords = psArrayAlloc(N); 86 85 87 for (psS32 i=0;i<N;i++)86 // Following should generate error for NULL minimize 88 87 { 89 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 90 ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) (i+10); 91 ((psVector *) (myCoords->data[i]))->data.F32[1] = (float) (i+3); 92 ((psVector *) (myCoords->data[i]))->n++; 93 } 94 for (psS32 i=0;i<NUM_PARAMS;i++) 95 { 96 expectedParm[i] = 2.32 + (float) (2 * i); 97 myParams->data.F32[i] = 0.0; 98 myParams->data.F32[i] = (float) i; 99 myParamMask->data.U8[i] = 0; 100 myParams->n++; 101 myParamMask->n++; 88 psMemId id = psMemGetId(); 89 bool tmpBool = psMinimizePowell(NULL, myParams, myParamMask, myCoords, 90 (psMinimizePowellFunc) myFunc); 91 ok(!tmpBool, "psMinimizePowell() returned FALSE with NULL psMinimize param"); 92 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 102 93 } 103 94 104 // Following should generate error for null minimize 105 if (0)95 96 // Following should generate error for NULL parameter vector 106 97 { 107 psMinimizePowell(NULL, myParams, myParamMask, myCoords, (psMinimizePowellFunc) myFunc); 98 psMemId id = psMemGetId(); 99 bool tmpBool = psMinimizePowell(min, NULL, myParamMask, myCoords,(psMinimizePowellFunc) myFunc); 100 ok(!tmpBool, "psMinimizePowell() returned FALSE with NULL parameter param"); 101 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 108 102 } 109 103 110 // Following should generate error for null parameter vector 111 if (0)104 105 // Following should generate error for NULL coords 112 106 { 113 psMinimizePowell(min, NULL, myParamMask, myCoords,(psMinimizePowellFunc) myFunc); 107 psMemId id = psMemGetId(); 108 bool tmpBool = psMinimizePowell(min, myParams, myParamMask, NULL, (psMinimizePowellFunc) myFunc); 109 ok(!tmpBool, "psMinimizePowell() returned FALSE with NULL coords param"); 110 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 114 111 } 115 112 116 // Following should generate error for null coords 117 if (0)113 114 // Following should generate error for NULL function 118 115 { 119 psMinimizePowell(min, myParams, myParamMask, NULL, (psMinimizePowellFunc) myFunc); 120 } 121 122 // Following should generate error for null function 123 if (0) 124 { 125 psMinimizePowell(min, myParams, myParamMask, myCoords, NULL); 116 psMemId id = psMemGetId(); 117 bool tmpBool = psMinimizePowell(min, myParams, myParamMask, myCoords, NULL); 118 ok(!tmpBool, "psMinimizePowell() returned FALSE with NULL function param"); 119 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 126 120 } 127 121 … … 130 124 psFree(min); 131 125 psFree(myCoords); 132 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");133 126 } 134 127 128 135 129 // Powell minimize with parameter mask 130 // XXX: This function aborts with a memory corruption error at around line 131 // 60 of psMinimizePowell.c, at the psFree(v): 132 // if (fabs(baseFuncVal - currFuncVal) <= min->tol) { 133 // psFree(v); 134 // psFree(pQP); 136 135 if (0) { 137 136 psMemId id = psMemGetId(); … … 155 154 } 156 155 157 bool tmpBool = psMinimizePowell(min, myParams, myParamMask, myCoords,156 bool tmpBool = psMinimizePowell(min, myParams, NULL, myCoords, 158 157 (psMinimizePowellFunc) myFunc); 159 158 ok(tmpBool, "psMinimizePowell() returned sucessfully"); … … 184 183 } 185 184 186 // Powell minimize with parameter mask 187 // The only difference from the previous block is that paramMask is now NULL 188 if (0) { 189 psMemId id = psMemGetId(); 190 psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); 191 psMinimization *min = psMinimizationAlloc(100, 0.01); 192 psArray *myCoords = psArrayAlloc(N); 193 bool tmpBool; 194 195 myCoords->n = N; 196 for (psS32 i=0;i<N;i++) 197 { 198 myCoords->data[i] = (psPtr *) psVectorAlloc(2, PS_TYPE_F32); 199 ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) (i+10); 200 ((psVector *) (myCoords->data[i]))->data.F32[1] = (float) (i+3); 201 } 202 for (psS32 i=0;i<NUM_PARAMS;i++) 203 { 204 expectedParm[i] = 2.32 + (float) (2 * i); 205 myParams->data.F32[i] = 0.0; 206 myParams->data.F32[i] = (float) i; 207 myParams->n++; 208 } 209 210 tmpBool = psMinimizePowell(min, myParams, NULL, myCoords, 211 (psMinimizePowellFunc) myFunc); 212 ok(tmpBool, "psMinimizePowell() returned sucessfully"); 213 skip_start(!tmpBool, 0, "Skipping tests because psMinimizePowell() failed"); 214 215 printf("\nThe minimum is %f (expected: %f)\n", min->value, MIN_VALUE); 216 for (psS32 i=0;i<NUM_PARAMS;i++) 217 { 218 printf("Parameter %d at the minimum is %.1f (expected: %.1f)\n", i, 219 myParams->data.F32[i], expectedParm[i]); 220 221 if (fabs(myParams->data.F32[i] - expectedParm[i]) > fabs(ERROR_TOLERANCE * expectedParm[i])) { 222 printf("ERROR: Parameter %d: (%.1f), expected was (%.1f)\n", 223 i, myParams->data.F32[i], expectedParm[i]); 224 testStatus = false; 225 } else { 226 printf("Parameter %d: (%.1f), expected was (%.1f)\n", 227 i, myParams->data.F32[i], expectedParm[i]); 228 } 229 } 230 psFree(myCoords); 231 psFree(myParams); 232 psFree(min); 233 skip_end(); 234 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 235 } 185 // XXX: Add tests with active parameter mask 236 186 } -
trunk/psLib/test/math/tap_psPolyFit1D.c
r11686 r13124 8 8 9 9 XXX: Try null stats. 10 11 XXX: The tests with "Some Vectors NULL" fail as of 2006/12, they had passed12 previously as of 2006/02. They are commented out for now.13 10 *****************************************************************************/ 14 11 #include <stdio.h> … … 352 349 { 353 350 psLogSetFormat("HLNM"); 354 psTraceSetLevel(".", 0); 355 psTraceSetLevel("psVectorClipFitPolynomial1D", 0); 356 psTraceSetLevel("VectorFitPolynomial1DOrd", 0); 357 psTraceSetLevel("VectorFitPolynomial1DCheb", 0); 358 psTraceSetLevel("vectorFitPolynomial1DCheb", 0); 359 psTraceSetLevel("vectorFitPolynomial1DChebSlow", 0); 360 psTraceSetLevel("vectorFitPolynomial1DChebFast", 0); 361 psTraceSetLevel("psVectorFitPolynomial1D", 0); 362 psTraceSetLevel("p_psCreateChebyshevPolys", 0); 363 351 psLogSetLevel(PS_LOG_INFO); 364 352 plan_tests(64); 365 353 … … 368 356 // 369 357 // All Vectors non-NULL 370 371 358 ok(genericTest(TS00_MASK_U8 | TS00_FERR_F32 | TS00_X_F32 | TS00_F_F32 | TS00_POLY_ORD, POLY_ORDER, NUM_DATA, true), "F32 tests: Ordinary polys, non-clip fit"); 372 359 // Some Vectors NULL … … 382 369 ok(genericTest(TS00_MASK_U8 | TS00_FERR_F32 | TS00_X_S32 | TS00_F_F32 | TS00_POLY_ORD, POLY_ORDER, NUM_DATA, false), "F32 tests: Ordinary polys, non-clip fit, Unallowable vector types"); 383 370 ok(genericTest(TS00_MASK_U8 | TS00_FERR_F32 | TS00_X_F32 | TS00_F_S32 | TS00_POLY_ORD, POLY_ORDER, NUM_DATA, false), "F32 tests: Ordinary polys, non-clip fit, Unallowable vector types"); 384 385 371 // Mismatch vector types 386 372 ok(genericTest(TS00_MASK_S32 | TS00_FERR_F32 | TS00_X_F32 | TS00_F_F32 | TS00_POLY_ORD, POLY_ORDER, NUM_DATA, false), "F32 tests: Ordinary polys, non-clip fit, Mismatch vector types"); … … 392 378 // 393 379 // All Vectors non-NULL 394 395 380 ok(genericTest(TS00_MASK_U8 | TS00_FERR_F64 | TS00_X_F64 | TS00_F_F64 | TS00_POLY_ORD, POLY_ORDER, NUM_DATA, true), "F64 tests: Ordinary polys, non-clip fit"); 396 381 // Some Vectors NULL -
trunk/psLib/test/math/tap_psPolyFit2D.c
r12199 r13124 363 363 { 364 364 psLogSetFormat("HLNM"); 365 psTraceSetLevel(".", 0); 366 psTraceSetLevel("psVectorClipFitPolynomial2D", 0); 367 psTraceSetLevel("VectorFitPolynomial2DOrd", 0); 368 psTraceSetLevel("psVectorFitPolynomial2D", 0); 369 365 psLogSetLevel(PS_LOG_INFO); 370 366 plan_tests(44); 371 367 -
trunk/psLib/test/math/tap_psPolyFit3D.c
r11686 r13124 413 413 { 414 414 psLogSetFormat("HLNM"); 415 psTraceSetLevel(".", 0); 416 psTraceSetLevel("psVectorClipFitPolynomial3D", 0); 417 psTraceSetLevel("VectorFitPolynomial3DOrd", 0); 418 psTraceSetLevel("psVectorFitPolynomial3D", 0); 419 415 psLogSetLevel(PS_LOG_INFO); 420 416 plan_tests(52); 421 417 -
trunk/psLib/test/math/tap_psPolyFit4D.c
r11686 r13124 471 471 { 472 472 psLogSetFormat("HLNM"); 473 psTraceSetLevel(".", 0); 474 psTraceSetLevel("psVectorClipFitPolynomial4D", 0); 475 psTraceSetLevel("VectorFitPolynomial4DOrd", 0); 476 psTraceSetLevel("psVectorFitPolynomial4D", 0); 477 473 psLogSetLevel(PS_LOG_INFO); 478 474 plan_tests(60); 479 475 -
trunk/psLib/test/math/tap_psPolynomialEval1D.c
r12781 r13124 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 4-10 21:09:30$6 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-05-02 04:20:06 $ 8 8 * 9 9 * XXX: Probably should test single- and multi-dimensional polynomials in … … 44 44 psLogSetFormat("HLNM"); 45 45 psLogSetLevel(PS_LOG_INFO); 46 plan_tests(24); 46 plan_tests(30); 47 48 49 // Allocate polynomial with unallowable type 50 { 51 psMemId id = psMemGetId(); 52 psPolynomial1D* polyOrd = psPolynomial1DAlloc(99, TERMS-1); 53 ok(polyOrd==NULL, "psPolynomial1DAlloc() returned NULL with unallowed type"); 54 psFree(polyOrd); 55 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 56 } 57 58 59 // Evaluate a NULL polynomial 60 { 61 psMemId id = psMemGetId(); 62 psF64 result = psPolynomial1DEval(NULL, 0.0); 63 ok(isnan(result), "psPolynomial1DEval() returned NAN with NULL psPolynomial"); 64 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 65 } 66 47 67 48 68 // Allocate and evaluate an ordinary polynomial structure … … 75 95 skip_end(); 76 96 psFree(polyOrd); 77 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");97 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 78 98 } 79 99 … … 107 127 108 128 109 // Allocate polynomial with unallowable type110 // XXX: This is wierd: why the skip()?111 {112 psMemId id = psMemGetId();113 psPolynomial1D* polyOrd = psPolynomial1DAlloc(99, TERMS-1);114 ok(polyOrd==NULL, "psPolynomial1DAlloc() returned NULL, as expected");115 skip_start(polyOrd!=NULL, 1, "Skipping tests because psPolynomial1DAlloc() failed");116 117 // Attempt to evaluation invalid polynomial type118 psF64 result = psPolynomial1DEval(polyOrd, 0.0);119 ok(isnan(result), "psPolynomial1DEval() did not return NAN, as expected");120 skip_end();121 psFree(polyOrd);122 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");123 }124 125 126 129 // Allocate polynomial, test the psPolynomial1DEvalVector() routines 127 130 { … … 162 165 ok(!errorFlag, "psPolynomial1DEvalVector() produced the correct answers"); 163 166 164 // Attempt to invoke function with null polynomial 165 ok(psPolynomial1DEvalVector(NULL, inputOrd) == NULL, "psPolynomial1DEvalVector() produced NULL when called with NULL polynomial"); 166 167 // Attempt to invoke function with null input vector 168 ok(psPolynomial1DEvalVector(polyOrd,NULL) == NULL, "psPolynomial1DEvalVector() produced NULL when called with NULL input vector"); 167 // Attempt to invoke function with NULL polynomial 168 { 169 psMemId id = psMemGetId(); 170 ok(psPolynomial1DEvalVector(NULL, inputOrd) == NULL, "psPolynomial1DEvalVector() produced NULL when called with NULL polynomial"); 171 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 172 } 173 174 // Attempt to invoke function with NULL input vector 175 { 176 psMemId id = psMemGetId(); 177 ok(psPolynomial1DEvalVector(polyOrd, NULL) == NULL, "psPolynomial1DEvalVector() produced NULL when called with NULL input vector"); 178 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 179 } 169 180 170 181 // Attempt to invoke function with a non F64 type input vector 171 inputOrd->type.type = PS_TYPE_U8; 172 ok(psPolynomial1DEvalVector(polyOrd,inputOrd) == NULL, "psPolynomial1DEvalVector() produced NULL when called with non F64 input vector"); 182 { 183 psMemId id = psMemGetId(); 184 inputOrd->type.type = PS_TYPE_U8; 185 ok(psPolynomial1DEvalVector(polyOrd,inputOrd) == NULL, "psPolynomial1DEvalVector() produced NULL when called with non F64 input vector"); 186 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 187 } 173 188 psFree(outputOrd); 174 189 skip_end(); … … 216 231 ok(!errorFlag, "psPolynomial1DEvalVector() produced the correct answers"); 217 232 218 // Attempt to invoke function with null input vector 219 ok(psPolynomial1DEvalVector(polyCheb,NULL) == NULL, "psPolynomial1DEvalVector() produced NULL when called with NULL input vector"); 233 234 // Attempt to invoke function with NULL input vector 235 { 236 psMemId id = psMemGetId(); 237 ok(psPolynomial1DEvalVector(polyCheb,NULL) == NULL, "psPolynomial1DEvalVector() produced NULL when called with NULL input vector"); 238 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 239 } 240 220 241 221 242 // Attempt to invoke function with a non F64 type input vector 222 inputCheb->type.type = PS_TYPE_U8; 223 ok(psPolynomial1DEvalVector(polyCheb,inputCheb) == NULL, "psPolynomial1DEvalVector() produced NULL when called with non F64 input vector"); 243 { 244 psMemId id = psMemGetId(); 245 inputCheb->type.type = PS_TYPE_U8; 246 ok(psPolynomial1DEvalVector(polyCheb,inputCheb) == NULL, "psPolynomial1DEvalVector() produced NULL when called with non F64 input vector"); 247 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 248 } 249 250 224 251 psFree(outputCheb); 225 252 skip_end(); -
trunk/psLib/test/math/tap_psPolynomialEval2D.c
r11423 r13124 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-30 04:52:42$6 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-05-02 04:20:06 $ 8 8 * 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 70 70 psLogSetFormat("HLNM"); 71 71 psLogSetLevel(PS_LOG_INFO); 72 plan_tests(28); 72 plan_tests(40); 73 74 75 // Allocate polynomial with unallowed type 76 { 77 psMemId id = psMemGetId(); 78 psPolynomial2D* polyOrd = psPolynomial2DAlloc(99, TERMS-1, TERMS-1); 79 ok(polyOrd == NULL, "psPolynomial2DAlloc() returned NULL with unallowed tpye"); 80 psFree(polyOrd); 81 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 82 } 83 84 85 // Evaluate a NULL polynomial 86 { 87 psMemId id = psMemGetId(); 88 psF64 result = psPolynomial2DEval(NULL, 0.0, 0.0); 89 ok(isnan(result), "psPolynomial2DEval() returned NAN with NULL psPolynomial"); 90 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 91 } 92 73 93 74 94 // Allocate and evaluate an ordinary polynomial structure … … 138 158 skip_end(); 139 159 psFree(polyCheb); 140 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");141 }142 143 144 // Allocate polynomial with unallowed type145 {146 psMemId id = psMemGetId();147 psPolynomial2D* polyOrd = psPolynomial2DAlloc(99, TERMS-1, TERMS-1);148 ok(polyOrd == NULL, "psPolynomial2DAlloc() returned NULL with unallowed tpye");149 // skip_start(polyOrd == NULL, 1, "Skipping tests because psPolynomial2DAlloc() failed");150 // // Attempt to evaluate invalid polynomial type151 // psF64 result = psPolynomial2DEval(polyOrd,0.0, 0.0);152 // ok(isnan(result), "psPolynomial2DEval() did not return NAN, as expected");153 // skip_end();154 psFree(polyOrd);155 160 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 156 161 } … … 200 205 ok(!errorFlag, "psPolynomial2DEvalVector() produced the correct answers"); 201 206 202 // Attempt to invoke function with null polynomial 203 ok(psPolynomial2DEvalVector(NULL, inputOrdX, inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL polynomial"); 204 205 // Attempt to invoke function with null input vector 206 ok(psPolynomial2DEvalVector(polyOrd,NULL,inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 207 208 // Attempt to invoke function with null input vector 209 ok(psPolynomial2DEvalVector(polyOrd,inputOrdX,NULL) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 210 207 208 // Attempt to invoke function with NULL polynomial 209 { 210 psMemId id = psMemGetId(); 211 ok(psPolynomial2DEvalVector(NULL, inputOrdX, inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL polynomial"); 212 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 213 } 214 215 216 // Attempt to invoke function with NULL input vector 217 { 218 psMemId id = psMemGetId(); 219 ok(psPolynomial2DEvalVector(polyOrd,NULL,inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 220 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 221 } 222 223 224 // Attempt to invoke function with NULL input vector 225 { 226 psMemId id = psMemGetId(); 227 ok(psPolynomial2DEvalVector(polyOrd,inputOrdX,NULL) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 228 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 229 } 230 231 211 232 // Attempt to invoke function with a non F64 type input vector 212 inputOrdX->type.type = PS_TYPE_U8; 213 ok(psPolynomial2DEvalVector(polyOrd,inputOrdX,inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 233 { 234 psMemId id = psMemGetId(); 235 inputOrdX->type.type = PS_TYPE_U8; 236 ok(psPolynomial2DEvalVector(polyOrd,inputOrdX,inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 237 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 238 } 239 214 240 inputOrdX->type.type = PS_TYPE_F64; 215 216 241 // Attempt to invoke function with a non F64 type input vector 217 inputOrdY->type.type = PS_TYPE_U8; 218 ok(psPolynomial2DEvalVector(polyOrd,inputOrdX, inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 242 { 243 psMemId id = psMemGetId(); 244 inputOrdY->type.type = PS_TYPE_U8; 245 ok(psPolynomial2DEvalVector(polyOrd,inputOrdX, inputOrdY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 246 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 247 } 219 248 psFree(outputOrd); 220 249 skip_end(); … … 227 256 228 257 229 230 231 232 258 // Allocate polynomial, test the psPolynomial2DEvalVector() routines 233 259 { … … 274 300 ok(!errorFlag, "psPolynomial2DEvalVector() produced the correct answers"); 275 301 276 // Attempt to invoke function with null polynomial 277 ok(psPolynomial2DEvalVector(NULL, inputChebX, inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL polynomial"); 278 279 // Attempt to invoke function with null input vector 280 ok(psPolynomial2DEvalVector(polyCheb,NULL,inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 281 282 // Attempt to invoke function with null input vector 283 ok(psPolynomial2DEvalVector(polyCheb,inputChebX,NULL) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 302 // Attempt to invoke function with NULL polynomial 303 { 304 psMemId id = psMemGetId(); 305 ok(psPolynomial2DEvalVector(NULL, inputChebX, inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL polynomial"); 306 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 307 } 308 309 310 // Attempt to invoke function with NULL input vector 311 { 312 psMemId id = psMemGetId(); 313 ok(psPolynomial2DEvalVector(polyCheb,NULL,inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 314 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 315 } 316 317 318 // Attempt to invoke function with NULL input vector 319 { 320 psMemId id = psMemGetId(); 321 ok(psPolynomial2DEvalVector(polyCheb,inputChebX,NULL) == NULL, "psPolynomial2DEvalVector() produced NULL when called with NULL input vector"); 322 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 323 } 324 284 325 285 326 // Attempt to invoke function with a non F64 type input vector 286 inputChebX->type.type = PS_TYPE_U8; 287 ok(psPolynomial2DEvalVector(polyCheb,inputChebX,inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 327 { 328 psMemId id = psMemGetId(); 329 inputChebX->type.type = PS_TYPE_U8; 330 ok(psPolynomial2DEvalVector(polyCheb,inputChebX,inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 331 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 332 } 333 334 288 335 inputChebX->type.type = PS_TYPE_F64; 289 336 290 337 // Attempt to invoke function with a non F64 type input vector 291 inputChebY->type.type = PS_TYPE_U8; 292 ok(psPolynomial2DEvalVector(polyCheb,inputChebX, inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 338 { 339 psMemId id = psMemGetId(); 340 inputChebY->type.type = PS_TYPE_U8; 341 ok(psPolynomial2DEvalVector(polyCheb,inputChebX, inputChebY) == NULL, "psPolynomial2DEvalVector() produced NULL when called with non F64 input vector"); 342 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 343 } 293 344 psFree(outputCheb); 294 345 skip_end(); -
trunk/psLib/test/math/tap_psPolynomialEval3D.c
r11423 r13124 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-30 04:52:42$6 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-05-02 04:20:06 $ 8 8 * 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 121 121 psLogSetFormat("HLNM"); 122 122 psLogSetLevel(PS_LOG_INFO); 123 plan_tests(32); 123 plan_tests(44); 124 125 126 // Allocate polynomial with unallowed type 127 { 128 psMemId id = psMemGetId(); 129 psPolynomial3D* polyOrd = psPolynomial3DAlloc(99, TERMS-1, TERMS-1, TERMS-1); 130 ok(polyOrd == NULL, "psPolynomial3DAlloc() returned NULL with unallowed type"); 131 psFree(polyOrd); 132 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 133 134 } 135 136 137 // Evaluate NULL polynomial 138 { 139 psMemId id = psMemGetId(); 140 psF64 result = psPolynomial3DEval(NULL, 0.0, 0.0, 0.0); 141 ok(isnan(result), "psPolynomial3DEval() returned NAN with NULL polynomial"); 142 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 143 144 } 145 124 146 125 147 // Allocate and evaluate an ordinary polynomial structure … … 202 224 203 225 204 205 // Allocate polynomial with unallowed type206 // XXX: This is odd.207 {208 psMemId id = psMemGetId();209 psPolynomial3D* polyOrd = psPolynomial3DAlloc(99, TERMS-1, TERMS-1, TERMS-1);210 ok(polyOrd == NULL, "psPolynomial3DAlloc() returned NULL with unallowed type");211 // skip_start(polyOrd == NULL, 1, "Skipping tests because psPolynomial3DAlloc() failed");212 // // Attempt to evaluation invalid polynomial type213 // psF64 result = psPolynomial3DEval(polyOrd,0.0, 0.0, 0.0);214 // ok(isnan(result), "psPolynomial3DEval() did not return NAN, as expected");215 // skip_end();216 psFree(polyOrd);217 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");218 219 }220 221 226 // Allocate polynomial, test the psPolynomial3DEvalVector() routines 222 227 { … … 267 272 ok(!errorFlag, "psPolynomial3DEvalVector() produced the correct answers"); 268 273 269 // Attempt to invoke function with null polynomial 270 ok(psPolynomial3DEvalVector(NULL,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL polynomial"); 271 272 // Attempt to invoke function with null input vector 273 ok(psPolynomial3DEvalVector(polyOrd,NULL,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 274 275 // Attempt to invoke function with null input vector 276 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,NULL,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 277 278 // Attempt to invoke function with null input vector 279 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,NULL) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 280 281 // Attempt to invoke function with a non F64 type input vector 282 inputOrdX->type.type = PS_TYPE_U8; 283 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 274 275 // Attempt to invoke function with NULL polynomial 276 { 277 psMemId id = psMemGetId(); 278 ok(psPolynomial3DEvalVector(NULL,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL polynomial"); 279 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 280 } 281 282 283 // Attempt to invoke function with NULL input vector 284 { 285 psMemId id = psMemGetId(); 286 ok(psPolynomial3DEvalVector(polyOrd,NULL,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 287 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 288 } 289 290 291 // Attempt to invoke function with NULL input vector 292 { 293 psMemId id = psMemGetId(); 294 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,NULL,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 295 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 296 } 297 298 299 // Attempt to invoke function with NULL input vector 300 { 301 psMemId id = psMemGetId(); 302 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,NULL) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 303 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 304 } 305 306 307 // Attempt to invoke function with a non F64 type input vector 308 { 309 psMemId id = psMemGetId(); 310 inputOrdX->type.type = PS_TYPE_U8; 311 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 312 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 313 } 284 314 inputOrdX->type.type = PS_TYPE_F64; 285 315 286 // Attempt to invoke function with a non F64 type input vector 287 inputOrdY->type.type = PS_TYPE_U8; 288 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 316 317 // Attempt to invoke function with a non F64 type input vector 318 { 319 psMemId id = psMemGetId(); 320 inputOrdY->type.type = PS_TYPE_U8; 321 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 322 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 323 } 289 324 inputOrdY->type.type = PS_TYPE_F64; 290 325 291 326 // Attempt to invoke function with a non F64 type input vector 292 inputOrdZ->type.type = PS_TYPE_U8; 293 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 327 { 328 psMemId id = psMemGetId(); 329 inputOrdZ->type.type = PS_TYPE_U8; 330 ok(psPolynomial3DEvalVector(polyOrd,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 331 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 332 } 294 333 psFree(outputOrd); 295 334 skip_end(); … … 302 341 303 342 304 305 306 343 // Allocate polynomial, test the psPolynomial3DEvalVector() routines 307 344 { … … 351 388 ok(!errorFlag, "psPolynomial3DEvalVector() produced the correct answers"); 352 389 353 // Attempt to invoke function with null polynomial 354 ok(psPolynomial3DEvalVector(NULL,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL polynomial"); 355 356 // Attempt to invoke function with null input vector 357 ok(psPolynomial3DEvalVector(polyCheb,NULL,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 358 359 // Attempt to invoke function with null input vector 360 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,NULL,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 361 362 // Attempt to invoke function with null input vector 363 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,NULL) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 364 365 // Attempt to invoke function with a non F64 type input vector 366 inputChebX->type.type = PS_TYPE_U8; 367 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 390 // Attempt to invoke function with NULL polynomial 391 { 392 psMemId id = psMemGetId(); 393 ok(psPolynomial3DEvalVector(NULL,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL polynomial"); 394 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 395 } 396 397 398 // Attempt to invoke function with NULL input vector 399 { 400 psMemId id = psMemGetId(); 401 ok(psPolynomial3DEvalVector(polyCheb,NULL,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 402 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 403 } 404 405 406 // Attempt to invoke function with NULL input vector 407 { 408 psMemId id = psMemGetId(); 409 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,NULL,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 410 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 411 } 412 413 414 // Attempt to invoke function with NULL input vector 415 { 416 psMemId id = psMemGetId(); 417 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,NULL) == NULL, "psPolynomial3DEvalVector() produced NULL when called with NULL input vector"); 418 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 419 } 420 421 422 // Attempt to invoke function with a non F64 type input vector 423 { 424 psMemId id = psMemGetId(); 425 inputChebX->type.type = PS_TYPE_U8; 426 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 427 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 428 } 368 429 inputChebX->type.type = PS_TYPE_F64; 369 430 370 // Attempt to invoke function with a non F64 type input vector 371 inputChebY->type.type = PS_TYPE_U8; 372 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 431 432 // Attempt to invoke function with a non F64 type input vector 433 { 434 psMemId id = psMemGetId(); 435 inputChebY->type.type = PS_TYPE_U8; 436 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 437 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 438 } 373 439 inputChebY->type.type = PS_TYPE_F64; 374 440 375 // Attempt to invoke function with a non F64 type input vector 376 inputChebZ->type.type = PS_TYPE_U8; 377 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 441 442 // Attempt to invoke function with a non F64 type input vector 443 { 444 psMemId id = psMemGetId(); 445 inputChebZ->type.type = PS_TYPE_U8; 446 ok(psPolynomial3DEvalVector(polyCheb,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial3DEvalVector() produced NULL when called with non F64 input vector"); 447 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 448 } 378 449 psFree(outputCheb); 379 450 skip_end(); -
trunk/psLib/test/math/tap_psPolynomialEval4D.c
r11422 r13124 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-30 04:49:52$6 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-05-02 04:20:06 $ 8 8 * 9 9 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 363 363 psLogSetFormat("HLNM"); 364 364 psLogSetLevel(PS_LOG_INFO); 365 plan_tests(37); 365 plan_tests(56); 366 367 368 // Allocate polynomial with unallowed type 369 { 370 psMemId id = psMemGetId(); 371 psPolynomial4D* polyOrd = psPolynomial4DAlloc(99, TERMS-1, TERMS-1, TERMS-1, TERMS-1); 372 ok(polyOrd == NULL, "psPolynomial4DAlloc() returned NULL with unallowed type"); 373 psFree(polyOrd); 374 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 375 } 376 377 378 // Evaluate NULL polynomial 379 { 380 psMemId id = psMemGetId(); 381 psF64 result = psPolynomial4DEval(NULL, 0.0, 0.0, 0.0, 0.0); 382 ok(isnan(result), "psPolynomial4DEval() returned NAN with unallowed type"); 383 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 384 } 385 366 386 367 387 // Allocate and evaluate an ordinary polynomial structure … … 444 464 445 465 446 // XXX: This is wierd: why the skip()?447 // Allocate polynomial with unallowed type448 {449 psMemId id = psMemGetId();450 psPolynomial4D* polyOrd = psPolynomial4DAlloc(99, TERMS-1, TERMS-1, TERMS-1, TERMS-1);451 ok(polyOrd == NULL, "Ordinary polynomial allocation successful");452 skip_start(polyOrd == NULL, 1, "Skipping tests because psPolynomial4DAlloc() failed");453 454 // Attempt to evaluation invalid polynomial type455 psF64 result = psPolynomial4DEval(polyOrd,0.0, 0.0, 0.0, 0.0);456 ok(isnan(result), "psPolynomial3DEval() did not return NAN, as expected");457 skip_end();458 psFree(polyOrd);459 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");460 }461 462 466 // Allocate polynomial, test the psPolynomial4DEvalVector() routines 463 467 { … … 514 518 ok(!errorFlag, "psPolynomial4DEvalVector() produced the correct answers"); 515 519 516 // Attempt to invoke function with null polynomial 517 ok(psPolynomial4DEvalVector(NULL,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL polynomial"); 518 519 // Attempt to invoke function with null input vector 520 ok(psPolynomial4DEvalVector(polyOrd,NULL,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 521 522 // Attempt to invoke function with null input vector 523 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,NULL,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 524 525 // Attempt to invoke function with null input vector 526 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,NULL,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 527 528 // Attempt to invoke function with null input vector 529 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,NULL) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 520 521 // Attempt to invoke function with NULL polynomial 522 { 523 psMemId id = psMemGetId(); 524 ok(psPolynomial4DEvalVector(NULL,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL polynomial"); 525 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 526 } 527 528 529 // Attempt to invoke function with NULL input vector 530 { 531 psMemId id = psMemGetId(); 532 ok(psPolynomial4DEvalVector(polyOrd,NULL,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 533 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 534 } 535 536 537 // Attempt to invoke function with NULL input vector 538 { 539 psMemId id = psMemGetId(); 540 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,NULL,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 541 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 542 } 543 544 545 // Attempt to invoke function with NULL input vector 546 { 547 psMemId id = psMemGetId(); 548 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,NULL,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 549 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 550 } 551 552 553 // Attempt to invoke function with NULL input vector 554 { 555 psMemId id = psMemGetId(); 556 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,NULL) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 557 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 558 } 559 530 560 531 561 // Attempt to invoke function with a non F64 type input vector 532 inputOrdX->type.type = PS_TYPE_U8; 533 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 562 { 563 psMemId id = psMemGetId(); 564 inputOrdX->type.type = PS_TYPE_U8; 565 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 566 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 567 } 534 568 inputOrdX->type.type = PS_TYPE_F64; 535 569 570 536 571 // Attempt to invoke function with a non F64 type input vector 537 inputOrdY->type.type = PS_TYPE_U8; 538 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 572 { 573 psMemId id = psMemGetId(); 574 inputOrdY->type.type = PS_TYPE_U8; 575 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 576 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 577 } 539 578 inputOrdY->type.type = PS_TYPE_F64; 540 579 580 541 581 // Attempt to invoke function with a non F64 type input vector 542 inputOrdZ->type.type = PS_TYPE_U8; 543 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 582 { 583 psMemId id = psMemGetId(); 584 inputOrdZ->type.type = PS_TYPE_U8; 585 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 586 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 587 } 544 588 inputOrdZ->type.type = PS_TYPE_F64; 545 589 590 546 591 // Attempt to invoke function with a non F64 type input vector 547 inputOrdW->type.type = PS_TYPE_U8; 548 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 592 { 593 psMemId id = psMemGetId(); 594 inputOrdW->type.type = PS_TYPE_U8; 595 ok(psPolynomial4DEvalVector(polyOrd,inputOrdW,inputOrdX,inputOrdY,inputOrdZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 596 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 597 } 549 598 inputOrdW->type.type = PS_TYPE_F64; 550 599 psFree(outputOrd); … … 613 662 ok(!errorFlag, "psPolynomial4DEvalVector() produced the correct answers"); 614 663 615 // Attempt to invoke function with null polynomial 616 ok(psPolynomial4DEvalVector(NULL,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL polynomial"); 617 618 // Attempt to invoke function with null input vector 619 ok(psPolynomial4DEvalVector(polyCheb,NULL,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 620 621 // Attempt to invoke function with null input vector 622 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,NULL,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 623 624 // Attempt to invoke function with null input vector 625 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,NULL,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 626 627 // Attempt to invoke function with null input vector 628 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,NULL) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 664 665 // Attempt to invoke function with NULL polynomial 666 { 667 psMemId id = psMemGetId(); 668 ok(psPolynomial4DEvalVector(NULL,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL polynomial"); 669 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 670 } 671 672 673 // Attempt to invoke function with NULL input vector 674 { 675 psMemId id = psMemGetId(); 676 ok(psPolynomial4DEvalVector(polyCheb,NULL,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 677 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 678 } 679 680 681 // Attempt to invoke function with NULL input vector 682 { 683 psMemId id = psMemGetId(); 684 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,NULL,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 685 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 686 } 687 688 689 // Attempt to invoke function with NULL input vector 690 { 691 psMemId id = psMemGetId(); 692 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,NULL,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 693 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 694 } 695 696 697 // Attempt to invoke function with NULL input vector 698 { 699 psMemId id = psMemGetId(); 700 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,NULL) == NULL, "psPolynomial4DEvalVector() produced NULL when called with NULL input vector"); 701 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 702 } 703 629 704 630 705 // Attempt to invoke function with a non F64 type input vector 631 inputChebX->type.type = PS_TYPE_U8; 632 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 706 { 707 psMemId id = psMemGetId(); 708 inputChebX->type.type = PS_TYPE_U8; 709 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 710 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 711 } 633 712 inputChebX->type.type = PS_TYPE_F64; 634 713 714 635 715 // Attempt to invoke function with a non F64 type input vector 636 inputChebY->type.type = PS_TYPE_U8; 637 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 716 { 717 psMemId id = psMemGetId(); 718 inputChebY->type.type = PS_TYPE_U8; 719 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 720 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 721 } 638 722 inputChebY->type.type = PS_TYPE_F64; 639 723 724 640 725 // Attempt to invoke function with a non F64 type input vector 641 inputChebZ->type.type = PS_TYPE_U8; 642 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 726 { 727 psMemId id = psMemGetId(); 728 inputChebZ->type.type = PS_TYPE_U8; 729 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 730 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 731 } 643 732 inputChebZ->type.type = PS_TYPE_F64; 644 733 734 645 735 // Attempt to invoke function with a non F64 type input vector 646 inputChebW->type.type = PS_TYPE_U8; 647 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 736 { 737 psMemId id = psMemGetId(); 738 inputChebW->type.type = PS_TYPE_U8; 739 ok(psPolynomial4DEvalVector(polyCheb,inputChebW,inputChebX,inputChebY,inputChebZ) == NULL, "psPolynomial4DEvalVector() produced NULL when called with non F64 input vector"); 740 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 741 } 648 742 inputChebW->type.type = PS_TYPE_F64; 649 743 psFree(outputCheb); -
trunk/psLib/test/math/tap_psSparse.c
r13123 r13124 1 #include <stdio.h>1 #include <stdio.h> 2 2 #include <string.h> 3 3 #include <pslib.h> … … 6 6 #include "pstap.h" 7 7 8 int main (void)8 int main(void) 9 9 { 10 plan_tests(26); 10 psLogSetFormat("HLNM"); 11 psLogSetLevel(PS_LOG_INFO); 12 plan_tests(40); 13 14 15 // test psSparseAlloc() 16 { 17 psMemId id = psMemGetId(); 18 psSparse *matrix = psSparseAlloc(10, 20); 19 ok(matrix != NULL, "psSparse successfully allocated"); 20 skip_start(matrix == NULL, 12, "skipping tests because psSparseAlloc() returned NULL"); 21 ok(matrix->Aij != NULL, "psSparseAlloc() set ->Aij correctly"); 22 ok(matrix->Aij->n == 0, "psSparseAlloc() set ->Aij->n correctly"); 23 ok(matrix->Si != NULL, "psSparseAlloc() set ->Si correctly"); 24 ok(matrix->Si->n == 0, "psSparseAlloc() set ->Si->n correctly"); 25 ok(matrix->Sj != NULL, "psSparseAlloc() set ->Sj correctly"); 26 ok(matrix->Sj->n == 0, "psSparseAlloc() set ->Sj->n correctly"); 27 ok(matrix->Bfj != NULL, "psSparseAlloc() set ->Bfj correctly"); 28 ok(matrix->Bfj->n == 10, "psSparseAlloc() set ->Bfj->n correctly"); 29 ok(matrix->Qii != NULL, "psSparseAlloc() set ->Qii correctly"); 30 ok(matrix->Qii->n == 10, "psSparseAlloc() set ->Qii->n correctly"); 31 ok(matrix->Nelem == 0, "psSparseAlloc() set ->Nelem correctly"); 32 ok(matrix->Nrows == 10, "psSparseAlloc() set ->Nrows correctly"); 33 skip_end(); 34 psFree(matrix); 35 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 36 } 37 11 38 12 39 // test psSparseSolve for a simple normal example matrix 13 40 { 14 41 psMemId id = psMemGetId(); 15 16 //solve a normalized matrix equation with psSparseSolve17 18 42 // the basic equation is Ax = b 19 43 … … 22 46 // Ax = b for x using psSparseSolve. compare with the input values for x. 23 47 24 psSparse *matrix = psSparseAlloc (100, 100);48 psSparse *matrix = psSparseAlloc(100, 100); 25 49 ok(matrix != NULL, "psSparse successfully allocated"); 26 50 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 27 51 28 for (int i = 0; i < 100; i++) {29 psSparseMatrixElement (matrix, i, i, 1.0);52 for(int i = 0; i < 100; i++) { 53 psSparseMatrixElement(matrix, i, i, 1.0); 30 54 if (i + 1 < 100) { 31 psSparseMatrixElement (matrix, i + 1, i, 0.1);55 psSparseMatrixElement(matrix, i + 1, i, 0.1); 32 56 } 33 57 } … … 37 61 psSparseResort(matrix); 38 62 39 psVector *xRef = psVectorAlloc (100, PS_TYPE_F32); 40 for (int i = 0; i < 100; i++) 41 { 63 psVector *xRef = psVectorAlloc(100, PS_TYPE_F32); 64 for (int i = 0; i < 100; i++) { 42 65 xRef->data.F32[i] = 1.0; 43 66 } … … 60 83 float dS = 0; 61 84 float dS2 = 0; 62 for (int i = 0; i < 100; i++) 63 { 85 for (int i = 0; i < 100; i++) { 64 86 float dX = xRef->data.F32[i] - xFit->data.F32[i]; 65 // fprintf (stderr, "%5.3f %5.3f %5.3f %5.3f\n", bVec->data.F32[i], xRef->data.F32[i], xFit->data.F32[i], dX);87 // fprintf(stderr, "%5.3f %5.3f %5.3f %5.3f\n", bVec->data.F32[i], xRef->data.F32[i], xFit->data.F32[i], dX); 66 88 dS2 += PS_SQR(dX); 67 89 dS += dX; 68 90 } 69 91 dS /= 100.0; 70 dS2 = sqrt (dS2/100.0 - dS*dS);71 72 is_float_tol (dS2, 0.0, 1e-4, "scatter: %.20f", dS2);73 74 psFree (matrix);75 psFree (xRef);76 psFree (bVec);77 psFree (xFit);78 79 skip_end(); 80 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");92 dS2 = sqrt(dS2/100.0 - dS*dS); 93 94 is_float_tol(dS2, 0.0, 1e-4, "scatter: %.20f", dS2); 95 96 psFree(matrix); 97 psFree(xRef); 98 psFree(bVec); 99 psFree(xFit); 100 101 skip_end(); 102 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 81 103 } 82 104 … … 84 106 { 85 107 psMemId id = psMemGetId(); 86 87 //solve a non-normalized matrix equation with psSparseSolve88 108 // the basic equation is Ax = b 109 89 110 // create a matrix A with diagonals of 1 and a small number of off diagonal elements. 90 111 // construct a vector x, construct the corresponding vector b by multiplication. solve 91 112 // Ax = b for x using psSparseSolve. compare with the input values for x. 92 113 93 psSparse *matrix = psSparseAlloc (100, 100);114 psSparse *matrix = psSparseAlloc(100, 100); 94 115 ok(matrix != NULL, "psSparse successfully allocated"); 95 116 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 96 117 97 118 for (int i = 0; i < 100; i++) { 98 psSparseMatrixElement (matrix, i, i, 5.0);119 psSparseMatrixElement(matrix, i, i, 5.0); 99 120 if (i + 1 < 100) { 100 psSparseMatrixElement (matrix, i + 1, i, 0.1);121 psSparseMatrixElement(matrix, i + 1, i, 0.1); 101 122 } 102 123 } … … 106 127 psSparseResort(matrix); 107 128 108 psVector *xRef = psVectorAlloc (100, PS_TYPE_F32); 109 for (int i = 0; i < 100; i++) 110 { 129 psVector *xRef = psVectorAlloc(100, PS_TYPE_F32); 130 for (int i = 0; i < 100; i++) { 111 131 xRef->data.F32[i] = 1.0; 112 132 } … … 123 143 constraint.paramDelta = 1e8; 124 144 125 // solve for normalization terms (need include local sky?)145 // solve for normalization terms(need include local sky?) 126 146 psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4); 127 147 … … 129 149 float dS = 0; 130 150 float dS2 = 0; 131 for (int i = 0; i < 100; i++) 132 { 151 for (int i = 0; i < 100; i++) { 133 152 float dX = xRef->data.F32[i] - xFit->data.F32[i]; 134 // fprintf (stderr, "%5.3f %5.3f %5.3f %5.3f\n", bVec->data.F32[i], xRef->data.F32[i], xFit->data.F32[i], dX);153 // fprintf(stderr, "%5.3f %5.3f %5.3f %5.3f\n", bVec->data.F32[i], xRef->data.F32[i], xFit->data.F32[i], dX); 135 154 dS2 += PS_SQR(dX); 136 155 dS += dX; 137 156 } 138 157 dS /= 100.0; 139 dS2 = sqrt (dS2/100.0 - dS*dS);140 141 is_float_tol (dS2, 0.0, 1e-4, "scatter: %.20f", dS2);142 143 psFree (matrix);144 psFree (xRef);145 psFree (bVec);146 psFree (xFit);147 148 skip_end(); 149 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");158 dS2 = sqrt(dS2/100.0 - dS*dS); 159 160 is_float_tol(dS2, 0.0, 1e-4, "scatter: %.20f", dS2); 161 162 psFree(matrix); 163 psFree(xRef); 164 psFree(bVec); 165 psFree(xFit); 166 167 skip_end(); 168 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 150 169 } 151 170 … … 164 183 { 165 184 psMemId id = psMemGetId(); 166 167 //solve a simple, small matrix equation 168 169 // the basic equation (Ax = b) is: 185 // the basic equation(Ax = b) is: 170 186 // |S B'||x| = |f| 171 187 // |B Q ||y| = |g| … … 180 196 181 197 // construct the sparse matrix 182 psSparse *matrix = psSparseAlloc (Nrows, Nrows);198 psSparse *matrix = psSparseAlloc(Nrows, Nrows); 183 199 ok(matrix != NULL, "psSparse successfully allocated"); 184 200 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); … … 190 206 191 207 // border region has a width of 1: 192 psSparseBorder *border = psSparseBorderAlloc (matrix, Nborder);208 psSparseBorder *border = psSparseBorderAlloc(matrix, Nborder); 193 209 194 210 // construct the B component: 195 psSparseBorderElementB (border, 0, 0, 0.1);196 psSparseBorderElementB (border, 1, 0, 0.2);211 psSparseBorderElementB(border, 0, 0, 0.1); 212 psSparseBorderElementB(border, 1, 0, 0.2); 197 213 198 214 // construct the T component: 199 psSparseBorderElementT (border, 0, 0, 0.5);215 psSparseBorderElementT(border, 0, 0, 0.5); 200 216 201 217 // construct the X and Y vectors: 202 psVector *xRef = psVectorAlloc (Nrows, PS_TYPE_F32);218 psVector *xRef = psVectorAlloc(Nrows, PS_TYPE_F32); 203 219 xRef->data.F32[0] = 1.0; 204 220 xRef->data.F32[1] = 1.0; 205 psVector *yRef = psVectorAlloc (Nborder, PS_TYPE_F32);221 psVector *yRef = psVectorAlloc(Nborder, PS_TYPE_F32); 206 222 yRef->data.F32[0] = 0.5; 207 223 … … 210 226 211 227 // test the support functions: LowerProduct 212 fVec = psSparseBorderLowerProduct (NULL, border, xRef);213 is_float (fVec->n, 1.0, "f dimen: %d", fVec->n);214 is_float (fVec->data.F32[0], 0.3, "f(0): %f", fVec->data.F32[0]);215 psFree (fVec);228 fVec = psSparseBorderLowerProduct(NULL, border, xRef); 229 is_float(fVec->n, 1.0, "f dimen: %d", fVec->n); 230 is_float(fVec->data.F32[0], 0.3, "f(0): %f", fVec->data.F32[0]); 231 psFree(fVec); 216 232 217 233 // test the support functions: Upper Product 218 fVec = psSparseBorderUpperProduct (NULL, border, yRef);219 is_float (fVec->n, 2.0, "f dimen: %d", fVec->n);220 is_float (fVec->data.F32[0], 0.05, "f(0): %f", fVec->data.F32[0]);221 is_float (fVec->data.F32[1], 0.10, "f(0): %f", fVec->data.F32[1]);222 psFree (fVec);234 fVec = psSparseBorderUpperProduct(NULL, border, yRef); 235 is_float(fVec->n, 2.0, "f dimen: %d", fVec->n); 236 is_float(fVec->data.F32[0], 0.05, "f(0): %f", fVec->data.F32[0]); 237 is_float(fVec->data.F32[1], 0.10, "f(0): %f", fVec->data.F32[1]); 238 psFree(fVec); 223 239 224 240 // test the support functions: Square Product 225 fVec = psSparseBorderSquareProduct (NULL, border, yRef);226 is_float (fVec->n, 1.0, "f dimen: %d", fVec->n);227 is_float (fVec->data.F32[0], 0.25, "f(0): %f", fVec->data.F32[0]);228 psFree (fVec);241 fVec = psSparseBorderSquareProduct(NULL, border, yRef); 242 is_float(fVec->n, 1.0, "f dimen: %d", fVec->n); 243 is_float(fVec->data.F32[0], 0.25, "f(0): %f", fVec->data.F32[0]); 244 psFree(fVec); 229 245 230 246 fVec = NULL; 231 247 psVector *gVec = NULL; 232 psSparseBorderMultiply (&fVec, &gVec, border, xRef, yRef);233 is_float (fVec->data.F32[0], 1.15, "f(0): %f", fVec->data.F32[0]);234 is_float (fVec->data.F32[1], 1.20, "f(1): %f", fVec->data.F32[1]);235 is_float (gVec->data.F32[0], 0.55, "g(0): %f", gVec->data.F32[0]);248 psSparseBorderMultiply(&fVec, &gVec, border, xRef, yRef); 249 is_float(fVec->data.F32[0], 1.15, "f(0): %f", fVec->data.F32[0]); 250 is_float(fVec->data.F32[1], 1.20, "f(1): %f", fVec->data.F32[1]); 251 is_float(gVec->data.F32[0], 0.55, "g(0): %f", gVec->data.F32[0]); 236 252 237 253 // supply the fVec and gVec data to the border … … 253 269 psVector *yFit = NULL; 254 270 psSparseBorderSolve(&xFit, &yFit, constraint, border, 4); 255 is_float_tol (xFit->data.F32[0], 1.0, 1e-4, "f(0): %f", xFit->data.F32[0]);256 is_float_tol (xFit->data.F32[1], 1.0, 1e-4, "f(1): %f", xFit->data.F32[1]);257 is_float_tol (yFit->data.F32[0], 0.5, 1e-4, "g(0): %f", yFit->data.F32[0]);258 259 psFree (xFit);260 psFree (yFit);261 psFree (fVec);262 psFree (gVec);263 psFree (xRef);264 psFree (yRef);265 psFree (border);266 psFree (matrix);267 skip_end(); 268 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");271 is_float_tol(xFit->data.F32[0], 1.0, 1e-4, "f(0): %f", xFit->data.F32[0]); 272 is_float_tol(xFit->data.F32[1], 1.0, 1e-4, "f(1): %f", xFit->data.F32[1]); 273 is_float_tol(yFit->data.F32[0], 0.5, 1e-4, "g(0): %f", yFit->data.F32[0]); 274 275 psFree(xFit); 276 psFree(yFit); 277 psFree(fVec); 278 psFree(gVec); 279 psFree(xRef); 280 psFree(yRef); 281 psFree(border); 282 psFree(matrix); 283 skip_end(); 284 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 269 285 } 270 286 … … 272 288 { 273 289 psMemId id = psMemGetId(); 274 275 // solve a simple, small matrix equation 276 277 // the basic equation (Ax = b) is: 290 // the basic equation(Ax = b) is: 278 291 // |S B'||x| = |f| 279 292 // |B Q ||y| = |g| … … 288 301 289 302 // construct the sparse matrix 290 psSparse *matrix = psSparseAlloc (Nrows, Nrows);303 psSparse *matrix = psSparseAlloc(Nrows, Nrows); 291 304 ok(matrix != NULL, "psSparse successfully allocated"); 292 305 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); … … 301 314 302 315 // border region has a width of 1: 303 psSparseBorder *border = psSparseBorderAlloc (matrix, Nborder);316 psSparseBorder *border = psSparseBorderAlloc(matrix, Nborder); 304 317 305 318 // construct the B component: 306 for (int i = 0; i < Nrows; i++) 307 { 319 for (int i = 0; i < Nrows; i++) { 308 320 for (int j = 0; j < Nborder; j++) { 309 psSparseBorderElementB (border, i, j, 0.1);321 psSparseBorderElementB(border, i, j, 0.1); 310 322 } 311 323 } … … 313 325 314 326 // construct the Q component: 315 for (int i = 0; i < Nborder; i++) 316 { 327 for (int i = 0; i < Nborder; i++) { 317 328 for (int j = 0; j < Nborder; j++) { 318 psSparseBorderElementT (border, i, j, i+j+2);329 psSparseBorderElementT(border, i, j, i+j+2); 319 330 } 320 331 } 321 332 322 333 // construct the X and Y vectors: 323 psVector *xRef = psVectorAlloc (Nrows, PS_TYPE_F32); 324 for (int i = 0; i < Nrows; i++) 325 { 334 psVector *xRef = psVectorAlloc(Nrows, PS_TYPE_F32); 335 for (int i = 0; i < Nrows; i++) { 326 336 xRef->data.F32[i] = 1.0; 327 337 } 328 psVector *yRef = psVectorAlloc (Nborder, PS_TYPE_F32); 329 for (int i = 0; i < Nborder; i++) 330 { 338 psVector *yRef = psVectorAlloc(Nborder, PS_TYPE_F32); 339 for (int i = 0; i < Nborder; i++) { 331 340 yRef->data.F32[i] = 1.0; 332 341 } … … 335 344 psVector *fVec = NULL; 336 345 psVector *gVec = NULL; 337 psSparseBorderMultiply (&fVec, &gVec, border, xRef, yRef);346 psSparseBorderMultiply(&fVec, &gVec, border, xRef, yRef); 338 347 339 348 // supply the fVec and gVec data to the border … … 351 360 constraint.paramDelta = 1e8; 352 361 353 // solve for normalization terms (need include local sky?)362 // solve for normalization terms(need include local sky?) 354 363 psVector *xFit = NULL; 355 364 psVector *yFit = NULL; … … 359 368 float dS = 0; 360 369 float dS2 = 0; 361 for (int i = 0; i < Nrows; i++) 362 { 370 for (int i = 0; i < Nrows; i++) { 363 371 float dX = xRef->data.F32[i] - xFit->data.F32[i]; 364 // fprintf (stderr, "%5.3f %5.3f %5.3f %5.3f\n", fVec->data.F32[i], xRef->data.F32[i], xFit->data.F32[i], dX);372 // fprintf(stderr, "%5.3f %5.3f %5.3f %5.3f\n", fVec->data.F32[i], xRef->data.F32[i], xFit->data.F32[i], dX); 365 373 dS2 += PS_SQR(dX); 366 374 dS += dX; 367 375 } 368 376 dS /= Nrows; 369 dS2 = sqrt (dS2/Nrows - dS*dS);370 is_float_tol (dS2, 0.0, 1e-4, "scatter: %.20f", dS2);377 dS2 = sqrt(dS2/Nrows - dS*dS); 378 is_float_tol(dS2, 0.0, 1e-4, "scatter: %.20f", dS2); 371 379 372 380 // measure stdev between yFit and yRef 373 381 float dY = yRef->data.F32[0] - yFit->data.F32[0]; 374 // fprintf (stderr, "%5.3f %5.3f %5.3f %5.3f\n", gVec->data.F32[0], yRef->data.F32[0], yFit->data.F32[0], dS); 375 is_float_tol (dY, 0.0, 2e-4, "scatter: %.20f", dY); 376 377 psFree (xRef); 378 psFree (yRef); 379 psFree (xFit); 380 psFree (yFit); 381 psFree (fVec); 382 psFree (gVec); 383 psFree (matrix); 384 psFree (border); 385 386 skip_end(); 387 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 388 } 389 390 return exit_status(); 382 // fprintf(stderr, "%5.3f %5.3f %5.3f %5.3f\n", gVec->data.F32[0], yRef->data.F32[0], yFit->data.F32[0], dS); 383 is_float_tol(dY, 0.0, 2e-4, "scatter: %.20f", dY); 384 385 psFree(xRef); 386 psFree(yRef); 387 psFree(xFit); 388 psFree(yFit); 389 psFree(fVec); 390 psFree(gVec); 391 psFree(matrix); 392 psFree(border); 393 394 skip_end(); 395 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 396 } 391 397 } -
trunk/psLib/test/math/tap_psSpline1D.c
r10945 r13124 13 13 * @author GLG, MHPCC 14 14 * 15 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $16 * @date $Date: 2007-0 1-06 00:48:54$15 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2007-05-02 04:20:06 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 257 257 psLogSetFormat("HLNM"); 258 258 psLogSetLevel( PS_LOG_INFO ); 259 260 plan_tests(24); 259 plan_tests(28); 260 261 261 // psSplineAllocTest() 262 262 { … … 270 270 ok(tmpSpline->p_psDeriv2 == NULL, "psSpline1DAlloc() properly set the psSpline1D->p_psDeriv2 member"); 271 271 psFree(tmpSpline); 272 273 272 skip_end(); 274 273 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 282 281 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 283 282 } 283 284 // Verify psSpline1DEval() for NULL input 285 // Verify with spline->n==0, and spline->knots PS_TYPE_F64 286 { 287 psMemId id = psMemGetId(); 288 float y = psSpline1DEval(NULL, 0.0); 289 ok(isnan(y), "psSpline1DEval() returned NAN will NULL input spline"); 290 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 291 } 292 293 294 // Verify psSpline1DEvalVector() for NULL input spline 295 { 296 psMemId id = psMemGetId(); 297 psVector *x = psVectorAlloc(10, PS_TYPE_F32); 298 psVector *y = psSpline1DEvalVector(NULL, x); 299 ok(y == NULL, "psSpline1DEvalVector() returned NAN will NULL input spline"); 300 psFree(x); 301 psFree(y); 302 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 303 } 304 305 306 // Verify psSpline1DEvalVector() for NULL input vector 307 // XXX: Move this where we have a good spline. It currently fails because 308 // were calling it with an un-fully-allocated one. 309 if (0) { 310 psMemId id = psMemGetId(); 311 psSpline1D *tmpSpline = psSpline1DAlloc(); 312 psVector *y = psSpline1DEvalVector(tmpSpline, NULL); 313 ok(y == NULL, "psSpline1DEvalVector() returned NAN will NULL input vector"); 314 psFree(tmpSpline); 315 psFree(y); 316 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 317 } 318 284 319 285 320 ok(genericF32Test(1, myFunc00, false), "Generic, simple mapping, F32 test. 1 spline");
Note:
See TracChangeset
for help on using the changeset viewer.
