98 | | <a name="l00040"></a>00040 <span class="preprocessor">#ifdef TTT</span> |
99 | | <a name="l00041"></a>00041 <span class="preprocessor"></span> |
100 | | <a name="l00045"></a>00045 <span class="keyword">class </span>Gamma_RNG { |
101 | | <a name="l00046"></a>00046 <span class="keyword">public</span>: |
102 | | <a name="l00048"></a>00048 Gamma_RNG ( <span class="keywordtype">double</span> a=1.0, <span class="keywordtype">double</span> b=1.0 ); |
103 | | <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;} |
104 | | <a name="l00052"></a>00052 <span class="keywordtype">double</span> get_setup() <span class="keyword">const</span>; |
105 | | <a name="l00054"></a>00054 <span class="keywordtype">double</span> operator() () { <span class="keywordflow">return</span> sample(); } |
106 | | <a name="l00056"></a>00056 vec operator() ( <span class="keywordtype">int</span> n ); |
107 | | <a name="l00058"></a>00058 mat operator() ( <span class="keywordtype">int</span> h, <span class="keywordtype">int</span> w ); |
108 | | <a name="l00059"></a>00059 <span class="keyword">protected</span>: |
109 | | <a name="l00060"></a>00060 <span class="keyword">private</span>: |
110 | | <a name="l00062"></a>00062 <span class="keywordtype">double</span> sample(); |
111 | | <a name="l00064"></a>00064 <span class="keywordtype">double</span> alpha; |
112 | | <a name="l00066"></a>00066 <span class="keywordtype">double</span> beta; |
113 | | <a name="l00068"></a>00068 Random_Generator RNG; |
114 | | <a name="l00069"></a>00069 Normal_RNG NRNG; |
115 | | <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() );} |
116 | | <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();} |
117 | | <a name="l00073"></a>00073 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |
118 | | <a name="l00074"></a>00074 |
119 | | <a name="l00075"></a>00075 }; |
120 | | <a name="l00076"></a>00076 <span class="preprocessor">#endif</span> |
121 | | <a name="l00077"></a>00077 <span class="preprocessor"></span> <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
122 | | <a name="l00078"></a>00078 |
123 | | <a name="l00080"></a>00080 std::string num2str(<span class="keywordtype">double</span> d); |
124 | | <a name="l00081"></a>00081 |
125 | | <a name="l00083"></a>00083 std::string num2str(<span class="keywordtype">int</span> i); |
126 | | <a name="l00084"></a>00084 } |
127 | | <a name="l00085"></a>00085 |
128 | | <a name="l00086"></a>00086 |
129 | | <a name="l00087"></a>00087 <span class="preprocessor">#endif //ITEX_H</span> |
| 98 | <a name="l00040"></a>00040 <span class="comment">// /*!</span> |
| 99 | <a name="l00041"></a>00041 <span class="comment">// \brief Gamma distribution</span> |
| 100 | <a name="l00042"></a>00042 <span class="comment">// \ingroup randgen</span> |
| 101 | <a name="l00043"></a>00043 <span class="comment">// */</span> |
| 102 | <a name="l00044"></a>00044 <span class="comment">// class Gamma_RNG {</span> |
| 103 | <a name="l00045"></a>00045 <span class="comment">// public:</span> |
| 104 | <a name="l00046"></a>00046 <span class="comment">// //! constructor. Set lambda.</span> |
| 105 | <a name="l00047"></a>00047 <span class="comment">// Gamma_RNG ( double a=1.0, double b=1.0 );</span> |
| 106 | <a name="l00048"></a>00048 <span class="comment">// //! Set lambda</span> |
| 107 | <a name="l00049"></a>00049 <span class="comment">// void setup ( double a0, double b0 ) { alpha=a0; beta=b0;}</span> |
| 108 | <a name="l00050"></a>00050 <span class="comment">// //! get lambda</span> |
| 109 | <a name="l00051"></a>00051 <span class="comment">// double get_setup() const;</span> |
| 110 | <a name="l00052"></a>00052 <span class="comment">// //! Get one sample.</span> |
| 111 | <a name="l00053"></a>00053 <span class="comment">// double operator() () { return sample(); }</span> |
| 112 | <a name="l00054"></a>00054 <span class="comment">// //! Get a sample vector.</span> |
| 113 | <a name="l00055"></a>00055 <span class="comment">// vec operator() ( int n );</span> |
| 114 | <a name="l00056"></a>00056 <span class="comment">// //! Get a sample matrix.</span> |
| 115 | <a name="l00057"></a>00057 <span class="comment">// mat operator() ( int h, int w );</span> |
| 116 | <a name="l00058"></a>00058 <span class="comment">// protected:</span> |
| 117 | <a name="l00059"></a>00059 <span class="comment">// private:</span> |
| 118 | <a name="l00060"></a>00060 <span class="comment">// //!</span> |
| 119 | <a name="l00061"></a>00061 <span class="comment">// double sample();</span> |
| 120 | <a name="l00062"></a>00062 <span class="comment">// //!</span> |
| 121 | <a name="l00063"></a>00063 <span class="comment">// double alpha;</span> |
| 122 | <a name="l00064"></a>00064 <span class="comment">// //!</span> |
| 123 | <a name="l00065"></a>00065 <span class="comment">// double beta;</span> |
| 124 | <a name="l00066"></a>00066 <span class="comment">// //!</span> |
| 125 | <a name="l00067"></a>00067 <span class="comment">// Random_Generator RNG;</span> |
| 126 | <a name="l00068"></a>00068 <span class="comment">// Normal_RNG NRNG;</span> |
| 127 | <a name="l00069"></a>00069 <span class="comment">// //! compatibility with R</span> |
| 128 | <a name="l00070"></a>00070 <span class="comment">// inline double exp_rand() {return -std::log ( RNG.random_01() );}</span> |
| 129 | <a name="l00071"></a>00071 <span class="comment">// inline double unif_rand() {return RNG.random_01();}</span> |
| 130 | <a name="l00072"></a>00072 <span class="comment">// inline double norm_rand() {return NRNG.sample();}</span> |
| 131 | <a name="l00073"></a>00073 <span class="comment">// </span> |
| 132 | <a name="l00074"></a>00074 <span class="comment">// };</span> |
| 133 | <a name="l00075"></a>00075 <span class="comment">// bool qr ( const mat &A, mat &R );</span> |
| 134 | <a name="l00076"></a>00076 <span class="comment">// </span> |
| 135 | <a name="l00077"></a>00077 <span class="comment">// //! reimplementation of matlab num2str</span> |
| 136 | <a name="l00078"></a>00078 <span class="comment">// std::string num2str(double d);</span> |
| 137 | <a name="l00079"></a>00079 <span class="comment">// </span> |
| 138 | <a name="l00080"></a>00080 <span class="comment">// //! reimplementation of matlabs num2str</span> |
| 139 | <a name="l00081"></a>00081 <span class="comment">// std::string num2str(int i);</span> |
| 140 | <a name="l00082"></a>00082 } |
| 141 | <a name="l00083"></a>00083 |
| 142 | <a name="l00084"></a>00084 |
| 143 | <a name="l00085"></a>00085 <span class="preprocessor">#endif //ITEX_H</span> |