Changeset 26590


Ignore:
Timestamp:
11/10/21 11:39:38 (3 years ago)
Author:
bulthuis
Message:

CHG: some changes in pseudo-random number generator classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/shared/Random/randomgenerator.h

    r26589 r26590  
    1717    unsigned int m;
    1818    unsigned _seed;
    19     double a1;
    20     double a2;
     19    double lbound;
     20    double ubound;
    2121
    2222    int drnd() { return( _seed = ( a * _seed + c ) % m ); }
     
    2525
    2626    /*constructors, destructors: */
    27     rnd_uniform_distribution() : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), a1(0.0), a2(1.0) {}
    28     rnd_uniform_distribution(double a_1,double a_2) : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), a1(a_1), a2(a_2) {}
     27    rnd_uniform_distribution() : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), lbound(0.0), ubound(1.0) {}
     28    rnd_uniform_distribution(double a_1,double a_2) : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), lbound(a_1), ubound(a_2) {}
     29    ~rnd_uniform_distribution(){}
    2930    void seed( unsigned int s ) { _seed = s; }
    3031    unsigned int get_seed() { return _seed; }
    31     double generator() { return (a2-a1)*(double) drnd()/ m + a1; }
     32    double generator() { return (ubound-lbound)*(double) drnd()/ m + lbound; }
    3233
    3334};
     
    4445    rnd_normal_distribution() : _seed( 0 ), mean( 0), sdev(1.0) {}
    4546    rnd_normal_distribution(double m,double s) : _seed( 0 ), mean( m ), sdev(s) {}
     47    ~rnd_normal_distribution(){}
    4648    void seed( unsigned int s ) { _seed = s; }
    4749    double generator()
Note: See TracChangeset for help on using the changeset viewer.