72 | | <a name="l00024"></a><a class="code" href="classchmat.html">00024</a> <span class="keyword">class </span><a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> : <span class="keyword">public</span> <a class="code" href="classsqmat.html" title="Virtual class for representation of double symmetric matrices in square-root form...">sqmat</a> { |
73 | | <a name="l00025"></a>00025 <span class="keyword">protected</span>: |
74 | | <a name="l00027"></a><a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c">00027</a> mat <a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>; |
75 | | <a name="l00028"></a>00028 <span class="keyword">public</span>: |
76 | | <a name="l00029"></a>00029 |
77 | | <a name="l00030"></a>00030 <span class="keywordtype">void</span> <a class="code" href="classchmat.html#bbc2d98d7455b1f38828907d442836bf">opupdt</a> ( <span class="keyword">const</span> vec &v, <span class="keywordtype">double</span> w ); |
78 | | <a name="l00031"></a>00031 mat <a class="code" href="classchmat.html#045addd685f8d978efda232d7dcb070e" title="Conversion to full matrix.">to_mat</a>() <span class="keyword">const</span>; |
79 | | <a name="l00032"></a>00032 <span class="keywordtype">void</span> <a class="code" href="classchmat.html#66f509f92b0ccf020e2a2a32566e0777" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <span class="keyword">const</span> mat &C ); |
80 | | <a name="l00033"></a>00033 <span class="keywordtype">void</span> <a class="code" href="classchmat.html#66f509f92b0ccf020e2a2a32566e0777" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <span class="keyword">const</span> mat &C , <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &U ) <span class="keyword">const</span>; |
81 | | <a name="l00034"></a>00034 <span class="keywordtype">void</span> <a class="code" href="classchmat.html#07f50d1332b901eee962e8b1913102f7" title="Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. .">mult_sym_t</a> ( <span class="keyword">const</span> mat &C ); |
82 | | <a name="l00035"></a>00035 <span class="keywordtype">void</span> <a class="code" href="classchmat.html#07f50d1332b901eee962e8b1913102f7" title="Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. .">mult_sym_t</a> ( <span class="keyword">const</span> mat &C, <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &U ) <span class="keyword">const</span>; |
83 | | <a name="l00036"></a>00036 <span class="keywordtype">double</span> <a class="code" href="classchmat.html#b504ca818203b13e667cb3c503980382" title="Logarithm of a determinant.">logdet</a>() <span class="keyword">const</span>; |
84 | | <a name="l00037"></a>00037 vec <a class="code" href="classchmat.html#b22aa239dbaca33e3fb93b4f674d7051" title="Multiplies square root of by vector .">sqrt_mult</a> ( <span class="keyword">const</span> vec &v ) <span class="keyword">const</span>; |
85 | | <a name="l00038"></a>00038 <span class="keywordtype">double</span> <a class="code" href="classchmat.html#6807737c7ffdb7041256b51db7592248" title="Evaluates quadratic form ;.">qform</a> ( <span class="keyword">const</span> vec &v ) <span class="keyword">const</span>; |
86 | | <a name="l00039"></a>00039 <span class="keywordtype">double</span> <a class="code" href="classchmat.html#b49427cff186c62f5df3724e5d2c34b4" title="Evaluates quadratic form ;.">invqform</a> ( <span class="keyword">const</span> vec &v ) <span class="keyword">const</span>; |
87 | | <a name="l00040"></a>00040 <span class="keywordtype">void</span> <a class="code" href="classchmat.html#d0a995d312ecc11d3b43693f5e224ba9" title="Clearing matrix so that it corresponds to zeros.">clear</a>(); |
88 | | <a name="l00042"></a><a class="code" href="classchmat.html#f3921e3e5e31337cdbda40a3a5467257">00042</a> <span class="keywordtype">void</span> <span class="keyword">add</span> ( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2, <span class="keywordtype">double</span> w=1.0 ) {}; |
89 | | <a name="l00044"></a><a class="code" href="classchmat.html#5ce4e21a9012a4e98c1f0ed1ca5669bd">00044</a> <span class="keywordtype">void</span> <a class="code" href="classchmat.html#5ce4e21a9012a4e98c1f0ed1ca5669bd" title="Inversion in the same form, i.e. cholesky.">inv</a> ( <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &Inv )<span class="keyword"> const </span>{ ( Inv.<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a> ) = itpp::inv ( <a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a> ).T();}; <span class="comment">//Fixme: can be more efficient</span> |
90 | | <a name="l00045"></a>00045 ; |
91 | | <a name="l00046"></a>00046 <span class="comment">// void inv ( mat &Inv );</span> |
92 | | <a name="l00047"></a>00047 |
93 | | <a name="l00049"></a><a class="code" href="classchmat.html#ba62fbf7cb8e065a4f3d24457824e89b">00049</a> <span class="keyword">virtual</span> <a class="code" href="classchmat.html#ba62fbf7cb8e065a4f3d24457824e89b" title="Destructor for future use;.">~chmat</a>() {}; |
94 | | <a name="l00051"></a>00051 <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> ( ) : <a class="code" href="classsqmat.html" title="Virtual class for representation of double symmetric matrices in square-root form...">sqmat</a> (),<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a> ( ) {}; |
95 | | <a name="l00053"></a><a class="code" href="classchmat.html#fdd73b0c596161637fd25bdf2c670c39">00053</a> <a class="code" href="classchmat.html#fdd73b0c596161637fd25bdf2c670c39" title="Default constructor.">chmat</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> dim0 ) : <a class="code" href="classsqmat.html" title="Virtual class for representation of double symmetric matrices in square-root form...">sqmat</a> ( dim0 ),<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a> ( dim0,dim0 ) {}; |
96 | | <a name="l00055"></a><a class="code" href="classchmat.html#d4f0a94e81279295e60e72812130f9d4">00055</a> <a class="code" href="classchmat.html#d4f0a94e81279295e60e72812130f9d4" title="Default constructor.">chmat</a> ( <span class="keyword">const</span> vec &v) : <a class="code" href="classsqmat.html" title="Virtual class for representation of double symmetric matrices in square-root form...">sqmat</a> ( v.length() ),<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a> ( diag(sqrt(v)) ) {}; |
97 | | <a name="l00057"></a><a class="code" href="classchmat.html#d92f3bd9a727b8c88a8c7385feb3449a">00057</a> <a class="code" href="classchmat.html#d92f3bd9a727b8c88a8c7385feb3449a" title="Copy constructor.">chmat</a> ( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &Ch0) : <a class="code" href="classsqmat.html" title="Virtual class for representation of double symmetric matrices in square-root form...">sqmat</a> ( Ch0.<a class="code" href="classsqmat.html#0abed904bdc0882373ba9adba919689d" title="dimension of the square matrix">dim</a>),<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a> ( Ch0.<a class="code" href="classsqmat.html#0abed904bdc0882373ba9adba919689d" title="dimension of the square matrix">dim</a>,Ch0.<a class="code" href="classsqmat.html#0abed904bdc0882373ba9adba919689d" title="dimension of the square matrix">dim</a> ) {<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>=Ch0.<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>;}; |
98 | | <a name="l00059"></a><a class="code" href="classchmat.html#8334a00f30f0a05f893c2aeec395ef10">00059</a> <a class="code" href="classchmat.html#8334a00f30f0a05f893c2aeec395ef10" title="Default constructor (m3k:cholform).">chmat</a> ( <span class="keyword">const</span> mat &M ) : <a class="code" href="classsqmat.html" title="Virtual class for representation of double symmetric matrices in square-root form...">sqmat</a> ( M.<a class="code" href="classsqmat.html#071e80ced9cc3b8cbb360fa7462eb646" title="Reimplementing common functions of mat: cols().">rows</a>() ),<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a> ( M.<a class="code" href="classsqmat.html#071e80ced9cc3b8cbb360fa7462eb646" title="Reimplementing common functions of mat: cols().">rows</a>(),M.<a class="code" href="classsqmat.html#ecc2e2540f95a04f4449842588170f5b" title="Reimplementing common functions of mat: cols().">cols</a>() ) { |
99 | | <a name="l00060"></a>00060 mat Q; |
100 | | <a name="l00061"></a>00061 it_assert_debug ( M.rows() ==M.cols(),<span class="stringliteral">"chmat:: input matrix must be square!"</span> ); |
101 | | <a name="l00062"></a>00062 <a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>=chol ( M ); |
102 | | <a name="l00063"></a>00063 }; |
103 | | <a name="l00065"></a><a class="code" href="classchmat.html#24de7f42e0a86bb270588cd0dd9d60b4">00065</a> <a class="code" href="classchmat.html#24de7f42e0a86bb270588cd0dd9d60b4" title="Constructor.">chmat</a> ( <span class="keyword">const</span> <a class="code" href="classchmat.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="classsqmat.html" title="Virtual class for representation of double symmetric matrices in square-root form...">sqmat</a>(M.<a class="code" href="classsqmat.html#071e80ced9cc3b8cbb360fa7462eb646" title="Reimplementing common functions of mat: cols().">rows</a>()){it_error(<span class="stringliteral">"not implemneted"</span>);}; |
104 | | <a name="l00067"></a><a class="code" href="classchmat.html#9c50d31c999d85d8e9d8cf2b69b6ac8c">00067</a> mat & <a class="code" href="classchmat.html#9c50d31c999d85d8e9d8cf2b69b6ac8c" title="Access function.">_Ch</a>() {<span class="keywordflow">return</span> <a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>;} |
105 | | <a name="l00069"></a><a class="code" href="classchmat.html#0e2982a88febb5e604f96505ea40bd95">00069</a> <span class="keyword">const</span> mat & <a class="code" href="classchmat.html#0e2982a88febb5e604f96505ea40bd95" title="Access function.">_Ch</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>;} |
106 | | <a name="l00071"></a><a class="code" href="classchmat.html#a4fc7f9b0539b97c414442a22f3db6e8">00071</a> <span class="keywordtype">void</span> <a class="code" href="classchmat.html#a4fc7f9b0539b97c414442a22f3db6e8" title="Access functions.">setD</a> ( <span class="keyword">const</span> vec &nD ) {<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>=diag ( sqrt(nD) );} |
107 | | <a name="l00073"></a><a class="code" href="classchmat.html#4c8b321967b14ed2616a2abb9498a979">00073</a> <span class="keywordtype">void</span> <a class="code" href="classchmat.html#4c8b321967b14ed2616a2abb9498a979" title="Access functions.">setCh</a> ( <span class="keyword">const</span> vec &chQ ) { |
108 | | <a name="l00074"></a>00074 it_assert_debug(chQ.length()==<a class="code" href="classsqmat.html#0abed904bdc0882373ba9adba919689d" title="dimension of the square matrix">dim</a>*<a class="code" href="classsqmat.html#0abed904bdc0882373ba9adba919689d" title="dimension of the square matrix">dim</a>,<span class="stringliteral">""</span>); |
109 | | <a name="l00075"></a>00075 copy_vector(dim*dim, chQ._data(), <a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>._data()); |
110 | | <a name="l00076"></a>00076 } |
111 | | <a name="l00078"></a><a class="code" href="classchmat.html#4b9271097d8317d9514c5d0d62cccb39">00078</a> <span class="keywordtype">void</span> <a class="code" href="classchmat.html#4b9271097d8317d9514c5d0d62cccb39" title="Access functions.">setD</a> ( <span class="keyword">const</span> vec &nD, <span class="keywordtype">int</span> i ) {<span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j=i;j<nD.length();j++ ) {<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>( j,j ) =sqrt(nD ( j-i ));}} <span class="comment">//Fixme can be more general</span> |
112 | | <a name="l00079"></a>00079 |
113 | | <a name="l00081"></a>00081 <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classchmat.html#6a8b39fe3a28d2c8e3fc0d74141229fb" title="Operators.">operator += </a>( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ); |
114 | | <a name="l00082"></a>00082 <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classchmat.html#a8c3628a8c15eb0009e57c66fcac1a76" title="mapping of negative add operation to operators">operator -= </a>( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ) ; |
115 | | <a name="l00083"></a>00083 <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& operator * ( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ); |
116 | | <a name="l00084"></a>00084 <a class="code" href="classchmat.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 ){<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>*d; <span class="keywordflow">return</span> *<span class="keyword">this</span>;}; |
117 | | <a name="l00085"></a>00085 <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& operator = ( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ){<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>=A2.<a class="code" href="classchmat.html#95158bb150f5e7f939168abcd577fd9c" title="Upper triangle of the cholesky matrix.">Ch</a>;<a class="code" href="classsqmat.html#0abed904bdc0882373ba9adba919689d" title="dimension of the square matrix">dim</a>=A2.<a class="code" href="classsqmat.html#0abed904bdc0882373ba9adba919689d" title="dimension of the square matrix">dim</a>;<span class="keywordflow">return</span> *<span class="keyword">this</span>;} |
118 | | <a name="l00086"></a>00086 }; |
119 | | <a name="l00087"></a>00087 |
120 | | <a name="l00088"></a>00088 |
121 | | <a name="l00091"></a><a class="code" href="classchmat.html#6a8b39fe3a28d2c8e3fc0d74141229fb">00091</a> <span class="keyword">inline</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classchmat.html#6a8b39fe3a28d2c8e3fc0d74141229fb" title="Operators.">chmat::operator += </a>( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ) {this-><span class="keyword">add</span> ( A2 );<span class="keywordflow">return</span> *<span class="keyword">this</span>;} |
122 | | <a name="l00093"></a><a class="code" href="classchmat.html#a8c3628a8c15eb0009e57c66fcac1a76">00093</a> <span class="keyword">inline</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classchmat.html#a8c3628a8c15eb0009e57c66fcac1a76" title="mapping of negative add operation to operators">chmat::operator -= </a>( <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &A2 ) {this-><span class="keyword">add</span> ( A2,-1.0 );<span class="keywordflow">return</span> *<span class="keyword">this</span>;} |
123 | | <a name="l00094"></a>00094 |
124 | | <a name="l00095"></a>00095 <span class="preprocessor">#endif // CHMAT_H</span> |
| 71 | <a name="l00019"></a>00019 <span class="keyword">namespace </span>bdm |
| 72 | <a name="l00020"></a>00020 { |
| 73 | <a name="l00021"></a>00021 |
| 74 | <a name="l00027"></a><a class="code" href="classbdm_1_1chmat.html">00027</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> { |
| 75 | <a name="l00028"></a>00028 <span class="keyword">protected</span>: |
| 76 | <a name="l00030"></a><a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223">00030</a> mat <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>; |
| 77 | <a name="l00031"></a>00031 <span class="keyword">public</span>: |
| 78 | <a name="l00032"></a>00032 |
| 79 | <a name="l00033"></a>00033 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#bea30d9ae395363e5aef36f6359b15fd">opupdt</a> ( <span class="keyword">const</span> vec &v, <span class="keywordtype">double</span> w ); |
| 80 | <a name="l00034"></a>00034 mat <a class="code" href="classbdm_1_1chmat.html#4b4c5d4dbb8a3d585b68d936cb6df31b" title="Conversion to full matrix.">to_mat</a>() <span class="keyword">const</span>; |
| 81 | <a name="l00035"></a>00035 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#832d1a18bbf33ee7681adf01d5d08e21" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <span class="keyword">const</span> mat &C ); |
| 82 | <a name="l00036"></a>00036 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#832d1a18bbf33ee7681adf01d5d08e21" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <span class="keyword">const</span> mat &C , <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &U ) <span class="keyword">const</span>; |
| 83 | <a name="l00037"></a>00037 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#7a4f54f1ea8b802f318de77a78f6ddb0" title="Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. .">mult_sym_t</a> ( <span class="keyword">const</span> mat &C ); |
| 84 | <a name="l00038"></a>00038 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#7a4f54f1ea8b802f318de77a78f6ddb0" title="Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. .">mult_sym_t</a> ( <span class="keyword">const</span> mat &C, <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &U ) <span class="keyword">const</span>; |
| 85 | <a name="l00039"></a>00039 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1chmat.html#949ccd174ed19f9cfe36366cbd5c56a4" title="Logarithm of a determinant.">logdet</a>() <span class="keyword">const</span>; |
| 86 | <a name="l00040"></a>00040 vec <a class="code" href="classbdm_1_1chmat.html#ec8d3a1cbf3b50183f246a858663c92d" title="Multiplies square root of by vector .">sqrt_mult</a> ( <span class="keyword">const</span> vec &v ) <span class="keyword">const</span>; |
| 87 | <a name="l00041"></a>00041 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1chmat.html#6e0aee9691909602d341fe5ebd1f1ca8" title="Evaluates quadratic form ;.">qform</a> ( <span class="keyword">const</span> vec &v ) <span class="keyword">const</span>; |
| 88 | <a name="l00042"></a>00042 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1chmat.html#3ac8d00a14a22a21760a8374fe5c5757" title="Evaluates quadratic form ;.">invqform</a> ( <span class="keyword">const</span> vec &v ) <span class="keyword">const</span>; |
| 89 | <a name="l00043"></a>00043 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#bc753cb54aa8946ce41d95e82fc148b5" title="Clearing matrix so that it corresponds to zeros.">clear</a>(); |
| 90 | <a name="l00045"></a><a class="code" href="classbdm_1_1chmat.html#6b3d5b772f791fc7c5df544a418278c7">00045</a> <span class="keywordtype">void</span> <span class="keyword">add</span> ( <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, <span class="keywordtype">double</span> w = 1.0 ) { |
| 91 | <a name="l00046"></a>00046 it_assert_debug ( <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> == A2.dim, <span class="stringliteral">"Matrices of unequal dimension"</span> ); |
| 92 | <a name="l00047"></a>00047 mat pre = concat_vertical ( <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>, sqrt ( w ) * A2.Ch ); |
| 93 | <a name="l00048"></a>00048 mat post = zeros ( pre.rows(), pre.cols() ); |
| 94 | <a name="l00049"></a>00049 <span class="keywordflow">if</span> ( !qr ( pre, post ) ) { |
| 95 | <a name="l00050"></a>00050 it_warning ( <span class="stringliteral">"Unstable QR in chmat add"</span> ); |
| 96 | <a name="l00051"></a>00051 } |
| 97 | <a name="l00052"></a>00052 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = post ( 0, <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> - 1, 0, <a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> - 1 ); |
| 98 | <a name="l00053"></a>00053 }; |
| 99 | <a name="l00055"></a><a class="code" href="classbdm_1_1chmat.html#cbf3389db96dff41fb2e9532d59b13c0">00055</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1chmat.html#cbf3389db96dff41fb2e9532d59b13c0" title="Inversion in the same form, i.e. cholesky.">inv</a> ( <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &Inv )<span class="keyword"> const </span>{ |
| 100 | <a name="l00056"></a>00056 ( Inv.<a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ) = itpp::inv ( <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ).T(); |
| 101 | <a name="l00057"></a>00057 }; <span class="comment">//Fixme: can be more efficient</span> |
| 102 | <a name="l00058"></a>00058 ; |
| 103 | <a name="l00059"></a>00059 <span class="comment">// void inv ( mat &Inv );</span> |
| 104 | <a name="l00060"></a>00060 |
| 105 | <a name="l00062"></a><a class="code" href="classbdm_1_1chmat.html#a888e866a163bffe94b51e58af65901b">00062</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1chmat.html#a888e866a163bffe94b51e58af65901b" title="Destructor for future use;.">~chmat</a>() {}; |
| 106 | <a name="l00064"></a>00064 <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_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> (), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( ) {}; |
| 107 | <a name="l00066"></a><a class="code" href="classbdm_1_1chmat.html#947c52c64022ef364d8ef17c94a65ef1">00066</a> <a class="code" href="classbdm_1_1chmat.html#947c52c64022ef364d8ef17c94a65ef1" title="Default constructor.">chmat</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> dim0 ) : <a class="code" href="classbdm_1_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> ( dim0 ), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( dim0, dim0 ) {}; |
| 108 | <a name="l00068"></a><a class="code" href="classbdm_1_1chmat.html#ae4dd65ff29d7d951b18903b100bd39d">00068</a> <a class="code" href="classbdm_1_1chmat.html#ae4dd65ff29d7d951b18903b100bd39d" title="Default constructor.">chmat</a> ( <span class="keyword">const</span> vec &v ) : <a class="code" href="classbdm_1_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> ( v.length() ), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( diag ( sqrt ( v ) ) ) {}; |
| 109 | <a name="l00070"></a><a class="code" href="classbdm_1_1chmat.html#57513fca80f91194faf90297f2ab2b24">00070</a> <a class="code" href="classbdm_1_1chmat.html#57513fca80f91194faf90297f2ab2b24" title="Copy 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> &Ch0 ) : <a class="code" href="classbdm_1_1sqmat.html" title="Abstract class for representation of double symmetric matrices in square-root form...">sqmat</a> ( Ch0.<a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> ), <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> ( Ch0.<a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a>, Ch0.<a class="code" href="classbdm_1_1sqmat.html#05111b5744a494880e62cb0f3d42293f" title="dimension of the square matrix">dim</a> ) { |
| 110 | <a name="l00071"></a>00071 <a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a> = Ch0.<a class="code" href="classbdm_1_1chmat.html#3e4f39b1895a0a870f8db98329635223" title="Upper triangle of the cholesky matrix.">Ch</a>; |
| 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 } |
| 137 | <a name="l00105"></a>00105 } |
| 138 | <a name="l00106"></a>00106 |
| 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 |
| 166 | <a name="l00138"></a>00138 } |
| 167 | <a name="l00139"></a>00139 |
| 168 | <a name="l00140"></a>00140 <span class="preprocessor">#endif // CHMAT_H</span> |