Changeset 23259 for trunk/psLib/test/math
- Timestamp:
- Mar 10, 2009, 4:53:42 PM (17 years ago)
- Location:
- trunk/psLib/test/math
- Files:
-
- 16 edited
-
tap_psMinimizeLMM.c (modified) (2 diffs)
-
tap_psPolyFit1D.c (modified) (1 diff)
-
tap_psPolyFit2D.c (modified) (1 diff)
-
tap_psPolyFit3D.c (modified) (1 diff)
-
tap_psPolyFit4D.c (modified) (1 diff)
-
tap_psRandom.c (modified) (11 diffs)
-
tap_psStats07.c (modified) (1 diff)
-
tap_psStats09.c (modified) (1 diff)
-
tap_psStatsTiming.c (modified) (1 diff)
-
tst_psMinimizeLMM.c (modified) (1 diff)
-
tst_psPolyFit1D.c (modified) (1 diff)
-
tst_psPolyFit2D.c (modified) (1 diff)
-
tst_psPolyFit3D.c (modified) (1 diff)
-
tst_psPolyFit4D.c (modified) (1 diff)
-
tst_psRandom.c (modified) (13 diffs)
-
tst_psStats09.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tap_psMinimizeLMM.c
r13124 r23259 95 95 { 96 96 psMemId id = psMemGetId(); 97 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed97 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 98 98 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 99 99 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); … … 203 203 { 204 204 psMemId id = psMemGetId(); 205 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed205 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 206 206 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 207 207 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); -
trunk/psLib/test/math/tap_psPolyFit1D.c
r13337 r23259 109 109 psVector *xTruth = psVectorAlloc(numData, PS_TYPE_F64); 110 110 psVector *fTruth = psVectorAlloc(numData, PS_TYPE_F64); 111 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using a known seed111 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using a known seed 112 112 for (int i = 0; i < numData; i++) { 113 113 xTruth->data.F64[i] = (flags & TS00_X_NULL) ? i : 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psPolyFit2D.c
r17567 r23259 108 108 yTruth->n = numData; 109 109 fTruth->n = numData; 110 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using an RNG with a known seed110 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using an RNG with a known seed 111 111 for (int i = 0; i < numData; i++) { 112 112 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psPolyFit3D.c
r17567 r23259 108 108 zTruth->n = numData; 109 109 fTruth->n = numData; 110 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed110 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 111 111 for (int i = 0; i < numData; i++) { 112 112 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psPolyFit4D.c
r17567 r23259 132 132 tTruth->n = numData; 133 133 fTruth->n = numData; 134 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed134 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 135 135 for (int i = 0; i < numData; i++) { 136 136 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tap_psRandom.c
r13123 r23259 3 3 work properly. 4 4 5 ensure that psRandom structs are properly allocated by psRandomAlloc ().5 ensure that psRandom structs are properly allocated by psRandomAllocSpecific(). 6 6 ensure that psRandomUniform() produces a sequence of numbers with 7 7 proper mean and stdev. … … 47 47 plan_tests(34); 48 48 49 // ensure that psRandom structs are properly allocated by psRandomAlloc ()49 // ensure that psRandom structs are properly allocated by psRandomAllocSpecific() 50 50 { 51 51 psMemId id = psMemGetId(); 52 52 // Valid type allocation 53 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);54 ok(myRNG != NULL, "psRandom struct was allocated properly"); 55 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");56 ok(myRNG->type == PS_RANDOM_TAUS, "psRandomAlloc () set type properly");53 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 54 ok(myRNG != NULL, "psRandom struct was allocated properly"); 55 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 56 ok(myRNG->type == PS_RANDOM_TAUS, "psRandomAllocSpecific() set type properly"); 57 57 psFree(myRNG); 58 58 skip_end(); … … 63 63 { 64 64 psMemId id = psMemGetId(); 65 psRandom *myRNG = psRandomAlloc (100,SEED);66 ok(myRNG == NULL, "psRandomAlloc () refused to generate psRandom with unallowed type");65 psRandom *myRNG = psRandomAllocSpecific(100,SEED); 66 ok(myRNG == NULL, "psRandomAllocSpecific() refused to generate psRandom with unallowed type"); 67 67 psFree(myRNG); 68 68 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 72 72 { 73 73 psMemId id = psMemGetId(); 74 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS,-5);75 ok(myRNG != NULL, "psRandomAlloc () allows negative seed");74 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS,-5); 75 ok(myRNG != NULL, "psRandomAllocSpecific() allows negative seed"); 76 76 psFree(myRNG); 77 77 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 85 85 rans->n = rans->nalloc; 86 86 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 87 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);88 ok(myRNG != NULL, "psRandom struct was allocated properly"); 89 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");87 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 88 ok(myRNG != NULL, "psRandom struct was allocated properly"); 89 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 90 90 91 91 // Initialize vector data with random number … … 125 125 rans->n = rans->nalloc; 126 126 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 127 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);128 ok(myRNG != NULL, "psRandom struct was allocated properly"); 129 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");127 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 128 ok(myRNG != NULL, "psRandom struct was allocated properly"); 129 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 130 130 131 131 // Initialize vector with random data … … 167 167 rans->n = rans->nalloc; 168 168 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 169 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);170 ok(myRNG != NULL, "psRandom struct was allocated properly"); 171 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAlloc () failed");169 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 170 ok(myRNG != NULL, "psRandom struct was allocated properly"); 171 skip_start(myRNG == NULL, 2, "Skipping tests because psRandomAllocSpecific() failed"); 172 172 173 173 // Initialize vector with random data … … 210 210 rans02->n = rans02->nalloc; 211 211 212 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);213 ok(myRNG != NULL, "psRandom struct was allocated properly"); 214 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");212 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 213 ok(myRNG != NULL, "psRandom struct was allocated properly"); 214 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 215 215 216 216 … … 252 252 if (0) { 253 253 psRandom *myRNG1 = NULL; 254 myRNG1 = psRandomAlloc (PS_RANDOM_TAUS, SEED);254 myRNG1 = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 255 255 // psLogSetDestination("dest:stderr"); 256 256 psLogSetDestination(0); … … 275 275 rans02->n = rans02->nalloc; 276 276 277 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);278 ok(myRNG != NULL, "psRandom struct was allocated properly"); 279 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");277 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 278 ok(myRNG != NULL, "psRandom struct was allocated properly"); 279 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 280 280 281 281 … … 325 325 rans02->n = rans02->nalloc; 326 326 327 psRandom *myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);328 ok(myRNG != NULL, "psRandom struct was allocated properly"); 329 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAlloc () failed");327 psRandom *myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 328 ok(myRNG != NULL, "psRandom struct was allocated properly"); 329 skip_start(myRNG == NULL, 1, "Skipping tests because psRandomAllocSpecific() failed"); 330 330 331 331 // Initialize vectors with random data -
trunk/psLib/test/math/tap_psStats07.c
r12247 r23259 58 58 PS_ASSERT_INT_NONNEGATIVE(Npts, NULL); 59 59 60 // psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, p_psRandomGetSystemSeed());61 psRandom *r = psRandomAlloc (PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED);60 // psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, p_psRandomGetSystemSeed()); 61 psRandom *r = psRandomAllocSpecific(PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED); 62 62 psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32); 63 63 for (unsigned int i = 0; i < Npts; i++) { -
trunk/psLib/test/math/tap_psStats09.c
r12783 r23259 52 52 srand(SEED); 53 53 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 55 55 psVector *truth = psVectorAlloc(numData, PS_TYPE_F64); 56 56 for (long i = 0; i < numData; i++) { -
trunk/psLib/test/math/tap_psStatsTiming.c
r12513 r23259 20 20 21 21 // build a gauss-deviate vector (mean = 0.0, sigma = 1.0) for tests 22 psRandom *seed = psRandomAlloc (PS_RANDOM_TAUS, 0);22 psRandom *seed = psRandomAllocSpecific (PS_RANDOM_TAUS, 0); 23 23 psVector *rnd = psVectorAlloc (1000, PS_TYPE_F32); 24 24 for (int i = 0; i < rnd->n; i++) { -
trunk/psLib/test/math/tst_psMinimizeLMM.c
r11686 r23259 66 66 psBool testStatus = true; 67 67 68 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed68 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 69 69 psMinimization *min = psMinimizationAlloc(NUM_ITERATIONS, ERR_TOL); 70 70 psArray *ordinates = psArrayAlloc(NUM_DATA_POINTS); -
trunk/psLib/test/math/tst_psPolyFit1D.c
r11686 r23259 101 101 xTruth->n = numData; 102 102 fTruth->n = numData; 103 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using a known seed103 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using a known seed 104 104 for (int i = 0; i < numData; i++) { 105 105 xTruth->data.F64[i] = (flags & TS00_X_NULL) ? i : 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psPolyFit2D.c
r11686 r23259 100 100 yTruth->n = numData; 101 101 fTruth->n = numData; 102 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using an RNG with a known seed102 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using an RNG with a known seed 103 103 for (int i = 0; i < numData; i++) { 104 104 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psPolyFit3D.c
r11686 r23259 103 103 zTruth->n = numData; 104 104 fTruth->n = numData; 105 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed105 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 106 106 for (int i = 0; i < numData; i++) { 107 107 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psPolyFit4D.c
r11686 r23259 124 124 tTruth->n = numData; 125 125 fTruth->n = numData; 126 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Using known seed126 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Using known seed 127 127 for (int i = 0; i < numData; i++) { 128 128 xTruth->data.F64[i] = 2.0*psRandomUniform(rng) - 1.0; -
trunk/psLib/test/math/tst_psRandom.c
r6484 r23259 3 3 work properly. 4 4 5 t00(): ensure that psRandom structs are properly allocated by psRandomAlloc ().5 t00(): ensure that psRandom structs are properly allocated by psRandomAllocSpecific(). 6 6 t01(): ensure that psRandomUniform() produces a sequence of numbers with 7 7 proper mean and stdev. … … 45 45 46 46 testDescription tests[] = { 47 {testRandomAlloc,000,"psRandomAlloc ",0,false},47 {testRandomAlloc,000,"psRandomAllocSpecific",0,false}, 48 48 {testRandomUniform,000,"psRandomUniform",0,false}, 49 49 {testRandomGaussian,000,"psRandomGaussian",0,false}, … … 70 70 71 71 // Valid type allocation 72 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);72 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 73 73 if (myRNG == NULL) { 74 74 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 85 85 // psLogSetDestination("file:seed_msglog1.txt"); 86 86 psLogSetDestination(fd1); 87 myRNG = psRandomAlloc (PS_RANDOM_TAUS, 0);87 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, 0); 88 88 // psLogSetDestination("dest:stderr"); 89 89 psLogSetDestination(2); … … 100 100 // Invalid type allocation 101 101 psLogMsg(__func__,PS_LOG_INFO,"Invalid type, should generate error message"); 102 myRNG = psRandomAlloc (100,SEED);102 myRNG = psRandomAllocSpecific(100,SEED); 103 103 if (myRNG != NULL) { 104 104 psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid type"); … … 107 107 108 108 // Negative seed value 109 myRNG = psRandomAlloc (PS_RANDOM_TAUS,-5);109 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS,-5); 110 110 if(myRNG == NULL) { 111 111 psError(PS_ERR_UNKNOWN,true,"Did not return allocated psRandom"); … … 125 125 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 126 126 127 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);127 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 128 128 if (myRNG == NULL) { 129 129 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 171 171 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 172 172 173 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);173 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 174 174 if (myRNG == NULL) { 175 175 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 219 219 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 220 220 221 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);221 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 222 222 if (myRNG == NULL) { 223 223 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 268 268 rans02->n = rans02->nalloc; 269 269 270 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);270 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 271 271 if (myRNG == NULL) { 272 272 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 302 302 303 303 psRandom *myRNG1 = NULL; 304 myRNG1 = psRandomAlloc (PS_RANDOM_TAUS, SEED);304 myRNG1 = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 305 305 // psLogSetDestination("dest:stderr"); 306 306 psLogSetDestination(0); … … 326 326 rans02->n = rans02->nalloc; 327 327 328 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);328 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 329 329 if (myRNG == NULL) { 330 330 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); … … 372 372 rans02->n = rans02->nalloc; 373 373 374 myRNG = psRandomAlloc (PS_RANDOM_TAUS, SEED);374 myRNG = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED); 375 375 if (myRNG == NULL) { 376 376 psError(PS_ERR_UNKNOWN,true,"Could not allocate psRandom structure"); -
trunk/psLib/test/math/tst_psStats09.c
r11686 r23259 52 52 printPositiveTestHeader(stdout, "psMathUtils functions", "psVectorStats Clipped Stats Routine"); 53 53 54 psRandom *rng = psRandomAlloc (PS_RANDOM_TAUS, 1); // Random number generator; using known seed54 psRandom *rng = psRandomAllocSpecific(PS_RANDOM_TAUS, 1); // Random number generator; using known seed 55 55 psVector *truth = psVectorAlloc(numData, PS_TYPE_F64); 56 56 truth->n = numData;
Note:
See TracChangeset
for help on using the changeset viewer.
