IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2007, 6:14:33 PM (19 years ago)
Author:
gusciora
Message:

Added tabular file of all psLib functions in Chapter 6 of the SDRS (Data
Manipulation). Most of the test file changes in this check-in are fairly
cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/math/tap_psRandom.c

    r13084 r13123  
    4747    plan_tests(34);
    4848
    49     diag("ensure that psRandom structs are properly allocated by psRandomAlloc()");
    5049    // ensure that psRandom structs are properly allocated by psRandomAlloc()
    5150    {
     
    8180    // testRandomUniform(void)
    8281    {
    83         diag("testRandomUniform()");
     82        // testRandomUniform()
    8483        psMemId id = psMemGetId();
    8584        psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
     
    9190
    9291        // 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++) {
    9593            rans->data.F64[i] = psRandomUniform(myRNG);
    9694        }
    9795
    9896        // Perform vector stats on random data (mean, stdev)
    99         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     97        psVectorStats(stats, rans, NULL, NULL, 0);
    10098        stats->options = PS_STAT_SAMPLE_STDEV;
    101         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     99        psVectorStats(stats, rans, NULL, NULL, 0);
    102100
    103101        // Verify mean and stdev
     
    132130
    133131        // Initialize vector with random data
    134         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    135         {
     132        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    136133            rans->data.F64[i] = psRandomGaussian(myRNG);
    137134        }
    138135
    139136        // Perform vector stats on data (mean, stdev)
    140         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     137        psVectorStats(stats, rans, NULL, NULL, 0);
    141138        stats->options = PS_STAT_SAMPLE_STDEV;
    142         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     139        psVectorStats(stats, rans, NULL, NULL, 0);
    143140
    144141        // Verify mean and stdev
     
    175172
    176173        // Initialize vector with random data
    177         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    178         {
     174        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    179175            rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    180176        }
    181177
    182178        // Perform vector stats on random data (mean, stdev)
    183         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     179        psVectorStats(stats, rans, NULL, NULL, 0);
    184180        stats->options = PS_STAT_SAMPLE_STDEV;
    185         stats = psVectorStats(stats, rans, NULL, NULL, 0);
     181        psVectorStats(stats, rans, NULL, NULL, 0);
    186182        // Verify mean and stdev
    187183        is_float_tol_per(stats->sampleMean, POISSON_MEAN, ERROR_TOLERANCE, "Mean is within expected range");
     
    221217        // Random reset
    222218        psRandomReset(myRNG, SEED);
    223         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    224         {
     219        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    225220            rans00->data.F64[i] = psRandomUniform(myRNG);
    226221        }
    227222        psRandomReset(myRNG, SEED2);
    228         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    229         {
     223        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    230224            rans01->data.F64[i] = psRandomUniform(myRNG);
    231225        }
    232226        psRandomReset(myRNG, SEED);
    233         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    234         {
     227        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    235228            rans02->data.F64[i] = psRandomUniform(myRNG);
    236229        }
     
    273266    // testRandomResetGaussian(void)
    274267    {
    275         diag("testRandomGaussian(): ensure the seed resets properly");
     268        // testRandomGaussian(): ensure the seed resets properly
    276269        psMemId id = psMemGetId();
    277270        psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64);
     
    289282        // Initialize random data in vectors
    290283        psRandomReset(myRNG, SEED);
    291         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    292         {
     284        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    293285            rans00->data.F64[i] = psRandomGaussian(myRNG);
    294286        }
    295287        psRandomReset(myRNG, SEED2);
    296         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    297         {
     288        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    298289            rans01->data.F64[i] = psRandomGaussian(myRNG);
    299290        }
    300291        psRandomReset(myRNG, SEED);
    301         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    302         {
     292        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    303293            rans02->data.F64[i] = psRandomGaussian(myRNG);
    304294        }
     
    306296        // Verify data from original seed produces same data after reset
    307297        psBool errorFlag = false;
    308         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    309         {
     298        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    310299            if (rans00->data.F64[i] != rans02->data.F64[i]) {
    311300                if (VERBOSE) {
     
    315304            }
    316305        }
    317         ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
     306        ok(!errorFlag, "psRandomGaussian() produced the same results with the same seed");
    318307        skip_end();
    319308        psFree(myRNG);
     
    342331        // Initialize vectors with random data
    343332        psRandomReset(myRNG, SEED);
    344         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    345         {
     333        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    346334            rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    347335        }
    348336        psRandomReset(myRNG, SEED2);
    349         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    350         {
     337        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    351338            rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    352339        }
    353340        psRandomReset(myRNG, SEED);
    354         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    355         {
     341        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    356342            rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN);
    357343        }
     
    359345        // Verify the original seed produces same data after reset
    360346        psBool errorFlag = false;
    361         for (psS32 i = 0 ; i < NUM_DATA ; i++)
    362         {
     347        for (psS32 i = 0 ; i < NUM_DATA ; i++) {
    363348            if (rans00->data.F64[i] != rans02->data.F64[i]) {
    364349                if (VERBOSE) {
     
    368353            }
    369354        }
    370         ok(!errorFlag, "psRandomUniform() produced the same results with the same seed");
     355        ok(!errorFlag, "psRandomPoisson() produced the same results with the same seed");
    371356        skip_end();
    372357        psFree(myRNG);
Note: See TracChangeset for help on using the changeset viewer.