Matrix of generic size. The elements are stored in a one-dimensional array in row-major order. More...
#include <fMatrix.h>
Public Member Functions | |
int | col () const |
Returns the number of columns. More... | |
double * | data () const |
Returns the pointer to the first element. More... | |
void | ddiv (const fMat &mat1, const fMat &mat2) |
Element-wise division: ./ operator in MATLAB. More... | |
double | det (void) |
Computes the determinant. More... | |
void | dmul (const fMat &mat1, const fMat &mat2) |
Element-wise multiplication: .* operator in MATLAB. More... | |
int | eig (fVec &wr, fVec &wi) |
Computes the eigenvalues. More... | |
int | eig (fVec &wr, fVec &wi, fMat &v) |
Computes the eigenvalues and eigenvectors. More... | |
int | eig (fVec &wr, fVec &wi, fMat &vr, fMat &vi) |
Computes the eigenvalues and eigenvectors. More... | |
fMat () | |
Default constructor. More... | |
fMat (int m, int n, double *ini=0) | |
Constructor with size and initial values (optional). More... | |
fMat (int m, int n, double ini) | |
Constructor with size and common initial values. More... | |
fMat (const fMat &ini) | |
Copy constructor. More... | |
fMat (const fVec &ini) | |
Constructor from a vector. More... | |
void | get_submat (int row_start, int col_start, const fMat &allM) |
Extract a sub-matrix and set to myself. More... | |
void | identity () |
Creates an identity matrix (only for square matrices). More... | |
int | info () |
Returns the value of m_info. More... | |
int | inv_porfs (const fMat &) |
inverse of positive-definite, symmetric matrix More... | |
int | inv_posv (const fMat &) |
inverse of positive-definite, symmetric matrix More... | |
int | lineq_porfs (const fMat &A, const fMat &b) |
solve linear equation Ax = b, where A is positive-definite, symmetric More... | |
int | lineq_posv (const fMat &A, const fMat &b) |
solve linear equation Ax = b, where A is positive-definite, symmetric More... | |
operator double * () | |
Converts to an array of double. More... | |
double & | operator() (int i, int j) |
Returns the (non-constant) reference to the (i,j) element. More... | |
double | operator() (int i, int j) const |
Returns the value of the (i,j) element. More... | |
fMat | operator= (const fMat &mat) |
Assignment from a reference matrix. More... | |
void | operator= (double d) |
Assigns the same value to all elements. More... | |
int | resize (int i, int j) |
Changes the matrix size. More... | |
int | row () const |
Returns the number of rows. More... | |
void | set (double *_d) |
Sets the values from an array. More... | |
void | set_submat (int row_start, int col_start, const fMat &subM) |
Sets a sub-matrix of myself. More... | |
void | setinfo (int _info) |
Sets m_info. More... | |
int | svd (fMat &U, fVec &Sigma, fMat &VT) |
singular value decomposition More... | |
void | symmetric (char t='U') |
Change to symmetric matrix. More... | |
void | tran (const fMat &mat) |
Sets the transpose of a matrix. More... | |
void | tran () |
Transposes a matrix (only for square matrices). More... | |
void | zero () |
Creates a zero matrix. More... | |
~fMat () | |
Destructor. More... | |
functions | |
Operators in function forms (faster). | |
void | set (const fMat &mat) |
void | neg (const fMat &mat) |
void | add (const fMat &mat1, const fMat &mat2) |
void | add (const fMat &mat) |
void | sub (const fMat &mat1, const fMat &mat2) |
void | mul (const fMat &mat1, const fMat &mat2) |
void | mul (double d, const fMat &mat) |
void | mul (const fMat &mat, double d) |
void | mul_tran (const fMat &mat1, int trans_first) |
void | div (const fMat &mat, double d) |
Protected Attributes | |
int | m_info |
int | n_col |
int | n_row |
double * | p_data |
double | temp |
Friends | |
fMat | eigs (const fMat &mat, double *w) |
Compute the eigenvalues. More... | |
fMat | eigs2 (const fMat &mat, double *w) |
Compute the eigenvalues. More... | |
int | inv_col_replaced (const fMat &P, const fMat &q, const fMat &m2d, fMat &X, fMat &y) |
Computes the inverse when some columns are replaced. More... | |
int | inv_enlarge (const fMat &m12, const fMat &m21, const fMat &m22, const fMat &P, fMat &X, fMat &y, fMat &z, fMat &w) |
Computes the inverse of an enlarged matrix. More... | |
int | inv_row_replaced (const fMat &P, const fMat &q, const fMat &m2d, fMat &X, fMat &y) |
Computes the inverse when some rows are replaced. More... | |
int | inv_shrink (const fMat &P, const fMat &q, const fMat &r, const fMat &s, fMat &X) |
Computes the inverse of a shrinked matrix. More... | |
ostream & | operator<< (ostream &ost, const fMat &mat) |
Outputs to a stream. More... | |
fMat | tran (const fMat &mat) |
Returns the transpose of a matrix. More... | |
friend | |
int | inv (const fMat &) |
inverse More... | |
int | p_inv (const fMat &) |
pseudo inverse More... | |
int | sr_inv (const fMat &mat, fVec &w_err, fVec &w_norm, double k) |
singularity-robust (SR) inverse More... | |
int | lineq (const fMat &A, const fMat &b) |
solve linear equation Ax = b More... | |
int | lineq_sr (const fMat &A, fVec &w_err, fVec &w_norm, double k, const fMat &b) |
solve linear equation Ax = b using SR-inverse More... | |
int | inv_svd (const fMat &, int lwork=-1) |
inverse More... | |
int | p_inv_svd (const fMat &, int lwork=-1) |
pseudo inverse More... | |
int | sr_inv_svd (const fMat &mat, fVec &w_err, fVec &w_norm, double k, int lwork=-1) |
SR-inverse. More... | |
int | lineq_svd (const fMat &A, const fMat &b, int lwork=-1) |
solve linear equation Ax = b More... | |
fMat | inv (const fMat &mat) |
inverse More... | |
fMat | p_inv (const fMat &mat) |
pseudo inverse More... | |
fMat | sr_inv (const fMat &mat, fVec &w_err, fVec &w_norm, double k) |
singularity-robust (SR) inverse More... | |
fMat | lineq (const fMat &A, const fMat &b) |
solve linear equation Ax = b More... | |
fMat | lineq_sr (const fMat &A, fVec &w_err, fVec &w_norm, double k, const fMat &b) |
solve linear equation Ax = b using SR-inverse More... | |
fMat | inv_svd (const fMat &mat, int lwork) |
inverse More... | |
fMat | p_inv_svd (const fMat &mat, int lwork) |
pseudo inverse More... | |
fMat | sr_inv_svd (const fMat &mat, fVec &w_err, fVec &w_norm, double k, int lwork) |
SR-inverse. More... | |
fMat | lineq_svd (const fMat &A, const fMat &b, int lwork) |
solve linear equation Ax = b More... | |
operators | |
void | operator+= (const fMat &mat) |
void | operator-= (const fMat &mat) |
void | operator*= (double d) |
void | operator/= (double d) |
fMat | operator- (const fMat &mat) |
fMat | operator+ (const fMat &mat1, const fMat &mat2) |
fMat | operator- (const fMat &mat1, const fMat &mat2) |
fMat | operator* (const fMat &mat1, const fMat &mat2) |
fVec | operator* (const fMat &mat, const fVec &vec) |
fMat | operator* (double d, const fMat &mat) |
fMat | operator* (const fMat &mat, double d) |
fMat | operator/ (const fMat &mat, double d) |
Matrix of generic size. The elements are stored in a one-dimensional array in row-major order.
|
inline |
Constructor from a vector.
Creates an nx1 matrix from a vector.
[in] | ini | The reference vector. |
Definition at line 21 of file fMatrix.cpp.
Definition at line 1169 of file fMatrix.cpp.
Definition at line 1180 of file fMatrix.cpp.
|
inline |
|
inline |
Element-wise division: ./ operator in MATLAB.
Definition at line 1737 of file fMatrix.cpp.
double fMat::det | ( | void | ) |
Computes the determinant.
Definition at line 1785 of file fMatrix.cpp.
Definition at line 1428 of file fMatrix.cpp.
Element-wise multiplication: .* operator in MATLAB.
Definition at line 1688 of file fMatrix.cpp.
Computes the eigenvalues.
Computes the eigenvalues.
[out] | wr | Vector of the real parts. |
[out] | wi | Vector of the imaginary parts. |
Definition at line 1800 of file fMatrix.cpp.
Computes the eigenvalues and eigenvectors.
Computes the eigenvalues and eigenvectors.
[out] | wr | Vector of the real parts of the eigenvalues. |
[out] | wi | Vector of the imaginary parts of the eigenvlaues. |
[out] | v | Eigenvectors. |
Definition at line 1819 of file fMatrix.cpp.
Computes the eigenvalues and eigenvectors.
Computes the eigenvalues and eigenvectors.
[out] | wr | Vector of the real parts of the eigenvalues. |
[out] | wi | Vector of the imaginary parts of the eigenvlaues. |
[out] | vr | Real parts of the eigenvectors. |
[out] | vi | Imaginary parts of the eigenvectors. |
Definition at line 1840 of file fMatrix.cpp.
Extract a sub-matrix and set to myself.
Extracts an n_row x n_col sub-matrix from a large matrix.
[in] | row_start | First row to extract. |
[in] | col_start | First column to extract. |
[in] | allM | The original matrix. |
Definition at line 32 of file fMatrix.cpp.
void fMat::identity | ( | ) |
Creates an identity matrix (only for square matrices).
Definition at line 1058 of file fMatrix.cpp.
inverse of positive-definite, symmetric matrix
Definition at line 780 of file fMatrix.cpp.
inverse of positive-definite, symmetric matrix
Definition at line 757 of file fMatrix.cpp.
solve linear equation Ax = b, where A is positive-definite, symmetric
Definition at line 772 of file fMatrix.cpp.
solve linear equation Ax = b, where A is positive-definite, symmetric
Definition at line 746 of file fMatrix.cpp.
solve linear equation Ax = b using SR-inverse
Definition at line 1217 of file fMatrix.cpp.
Definition at line 1116 of file fMatrix.cpp.
Definition at line 1123 of file fMatrix.cpp.
Definition at line 1241 of file fMatrix.cpp.
Definition at line 1081 of file fMatrix.cpp.
|
inline |
void fMat::operator*= | ( | double | d | ) |
Definition at line 1110 of file fMatrix.cpp.
Definition at line 1096 of file fMatrix.cpp.
Definition at line 1103 of file fMatrix.cpp.
void fMat::operator/= | ( | double | d | ) |
Definition at line 1146 of file fMatrix.cpp.
Assignment from a reference matrix.
Definition at line 1152 of file fMatrix.cpp.
void fMat::operator= | ( | double | d | ) |
Assigns the same value to all elements.
Definition at line 1163 of file fMatrix.cpp.
Changes the matrix size.
Changes the size of the matrix. If the new size is the same as the previous, nothing happens (memory is not re-allocated). The values are not initialized.
[in] | i | The new row size. |
[in] | j | The new column size. |
|
inline |
|
inline |
Definition at line 1074 of file fMatrix.cpp.
Sets a sub-matrix of myself.
Sets subM as an subM.n_row x subM.n_col sub-matrix of myself.
[in] | row_start | First row to set. |
[in] | col_start | First column to set. |
[in] | subM | The original matrix. |
Definition at line 48 of file fMatrix.cpp.
singularity-robust (SR) inverse
SR-inverse.
Definition at line 1196 of file fMatrix.cpp.
singular value decomposition
Performs singular-value decomposition (SVD) M = U*S*V^T.
[out] | U | An mxm matrix. |
[out] | Sigma | Vector of min(m, n) elements containing the diagonal elements of S |
[out] | VT | An nxn matrix, transpose of V. |
Definition at line 733 of file fMatrix.cpp.
void fMat::symmetric | ( | char | t = 'U' | ) |
Change to symmetric matrix.
Creates a symmetric matrix
[in] | t | Command- 'A': average, 'U': use upper triangle, 'L': use lower triangle |
Definition at line 88 of file fMatrix.cpp.
void fMat::tran | ( | ) |
Transposes a matrix (only for square matrices).
Definition at line 1040 of file fMatrix.cpp.
Compute the eigenvalues.
Definition at line 1659 of file fMatrix.cpp.
inverse
Definition at line 176 of file fMatrix.cpp.
|
friend |
Computes the inverse when some columns are replaced.
Computes the inverse when some columns are replaced:
| X | = | M1 m2' |-1 | y |
where
| P | = | M1 m2 |-1 | q | | |
are known
Definition at line 1357 of file fMatrix.cpp.
|
friend |
Computes the inverse of an enlarged matrix.
Computes the inverse of an enlarged matrix:
| X y | = | M11 m12 |-1 | z w | | m21 m22 |
where M11, m12, m21, m22, and P=M11^{-1} are known
Definition at line 1288 of file fMatrix.cpp.
|
friend |
Computes the inverse when some rows are replaced.
Computes the inverse when some rows are replaced:
| X y | = | M1 |-1 | | | m2' |
where
| P q | = | M1 |-1 | | | m2 |
are known
Definition at line 1334 of file fMatrix.cpp.
Computes the inverse of a shrinked matrix.
Computes the inverse of a shrinked matrix: X = M11^(-1) where
| P q | = | M11 m12 |-1 | r s | | m21 m22 |
are known
Definition at line 1318 of file fMatrix.cpp.
inverse
Definition at line 484 of file fMatrix.cpp.
solve linear equation Ax = b
Definition at line 137 of file fMatrix.cpp.
solve linear equation Ax = b using SR-inverse
Definition at line 930 of file fMatrix.cpp.
solve linear equation Ax = b
Definition at line 416 of file fMatrix.cpp.
Definition at line 1268 of file fMatrix.cpp.
Definition at line 1412 of file fMatrix.cpp.
Definition at line 1130 of file fMatrix.cpp.
Definition at line 1138 of file fMatrix.cpp.
Definition at line 1187 of file fMatrix.cpp.
Definition at line 1088 of file fMatrix.cpp.
Definition at line 1208 of file fMatrix.cpp.
Definition at line 1435 of file fMatrix.cpp.
pseudo inverse
Definition at line 191 of file fMatrix.cpp.
pseudo inverse
Definition at line 501 of file fMatrix.cpp.
singularity-robust (SR) inverse
Definition at line 226 of file fMatrix.cpp.
|
friend |
SR-inverse.
Definition at line 536 of file fMatrix.cpp.
Returns the transpose of a matrix.
Definition at line 1013 of file fMatrix.cpp.