104 | | <a name="l00040"></a>00040 <span class="preprocessor">#if 0</span> |
105 | | <a name="l00041"></a>00041 <span class="preprocessor"></span> |
106 | | <a name="l00045"></a>00045 <span class="keyword">class </span>Gamma_RNG { |
107 | | <a name="l00046"></a>00046 <span class="keyword">public</span>: |
108 | | <a name="l00048"></a>00048 Gamma_RNG ( <span class="keywordtype">double</span> a=1.0, <span class="keywordtype">double</span> b=1.0 ); |
109 | | <a name="l00050"></a>00050 <span class="keywordtype">void</span> setup ( <span class="keywordtype">double</span> a0, <span class="keywordtype">double</span> b0 ) { alpha=a0; beta=b0;} |
110 | | <a name="l00052"></a>00052 <span class="keywordtype">double</span> get_setup() <span class="keyword">const</span>; |
111 | | <a name="l00054"></a>00054 <span class="keywordtype">double</span> operator() () { <span class="keywordflow">return</span> sample(); } |
112 | | <a name="l00056"></a>00056 vec operator() ( <span class="keywordtype">int</span> n ); |
113 | | <a name="l00058"></a>00058 mat operator() ( <span class="keywordtype">int</span> h, <span class="keywordtype">int</span> w ); |
114 | | <a name="l00059"></a>00059 <span class="keyword">protected</span>: |
115 | | <a name="l00060"></a>00060 <span class="keyword">private</span>: |
116 | | <a name="l00062"></a>00062 <span class="keywordtype">double</span> sample(); |
117 | | <a name="l00064"></a>00064 <span class="keywordtype">double</span> alpha; |
118 | | <a name="l00066"></a>00066 <span class="keywordtype">double</span> beta; |
119 | | <a name="l00068"></a>00068 Random_Generator RNG; |
120 | | <a name="l00069"></a>00069 Normal_RNG NRNG; |
121 | | <a name="l00071"></a>00071 <span class="keyword">inline</span> <span class="keywordtype">double</span> exp_rand() {<span class="keywordflow">return</span> -std::log ( RNG.random_01() );} |
122 | | <a name="l00072"></a>00072 <span class="keyword">inline</span> <span class="keywordtype">double</span> unif_rand() {<span class="keywordflow">return</span> RNG.random_01();} |
123 | | <a name="l00073"></a>00073 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |
124 | | <a name="l00074"></a>00074 |
125 | | <a name="l00075"></a>00075 }; |
126 | | <a name="l00076"></a>00076 <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
127 | | <a name="l00077"></a>00077 <span class="preprocessor">#endif</span> |
128 | | <a name="l00079"></a>00079 <span class="preprocessor"> std::string num2str(double d);</span> |
129 | | <a name="l00080"></a>00080 <span class="preprocessor"></span> |
130 | | <a name="l00082"></a>00082 std::string num2str(<span class="keywordtype">int</span> i); |
131 | | <a name="l00083"></a>00083 |
132 | | <a name="l00085"></a>00085 <span class="keywordtype">double</span> psi(<span class="keywordtype">double</span>); |
133 | | <a name="l00086"></a>00086 } |
| 104 | <a name="l00044"></a><a class="code" href="classitpp_1_1Gamma__RNG.html">00044</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Gamma__RNG.html" title="Gamma distribution.">Gamma_RNG</a> { |
| 105 | <a name="l00045"></a>00045 <span class="keyword">public</span>: |
| 106 | <a name="l00047"></a>00047 <a class="code" href="classitpp_1_1Gamma__RNG.html#e132860f825f427d63652edd02c25b54" title="constructor. Set lambda.">Gamma_RNG</a> ( <span class="keywordtype">double</span> a=1.0, <span class="keywordtype">double</span> b=1.0 ); |
| 107 | <a name="l00049"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#dfaae19411e39aa87e1f72e409b6babe">00049</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Gamma__RNG.html#dfaae19411e39aa87e1f72e409b6babe" title="Set lambda.">setup</a> ( <span class="keywordtype">double</span> a0, <span class="keywordtype">double</span> b0 ) { alpha=a0; beta=b0;} |
| 108 | <a name="l00051"></a>00051 <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Gamma__RNG.html#8e666953249038f262cece2d3ed952d6" title="get lambda">get_setup</a>() <span class="keyword">const</span>; |
| 109 | <a name="l00053"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e">00053</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e" title="Get one sample.">operator() </a>() { <span class="keywordflow">return</span> sample(); } |
| 110 | <a name="l00055"></a>00055 vec <a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e" title="Get one sample.">operator() </a>( <span class="keywordtype">int</span> n ); |
| 111 | <a name="l00057"></a>00057 mat <a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e" title="Get one sample.">operator() </a>( <span class="keywordtype">int</span> h, <span class="keywordtype">int</span> w ); |
| 112 | <a name="l00058"></a>00058 <span class="keyword">protected</span>: |
| 113 | <a name="l00059"></a>00059 <span class="keyword">private</span>: |
| 114 | <a name="l00061"></a>00061 <span class="keywordtype">double</span> sample(); |
| 115 | <a name="l00063"></a>00063 <span class="keywordtype">double</span> alpha; |
| 116 | <a name="l00065"></a>00065 <span class="keywordtype">double</span> beta; |
| 117 | <a name="l00067"></a>00067 Random_Generator RNG; |
| 118 | <a name="l00068"></a>00068 Normal_RNG NRNG; |
| 119 | <a name="l00070"></a>00070 <span class="keyword">inline</span> <span class="keywordtype">double</span> exp_rand() {<span class="keywordflow">return</span> -std::log ( RNG.random_01() );} |
| 120 | <a name="l00071"></a>00071 <span class="keyword">inline</span> <span class="keywordtype">double</span> unif_rand() {<span class="keywordflow">return</span> RNG.random_01();} |
| 121 | <a name="l00072"></a>00072 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |
| 122 | <a name="l00073"></a>00073 |
| 123 | <a name="l00074"></a>00074 }; |
| 124 | <a name="l00075"></a>00075 <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
| 125 | <a name="l00076"></a>00076 |
| 126 | <a name="l00078"></a>00078 std::string num2str(<span class="keywordtype">double</span> d); |
| 127 | <a name="l00079"></a>00079 |
| 128 | <a name="l00081"></a>00081 std::string num2str(<span class="keywordtype">int</span> i); |
| 129 | <a name="l00082"></a>00082 |
| 130 | <a name="l00084"></a>00084 <span class="keywordtype">double</span> psi(<span class="keywordtype">double</span>); |
| 131 | <a name="l00085"></a>00085 } |
| 132 | <a name="l00086"></a>00086 |