[33] | 1 | \section{ldmat Class Reference} |
---|
| 2 | \label{classldmat}\index{ldmat@{ldmat}} |
---|
| 3 | Matrix stored in LD form, (typically known as UD). |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | {\tt \#include $<$libDC.h$>$} |
---|
| 7 | |
---|
| 8 | Inheritance diagram for ldmat:\nopagebreak |
---|
| 9 | \begin{figure}[H] |
---|
| 10 | \begin{center} |
---|
| 11 | \leavevmode |
---|
[91] | 12 | \includegraphics[width=43pt]{classldmat__inherit__graph} |
---|
[33] | 13 | \end{center} |
---|
| 14 | \end{figure} |
---|
| 15 | Collaboration diagram for ldmat:\nopagebreak |
---|
| 16 | \begin{figure}[H] |
---|
| 17 | \begin{center} |
---|
| 18 | \leavevmode |
---|
[91] | 19 | \includegraphics[width=43pt]{classldmat__coll__graph} |
---|
[33] | 20 | \end{center} |
---|
| 21 | \end{figure} |
---|
| 22 | \subsection*{Public Member Functions} |
---|
| 23 | \begin{CompactItemize} |
---|
| 24 | \item |
---|
| 25 | {\bf ldmat} (const mat \&{\bf L}, const vec \&{\bf D})\label{classldmat_968113788422e858da23a477e98fd3a1} |
---|
| 26 | |
---|
| 27 | \begin{CompactList}\small\item\em Construct by copy of L and D. \item\end{CompactList}\item |
---|
| 28 | {\bf ldmat} (const mat \&V)\label{classldmat_5f21785358072d36892d538eed1d1ea5} |
---|
| 29 | |
---|
| 30 | \begin{CompactList}\small\item\em Construct by decomposition of full matrix V. \item\end{CompactList}\item |
---|
| 31 | {\bf ldmat} (vec D0)\label{classldmat_abe16e0f86668ef61a9a4896c8565dee} |
---|
| 32 | |
---|
| 33 | \begin{CompactList}\small\item\em Construct diagonal matrix with diagonal D0. \item\end{CompactList}\item |
---|
| 34 | {\bf ldmat} ()\label{classldmat_a12dda6f529580b0377cc45226b43303} |
---|
| 35 | |
---|
| 36 | \begin{CompactList}\small\item\em Default constructor. \item\end{CompactList}\item |
---|
| 37 | {\bf ldmat} (const int dim0)\label{classldmat_163ee002a7858d104da1c59dd11f016d} |
---|
| 38 | |
---|
| 39 | \begin{CompactList}\small\item\em Default initialization with proper size. \item\end{CompactList}\item |
---|
| 40 | virtual {\bf $\sim$ldmat} ()\label{classldmat_1e2734c0164ce5233c4d709679555138} |
---|
| 41 | |
---|
| 42 | \begin{CompactList}\small\item\em Destructor for future use;. \item\end{CompactList}\item |
---|
| 43 | void {\bf opupdt} (const vec \&v, double w) |
---|
| 44 | \item |
---|
| 45 | mat {\bf to\_\-mat} ()\label{classldmat_5b0515da8dc2293d9e4360b74cc26c9e} |
---|
| 46 | |
---|
| 47 | \begin{CompactList}\small\item\em Conversion to full matrix. \item\end{CompactList}\item |
---|
| 48 | void {\bf mult\_\-sym} (const mat \&C) |
---|
[79] | 49 | \begin{CompactList}\small\item\em Inplace symmetric multiplication by a SQUARE matrix $C$, i.e. $V = C*V*C'$. \item\end{CompactList}\item |
---|
[33] | 50 | void {\bf mult\_\-sym\_\-t} (const mat \&C) |
---|
[79] | 51 | \begin{CompactList}\small\item\em Inplace symmetric multiplication by a SQUARE transpose of matrix $C$, i.e. $V = C'*V*C$. \item\end{CompactList}\item |
---|
[33] | 52 | void {\bf add} (const {\bf ldmat} \&ld2, double w=1.0)\label{classldmat_a60f2c7e4f3c6a7738eaaaab81ffad20} |
---|
| 53 | |
---|
| 54 | \begin{CompactList}\small\item\em Add another matrix in LD form with weight w. \item\end{CompactList}\item |
---|
| 55 | double {\bf logdet} () const \label{classldmat_2b42750ba4962d439aa52a77ae12949b} |
---|
| 56 | |
---|
| 57 | \begin{CompactList}\small\item\em Logarithm of a determinant. \item\end{CompactList}\item |
---|
| 58 | double {\bf qform} (const vec \&v) const \label{classldmat_d64f331b781903e913cb2ee836886f3f} |
---|
| 59 | |
---|
[79] | 60 | \begin{CompactList}\small\item\em Evaluates quadratic form $x= v'*V*v$;. \item\end{CompactList}\item |
---|
| 61 | double {\bf invqform} (const vec \&v) const \label{classldmat_d876c5f83e02b3e809b35c9de5068f14} |
---|
| 62 | |
---|
| 63 | \begin{CompactList}\small\item\em Evaluates quadratic form $x= v'*inv(V)*v$;. \item\end{CompactList}\item |
---|
[33] | 64 | void {\bf clear} ()\label{classldmat_4d6e401de9607332305c27e67972a07a} |
---|
| 65 | |
---|
| 66 | \begin{CompactList}\small\item\em Clearing matrix so that it corresponds to zeros. \item\end{CompactList}\item |
---|
| 67 | int {\bf cols} () const \label{classldmat_0fceb6b5b637cec89bb0a3d2e6be1306} |
---|
| 68 | |
---|
| 69 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\item |
---|
| 70 | int {\bf rows} () const \label{classldmat_96dfb21865db4f5bd36fa70f9b0b1163} |
---|
| 71 | |
---|
| 72 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\item |
---|
| 73 | vec {\bf sqrt\_\-mult} (const vec \&v) const |
---|
[79] | 74 | \begin{CompactList}\small\item\em Multiplies square root of $V$ by vector $x$. \item\end{CompactList}\item |
---|
[33] | 75 | virtual void {\bf inv} ({\bf ldmat} \&Inv) const |
---|
| 76 | \begin{CompactList}\small\item\em Matrix inversion preserving the chosen form. \item\end{CompactList}\item |
---|
| 77 | void {\bf mult\_\-sym} (const mat \&C, {\bf ldmat} \&U) const |
---|
[79] | 78 | \begin{CompactList}\small\item\em Symmetric multiplication of $U$ by a general matrix $C$, result of which is stored in the current class. \item\end{CompactList}\item |
---|
[33] | 79 | void {\bf mult\_\-sym\_\-t} (const mat \&C, {\bf ldmat} \&U) const |
---|
[79] | 80 | \begin{CompactList}\small\item\em Symmetric multiplication of $U$ by a transpose of a general matrix $C$, result of which is stored in the current class. \item\end{CompactList}\item |
---|
[33] | 81 | void {\bf ldform} (const mat \&A, const vec \&D0) |
---|
[79] | 82 | \begin{CompactList}\small\item\em Transforms general $A'D0 A$ into pure $L'DL$. \item\end{CompactList}\item |
---|
[33] | 83 | void {\bf setD} (const vec \&nD)\label{classldmat_0884a613b94fde61bfc84288e73ce57f} |
---|
| 84 | |
---|
| 85 | \begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item |
---|
| 86 | void {\bf setD} (const vec \&nD, int i)\label{classldmat_7619922b4de18830ce5351c6b5667e60} |
---|
| 87 | |
---|
| 88 | \begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item |
---|
| 89 | void {\bf setL} (const vec \&nL)\label{classldmat_32ff66296627ff5341d7c0b973249614} |
---|
| 90 | |
---|
| 91 | \begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item |
---|
[99] | 92 | const vec \& {\bf \_\-D} () const \label{classldmat_282c879f50aa9ef934e7f46d86881582} |
---|
| 93 | |
---|
| 94 | \begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item |
---|
| 95 | const mat \& {\bf \_\-L} () const \label{classldmat_5f44f100248c6627314afaa653b9e5bd} |
---|
| 96 | |
---|
| 97 | \begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item |
---|
[33] | 98 | {\bf ldmat} \& {\bf operator+=} (const {\bf ldmat} \&ldA) |
---|
| 99 | \begin{CompactList}\small\item\em add another \doxyref{ldmat}{p.}{classldmat} matrix \item\end{CompactList}\item |
---|
| 100 | {\bf ldmat} \& {\bf operator-=} (const {\bf ldmat} \&ldA) |
---|
| 101 | \begin{CompactList}\small\item\em subtract another \doxyref{ldmat}{p.}{classldmat} matrix \item\end{CompactList}\item |
---|
[91] | 102 | {\bf ldmat} \& {\bf operator$\ast$=} (double x)\label{classldmat_875b7e6dcf73ae7001329099019fdb1d} |
---|
[33] | 103 | |
---|
| 104 | \begin{CompactList}\small\item\em multiply by a scalar \item\end{CompactList}\end{CompactItemize} |
---|
| 105 | \subsection*{Protected Attributes} |
---|
| 106 | \begin{CompactItemize} |
---|
| 107 | \item |
---|
| 108 | vec {\bf D}\label{classldmat_4cce04824539c4a8d062d9a36d6e014e} |
---|
| 109 | |
---|
[79] | 110 | \begin{CompactList}\small\item\em Positive vector $D$. \item\end{CompactList}\item |
---|
[33] | 111 | mat {\bf L}\label{classldmat_f74a64b99fe58a75ebd37bb679e121ea} |
---|
| 112 | |
---|
[79] | 113 | \begin{CompactList}\small\item\em Lower-triangular matrix $L$. \item\end{CompactList}\end{CompactItemize} |
---|
[33] | 114 | \subsection*{Friends} |
---|
| 115 | \begin{CompactItemize} |
---|
| 116 | \item |
---|
| 117 | std::ostream \& {\bf operator$<$$<$} (std::ostream \&os, const {\bf ldmat} \&sq)\label{classldmat_eaaa0baa6026b84cfcbced41c84599d1} |
---|
| 118 | |
---|
| 119 | \begin{CompactList}\small\item\em print both {\tt L} and {\tt D} \item\end{CompactList}\end{CompactItemize} |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | \subsection{Detailed Description} |
---|
| 123 | Matrix stored in LD form, (typically known as UD). |
---|
| 124 | |
---|
[79] | 125 | Matrix is decomposed as follows: \[M = L'DL\] where only $L$ and $D$ matrices are stored. All inplace operations modifies only these and the need to compose and decompose the matrix is avoided. |
---|
[33] | 126 | |
---|
| 127 | \subsection{Member Function Documentation} |
---|
| 128 | \index{ldmat@{ldmat}!opupdt@{opupdt}} |
---|
| 129 | \index{opupdt@{opupdt}!ldmat@{ldmat}} |
---|
[140] | 130 | \subsubsection[opupdt]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::opupdt (const vec \& {\em v}, \/ double {\em w})\hspace{0.3cm}{\tt [virtual]}}\label{classldmat_0f0f6e083e6d947cf58097ffce3ccd1a} |
---|
[33] | 131 | |
---|
| 132 | |
---|
[79] | 133 | Perfroms a rank-1 update by outer product of vectors: $V = V + w v v'$. \begin{Desc} |
---|
[33] | 134 | \item[Parameters:] |
---|
| 135 | \begin{description} |
---|
| 136 | \item[{\em v}]Vector forming the outer product to be added \item[{\em w}]weight of updating; can be negative\end{description} |
---|
| 137 | \end{Desc} |
---|
| 138 | BLAS-2b operation. |
---|
| 139 | |
---|
[91] | 140 | Implements {\bf sqmat} \doxyref{}{p.}{classsqmat_b223484796661f2dadb5607a86ce0581}. |
---|
| 141 | |
---|
| 142 | References D, sqmat::dim, and L. |
---|
| 143 | |
---|
[140] | 144 | Referenced by add(), and ARX::bayes().\index{ldmat@{ldmat}!mult\_\-sym@{mult\_\-sym}} |
---|
[91] | 145 | \index{mult\_\-sym@{mult\_\-sym}!ldmat@{ldmat}} |
---|
[140] | 146 | \subsubsection[mult\_\-sym]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::mult\_\-sym (const mat \& {\em C})\hspace{0.3cm}{\tt [virtual]}}\label{classldmat_e967b9425007f0cb6cd59b845f9756d8} |
---|
[33] | 147 | |
---|
| 148 | |
---|
[79] | 149 | Inplace symmetric multiplication by a SQUARE matrix $C$, i.e. $V = C*V*C'$. |
---|
[33] | 150 | |
---|
| 151 | \begin{Desc} |
---|
| 152 | \item[Parameters:] |
---|
| 153 | \begin{description} |
---|
| 154 | \item[{\em C}]multiplying matrix, \end{description} |
---|
| 155 | \end{Desc} |
---|
| 156 | |
---|
| 157 | |
---|
[91] | 158 | Implements {\bf sqmat} \doxyref{}{p.}{classsqmat_60fbbfa9e483b8187c135f787ee53afa}. |
---|
| 159 | |
---|
| 160 | References D, L, and ldform().\index{ldmat@{ldmat}!mult\_\-sym\_\-t@{mult\_\-sym\_\-t}} |
---|
| 161 | \index{mult\_\-sym\_\-t@{mult\_\-sym\_\-t}!ldmat@{ldmat}} |
---|
[140] | 162 | \subsubsection[mult\_\-sym\_\-t]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::mult\_\-sym\_\-t (const mat \& {\em C})\hspace{0.3cm}{\tt [virtual]}}\label{classldmat_4fd155f38eb6dd5af4bdf9c98a7999a9} |
---|
[33] | 163 | |
---|
| 164 | |
---|
[79] | 165 | Inplace symmetric multiplication by a SQUARE transpose of matrix $C$, i.e. $V = C'*V*C$. |
---|
[33] | 166 | |
---|
| 167 | \begin{Desc} |
---|
| 168 | \item[Parameters:] |
---|
| 169 | \begin{description} |
---|
| 170 | \item[{\em C}]multiplying matrix, \end{description} |
---|
| 171 | \end{Desc} |
---|
| 172 | |
---|
| 173 | |
---|
[91] | 174 | Implements {\bf sqmat} \doxyref{}{p.}{classsqmat_6909e906da17725b1b80f3cae7cf3325}. |
---|
| 175 | |
---|
| 176 | References D, L, and ldform().\index{ldmat@{ldmat}!sqrt\_\-mult@{sqrt\_\-mult}} |
---|
| 177 | \index{sqrt\_\-mult@{sqrt\_\-mult}!ldmat@{ldmat}} |
---|
[140] | 178 | \subsubsection[sqrt\_\-mult]{\setlength{\rightskip}{0pt plus 5cm}vec ldmat::sqrt\_\-mult (const vec \& {\em v}) const\hspace{0.3cm}{\tt [virtual]}}\label{classldmat_fc380626ced6f9244fb58c5f0231174d} |
---|
[33] | 179 | |
---|
| 180 | |
---|
[79] | 181 | Multiplies square root of $V$ by vector $x$. |
---|
[33] | 182 | |
---|
| 183 | Used e.g. in generating normal samples. |
---|
| 184 | |
---|
[91] | 185 | Implements {\bf sqmat} \doxyref{}{p.}{classsqmat_6b79438b5d7544a9c8e110a145355d8f}. |
---|
| 186 | |
---|
| 187 | References D, sqmat::dim, and L.\index{ldmat@{ldmat}!inv@{inv}} |
---|
[33] | 188 | \index{inv@{inv}!ldmat@{ldmat}} |
---|
[140] | 189 | \subsubsection[inv]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::inv ({\bf ldmat} \& {\em Inv}) const\hspace{0.3cm}{\tt [virtual]}}\label{classldmat_2c160cb123c1102face7a50ec566a031} |
---|
[33] | 190 | |
---|
| 191 | |
---|
| 192 | Matrix inversion preserving the chosen form. |
---|
| 193 | |
---|
| 194 | \begin{Desc} |
---|
| 195 | \item[Parameters:] |
---|
| 196 | \begin{description} |
---|
| 197 | \item[{\em Inv}]a space where the inverse is stored. \end{description} |
---|
| 198 | \end{Desc} |
---|
| 199 | |
---|
| 200 | |
---|
[140] | 201 | References clear(), D, sqmat::dim, L, and ldform().\index{ldmat@{ldmat}!mult\_\-sym@{mult\_\-sym}} |
---|
[91] | 202 | \index{mult\_\-sym@{mult\_\-sym}!ldmat@{ldmat}} |
---|
[140] | 203 | \subsubsection[mult\_\-sym]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::mult\_\-sym (const mat \& {\em C}, \/ {\bf ldmat} \& {\em U}) const}\label{classldmat_e7207748909325bb0f99b43f090a2b7e} |
---|
[91] | 204 | |
---|
| 205 | |
---|
[79] | 206 | Symmetric multiplication of $U$ by a general matrix $C$, result of which is stored in the current class. |
---|
[33] | 207 | |
---|
| 208 | \begin{Desc} |
---|
| 209 | \item[Parameters:] |
---|
| 210 | \begin{description} |
---|
| 211 | \item[{\em C}]matrix to multiply with \item[{\em U}]a space where the inverse is stored. \end{description} |
---|
| 212 | \end{Desc} |
---|
| 213 | |
---|
| 214 | |
---|
[91] | 215 | References D, L, and ldform().\index{ldmat@{ldmat}!mult\_\-sym\_\-t@{mult\_\-sym\_\-t}} |
---|
| 216 | \index{mult\_\-sym\_\-t@{mult\_\-sym\_\-t}!ldmat@{ldmat}} |
---|
[140] | 217 | \subsubsection[mult\_\-sym\_\-t]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::mult\_\-sym\_\-t (const mat \& {\em C}, \/ {\bf ldmat} \& {\em U}) const}\label{classldmat_f94dc3a233f3d40fc853d8d4ac3b8eab} |
---|
[91] | 218 | |
---|
| 219 | |
---|
[79] | 220 | Symmetric multiplication of $U$ by a transpose of a general matrix $C$, result of which is stored in the current class. |
---|
[33] | 221 | |
---|
| 222 | \begin{Desc} |
---|
| 223 | \item[Parameters:] |
---|
| 224 | \begin{description} |
---|
| 225 | \item[{\em C}]matrix to multiply with \item[{\em U}]a space where the inverse is stored. \end{description} |
---|
| 226 | \end{Desc} |
---|
[91] | 227 | |
---|
| 228 | |
---|
| 229 | References D, L, and ldform().\index{ldmat@{ldmat}!ldform@{ldform}} |
---|
[33] | 230 | \index{ldform@{ldform}!ldmat@{ldmat}} |
---|
[140] | 231 | \subsubsection[ldform]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::ldform (const mat \& {\em A}, \/ const vec \& {\em D0})}\label{classldmat_f291faa073e7bc8dfafc7ae93daa2506} |
---|
[33] | 232 | |
---|
| 233 | |
---|
[79] | 234 | Transforms general $A'D0 A$ into pure $L'DL$. |
---|
[33] | 235 | |
---|
[79] | 236 | The new decomposition fullfills: $A'*diag(D)*A = self.L'*diag(self.D)*self.L$ \begin{Desc} |
---|
[33] | 237 | \item[Parameters:] |
---|
| 238 | \begin{description} |
---|
| 239 | \item[{\em A}]general matrix \item[{\em D0}]general vector \end{description} |
---|
| 240 | \end{Desc} |
---|
[91] | 241 | |
---|
| 242 | |
---|
| 243 | References D, sqmat::dim, and L. |
---|
| 244 | |
---|
[140] | 245 | Referenced by inv(), ldmat(), mult\_\-sym(), and mult\_\-sym\_\-t().\index{ldmat@{ldmat}!operator+=@{operator+=}} |
---|
[33] | 246 | \index{operator+=@{operator+=}!ldmat@{ldmat}} |
---|
[140] | 247 | \subsubsection[operator+=]{\setlength{\rightskip}{0pt plus 5cm}{\bf ldmat} \& ldmat::operator+= (const {\bf ldmat} \& {\em ldA})\hspace{0.3cm}{\tt [inline]}}\label{classldmat_ca445ee152a56043af946ea095b2d8f8} |
---|
[33] | 248 | |
---|
| 249 | |
---|
| 250 | add another \doxyref{ldmat}{p.}{classldmat} matrix |
---|
| 251 | |
---|
| 252 | Operations: mapping of add operation to operators \index{ldmat@{ldmat}!operator-=@{operator-=}} |
---|
| 253 | \index{operator-=@{operator-=}!ldmat@{ldmat}} |
---|
[140] | 254 | \subsubsection[operator-=]{\setlength{\rightskip}{0pt plus 5cm}{\bf ldmat} \& ldmat::operator-= (const {\bf ldmat} \& {\em ldA})\hspace{0.3cm}{\tt [inline]}}\label{classldmat_e3f4d2d85ab1ba384c852329aa31d0fb} |
---|
[33] | 255 | |
---|
| 256 | |
---|
| 257 | subtract another \doxyref{ldmat}{p.}{classldmat} matrix |
---|
| 258 | |
---|
| 259 | mapping of negative add operation to operators |
---|
| 260 | |
---|
| 261 | The documentation for this class was generated from the following files:\begin{CompactItemize} |
---|
| 262 | \item |
---|
| 263 | work/mixpp/bdm/math/{\bf libDC.h}\item |
---|
| 264 | work/mixpp/bdm/math/libDC.cpp\end{CompactItemize} |
---|