Changeset 13123 for trunk/psLib/test/math/tap_psRandom.c
- Timestamp:
- May 1, 2007, 6:14:33 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/math/tap_psRandom.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tap_psRandom.c
r13084 r13123 47 47 plan_tests(34); 48 48 49 diag("ensure that psRandom structs are properly allocated by psRandomAlloc()");50 49 // ensure that psRandom structs are properly allocated by psRandomAlloc() 51 50 { … … 81 80 // testRandomUniform(void) 82 81 { 83 diag("testRandomUniform()");82 // testRandomUniform() 84 83 psMemId id = psMemGetId(); 85 84 psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64); … … 91 90 92 91 // Initialize vector data with random number 93 for (psS32 i = 0 ; i < NUM_DATA ; i++) 94 { 92 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 95 93 rans->data.F64[i] = psRandomUniform(myRNG); 96 94 } 97 95 98 96 // Perform vector stats on random data (mean, stdev) 99 stats =psVectorStats(stats, rans, NULL, NULL, 0);97 psVectorStats(stats, rans, NULL, NULL, 0); 100 98 stats->options = PS_STAT_SAMPLE_STDEV; 101 stats =psVectorStats(stats, rans, NULL, NULL, 0);99 psVectorStats(stats, rans, NULL, NULL, 0); 102 100 103 101 // Verify mean and stdev … … 132 130 133 131 // Initialize vector with random data 134 for (psS32 i = 0 ; i < NUM_DATA ; i++) 135 { 132 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 136 133 rans->data.F64[i] = psRandomGaussian(myRNG); 137 134 } 138 135 139 136 // Perform vector stats on data (mean, stdev) 140 stats =psVectorStats(stats, rans, NULL, NULL, 0);137 psVectorStats(stats, rans, NULL, NULL, 0); 141 138 stats->options = PS_STAT_SAMPLE_STDEV; 142 stats =psVectorStats(stats, rans, NULL, NULL, 0);139 psVectorStats(stats, rans, NULL, NULL, 0); 143 140 144 141 // Verify mean and stdev … … 175 172 176 173 // Initialize vector with random data 177 for (psS32 i = 0 ; i < NUM_DATA ; i++) 178 { 174 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 179 175 rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 180 176 } 181 177 182 178 // Perform vector stats on random data (mean, stdev) 183 stats =psVectorStats(stats, rans, NULL, NULL, 0);179 psVectorStats(stats, rans, NULL, NULL, 0); 184 180 stats->options = PS_STAT_SAMPLE_STDEV; 185 stats =psVectorStats(stats, rans, NULL, NULL, 0);181 psVectorStats(stats, rans, NULL, NULL, 0); 186 182 // Verify mean and stdev 187 183 is_float_tol_per(stats->sampleMean, POISSON_MEAN, ERROR_TOLERANCE, "Mean is within expected range"); … … 221 217 // Random reset 222 218 psRandomReset(myRNG, SEED); 223 for (psS32 i = 0 ; i < NUM_DATA ; i++) 224 { 219 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 225 220 rans00->data.F64[i] = psRandomUniform(myRNG); 226 221 } 227 222 psRandomReset(myRNG, SEED2); 228 for (psS32 i = 0 ; i < NUM_DATA ; i++) 229 { 223 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 230 224 rans01->data.F64[i] = psRandomUniform(myRNG); 231 225 } 232 226 psRandomReset(myRNG, SEED); 233 for (psS32 i = 0 ; i < NUM_DATA ; i++) 234 { 227 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 235 228 rans02->data.F64[i] = psRandomUniform(myRNG); 236 229 } … … 273 266 // testRandomResetGaussian(void) 274 267 { 275 diag("testRandomGaussian(): ensure the seed resets properly");268 // testRandomGaussian(): ensure the seed resets properly 276 269 psMemId id = psMemGetId(); 277 270 psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64); … … 289 282 // Initialize random data in vectors 290 283 psRandomReset(myRNG, SEED); 291 for (psS32 i = 0 ; i < NUM_DATA ; i++) 292 { 284 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 293 285 rans00->data.F64[i] = psRandomGaussian(myRNG); 294 286 } 295 287 psRandomReset(myRNG, SEED2); 296 for (psS32 i = 0 ; i < NUM_DATA ; i++) 297 { 288 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 298 289 rans01->data.F64[i] = psRandomGaussian(myRNG); 299 290 } 300 291 psRandomReset(myRNG, SEED); 301 for (psS32 i = 0 ; i < NUM_DATA ; i++) 302 { 292 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 303 293 rans02->data.F64[i] = psRandomGaussian(myRNG); 304 294 } … … 306 296 // Verify data from original seed produces same data after reset 307 297 psBool errorFlag = false; 308 for (psS32 i = 0 ; i < NUM_DATA ; i++) 309 { 298 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 310 299 if (rans00->data.F64[i] != rans02->data.F64[i]) { 311 300 if (VERBOSE) { … … 315 304 } 316 305 } 317 ok(!errorFlag, "psRandom Uniform() produced the same results with the same seed");306 ok(!errorFlag, "psRandomGaussian() produced the same results with the same seed"); 318 307 skip_end(); 319 308 psFree(myRNG); … … 342 331 // Initialize vectors with random data 343 332 psRandomReset(myRNG, SEED); 344 for (psS32 i = 0 ; i < NUM_DATA ; i++) 345 { 333 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 346 334 rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 347 335 } 348 336 psRandomReset(myRNG, SEED2); 349 for (psS32 i = 0 ; i < NUM_DATA ; i++) 350 { 337 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 351 338 rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 352 339 } 353 340 psRandomReset(myRNG, SEED); 354 for (psS32 i = 0 ; i < NUM_DATA ; i++) 355 { 341 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 356 342 rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 357 343 } … … 359 345 // Verify the original seed produces same data after reset 360 346 psBool errorFlag = false; 361 for (psS32 i = 0 ; i < NUM_DATA ; i++) 362 { 347 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 363 348 if (rans00->data.F64[i] != rans02->data.F64[i]) { 364 349 if (VERBOSE) { … … 368 353 } 369 354 } 370 ok(!errorFlag, "psRandom Uniform() produced the same results with the same seed");355 ok(!errorFlag, "psRandomPoisson() produced the same results with the same seed"); 371 356 skip_end(); 372 357 psFree(myRNG);
Note:
See TracChangeset
for help on using the changeset viewer.
