Changeset 26575
- Timestamp:
- 11/09/21 10:58:56 (3 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/shared/Random/randomgenerator.cpp
r26574 r26575 9 9 #define M_PI 3.141592653589793238462643 10 10 11 namespace rdn 12 { 13 uniform_distribution::uniform_distribution(){/*{{{*/ 11 12 uniform_distribution_rnd::uniform_distribution_rnd(){/*{{{*/ 14 13 15 14 a = 1103515245; // BSD Formula … … 20 19 ubound = 1.0; 21 20 return; 22 21 } 23 22 /*}}}*/ 24 uniform_distribution::uniform_distribution(double lower,double upper){/*{{{*/23 uniform_distribution_rnd::uniform_distribution_rnd(double lower,double upper){/*{{{*/ 25 24 26 25 a = 1103515245; // BSD Formula … … 31 30 ubound = upper; 32 31 return; 33 32 } 34 33 /*}}}*/ 35 uniform_distribution::~uniform_distribution(){}36 void uniform_distribution::seed( unsigned int s ) { _seed = s; }37 unsigned int uniform_distribution::get_seed() { return _seed; }38 double uniform_distribution::generator() {34 uniform_distribution_rnd::~uniform_distribution_rnd(){} 35 void uniform_distribution_rnd::seed( unsigned int s ) { _seed = s; } 36 unsigned int uniform_distribution_rnd::get_seed() { return _seed; } 37 double uniform_distribution_rnd::generator() { 39 38 _seed = ( a * _seed + c ) % m ; 40 39 return (ubound-lbound)*(double) _seed/ m + lbound; 41 40 } 42 41 43 42 44 normal_distribution::normal_distribution(){/*{{{*/43 normal_distribution_rnd::normal_distribution_rnd(){/*{{{*/ 45 44 46 45 _seed = 0; … … 48 47 sdev = 1.0; 49 48 return; 50 51 52 normal_distribution::normal_distribution(double m,double s){/*{{{*/49 } 50 /*}}}*/ 51 normal_distribution_rnd::normal_distribution_rnd(double m,double s){/*{{{*/ 53 52 54 53 _seed = 0; … … 56 55 sdev = s; 57 56 return; 58 57 } 59 58 /*}}}*/ 60 normal_distribution::~normal_distribution(){}61 void normal_distribution::seed( unsigned int s ) { _seed = s; }62 double normal_distribution::generator(){/*{{{*/59 normal_distribution_rnd::~normal_distribution_rnd(){} 60 void normal_distribution_rnd::seed( unsigned int s ) { _seed = s; } 61 double normal_distribution_rnd::generator(){/*{{{*/ 63 62 64 uniform_distribution unifdistri;63 uniform_distribution_rnd unifdistri; 65 64 unifdistri.seed(_seed); 66 65 … … 77 76 } 78 77 /*}}}*/ 79 } -
issm/trunk-jpl/src/c/shared/Random/randomgenerator.h
r26574 r26575 6 6 #define _RANDOMGENERATOR_H_ 7 7 8 namespace rdn 8 class uniform_distribution_rnd 9 9 { 10 class uniform_distribution11 {12 10 13 11 private: … … 23 21 24 22 /*constructors, destructors: */ 25 uniform_distribution ();26 uniform_distribution (double a_1, double a_2);27 ~uniform_distribution ();23 uniform_distribution_rnd(); 24 uniform_distribution_rnd(double a_1, double a_2); 25 ~uniform_distribution_rnd(); 28 26 29 27 void seed( unsigned int s ); … … 31 29 double generator(); 32 30 33 31 }; 34 32 35 class normal_distribution 36 33 class normal_distribution_rnd 34 { 37 35 38 36 private: … … 44 42 45 43 /*constructors, destructors: */ 46 normal_distribution ();47 normal_distribution (double m,double s);48 ~normal_distribution ();44 normal_distribution_rnd(); 45 normal_distribution_rnd(double m,double s); 46 ~normal_distribution_rnd(); 49 47 50 48 void seed( unsigned int s ); 51 49 double generator(); 52 50 53 51 }; 54 52 55 56 }57 53 #endif //ifndef _RANDOMGENERATOR_H_ -
issm/trunk-jpl/src/c/solutionsequences/solutionsequence_sampling.cpp
r26574 r26575 18 18 19 19 /*Define seed*/ 20 rdn::normal_distributiondistribution;20 normal_distribution_rnd distribution; 21 21 if(seed<0){ 22 22 std::random_device rd;
Note:
See TracChangeset
for help on using the changeset viewer.