48 | | <a name="l00036"></a><a class="code" href="classitpp_1_1Gamma__RNG.html">00036</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Gamma__RNG.html" title="Gamma distribution.">Gamma_RNG</a> { |
49 | | <a name="l00037"></a>00037 <span class="keyword">public</span>: |
50 | | <a name="l00039"></a>00039 <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 ); |
51 | | <a name="l00041"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#dfaae19411e39aa87e1f72e409b6babe">00041</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;} |
52 | | <a name="l00043"></a>00043 <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>; |
53 | | <a name="l00045"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e">00045</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(); } |
54 | | <a name="l00047"></a>00047 vec <a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e" title="Get one sample.">operator() </a>( <span class="keywordtype">int</span> n ); |
55 | | <a name="l00049"></a>00049 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 ); |
56 | | <a name="l00050"></a>00050 <span class="keyword">protected</span>: |
57 | | <a name="l00051"></a>00051 <span class="keyword">private</span>: |
58 | | <a name="l00053"></a>00053 <span class="keywordtype">double</span> sample(); |
59 | | <a name="l00055"></a>00055 <span class="keywordtype">double</span> alpha; |
60 | | <a name="l00057"></a>00057 <span class="keywordtype">double</span> beta; |
61 | | <a name="l00059"></a>00059 Random_Generator RNG; |
62 | | <a name="l00060"></a>00060 Normal_RNG NRNG; |
63 | | <a name="l00062"></a>00062 <span class="keyword">inline</span> <span class="keywordtype">double</span> exp_rand() {<span class="keywordflow">return</span> -std::log ( RNG.random_01() );} |
64 | | <a name="l00063"></a>00063 <span class="keyword">inline</span> <span class="keywordtype">double</span> unif_rand() {<span class="keywordflow">return</span> RNG.random_01();} |
65 | | <a name="l00064"></a>00064 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |
66 | | <a name="l00065"></a>00065 |
67 | | <a name="l00066"></a>00066 }; |
68 | | <a name="l00067"></a>00067 |
69 | | <a name="l00068"></a>00068 <span class="keywordtype">bool</span> qr ( <span class="keyword">const</span> mat &A, mat &R ); |
70 | | <a name="l00069"></a>00069 |
71 | | <a name="l00070"></a>00070 } |
| 48 | <a name="l00032"></a>00032 <span class="keyword">template</span><<span class="keyword">class</span> Num_T> <span class="keyword">inline</span> |
| 49 | <a name="l00033"></a>00033 <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) |
| 50 | <a name="l00034"></a>00034 { |
| 51 | <a name="l00035"></a>00035 copy_vector(v.size(), v._data(), M._data() + c*M.rows()); |
| 52 | <a name="l00036"></a>00036 } |
| 53 | <a name="l00037"></a>00037 |
| 54 | <a name="l00042"></a><a class="code" href="classitpp_1_1Gamma__RNG.html">00042</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Gamma__RNG.html" title="Gamma distribution.">Gamma_RNG</a> { |
| 55 | <a name="l00043"></a>00043 <span class="keyword">public</span>: |
| 56 | <a name="l00045"></a>00045 <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 ); |
| 57 | <a name="l00047"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#dfaae19411e39aa87e1f72e409b6babe">00047</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;} |
| 58 | <a name="l00049"></a>00049 <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>; |
| 59 | <a name="l00051"></a><a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e">00051</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(); } |
| 60 | <a name="l00053"></a>00053 vec <a class="code" href="classitpp_1_1Gamma__RNG.html#98e2e65456bca33fca602b2bd607235e" title="Get one sample.">operator() </a>( <span class="keywordtype">int</span> n ); |
| 61 | <a name="l00055"></a>00055 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 ); |
| 62 | <a name="l00056"></a>00056 <span class="keyword">protected</span>: |
| 63 | <a name="l00057"></a>00057 <span class="keyword">private</span>: |
| 64 | <a name="l00059"></a>00059 <span class="keywordtype">double</span> sample(); |
| 65 | <a name="l00061"></a>00061 <span class="keywordtype">double</span> alpha; |
| 66 | <a name="l00063"></a>00063 <span class="keywordtype">double</span> beta; |
| 67 | <a name="l00065"></a>00065 Random_Generator RNG; |
| 68 | <a name="l00066"></a>00066 Normal_RNG NRNG; |
| 69 | <a name="l00068"></a>00068 <span class="keyword">inline</span> <span class="keywordtype">double</span> exp_rand() {<span class="keywordflow">return</span> -std::log ( RNG.random_01() );} |
| 70 | <a name="l00069"></a>00069 <span class="keyword">inline</span> <span class="keywordtype">double</span> unif_rand() {<span class="keywordflow">return</span> RNG.random_01();} |
| 71 | <a name="l00070"></a>00070 <span class="keyword">inline</span> <span class="keywordtype">double</span> norm_rand() {<span class="keywordflow">return</span> NRNG.sample();} |