Changeset 26590
- Timestamp:
- 11/10/21 11:39:38 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/shared/Random/randomgenerator.h
r26589 r26590 17 17 unsigned int m; 18 18 unsigned _seed; 19 double a1;20 double a2;19 double lbound; 20 double ubound; 21 21 22 22 int drnd() { return( _seed = ( a * _seed + c ) % m ); } … … 25 25 26 26 /*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(){} 29 30 void seed( unsigned int s ) { _seed = s; } 30 31 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; } 32 33 33 34 }; … … 44 45 rnd_normal_distribution() : _seed( 0 ), mean( 0), sdev(1.0) {} 45 46 rnd_normal_distribution(double m,double s) : _seed( 0 ), mean( m ), sdev(s) {} 47 ~rnd_normal_distribution(){} 46 48 void seed( unsigned int s ) { _seed = s; } 47 49 double generator()
Note:
See TracChangeset
for help on using the changeset viewer.