111 | | <a name="l00072"></a>00072 }; |
112 | | <a name="l00074"></a><a class="code" href="classbdm_1_1chmat.html#796ee52e1343bc53d278f17c55bb1cc7">00074</a> <a class="code" href="classbdm_1_1chmat.html#796ee52e1343bc53d278f17c55bb1cc7" title="Default constructor (m3k:cholform).">chmat</a> ( <span class="keyword">const</span> mat &M ) : <a class="code" href="classbdm_1_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> ( M.<a class="code" href="classbdm_1_1sqmat.html#73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>() ), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( M.<a class="code" href="classbdm_1_1sqmat.html#73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>(), M.<a class="code" href="classbdm_1_1sqmat.html#445ef762cf5d2d6cfdf53c72942363cf" title="Reimplementing common functions of mat: cols().">cols</a>() ) { |
113 | | <a name="l00075"></a>00075 mat Q; |
114 | | <a name="l00076"></a>00076 it_assert_debug ( M.rows() == M.cols(), <span class="stringliteral">"chmat:: input matrix must be square!"</span> ); |
115 | | <a name="l00077"></a>00077 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = chol ( M ); |
116 | | <a name="l00078"></a>00078 }; |
117 | | <a name="l00080"></a><a class="code" href="classbdm_1_1chmat.html#3c4e675e7efd91f78faa3dcf23aec153">00080</a> <a class="code" href="classbdm_1_1chmat.html#3c4e675e7efd91f78faa3dcf23aec153" title="Constructor.">chmat</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &M, <span class="keyword">const</span> ivec &perm ) : <a class="code" href="classbdm_1_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> ( M.<a class="code" href="classbdm_1_1sqmat.html#73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>() ) { |
118 | | <a name="l00081"></a>00081 it_error ( <span class="stringliteral">"not implemneted"</span> ); |
119 | | <a name="l00082"></a>00082 }; |
120 | | <a name="l00084"></a><a class="code" href="classbdm_1_1chmat.html#17daa8c5c5914bd3194cb3053c5793a5">00084</a> mat & <a class="code" href="classbdm_1_1chmat.html#17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>() { |
121 | | <a name="l00085"></a>00085 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>; |
122 | | <a name="l00086"></a>00086 } |
123 | | <a name="l00088"></a><a class="code" href="classbdm_1_1chmat.html#3e9e137c1a6f46d13c2b6790cfddaa92">00088</a> <span class="keyword">const</span> mat & <a class="code" href="classbdm_1_1chmat.html#3e9e137c1a6f46d13c2b6790cfddaa92" title="Access function.">_Ch</a>()<span class="keyword"> const </span>{ |
124 | | <a name="l00089"></a>00089 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>; |
125 | | <a name="l00090"></a>00090 } |
126 | | <a name="l00092"></a><a class="code" href="classbdm_1_1chmat.html#b192df5b54b173ba9bc6922ee9983bc9">00092</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#b192df5b54b173ba9bc6922ee9983bc9" title="Access functions.">setD</a> ( <span class="keyword">const</span> vec &nD ) { |
127 | | <a name="l00093"></a>00093 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = diag ( sqrt ( nD ) ); |
128 | | <a name="l00094"></a>00094 } |
129 | | <a name="l00096"></a><a class="code" href="classbdm_1_1chmat.html#b8fd18754b0e5e0463f818cd16c710c8">00096</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#b8fd18754b0e5e0463f818cd16c710c8" title="Access functions.">setCh</a> ( <span class="keyword">const</span> vec &chQ ) { |
130 | | <a name="l00097"></a>00097 it_assert_debug ( chQ.length() == <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a>*<a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a>, <span class="stringliteral">""</span> ); |
131 | | <a name="l00098"></a>00098 copy_vector ( dim*dim, chQ._data(), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>._data() ); |
132 | | <a name="l00099"></a>00099 } |
133 | | <a name="l00101"></a><a class="code" href="classbdm_1_1chmat.html#18f4b97bde650086fe5e3d9461a13514">00101</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#18f4b97bde650086fe5e3d9461a13514" title="Access functions.">setD</a> ( <span class="keyword">const</span> vec &nD, <span class="keywordtype">int</span> i ) { |
134 | | <a name="l00102"></a>00102 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j = i; j < nD.length(); j++ ) { |
135 | | <a name="l00103"></a>00103 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( j, j ) = sqrt ( nD ( j - i ) ); <span class="comment">//Fixme can be more general</span> |
136 | | <a name="l00104"></a>00104 } |
| 111 | <a name="l00072"></a>00072 } |
| 112 | <a name="l00073"></a>00073 |
| 113 | <a name="l00075"></a><a class="code" href="classbdm_1_1chmat.html#796ee52e1343bc53d278f17c55bb1cc7">00075</a> <a class="code" href="classbdm_1_1chmat.html#796ee52e1343bc53d278f17c55bb1cc7" title="Default constructor (m3k:cholform).">chmat</a> ( <span class="keyword">const</span> mat &M ) : <a class="code" href="classbdm_1_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> ( M.<a class="code" href="classbdm_1_1sqmat.html#73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>() ), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( M.<a class="code" href="classbdm_1_1sqmat.html#73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>(), M.<a class="code" href="classbdm_1_1sqmat.html#445ef762cf5d2d6cfdf53c72942363cf" title="Reimplementing common functions of mat: cols().">cols</a>() ) { |
| 114 | <a name="l00076"></a>00076 mat Q; |
| 115 | <a name="l00077"></a>00077 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( M.rows() == M.cols(), <span class="stringliteral">"chmat:: input matrix must be square!"</span> ); |
| 116 | <a name="l00078"></a>00078 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = chol ( M ); |
| 117 | <a name="l00079"></a>00079 } |
| 118 | <a name="l00080"></a>00080 |
| 119 | <a name="l00085"></a><a class="code" href="classbdm_1_1chmat.html#3c4e675e7efd91f78faa3dcf23aec153">00085</a> <a class="code" href="classbdm_1_1chmat.html#3c4e675e7efd91f78faa3dcf23aec153">chmat</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &M, <span class="keyword">const</span> ivec &perm ) { |
| 120 | <a name="l00086"></a>00086 <a class="code" href="bdmerror_8h.html#7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> ( <span class="stringliteral">"not implemented"</span> ); |
| 121 | <a name="l00087"></a>00087 } |
| 122 | <a name="l00088"></a>00088 |
| 123 | <a name="l00090"></a><a class="code" href="classbdm_1_1chmat.html#17daa8c5c5914bd3194cb3053c5793a5">00090</a> mat & <a class="code" href="classbdm_1_1chmat.html#17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>() { |
| 124 | <a name="l00091"></a>00091 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>; |
| 125 | <a name="l00092"></a>00092 } |
| 126 | <a name="l00094"></a><a class="code" href="classbdm_1_1chmat.html#3e9e137c1a6f46d13c2b6790cfddaa92">00094</a> <span class="keyword">const</span> mat & <a class="code" href="classbdm_1_1chmat.html#3e9e137c1a6f46d13c2b6790cfddaa92" title="Access function.">_Ch</a>()<span class="keyword"> const </span>{ |
| 127 | <a name="l00095"></a>00095 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>; |
| 128 | <a name="l00096"></a>00096 } |
| 129 | <a name="l00098"></a><a class="code" href="classbdm_1_1chmat.html#b192df5b54b173ba9bc6922ee9983bc9">00098</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#b192df5b54b173ba9bc6922ee9983bc9" title="Access functions.">setD</a> ( <span class="keyword">const</span> vec &nD ) { |
| 130 | <a name="l00099"></a>00099 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = diag ( sqrt ( nD ) ); |
| 131 | <a name="l00100"></a>00100 } |
| 132 | <a name="l00102"></a><a class="code" href="classbdm_1_1chmat.html#b8fd18754b0e5e0463f818cd16c710c8">00102</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#b8fd18754b0e5e0463f818cd16c710c8" title="Access functions.">setCh</a> ( <span class="keyword">const</span> vec &chQ ) { |
| 133 | <a name="l00103"></a>00103 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( chQ.length() == <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> * <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a>, <span class="stringliteral">"wrong length"</span> ); |
| 134 | <a name="l00104"></a>00104 copy_vector ( dim*dim, chQ._data(), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>._data() ); |
139 | | <a name="l00108"></a>00108 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1chmat.html#029a0997afc656fde0c73bbf7724aca9" title="Operators.">operator += </a>( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ); |
140 | | <a name="l00109"></a>00109 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1chmat.html#f1d0180fb795d38b8c352df2686ec5ba" title="mapping of negative add operation to operators">operator -= </a>( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ); |
141 | | <a name="l00110"></a>00110 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& operator * ( <span class="keyword">const</span> <span class="keywordtype">double</span> &d ) { |
142 | | <a name="l00111"></a>00111 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>*sqrt ( d ); |
143 | | <a name="l00112"></a>00112 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
144 | | <a name="l00113"></a>00113 }; |
145 | | <a name="l00114"></a>00114 chmat& operator = ( <span class="keyword">const</span> chmat &A2 ) { |
146 | | <a name="l00115"></a>00115 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = A2.Ch; |
147 | | <a name="l00116"></a>00116 <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> = A2.dim; |
148 | | <a name="l00117"></a>00117 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
149 | | <a name="l00118"></a>00118 } |
150 | | <a name="l00119"></a>00119 chmat& operator *= ( <span class="keywordtype">double</span> x ) { |
151 | | <a name="l00120"></a>00120 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> *= sqrt ( x ); |
152 | | <a name="l00121"></a>00121 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
153 | | <a name="l00122"></a>00122 }; |
154 | | <a name="l00123"></a>00123 }; |
155 | | <a name="l00124"></a>00124 |
156 | | <a name="l00125"></a>00125 |
157 | | <a name="l00128"></a><a class="code" href="classbdm_1_1chmat.html#029a0997afc656fde0c73bbf7724aca9">00128</a> <span class="keyword">inline</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1chmat.html#029a0997afc656fde0c73bbf7724aca9" title="Operators.">chmat::operator += </a>( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> & A2 ) { |
158 | | <a name="l00129"></a>00129 this-><span class="keyword">add</span> ( A2 ); |
159 | | <a name="l00130"></a>00130 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
160 | | <a name="l00131"></a>00131 } |
161 | | <a name="l00133"></a><a class="code" href="classbdm_1_1chmat.html#f1d0180fb795d38b8c352df2686ec5ba">00133</a> <span class="keyword">inline</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1chmat.html#f1d0180fb795d38b8c352df2686ec5ba" title="mapping of negative add operation to operators">chmat::operator -= </a>( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> & A2 ) { |
162 | | <a name="l00134"></a>00134 this-><span class="keyword">add</span> ( A2, -1.0 ); |
163 | | <a name="l00135"></a>00135 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
164 | | <a name="l00136"></a>00136 } |
165 | | <a name="l00137"></a>00137 |
| 137 | <a name="l00108"></a><a class="code" href="classbdm_1_1chmat.html#18f4b97bde650086fe5e3d9461a13514">00108</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#18f4b97bde650086fe5e3d9461a13514" title="Access functions.">setD</a> ( <span class="keyword">const</span> vec &nD, <span class="keywordtype">int</span> i ) { |
| 138 | <a name="l00109"></a>00109 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j = i; j < nD.length(); j++ ) { |
| 139 | <a name="l00110"></a>00110 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( j, j ) = sqrt ( nD ( j - i ) ); <span class="comment">//Fixme can be more general</span> |
| 140 | <a name="l00111"></a>00111 } |
| 141 | <a name="l00112"></a>00112 } |
| 142 | <a name="l00113"></a>00113 |
| 143 | <a name="l00115"></a>00115 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1chmat.html#029a0997afc656fde0c73bbf7724aca9" title="Operators.">operator += </a>( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ); |
| 144 | <a name="l00116"></a>00116 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1chmat.html#f1d0180fb795d38b8c352df2686ec5ba" title="mapping of negative add operation to operators">operator -= </a>( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ); |
| 145 | <a name="l00117"></a>00117 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& operator * ( <span class="keyword">const</span> <span class="keywordtype">double</span> &d ) { |
| 146 | <a name="l00118"></a>00118 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>*sqrt ( d ); |
| 147 | <a name="l00119"></a>00119 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
| 148 | <a name="l00120"></a>00120 }; |
| 149 | <a name="l00121"></a>00121 chmat& operator = ( <span class="keyword">const</span> chmat &A2 ) { |
| 150 | <a name="l00122"></a>00122 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = A2.Ch; |
| 151 | <a name="l00123"></a>00123 <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> = A2.dim; |
| 152 | <a name="l00124"></a>00124 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
| 153 | <a name="l00125"></a>00125 } |
| 154 | <a name="l00126"></a>00126 chmat& operator *= ( <span class="keywordtype">double</span> x ) { |
| 155 | <a name="l00127"></a>00127 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> *= sqrt ( x ); |
| 156 | <a name="l00128"></a>00128 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
| 157 | <a name="l00129"></a>00129 }; |
| 158 | <a name="l00130"></a>00130 }; |
| 159 | <a name="l00131"></a>00131 |
| 160 | <a name="l00132"></a>00132 |
| 161 | <a name="l00135"></a><a class="code" href="classbdm_1_1chmat.html#029a0997afc656fde0c73bbf7724aca9">00135</a> <span class="keyword">inline</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1chmat.html#029a0997afc656fde0c73bbf7724aca9" title="Operators.">chmat::operator += </a>( <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> & A2 ) { |
| 162 | <a name="l00136"></a>00136 this-><span class="keyword">add</span> ( A2 ); |
| 163 | <a name="l00137"></a>00137 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |