source: issm/oecreview/Archive/25834-26739/ISSM-26586-26587.diff@ 26740

Last change on this file since 26740 was 26740, checked in by Mathieu Morlighem, 3 years ago

CHG: added 25834-26739

File size: 2.8 KB
RevLine 
[26740]1Index: ../trunk-jpl/src/c/shared/Random/randomgenerator.cpp
2===================================================================
3--- ../trunk-jpl/src/c/shared/Random/randomgenerator.cpp (revision 26586)
4+++ ../trunk-jpl/src/c/shared/Random/randomgenerator.cpp (revision 26587)
5@@ -4,3 +4,46 @@
6
7 #include <iostream>
8 #include "./randomgenerator.h"
9+
10+rnd_uniform_distribution::rnd_uniform_distribution()
11+{/*{{{*/
12+
13+ a = 1103515245; // BSD Formula
14+ c = 12345; // BSD Formula
15+ m = 2147483648; // BSD Formula
16+ _seed = 0;
17+ lbound = 0.0;
18+ ubound = 1.0;
19+ return;
20+}
21+/*}}}*/
22+rnd_uniform_distribution::rnd_uniform_distribution(double lower,double upper){/*{{{*/
23+
24+ a = 1103515245; // BSD Formula
25+ c = 12345; // BSD Formula
26+ m = 2147483648; // BSD Formula
27+ _seed = 0;
28+ lbound = lower;
29+ ubound = upper;
30+ return;
31+}
32+/*}}}*/
33+rnd_uniform_distribution::~rnd_uniform_distribution(){}
34+
35+rnd_normal_distribution::rnd_normal_distribution(){/*{{{*/
36+
37+ _seed = 0;
38+ mean = 0;
39+ sdev = 1.0;
40+ return;
41+}
42+/*}}}*/
43+rnd_normal_distribution::rnd_normal_distribution(double m,double s){/*{{{*/
44+
45+ _seed = 0;
46+ mean = m;
47+ sdev = s;
48+ return;
49+}
50+/*}}}*/
51+rnd_normal_distribution::~rnd_normal_distribution(){}
52Index: ../trunk-jpl/src/c/shared/Random/randomgenerator.h
53===================================================================
54--- ../trunk-jpl/src/c/shared/Random/randomgenerator.h (revision 26586)
55+++ ../trunk-jpl/src/c/shared/Random/randomgenerator.h (revision 26587)
56@@ -16,17 +16,21 @@
57 int c;
58 unsigned int m;
59 unsigned _seed;
60- double a1;
61- double a2;
62+ double lbound;
63+ double ubound;
64
65 int drnd() { return( _seed = ( a * _seed + c ) % m ); }
66
67 public:
68- rnd_uniform_distribution() : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), a1(0.0), a2(1.0) {}
69- rnd_uniform_distribution(double a_1,double a_2) : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), a1(a_1), a2(a_2) {}
70+
71+ /*constructors, destructors: */
72+ rnd_uniform_distribution();
73+ rnd_uniform_distribution(double a_1,double a_2);
74+ ~rnd_uniform_distribution();
75+
76 void seed( unsigned int s ) { _seed = s; }
77 unsigned int get_seed() { return _seed; }
78- double generator() { return (a2-a1)*(double) drnd()/ m + a1; }
79+ double generator() { return (ubound-lbound)*(double) drnd()/ m + lbound; }
80
81 };
82
83@@ -39,8 +43,12 @@
84 double sdev;
85
86 public:
87- rnd_normal_distribution() : _seed( 0 ), mean( 0), sdev(1.0) {}
88- rnd_normal_distribution(double m,double s) : _seed( 0 ), mean( m ), sdev(s) {}
89+
90+ /*constructors, destructors: */
91+ rnd_normal_distribution();
92+ rnd_normal_distribution(double m,double s);
93+ ~rnd_normal_distribution();
94+
95 void seed( unsigned int s ) { _seed = s; }
96 double generator()
97 {
Note: See TracBrowser for help on using the repository browser.