root/doc/html/chmat_8h-source.html @ 312

Revision 312, 20.8 kB (checked in by smidl, 16 years ago)

doc

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: chmat.h Source File</title>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.8 -->
8<script type="text/javascript">
9<!--
10function changeDisplayState (e){
11  var num=this.id.replace(/[^[0-9]/g,'');
12  var button=this.firstChild;
13  var sectionDiv=document.getElementById('dynsection'+num);
14  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15    sectionDiv.style.display='block';
16    button.src='open.gif';
17  }else{
18    sectionDiv.style.display='none';
19    button.src='closed.gif';
20  }
21}
22function initDynSections(){
23  var divs=document.getElementsByTagName('div');
24  var sectionCounter=1;
25  for(var i=0;i<divs.length-1;i++){
26    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27      var header=divs[i];
28      var section=divs[i+1];
29      var button=header.firstChild;
30      if (button!='IMG'){
31        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32        button=document.createElement('img');
33        divs[i].insertBefore(button,divs[i].firstChild);
34      }
35      header.style.cursor='pointer';
36      header.onclick=changeDisplayState;
37      header.id='dynheader'+sectionCounter;
38      button.src='closed.gif';
39      section.id='dynsection'+sectionCounter;
40      section.style.display='none';
41      section.style.marginLeft='14px';
42      sectionCounter++;
43    }
44  }
45}
46window.onload = initDynSections;
47-->
48</script>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="modules.html"><span>Modules</span></a></li>
55      <li><a href="annotated.html"><span>Classes</span></a></li>
56      <li class="current"><a href="files.html"><span>Files</span></a></li>
57    </ul>
58  </div>
59  <div class="tabs">
60    <ul>
61      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
62      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
63    </ul>
64  </div>
65<h1>chmat.h</h1><a href="chmat_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
66<a name="l00013"></a>00013 <span class="preprocessor">#ifndef CHMAT_H</span>
67<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define CHMAT_H</span>
68<a name="l00015"></a>00015 <span class="preprocessor"></span>
69<a name="l00016"></a>00016
70<a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="libDC_8h.html" title="Matrices in decomposed forms (LDL&amp;#39;, LU, UDU&amp;#39;, etc).">libDC.h</a>"</span>
71<a name="l00018"></a>00018
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 &amp;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 &amp;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 &amp;C , <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &amp;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 &amp;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 &amp;C, <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &amp;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 &amp;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 &amp;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 &amp;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> &amp;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> &amp;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 &amp;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 &amp;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> &amp;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 &amp;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> &amp;M, <span class="keyword">const</span> ivec &amp;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 &amp; <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 &amp; <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 &amp;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 &amp;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 &amp;nD, <span class="keywordtype">int</span> i ) {<span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j=i;j&lt;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>&amp; <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> &amp;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>&amp; <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> &amp;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>&amp; 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> &amp;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>&amp; operator * ( <span class="keyword">const</span> <span class="keywordtype">double</span> &amp;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>&amp; 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> &amp;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>&amp; <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> &amp;A2 )  {this-&gt;<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>&amp; <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> &amp;A2 )  {this-&gt;<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>
125</pre></div></div>
126<hr size="1"><address style="text-align: right;"><small>Generated on Thu Apr 9 14:33:20 2009 for mixpp by&nbsp;
127<a href="http://www.doxygen.org/index.html">
128<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
129</body>
130</html>
Note: See TracBrowser for help on using the browser.