1 | <?xml version='1.0' encoding='UTF-8' standalone='no'?> |
---|
2 | <doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.5.6"> |
---|
3 | <compounddef id="chmat_8cpp" kind="file"> |
---|
4 | <compoundname>chmat.cpp</compoundname> |
---|
5 | <includes local="no">itpp/itbase.h</includes> |
---|
6 | <includes refid="chmat_8h" local="yes">chmat.h</includes> |
---|
7 | <incdepgraph> |
---|
8 | <node id="283"> |
---|
9 | <label>work/git/mixpp/bdm/math/chmat.cpp</label> |
---|
10 | <link refid="chmat.cpp"/> |
---|
11 | <childnode refid="284" relation="include"> |
---|
12 | </childnode> |
---|
13 | <childnode refid="285" relation="include"> |
---|
14 | </childnode> |
---|
15 | </node> |
---|
16 | <node id="287"> |
---|
17 | <label>../itpp_ext.h</label> |
---|
18 | <link refid="itpp__ext_8h-source"/> |
---|
19 | <childnode refid="284" relation="include"> |
---|
20 | </childnode> |
---|
21 | </node> |
---|
22 | <node id="284"> |
---|
23 | <label>itpp/itbase.h</label> |
---|
24 | </node> |
---|
25 | <node id="285"> |
---|
26 | <label>chmat.h</label> |
---|
27 | <link refid="chmat_8h"/> |
---|
28 | <childnode refid="284" relation="include"> |
---|
29 | </childnode> |
---|
30 | <childnode refid="286" relation="include"> |
---|
31 | </childnode> |
---|
32 | <childnode refid="287" relation="include"> |
---|
33 | </childnode> |
---|
34 | </node> |
---|
35 | <node id="286"> |
---|
36 | <label>libDC.h</label> |
---|
37 | <link refid="libDC_8h"/> |
---|
38 | <childnode refid="284" relation="include"> |
---|
39 | </childnode> |
---|
40 | </node> |
---|
41 | </incdepgraph> |
---|
42 | <briefdescription> |
---|
43 | </briefdescription> |
---|
44 | <detaileddescription> |
---|
45 | </detaileddescription> |
---|
46 | <programlisting> |
---|
47 | <codeline lineno="1"><highlight class="preprocessor">#include<sp/><itpp/itbase.h></highlight><highlight class="normal"></highlight></codeline> |
---|
48 | <codeline lineno="2"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"<ref refid="chmat_8h" kindref="compound" tooltip="Matrices in decomposed forms (LDL&#39;, LU, UDU&#39;, etc).">chmat.h</ref>"</highlight><highlight class="normal"></highlight></codeline> |
---|
49 | <codeline lineno="3"><highlight class="normal"></highlight></codeline> |
---|
50 | <codeline lineno="4"><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal">itpp;</highlight></codeline> |
---|
51 | <codeline lineno="5"><highlight class="normal"></highlight></codeline> |
---|
52 | <codeline lineno="6"><highlight class="normal"></highlight><highlight class="comment">//using<sp/>std::endl;</highlight><highlight class="normal"></highlight></codeline> |
---|
53 | <codeline lineno="7"><highlight class="normal"></highlight></codeline> |
---|
54 | <codeline lineno="8"><highlight class="normal"></highlight></codeline> |
---|
55 | <codeline lineno="9" refid="classchmat_1bbc2d98d7455b1f38828907d442836bf" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classchmat_1bbc2d98d7455b1f38828907d442836bf" kindref="member">chmat::opupdt</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&v,<sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>w<sp/>)<sp/>{</highlight></codeline> |
---|
56 | <codeline lineno="10"><highlight class="normal"></highlight><highlight class="comment">//TODO<sp/>see<sp/>cholupdt<sp/>in<sp/>lhotse</highlight><highlight class="normal"></highlight></codeline> |
---|
57 | <codeline lineno="11"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>Z;</highlight></codeline> |
---|
58 | <codeline lineno="12"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>R;</highlight></codeline> |
---|
59 | <codeline lineno="13"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>V(1,v.length());</highlight></codeline> |
---|
60 | <codeline lineno="14"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>V.set_row(0,v*w);</highlight></codeline> |
---|
61 | <codeline lineno="15"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Z<sp/>=<sp/>concat_vertical<sp/>(<sp/><ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>,V<sp/>);</highlight></codeline> |
---|
62 | <codeline lineno="16"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>qr<sp/>(<sp/>Z,R<sp/>);</highlight></codeline> |
---|
63 | <codeline lineno="17"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref><sp/>=<sp/>R<sp/>(<sp/>0,<sp/><ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>.rows()-1,<sp/>0,<sp/><ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>.cols()-1<sp/>);</highlight></codeline> |
---|
64 | <codeline lineno="18"><highlight class="normal">};</highlight></codeline> |
---|
65 | <codeline lineno="19" refid="classchmat_1a37e2c726e4fc3ad50b26ac2ca6c1452" refkind="member"><highlight class="normal">mat<sp/><ref refid="classchmat_1a37e2c726e4fc3ad50b26ac2ca6c1452" kindref="member" tooltip="Conversion to full matrix.">chmat::to_mat</ref>()<sp/>{mat<sp/>F=<ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>.T()<sp/>*<ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>;</highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>F;};</highlight></codeline> |
---|
66 | <codeline lineno="20" refid="classchmat_166f509f92b0ccf020e2a2a32566e0777" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classchmat_166f509f92b0ccf020e2a2a32566e0777" kindref="member" tooltip="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">chmat::mult_sym</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>mat<sp/>&C<sp/>)<sp/>{</highlight></codeline> |
---|
67 | <codeline lineno="21"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_error<sp/>(<sp/></highlight><highlight class="stringliteral">"not<sp/>implemented"</highlight><highlight class="normal"><sp/>);</highlight></codeline> |
---|
68 | <codeline lineno="22"><highlight class="normal">};</highlight></codeline> |
---|
69 | <codeline lineno="23"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classchmat_166f509f92b0ccf020e2a2a32566e0777" kindref="member" tooltip="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">chmat::mult_sym</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>mat<sp/>&C<sp/>,<sp/><ref refid="classchmat" kindref="compound" tooltip="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</ref><sp/>&U<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline> |
---|
70 | <codeline lineno="24"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_error<sp/>(<sp/></highlight><highlight class="stringliteral">"not<sp/>implemented"</highlight><highlight class="normal"><sp/>);</highlight></codeline> |
---|
71 | <codeline lineno="25"><highlight class="normal">};</highlight></codeline> |
---|
72 | <codeline lineno="26" refid="classchmat_107f50d1332b901eee962e8b1913102f7" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classchmat_107f50d1332b901eee962e8b1913102f7" kindref="member" tooltip="Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. .">chmat::mult_sym_t</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>mat<sp/>&C<sp/>)<sp/>{</highlight></codeline> |
---|
73 | <codeline lineno="27"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_error<sp/>(<sp/></highlight><highlight class="stringliteral">"not<sp/>implemented"</highlight><highlight class="normal"><sp/>);</highlight></codeline> |
---|
74 | <codeline lineno="28"><highlight class="normal">};</highlight></codeline> |
---|
75 | <codeline lineno="29"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classchmat_107f50d1332b901eee962e8b1913102f7" kindref="member" tooltip="Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. .">chmat::mult_sym_t</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>mat<sp/>&C,<sp/><ref refid="classchmat" kindref="compound" tooltip="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</ref><sp/>&U<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline> |
---|
76 | <codeline lineno="30"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_error<sp/>(<sp/></highlight><highlight class="stringliteral">"not<sp/>implemented"</highlight><highlight class="normal"><sp/>);</highlight></codeline> |
---|
77 | <codeline lineno="31"><highlight class="normal">};</highlight></codeline> |
---|
78 | <codeline lineno="32" refid="classchmat_1b504ca818203b13e667cb3c503980382" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classchmat_1b504ca818203b13e667cb3c503980382" kindref="member" tooltip="Logarithm of a determinant.">chmat::logdet</ref>()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline> |
---|
79 | <codeline lineno="33"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>ldet=0.0;<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline> |
---|
80 | <codeline lineno="34"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//sum<sp/>of<sp/>logs<sp/>of<sp/>(possibly<sp/>negative!)<sp/>diagonal<sp/>entries</highlight><highlight class="normal"></highlight></codeline> |
---|
81 | <codeline lineno="35"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;i<<ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>.rows();i++<sp/>)<sp/>{ldet+=log<sp/>(<sp/>std::fabs<sp/>(<sp/><ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref><sp/>(<sp/>i,i<sp/>)<sp/>)<sp/>);}</highlight></codeline> |
---|
82 | <codeline lineno="36"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>2*ldet;<sp/></highlight><highlight class="comment">//compensate<sp/>for<sp/>Ch<sp/>being<sp/>sqrt()</highlight><highlight class="normal"></highlight></codeline> |
---|
83 | <codeline lineno="37"><highlight class="normal">};</highlight></codeline> |
---|
84 | <codeline lineno="38"><highlight class="normal"></highlight><highlight class="comment">//TODO<sp/>can<sp/>be<sp/>done<sp/>more<sp/>efficiently<sp/>using<sp/>BLAS,<sp/>see<sp/>triangular<sp/>matrices</highlight><highlight class="normal"></highlight></codeline> |
---|
85 | <codeline lineno="39" refid="classchmat_1b22aa239dbaca33e3fb93b4f674d7051" refkind="member"><highlight class="normal">vec<sp/><ref refid="classchmat_1b22aa239dbaca33e3fb93b4f674d7051" kindref="member" tooltip="Multiplies square root of by vector .">chmat::sqrt_mult</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&v<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{vec<sp/>pom;<sp/>pom<sp/>=<sp/><ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>*v;<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pom;};</highlight></codeline> |
---|
86 | <codeline lineno="40" refid="classchmat_16807737c7ffdb7041256b51db7592248" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classchmat_16807737c7ffdb7041256b51db7592248" kindref="member" tooltip="Evaluates quadratic form ;.">chmat::qform</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&v<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{vec<sp/>pom;<sp/>pom<sp/>=<sp/><ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>*v;<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pom*pom;};</highlight></codeline> |
---|
87 | <codeline lineno="41" refid="classchmat_1b49427cff186c62f5df3724e5d2c34b4" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/><ref refid="classchmat_1b49427cff186c62f5df3724e5d2c34b4" kindref="member" tooltip="Evaluates quadratic form ;.">chmat::invqform</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&v<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline> |
---|
88 | <codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>pom(v.length());</highlight></codeline> |
---|
89 | <codeline lineno="43"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>forward_substitution(<ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>.T(),v,pom);</highlight></codeline> |
---|
90 | <codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pom*pom;</highlight></codeline> |
---|
91 | <codeline lineno="45"><highlight class="normal">};</highlight></codeline> |
---|
92 | <codeline lineno="46" refid="classchmat_1d0a995d312ecc11d3b43693f5e224ba9" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classchmat_1d0a995d312ecc11d3b43693f5e224ba9" kindref="member" tooltip="Clearing matrix so that it corresponds to zeros.">chmat::clear</ref>()<sp/>{<ref refid="classchmat_195158bb150f5e7f939168abcd577fd9c" kindref="member" tooltip="Upper triangle of the cholesky matrix.">Ch</ref>.clear();};</highlight></codeline> |
---|
93 | </programlisting> |
---|
94 | <location file="/home/smidl/work/git/mixpp/bdm/math/chmat.cpp"/> |
---|
95 | </compounddef> |
---|
96 | </doxygen> |
---|