\hypertarget{classldmat}{
\section{ldmat Class Reference}
\label{classldmat}\index{ldmat@{ldmat}}
}
Matrix stored in LD form, (commonly known as UD).  


{\tt \#include $<$libDC.h$>$}

Inheritance diagram for ldmat:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=43pt]{classldmat__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for ldmat:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=43pt]{classldmat__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\hypertarget{classldmat_968113788422e858da23a477e98fd3a1}{
\hyperlink{classldmat_968113788422e858da23a477e98fd3a1}{ldmat} (const mat \&\hyperlink{classldmat_f74a64b99fe58a75ebd37bb679e121ea}{L}, const vec \&\hyperlink{classldmat_4cce04824539c4a8d062d9a36d6e014e}{D})}
\label{classldmat_968113788422e858da23a477e98fd3a1}

\begin{CompactList}\small\item\em Construct by copy of L and D. \item\end{CompactList}\item 
\hypertarget{classldmat_5f21785358072d36892d538eed1d1ea5}{
\hyperlink{classldmat_5f21785358072d36892d538eed1d1ea5}{ldmat} (const mat \&V)}
\label{classldmat_5f21785358072d36892d538eed1d1ea5}

\begin{CompactList}\small\item\em Construct by decomposition of full matrix V. \item\end{CompactList}\item 
\hypertarget{classldmat_8e88c818f9605bc726e52c4136c71cc5}{
\hyperlink{classldmat_8e88c818f9605bc726e52c4136c71cc5}{ldmat} (const \hyperlink{classldmat}{ldmat} \&V0, const ivec \&perm)}
\label{classldmat_8e88c818f9605bc726e52c4136c71cc5}

\begin{CompactList}\small\item\em Construct by restructuring of V0 accordint to permutation vector perm. \item\end{CompactList}\item 
\hypertarget{classldmat_abe16e0f86668ef61a9a4896c8565dee}{
\hyperlink{classldmat_abe16e0f86668ef61a9a4896c8565dee}{ldmat} (vec D0)}
\label{classldmat_abe16e0f86668ef61a9a4896c8565dee}

\begin{CompactList}\small\item\em Construct diagonal matrix with diagonal D0. \item\end{CompactList}\item 
\hypertarget{classldmat_a12dda6f529580b0377cc45226b43303}{
\hyperlink{classldmat_a12dda6f529580b0377cc45226b43303}{ldmat} ()}
\label{classldmat_a12dda6f529580b0377cc45226b43303}

\begin{CompactList}\small\item\em Default constructor. \item\end{CompactList}\item 
\hypertarget{classldmat_163ee002a7858d104da1c59dd11f016d}{
\hyperlink{classldmat_163ee002a7858d104da1c59dd11f016d}{ldmat} (const int dim0)}
\label{classldmat_163ee002a7858d104da1c59dd11f016d}

\begin{CompactList}\small\item\em Default initialization with proper size. \item\end{CompactList}\item 
\hypertarget{classldmat_1e2734c0164ce5233c4d709679555138}{
virtual \hyperlink{classldmat_1e2734c0164ce5233c4d709679555138}{$\sim$ldmat} ()}
\label{classldmat_1e2734c0164ce5233c4d709679555138}

\begin{CompactList}\small\item\em Destructor for future use;. \item\end{CompactList}\item 
void \hyperlink{classldmat_0f0f6e083e6d947cf58097ffce3ccd1a}{opupdt} (const vec \&v, double w)
\item 
\hypertarget{classldmat_2c1ebc071de4bafbba55b80afd8a7e8e}{
mat \hyperlink{classldmat_2c1ebc071de4bafbba55b80afd8a7e8e}{to\_\-mat} () const }
\label{classldmat_2c1ebc071de4bafbba55b80afd8a7e8e}

\begin{CompactList}\small\item\em Conversion to full matrix. \item\end{CompactList}\item 
void \hyperlink{classldmat_e967b9425007f0cb6cd59b845f9756d8}{mult\_\-sym} (const mat \&C)
\begin{CompactList}\small\item\em Inplace symmetric multiplication by a SQUARE matrix $C$, i.e. $V = C*V*C'$. \item\end{CompactList}\item 
void \hyperlink{classldmat_4fd155f38eb6dd5af4bdf9c98a7999a9}{mult\_\-sym\_\-t} (const mat \&C)
\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 
\hypertarget{classldmat_a60f2c7e4f3c6a7738eaaaab81ffad20}{
void \hyperlink{classldmat_a60f2c7e4f3c6a7738eaaaab81ffad20}{add} (const \hyperlink{classldmat}{ldmat} \&ld2, double w=1.0)}
\label{classldmat_a60f2c7e4f3c6a7738eaaaab81ffad20}

\begin{CompactList}\small\item\em Add another matrix in LD form with weight w. \item\end{CompactList}\item 
\hypertarget{classldmat_2b42750ba4962d439aa52a77ae12949b}{
double \hyperlink{classldmat_2b42750ba4962d439aa52a77ae12949b}{logdet} () const }
\label{classldmat_2b42750ba4962d439aa52a77ae12949b}

\begin{CompactList}\small\item\em Logarithm of a determinant. \item\end{CompactList}\item 
\hypertarget{classldmat_d64f331b781903e913cb2ee836886f3f}{
double \hyperlink{classldmat_d64f331b781903e913cb2ee836886f3f}{qform} (const vec \&v) const }
\label{classldmat_d64f331b781903e913cb2ee836886f3f}

\begin{CompactList}\small\item\em Evaluates quadratic form $x= v'*V*v$;. \item\end{CompactList}\item 
\hypertarget{classldmat_d876c5f83e02b3e809b35c9de5068f14}{
double \hyperlink{classldmat_d876c5f83e02b3e809b35c9de5068f14}{invqform} (const vec \&v) const }
\label{classldmat_d876c5f83e02b3e809b35c9de5068f14}

\begin{CompactList}\small\item\em Evaluates quadratic form $x= v'*inv(V)*v$;. \item\end{CompactList}\item 
\hypertarget{classldmat_4d6e401de9607332305c27e67972a07a}{
void \hyperlink{classldmat_4d6e401de9607332305c27e67972a07a}{clear} ()}
\label{classldmat_4d6e401de9607332305c27e67972a07a}

\begin{CompactList}\small\item\em Clearing matrix so that it corresponds to zeros. \item\end{CompactList}\item 
\hypertarget{group__math_g0fceb6b5b637cec89bb0a3d2e6be1306}{
int \hyperlink{group__math_g0fceb6b5b637cec89bb0a3d2e6be1306}{cols} () const }
\label{group__math_g0fceb6b5b637cec89bb0a3d2e6be1306}

\begin{CompactList}\small\item\em access function \item\end{CompactList}\item 
\hypertarget{group__math_g96dfb21865db4f5bd36fa70f9b0b1163}{
int \hyperlink{group__math_g96dfb21865db4f5bd36fa70f9b0b1163}{rows} () const }
\label{group__math_g96dfb21865db4f5bd36fa70f9b0b1163}

\begin{CompactList}\small\item\em access function \item\end{CompactList}\item 
vec \hyperlink{classldmat_fc380626ced6f9244fb58c5f0231174d}{sqrt\_\-mult} (const vec \&v) const 
\begin{CompactList}\small\item\em Multiplies square root of $V$ by vector $x$. \item\end{CompactList}\item 
virtual void \hyperlink{classldmat_2c160cb123c1102face7a50ec566a031}{inv} (\hyperlink{classldmat}{ldmat} \&Inv) const 
\begin{CompactList}\small\item\em Matrix inversion preserving the chosen form. \item\end{CompactList}\item 
void \hyperlink{classldmat_e7207748909325bb0f99b43f090a2b7e}{mult\_\-sym} (const mat \&C, \hyperlink{classldmat}{ldmat} \&U) const 
\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 
void \hyperlink{classldmat_f94dc3a233f3d40fc853d8d4ac3b8eab}{mult\_\-sym\_\-t} (const mat \&C, \hyperlink{classldmat}{ldmat} \&U) const 
\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 
void \hyperlink{classldmat_f291faa073e7bc8dfafc7ae93daa2506}{ldform} (const mat \&A, const vec \&D0)
\begin{CompactList}\small\item\em Transforms general $A'D0 A$ into pure $L'DL$. \item\end{CompactList}\item 
\hypertarget{classldmat_0884a613b94fde61bfc84288e73ce57f}{
void \hyperlink{classldmat_0884a613b94fde61bfc84288e73ce57f}{setD} (const vec \&nD)}
\label{classldmat_0884a613b94fde61bfc84288e73ce57f}

\begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item 
\hypertarget{classldmat_7619922b4de18830ce5351c6b5667e60}{
void \hyperlink{classldmat_7619922b4de18830ce5351c6b5667e60}{setD} (const vec \&nD, int i)}
\label{classldmat_7619922b4de18830ce5351c6b5667e60}

\begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item 
\hypertarget{classldmat_32ff66296627ff5341d7c0b973249614}{
void \hyperlink{classldmat_32ff66296627ff5341d7c0b973249614}{setL} (const vec \&nL)}
\label{classldmat_32ff66296627ff5341d7c0b973249614}

\begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item 
\hypertarget{classldmat_282c879f50aa9ef934e7f46d86881582}{
const vec \& \hyperlink{classldmat_282c879f50aa9ef934e7f46d86881582}{\_\-D} () const }
\label{classldmat_282c879f50aa9ef934e7f46d86881582}

\begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item 
\hypertarget{classldmat_5f44f100248c6627314afaa653b9e5bd}{
const mat \& \hyperlink{classldmat_5f44f100248c6627314afaa653b9e5bd}{\_\-L} () const }
\label{classldmat_5f44f100248c6627314afaa653b9e5bd}

\begin{CompactList}\small\item\em Access functions. \item\end{CompactList}\item 
\hyperlink{classldmat}{ldmat} \& \hyperlink{group__math_gca445ee152a56043af946ea095b2d8f8}{operator+=} (const \hyperlink{classldmat}{ldmat} \&ldA)
\begin{CompactList}\small\item\em add another \hyperlink{classldmat}{ldmat} matrix \item\end{CompactList}\item 
\hyperlink{classldmat}{ldmat} \& \hyperlink{group__math_ge3f4d2d85ab1ba384c852329aa31d0fb}{operator-=} (const \hyperlink{classldmat}{ldmat} \&ldA)
\begin{CompactList}\small\item\em subtract another \hyperlink{classldmat}{ldmat} matrix \item\end{CompactList}\item 
\hypertarget{classldmat_875b7e6dcf73ae7001329099019fdb1d}{
\hyperlink{classldmat}{ldmat} \& \hyperlink{classldmat_875b7e6dcf73ae7001329099019fdb1d}{operator$\ast$=} (double x)}
\label{classldmat_875b7e6dcf73ae7001329099019fdb1d}

\begin{CompactList}\small\item\em multiply by a scalar \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
\hypertarget{classldmat_4cce04824539c4a8d062d9a36d6e014e}{
vec \hyperlink{classldmat_4cce04824539c4a8d062d9a36d6e014e}{D}}
\label{classldmat_4cce04824539c4a8d062d9a36d6e014e}

\begin{CompactList}\small\item\em Positive vector $D$. \item\end{CompactList}\item 
\hypertarget{classldmat_f74a64b99fe58a75ebd37bb679e121ea}{
mat \hyperlink{classldmat_f74a64b99fe58a75ebd37bb679e121ea}{L}}
\label{classldmat_f74a64b99fe58a75ebd37bb679e121ea}

\begin{CompactList}\small\item\em Lower-triangular matrix $L$. \item\end{CompactList}\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
\hypertarget{classldmat_eaaa0baa6026b84cfcbced41c84599d1}{
std::ostream \& \hyperlink{classldmat_eaaa0baa6026b84cfcbced41c84599d1}{operator$<$$<$} (std::ostream \&os, const \hyperlink{classldmat}{ldmat} \&sq)}
\label{classldmat_eaaa0baa6026b84cfcbced41c84599d1}

\begin{CompactList}\small\item\em print both {\tt L} and {\tt D} \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Matrix stored in LD form, (commonly known as UD). 

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. 

\subsection{Member Function Documentation}
\hypertarget{classldmat_0f0f6e083e6d947cf58097ffce3ccd1a}{
\index{ldmat@{ldmat}!opupdt@{opupdt}}
\index{opupdt@{opupdt}!ldmat@{ldmat}}
\subsubsection[opupdt]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::opupdt (const vec \& {\em v}, \/  double {\em w})\hspace{0.3cm}{\tt  \mbox{[}virtual\mbox{]}}}}
\label{classldmat_0f0f6e083e6d947cf58097ffce3ccd1a}


Perfroms a rank-1 update by outer product of vectors: $V = V + w v v'$. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em v}]Vector forming the outer product to be added \item[{\em w}]weight of updating; can be negative\end{description}
\end{Desc}
BLAS-2b operation. 

Implements \hyperlink{classsqmat_b223484796661f2dadb5607a86ce0581}{sqmat}.

References D, sqmat::dim, dydr(), and L.

Referenced by add(), bdm::ARX::bayes(), and bdm::ARX::logpred().\hypertarget{classldmat_e967b9425007f0cb6cd59b845f9756d8}{
\index{ldmat@{ldmat}!mult\_\-sym@{mult\_\-sym}}
\index{mult\_\-sym@{mult\_\-sym}!ldmat@{ldmat}}
\subsubsection[mult\_\-sym]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::mult\_\-sym (const mat \& {\em C})\hspace{0.3cm}{\tt  \mbox{[}virtual\mbox{]}}}}
\label{classldmat_e967b9425007f0cb6cd59b845f9756d8}


Inplace symmetric multiplication by a SQUARE matrix $C$, i.e. $V = C*V*C'$. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em C}]multiplying matrix, \end{description}
\end{Desc}


Implements \hyperlink{classsqmat_60fbbfa9e483b8187c135f787ee53afa}{sqmat}.

References D, L, and ldform().\hypertarget{classldmat_4fd155f38eb6dd5af4bdf9c98a7999a9}{
\index{ldmat@{ldmat}!mult\_\-sym\_\-t@{mult\_\-sym\_\-t}}
\index{mult\_\-sym\_\-t@{mult\_\-sym\_\-t}!ldmat@{ldmat}}
\subsubsection[mult\_\-sym\_\-t]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::mult\_\-sym\_\-t (const mat \& {\em C})\hspace{0.3cm}{\tt  \mbox{[}virtual\mbox{]}}}}
\label{classldmat_4fd155f38eb6dd5af4bdf9c98a7999a9}


Inplace symmetric multiplication by a SQUARE transpose of matrix $C$, i.e. $V = C'*V*C$. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em C}]multiplying matrix, \end{description}
\end{Desc}


Implements \hyperlink{classsqmat_6909e906da17725b1b80f3cae7cf3325}{sqmat}.

References D, L, and ldform().\hypertarget{classldmat_fc380626ced6f9244fb58c5f0231174d}{
\index{ldmat@{ldmat}!sqrt\_\-mult@{sqrt\_\-mult}}
\index{sqrt\_\-mult@{sqrt\_\-mult}!ldmat@{ldmat}}
\subsubsection[sqrt\_\-mult]{\setlength{\rightskip}{0pt plus 5cm}vec ldmat::sqrt\_\-mult (const vec \& {\em v}) const\hspace{0.3cm}{\tt  \mbox{[}virtual\mbox{]}}}}
\label{classldmat_fc380626ced6f9244fb58c5f0231174d}


Multiplies square root of $V$ by vector $x$. 

Used e.g. in generating normal samples. 

Implements \hyperlink{classsqmat_6b79438b5d7544a9c8e110a145355d8f}{sqmat}.

References D, sqmat::dim, and L.\hypertarget{classldmat_2c160cb123c1102face7a50ec566a031}{
\index{ldmat@{ldmat}!inv@{inv}}
\index{inv@{inv}!ldmat@{ldmat}}
\subsubsection[inv]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::inv ({\bf ldmat} \& {\em Inv}) const\hspace{0.3cm}{\tt  \mbox{[}virtual\mbox{]}}}}
\label{classldmat_2c160cb123c1102face7a50ec566a031}


Matrix inversion preserving the chosen form. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Inv}]a space where the inverse is stored. \end{description}
\end{Desc}


References clear(), D, L, ldform(), and ltuinv().\hypertarget{classldmat_e7207748909325bb0f99b43f090a2b7e}{
\index{ldmat@{ldmat}!mult\_\-sym@{mult\_\-sym}}
\index{mult\_\-sym@{mult\_\-sym}!ldmat@{ldmat}}
\subsubsection[mult\_\-sym]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::mult\_\-sym (const mat \& {\em C}, \/  {\bf ldmat} \& {\em U}) const}}
\label{classldmat_e7207748909325bb0f99b43f090a2b7e}


Symmetric multiplication of $U$ by a general matrix $C$, result of which is stored in the current class. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em C}]matrix to multiply with \item[{\em U}]a space where the inverse is stored. \end{description}
\end{Desc}


References D, L, and ldform().\hypertarget{classldmat_f94dc3a233f3d40fc853d8d4ac3b8eab}{
\index{ldmat@{ldmat}!mult\_\-sym\_\-t@{mult\_\-sym\_\-t}}
\index{mult\_\-sym\_\-t@{mult\_\-sym\_\-t}!ldmat@{ldmat}}
\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}


Symmetric multiplication of $U$ by a transpose of a general matrix $C$, result of which is stored in the current class. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em C}]matrix to multiply with \item[{\em U}]a space where the inverse is stored. \end{description}
\end{Desc}


References D, L, and ldform().\hypertarget{classldmat_f291faa073e7bc8dfafc7ae93daa2506}{
\index{ldmat@{ldmat}!ldform@{ldform}}
\index{ldform@{ldform}!ldmat@{ldmat}}
\subsubsection[ldform]{\setlength{\rightskip}{0pt plus 5cm}void ldmat::ldform (const mat \& {\em A}, \/  const vec \& {\em D0})}}
\label{classldmat_f291faa073e7bc8dfafc7ae93daa2506}


Transforms general $A'D0 A$ into pure $L'DL$. 

The new decomposition fullfills: $A'*diag(D)*A = self.L'*diag(self.D)*self.L$ \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em A}]general matrix \item[{\em D0}]general vector \end{description}
\end{Desc}


References D, sqmat::dim, and L.

Referenced by inv(), ldmat(), mult\_\-sym(), and mult\_\-sym\_\-t().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
work/git/mixpp/bdm/math/\hyperlink{libDC_8h}{libDC.h}\item 
work/git/mixpp/bdm/math/libDC.cpp\end{CompactItemize}
