58 | | <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> { |
59 | | <a name="l00045"></a>00045 <span class="keyword">public</span>: |
60 | | <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 ); |
61 | | <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;} |
62 | | <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>; |
63 | | <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(); } |
64 | | <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 ); |
65 | | <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 ); |
66 | | <a name="l00058"></a>00058 <span class="keyword">protected</span>: |
67 | | <a name="l00059"></a>00059 <span class="keyword">private</span>: |
68 | | <a name="l00061"></a>00061 <span class="keywordtype">double</span> sample(); |
69 | | <a name="l00063"></a>00063 <span class="keywordtype">double</span> alpha; |
70 | | <a name="l00065"></a>00065 <span class="keywordtype">double</span> beta; |
71 | | <a name="l00067"></a>00067 Random_Generator RNG; |
72 | | <a name="l00068"></a>00068 Normal_RNG NRNG; |
73 | | <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() );} |
74 | | <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();} |
75 | | <a name="l00072"></a>00072 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |
76 | | <a name="l00073"></a>00073 |
77 | | <a name="l00074"></a>00074 }; |
78 | | <a name="l00075"></a>00075 |
79 | | <a name="l00076"></a>00076 <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
80 | | <a name="l00077"></a>00077 |
81 | | <a name="l00078"></a>00078 } |
82 | | <a name="l00079"></a>00079 |
83 | | <a name="l00080"></a>00080 |
84 | | <a name="l00081"></a>00081 <span class="preprocessor">#endif //ITEX_H</span> |
| 58 | <a name="l00040"></a>00040 <span class="preprocessor">#ifdef TTT</span> |
| 59 | <a name="l00041"></a>00041 <span class="preprocessor"></span> |
| 60 | <a name="l00045"></a>00045 <span class="keyword">class </span>Gamma_RNG { |
| 61 | <a name="l00046"></a>00046 <span class="keyword">public</span>: |
| 62 | <a name="l00048"></a>00048 Gamma_RNG ( <span class="keywordtype">double</span> a=1.0, <span class="keywordtype">double</span> b=1.0 ); |
| 63 | <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;} |
| 64 | <a name="l00052"></a>00052 <span class="keywordtype">double</span> get_setup() <span class="keyword">const</span>; |
| 65 | <a name="l00054"></a>00054 <span class="keywordtype">double</span> operator() () { <span class="keywordflow">return</span> sample(); } |
| 66 | <a name="l00056"></a>00056 vec operator() ( <span class="keywordtype">int</span> n ); |
| 67 | <a name="l00058"></a>00058 mat operator() ( <span class="keywordtype">int</span> h, <span class="keywordtype">int</span> w ); |
| 68 | <a name="l00059"></a>00059 <span class="keyword">protected</span>: |
| 69 | <a name="l00060"></a>00060 <span class="keyword">private</span>: |
| 70 | <a name="l00062"></a>00062 <span class="keywordtype">double</span> sample(); |
| 71 | <a name="l00064"></a>00064 <span class="keywordtype">double</span> alpha; |
| 72 | <a name="l00066"></a>00066 <span class="keywordtype">double</span> beta; |
| 73 | <a name="l00068"></a>00068 Random_Generator RNG; |
| 74 | <a name="l00069"></a>00069 Normal_RNG NRNG; |
| 75 | <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() );} |
| 76 | <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();} |
| 77 | <a name="l00073"></a>00073 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |
| 78 | <a name="l00074"></a>00074 |
| 79 | <a name="l00075"></a>00075 }; |
| 80 | <a name="l00076"></a>00076 <span class="preprocessor">#endif</span> |
| 81 | <a name="l00077"></a>00077 <span class="preprocessor"></span> <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
| 82 | <a name="l00078"></a>00078 |
| 83 | <a name="l00080"></a>00080 std::string num2str(<span class="keywordtype">double</span> d); |
| 84 | <a name="l00081"></a>00081 |
| 85 | <a name="l00083"></a>00083 std::string num2str(<span class="keywordtype">int</span> i); |
| 86 | <a name="l00084"></a>00084 } |
| 87 | <a name="l00085"></a>00085 |
| 88 | <a name="l00086"></a>00086 |
| 89 | <a name="l00087"></a>00087 <span class="preprocessor">#endif //ITEX_H</span> |