101 | | <a name="l00038"></a>00038 <span class="keyword">template</span><<span class="keyword">class</span> Num_T> <span class="keyword">inline</span> |
102 | | <a name="l00039"></a>00039 <span class="keywordtype">void</span> set_col_part(mat &M, <span class="keywordtype">int</span> c, <span class="keyword">const</span> Vec<Num_T> &v) |
103 | | <a name="l00040"></a>00040 { |
104 | | <a name="l00041"></a>00041 copy_vector(v.size(), v._data(), M._data() + c*M.rows()); |
105 | | <a name="l00042"></a>00042 } |
106 | | <a name="l00043"></a>00043 |
107 | | <a name="l00044"></a>00044 <span class="keyword">const</span> <span class="keywordtype">double</span> inf =std::numeric_limits<double>::infinity(); |
108 | | <a name="l00045"></a>00045 |
109 | | <a name="l00046"></a>00046 <span class="comment">//#if 0</span> |
110 | | <a name="l00051"></a><a class="code" href="classitpp_1_1Gamma__RNG.html">00051</a> <span class="comment"></span> <span class="keyword">class </span><a class="code" href="classitpp_1_1Gamma__RNG.html" title="Gamma distribution.">Gamma_RNG</a> { |
111 | | <a name="l00052"></a>00052 <span class="keyword">public</span>: |
112 | | <a name="l00054"></a>00054 <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 ); |
113 | | <a name="l00056"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#dfaae19411e39aa87e1f72e409b6babe">00056</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;} |
114 | | <a name="l00058"></a>00058 <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>; |
115 | | <a name="l00060"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e">00060</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(); } |
116 | | <a name="l00062"></a>00062 vec <a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e" title="Get one sample.">operator() </a>( <span class="keywordtype">int</span> n ); |
117 | | <a name="l00064"></a>00064 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 ); |
118 | | <a name="l00065"></a>00065 <span class="keyword">protected</span>: |
119 | | <a name="l00066"></a>00066 <span class="keyword">private</span>: |
120 | | <a name="l00068"></a>00068 <span class="keywordtype">double</span> sample(); |
121 | | <a name="l00070"></a>00070 <span class="keywordtype">double</span> alpha; |
122 | | <a name="l00072"></a>00072 <span class="keywordtype">double</span> beta; |
123 | | <a name="l00074"></a>00074 Random_Generator RNG; |
124 | | <a name="l00075"></a>00075 Normal_RNG NRNG; |
125 | | <a name="l00077"></a>00077 <span class="keyword">inline</span> <span class="keywordtype">double</span> exp_rand() {<span class="keywordflow">return</span> -std::log ( RNG.random_01() );} |
126 | | <a name="l00078"></a>00078 <span class="keyword">inline</span> <span class="keywordtype">double</span> unif_rand() {<span class="keywordflow">return</span> RNG.random_01();} |
127 | | <a name="l00079"></a>00079 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |
128 | | <a name="l00080"></a>00080 |
129 | | <a name="l00081"></a>00081 }; |
130 | | <a name="l00082"></a>00082 <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
131 | | <a name="l00083"></a>00083 <span class="comment">//#endif</span> |
132 | | <a name="l00085"></a>00085 <span class="comment"></span> std::string num2str(<span class="keywordtype">double</span> d); |
133 | | <a name="l00086"></a>00086 |
134 | | <a name="l00088"></a>00088 std::string num2str(<span class="keywordtype">int</span> i); |
135 | | <a name="l00089"></a>00089 |
136 | | <a name="l00091"></a>00091 <span class="keywordtype">double</span> psi(<span class="keywordtype">double</span>); |
137 | | <a name="l00092"></a>00092 } |
138 | | <a name="l00093"></a>00093 |
139 | | <a name="l00094"></a>00094 |
140 | | <a name="l00095"></a>00095 <span class="preprocessor">#endif //ITEX_H</span> |
| 104 | <a name="l00038"></a>00038 <span class="keyword">template</span><<span class="keyword">class</span> Num_T> <span class="keyword">inline</span> |
| 105 | <a name="l00039"></a>00039 <span class="keywordtype">void</span> set_col_part ( mat &M, <span class="keywordtype">int</span> c, <span class="keyword">const</span> Vec<Num_T> &v ) { |
| 106 | <a name="l00040"></a>00040 copy_vector ( v.size(), v._data(), M._data() + c*M.rows() ); |
| 107 | <a name="l00041"></a>00041 } |
| 108 | <a name="l00042"></a>00042 |
| 109 | <a name="l00043"></a>00043 <span class="keyword">const</span> <span class="keywordtype">double</span> inf = std::numeric_limits<double>::infinity(); |
| 110 | <a name="l00044"></a>00044 |
| 111 | <a name="l00045"></a>00045 <span class="preprocessor">#if 0</span> |
| 112 | <a name="l00046"></a>00046 <span class="preprocessor"></span> |
| 113 | <a name="l00050"></a>00050 <span class="keyword">class </span>Gamma_RNG { |
| 114 | <a name="l00051"></a>00051 <span class="keyword">public</span>: |
| 115 | <a name="l00053"></a>00053 Gamma_RNG ( <span class="keywordtype">double</span> a = 1.0, <span class="keywordtype">double</span> b = 1.0 ); |
| 116 | <a name="l00055"></a>00055 <span class="keywordtype">void</span> setup ( <span class="keywordtype">double</span> a0, <span class="keywordtype">double</span> b0 ) { |
| 117 | <a name="l00056"></a>00056 alpha = a0; |
| 118 | <a name="l00057"></a>00057 beta = b0; |
| 119 | <a name="l00058"></a>00058 } |
| 120 | <a name="l00060"></a>00060 <span class="keywordtype">double</span> get_setup() <span class="keyword">const</span>; |
| 121 | <a name="l00062"></a>00062 <span class="keywordtype">double</span> operator() () { |
| 122 | <a name="l00063"></a>00063 <span class="keywordflow">return</span> sample(); |
| 123 | <a name="l00064"></a>00064 } |
| 124 | <a name="l00066"></a>00066 vec operator() ( <span class="keywordtype">int</span> n ); |
| 125 | <a name="l00068"></a>00068 mat operator() ( <span class="keywordtype">int</span> h, <span class="keywordtype">int</span> w ); |
| 126 | <a name="l00069"></a>00069 <span class="keyword">protected</span>: |
| 127 | <a name="l00070"></a>00070 <span class="keyword">private</span>: |
| 128 | <a name="l00072"></a>00072 <span class="keywordtype">double</span> sample(); |
| 129 | <a name="l00074"></a>00074 <span class="keywordtype">double</span> alpha; |
| 130 | <a name="l00076"></a>00076 <span class="keywordtype">double</span> beta; |
| 131 | <a name="l00078"></a>00078 Random_Generator RNG; |
| 132 | <a name="l00079"></a>00079 Normal_RNG NRNG; |
| 133 | <a name="l00081"></a>00081 <span class="keyword">inline</span> <span class="keywordtype">double</span> exp_rand() { |
| 134 | <a name="l00082"></a>00082 <span class="keywordflow">return</span> -std::log ( RNG.random_01() ); |
| 135 | <a name="l00083"></a>00083 } |
| 136 | <a name="l00084"></a>00084 <span class="keyword">inline</span> <span class="keywordtype">double</span> unif_rand() { |
| 137 | <a name="l00085"></a>00085 <span class="keywordflow">return</span> RNG.random_01(); |
| 138 | <a name="l00086"></a>00086 } |
| 139 | <a name="l00087"></a>00087 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() { |
| 140 | <a name="l00088"></a>00088 <span class="keywordflow">return</span> NRNG.sample(); |
| 141 | <a name="l00089"></a>00089 } |
| 142 | <a name="l00090"></a>00090 |
| 143 | <a name="l00091"></a>00091 }; |
| 144 | <a name="l00092"></a>00092 <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
| 145 | <a name="l00093"></a>00093 <span class="preprocessor">#endif</span> |
| 146 | <a name="l00095"></a>00095 <span class="preprocessor">std::string num2str ( double d );</span> |
| 147 | <a name="l00096"></a>00096 <span class="preprocessor"></span> |
| 148 | <a name="l00098"></a>00098 std::string num2str ( <span class="keywordtype">int</span> i ); |
| 149 | <a name="l00099"></a>00099 |
| 150 | <a name="l00101"></a>00101 <span class="keywordtype">double</span> psi ( <span class="keywordtype">double</span> ); |
| 151 | <a name="l00102"></a>00102 |
| 152 | <a name="l00104"></a>00104 <span class="keywordtype">void</span> triu(mat &A); |
| 153 | <a name="l00105"></a>00105 |
| 154 | <a name="l00109"></a>00109 <span class="keywordtype">double</span> randun(); |
| 155 | <a name="l00111"></a>00111 vec randun(<span class="keywordtype">int</span> n); |
| 156 | <a name="l00113"></a>00113 mat randun(<span class="keywordtype">int</span> n, <span class="keywordtype">int</span> m); |
| 157 | <a name="l00114"></a>00114 |
| 158 | <a name="l00116"></a>00116 ivec unique(<span class="keyword">const</span> ivec &in); |
| 159 | <a name="l00117"></a>00117 |
| 160 | <a name="l00119"></a>00119 ivec unique_complement(<span class="keyword">const</span> ivec &in, <span class="keyword">const</span> ivec &base); |
| 161 | <a name="l00120"></a>00120 } |
| 162 | <a name="l00121"></a>00121 |
| 163 | <a name="l00122"></a>00122 |
| 164 | <a name="l00123"></a>00123 <span class="preprocessor">#endif //ITEX_H</span> |