Matrix stored in LD form, (commonly known as UD). More...
Matrix stored in LD form, (commonly known as UD).
Matrix is decomposed as follows:
where only and matrices are stored. All inplace operations modifies only these and the need to compose and decompose the matrix is avoided.
#include <square_mat.h>
Public Member Functions | |
ldmat (const mat &L, const vec &D) | |
Construct by copy of L and D. | |
ldmat (const mat &V) | |
Construct by decomposition of full matrix V. | |
ldmat (const ldmat &V0, const ivec &perm) | |
Construct by restructuring of V0 accordint to permutation vector perm. | |
ldmat (vec D0) | |
Construct diagonal matrix with diagonal D0. | |
ldmat () | |
Default constructor. | |
ldmat (const int dim0) | |
Default initialization with proper size. | |
virtual | ~ldmat () |
Destructor for future use;. | |
void | opupdt (const vec &v, double w) |
mat | to_mat () const |
Conversion to full matrix. | |
void | mult_sym (const mat &C) |
Inplace symmetric multiplication by a SQUARE matrix , i.e. . | |
void | mult_sym_t (const mat &C) |
Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. . | |
void | add (const ldmat &ld2, double w=1.0) |
Add another matrix in LD form with weight w. | |
double | logdet () const |
Logarithm of a determinant. | |
double | qform (const vec &v) const |
Evaluates quadratic form ;. | |
double | invqform (const vec &v) const |
Evaluates quadratic form ;. | |
void | clear () |
Clearing matrix so that it corresponds to zeros. | |
vec | sqrt_mult (const vec &v) const |
Multiplies square root of by vector . | |
void | inv (ldmat &Inv) const |
Matrix inversion preserving the chosen form. | |
void | mult_sym (const mat &C, ldmat &U) const |
Symmetric multiplication of by a general matrix , result of which is stored in the current class. | |
void | mult_sym_t (const mat &C, ldmat &U) const |
Symmetric multiplication of by a transpose of a general matrix , result of which is stored in the current class. | |
void | ldform (const mat &A, const vec &D0) |
Transforms general into pure . | |
void | setD (const vec &nD) |
Access functions. | |
void | setD (const vec &nD, int i) |
Access functions. | |
void | setL (const vec &nL) |
Access functions. | |
const vec & | _D () const |
Access functions. | |
const mat & | _L () const |
Access functions. | |
ldmat & | operator+= (const ldmat &ldA) |
add another ldmat matrix | |
ldmat & | operator-= (const ldmat &ldA) |
subtract another ldmat matrix | |
ldmat & | operator*= (double x) |
multiply by a scalar | |
int | cols () const |
Reimplementing common functions of mat: cols(). | |
int | rows () const |
Reimplementing common functions of mat: rows(). | |
Protected Attributes | |
vec | D |
Positive vector . | |
mat | L |
Lower-triangular matrix . | |
int | dim |
dimension of the square matrix | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const ldmat &sq) |
print both L and D |
void bdm::ldmat::inv | ( | ldmat & | Inv | ) | const |
Matrix inversion preserving the chosen form.
Inv | a space where the inverse is stored. |
References clear(), D, L, and ldform().
Referenced by bdm::egiw::variance().
void bdm::ldmat::ldform | ( | const mat & | A, | |
const vec & | D0 | |||
) |
Transforms general into pure .
The new decomposition fullfills:
A | general matrix | |
D0 | general vector |
References bdm_assert_debug, D, bdm::sqmat::dim, and L.
Referenced by inv(), ldmat(), mult_sym(), and mult_sym_t().
void bdm::ldmat::mult_sym | ( | const mat & | C, | |
ldmat & | U | |||
) | const |
void bdm::ldmat::mult_sym | ( | const mat & | C | ) | [virtual] |
Inplace symmetric multiplication by a SQUARE matrix , i.e. .
C | multiplying matrix, |
Reimplemented from bdm::sqmat.
void bdm::ldmat::mult_sym_t | ( | const mat & | C, | |
ldmat & | U | |||
) | const |
void bdm::ldmat::mult_sym_t | ( | const mat & | C | ) | [virtual] |
Inplace symmetric multiplication by a SQUARE transpose of matrix , i.e. .
C | multiplying matrix, |
Reimplemented from bdm::sqmat.
void bdm::ldmat::opupdt | ( | const vec & | v, | |
double | w | |||
) | [virtual] |
Perfroms a rank-1 update by outer product of vectors: .
v | Vector forming the outer product to be added | |
w | weight of updating; can be negative |
BLAS-2b operation.
Reimplemented from bdm::sqmat.
References bdm_assert_debug, D, bdm::sqmat::dim, and L.
Referenced by add(), bdm::ARX::bayes(), and bdm::ARX::logpred().
vec bdm::ldmat::sqrt_mult | ( | const vec & | v | ) | const [virtual] |
Multiplies square root of by vector .
Used e.g. in generating normal samples.
Reimplemented from bdm::sqmat.
References D, bdm::sqmat::dim, and L.