IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 10, 2009, 4:53:42 PM (17 years ago)
Author:
Paul Price
Message:

Changing API for psRandomAlloc() to make it easier to be deterministic. psRandomAlloc() now takes only a single argument, which is the generator type (only PS_RANDOM_TAUS is currently supported; others could easily be added). The seed used by the generator is set by psRandomSeed(). This allows us to use the same seed for the random number generator over multiple calls, which means that we can be deterministic by setting the seed. The old API for psRandomAlloc() is available using psRandomAllocSpecific(). Added to the configuration setup in psModules to include recording the random seed, and setting if desired. Updated all our products to use this API. Some fixes and updates to the configuration run-time information dumping. ppImage now dumps the configuration at the end, allowing the list of files in the run-time information to be set.

File:
1 edited

Legend:

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

    r13123 r23259  
    33work properly.
    44 
    5     ensure that psRandom structs are properly allocated by psRandomAlloc().
     5    ensure that psRandom structs are properly allocated by psRandomAllocSpecific().
    66    ensure that psRandomUniform() produces a sequence of numbers with
    77        proper mean and stdev.
     
    4747    plan_tests(34);
    4848
    49     // ensure that psRandom structs are properly allocated by psRandomAlloc()
     49    // ensure that psRandom structs are properly allocated by psRandomAllocSpecific()
    5050    {
    5151        psMemId id = psMemGetId();
    5252        // 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");
    5757        psFree(myRNG);
    5858        skip_end();
     
    6363    {
    6464        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");
    6767        psFree(myRNG);
    6868        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    7272    {
    7373        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");
    7676        psFree(myRNG);
    7777        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    8585        rans->n = rans->nalloc;
    8686        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");
    9090
    9191        // Initialize vector data with random number
     
    125125        rans->n = rans->nalloc;
    126126        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");
    130130
    131131        // Initialize vector with random data
     
    167167        rans->n = rans->nalloc;
    168168        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");
    172172
    173173        // Initialize vector with random data
     
    210210        rans02->n = rans02->nalloc;
    211211
    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");
    215215
    216216
     
    252252    if (0) {
    253253        psRandom *myRNG1 = NULL;
    254         myRNG1 = psRandomAlloc(PS_RANDOM_TAUS, SEED);
     254        myRNG1 = psRandomAllocSpecific(PS_RANDOM_TAUS, SEED);
    255255        //    psLogSetDestination("dest:stderr");
    256256        psLogSetDestination(0);
     
    275275        rans02->n = rans02->nalloc;
    276276
    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");
    280280
    281281
     
    325325        rans02->n = rans02->nalloc;
    326326
    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");
    330330
    331331        // Initialize vectors with random data
Note: See TracChangeset for help on using the changeset viewer.