#include <linalg.h>
Public Member Functions | |
Matrix (const std::vector< std::vector< double > > &A) | |
Construct a matrix from a vector of vectors. | |
Matrix (unsigned int nrows, unsigned int ncols) | |
Construct a matrix with given dimensions initialized to 0. | |
Matrix (const Matrix &A) | |
copy a matrix | |
~Matrix (void) | |
delete a matrix | |
double & | operator() (unsigned int i, unsigned int j) const |
data access to the element in row i and column j (indices starting with 0!) | |
void | print (void) |
print the matrix to stdout | |
unsigned int | getnrows (void) const |
get the number of rows | |
unsigned int | getncols (void) const |
get the number of columns | |
Matrix * | cholesky_dec (void) const |
return a pointer to a newly allocated Matrix L, such that L*L^T = A | |
Matrix * | lu_dec (void) const |
return a pointer to a newly allocated Matrix LU. If you construct a matrix L from the elements of LU below the diagnonal and L_ii = 1, and a matrix U from the elements above the diagnonal, then A=LU | |
Matrix * | qr_dec (void) const |
QR-decomposition of a matrix, where Q is orthogonal and R is upper right triangular. | |
Matrix * | inverse_qr (void) const |
Matrix inversion based on QR decomposition (more stable but slower). | |
Matrix * | regularized_inverse (double alpha) const |
Matrix inversion with Tichonov regularization (regularization factor alpha). | |
std::vector< double > | solve (const std::vector< double > &b) |
solve a linear equation Ax=b for x | |
Matrix * | inverse (void) |
return a pointer to the (newly allocated) inverse Matrix | |
std::vector< double > | operator* (std::vector< double > &x) |
right multiplication with a vector | |
void | scale (double a) |
scale the whole matrix by a constant factor | |
bool | symmetric (void) |
check whether the matrix is symmetric |
A very simple matrix class