#include <Matrix.hpp>
Public Member Functions | |
Matrix () | |
Default constructor. | |
Matrix (const Table &data) | |
Constructor with initial data. More... | |
Matrix (Dimen dimen, double val=0) | |
Constructor with a specific initial value. More... | |
Matrix (const Vector &data, Dimen dimen, bool byrow=true) | |
Constructor with initial data. More... | |
void | setData (const Table &data) |
Set matrix data. More... | |
void | setData (Dimen dimen, double val=0) |
Set Matrix data with a specific value. More... | |
void | setData (const Vector &data, Dimen dimen, bool byrow=true) |
Set matrix data. More... | |
Table | getData () const |
Get matrix data. More... | |
Dimen | dimen () const |
Get matrix dimension. More... | |
bool | dimen (Dimen dimen) |
Set matrix dimension. More... | |
int | nrow () const |
The number of rows. More... | |
int | ncol () const |
The number of columns. More... | |
Matrix | round (int ndec=4) const |
Round every element to specific decimal digits. More... | |
bool | eq (const Matrix &mat, const Epsilon &eps=Epsilon()) const |
Test whether two matrices are equal to the specific precision. More... | |
bool | square () const |
Test if the matrix is a square matrix. More... | |
bool | symmetric (const Epsilon &eps=Epsilon()) const |
Test if the matrix is symmetric. More... | |
bool | uptri (const Epsilon &eps=Epsilon()) const |
Test if the matrix is upper triangular. More... | |
bool | lowtri (const Epsilon &eps=Epsilon()) const |
Test if the matrix is lower triangular. More... | |
bool | diag (const Epsilon &eps=Epsilon()) const |
Test if the matrix is diagonal. More... | |
Vector | getRow (int m) const |
Get a row data. More... | |
Vector | getCol (int n) const |
Get a column data. More... | |
void | setRow (int m, const Vector &row) |
Set a row data. More... | |
void | setCol (int n, const Vector &col) |
Set a column data. More... | |
void | exchange (int i, int j, bool row=true) |
Exchange two rows or two columns. More... | |
Matrix | transpose () const |
Transpose matrix. More... | |
int | rank (const Epsilon &eps=Epsilon()) const |
Rank of matrix. More... | |
Matrix | submat (int frow, int lrow, int fcol, int lcol) |
Submatrix. More... | |
Matrix | resid (int i, int j) const |
Residual matrix. More... | |
double & | operator() (int m, int n) |
Access a specific element of the matrix. More... | |
double | operator() (int m, int n) const |
Access a specific element of the matrix (read only). More... | |
Matrix | operator+ (const Matrix &mat) const |
Matrix addition. More... | |
Matrix | operator- (const Matrix &mat) const |
Matrix subtraction. More... | |
Matrix | operator* (const Matrix &mat) const |
Matrix multiplication. More... | |
bool | operator== (const Matrix &mat) const |
Matrix equality. More... | |
bool | operator!= (const Matrix &mat) const |
Matrix inequality. More... | |
mathkit::Matrix::Matrix | ( | const Table & | data) |
Constructor with initial data.
data | The initial data. |
Definition at line 15 of file Matrix.cpp.
mathkit::Matrix::Matrix | ( | Dimen | dimen, |
double | val = 0 |
||
) |
Constructor with a specific initial value.
dimen | The dimension of the matrix. |
val | The specific initial value. |
Definition at line 20 of file Matrix.cpp.
Constructor with initial data.
data | A vector contains the initial data. |
dimen | The dimension of the matrix. |
byrow | The initial data is in row major or column major form. |
Definition at line 25 of file Matrix.cpp.
void mathkit::Matrix::setData | ( | const Table & | data) |
void mathkit::Matrix::setData | ( | Dimen | dimen, |
double | val = 0 |
||
) |
Set Matrix data with a specific value.
dimen | The dimension of the matrix. |
val | The specific value. |
Definition at line 34 of file Matrix.cpp.
Set matrix data.
data | A vector contains the new data. |
dimen | The dimension of the matrix. |
byrow | The new data is in row major or column major form. |
Definition at line 39 of file Matrix.cpp.
Table mathkit::Matrix::getData | ( | ) | const |
Dimen mathkit::Matrix::dimen | ( | ) | const |
bool mathkit::Matrix::dimen | ( | Dimen | dimen) |
Set matrix dimension.
The dimension could be set only when the matrix data is empty. Else this operation would fail.
This method should only be used when the matrix is contructed by default contructor and need to load data using stream extraction operator (>>).
dimen | The dimension. |
Definition at line 64 of file Matrix.cpp.
int mathkit::Matrix::nrow | ( | ) | const |
int mathkit::Matrix::ncol | ( | ) | const |
Matrix mathkit::Matrix::round | ( | int | ndec = 4 ) | const |
Round every element to specific decimal digits.
ndec | The number of decimal digits. |
Definition at line 78 of file Matrix.cpp.
Test whether two matrices are equal to the specific precision.
mat | The another matrix. |
eps | An Epsilon functor to control accurary. |
Definition at line 87 of file Matrix.cpp.
bool mathkit::Matrix::square | ( | ) | const |
Test if the matrix is a square matrix.
Definition at line 96 of file Matrix.cpp.
Test if the matrix is symmetric.
eps | An Epsilon functor to control accurary. |
Definition at line 100 of file Matrix.cpp.
Test if the matrix is upper triangular.
eps | An Epsilon functor to test zero elements. |
Definition at line 105 of file Matrix.cpp.
Test if the matrix is lower triangular.
eps | An Epsilon functor to test zero elements. |
Definition at line 114 of file Matrix.cpp.
Test if the matrix is diagonal.
eps | An Epsilon functor to test zero elements. |
Definition at line 123 of file Matrix.cpp.
Vector mathkit::Matrix::getRow | ( | int | m) | const |
Get a row data.
m | The row index (start from zero). |
Definition at line 127 of file Matrix.cpp.
Vector mathkit::Matrix::getCol | ( | int | n) | const |
Get a column data.
n | The column index (start from zero). |
Definition at line 133 of file Matrix.cpp.
void mathkit::Matrix::setRow | ( | int | m, |
const Vector & | row | ||
) |
Set a row data.
m | The row index (start from zero). |
row | The new row data. |
Definition at line 137 of file Matrix.cpp.
void mathkit::Matrix::setCol | ( | int | n, |
const Vector & | col | ||
) |
Set a column data.
n | The column index (start from zero). |
col | The new column data. |
Definition at line 141 of file Matrix.cpp.
void mathkit::Matrix::exchange | ( | int | i, |
int | j, | ||
bool | row = true |
||
) |
Exchange two rows or two columns.
i | The index of first row/column to exchange. |
j | The index of second row/column to exchange. |
row | Which stuff to exchange (row or column). |
Definition at line 145 of file Matrix.cpp.
Matrix mathkit::Matrix::transpose | ( | ) | const |
Rank of matrix.
eps | An Epsilon functor to test zero elements. |
Definition at line 165 of file Matrix.cpp.
Matrix mathkit::Matrix::submat | ( | int | frow, |
int | lrow, | ||
int | fcol, | ||
int | lcol | ||
) |
Submatrix.
frow | The first row index. |
lrow | The last row index. |
fcol | The first column index. |
lcol | The last column index. |
Definition at line 195 of file Matrix.cpp.
Matrix mathkit::Matrix::resid | ( | int | i, |
int | j | ||
) | const |
Residual matrix.
i | The row index (zero based). |
j | The column index (zero based). |
Definition at line 204 of file Matrix.cpp.
double & mathkit::Matrix::operator() | ( | int | m, |
int | n | ||
) |
Access a specific element of the matrix.
m | The row index (start from zero). |
n | The column index (start from zero). |
Definition at line 218 of file Matrix.cpp.
double mathkit::Matrix::operator() | ( | int | m, |
int | n | ||
) | const |
Access a specific element of the matrix (read only).
m | The row index (start from zero). |
n | The column index (start from zero). |
Definition at line 222 of file Matrix.cpp.
Matrix addition.
mat | The right matrix operand. |
Definition at line 226 of file Matrix.cpp.
Matrix subtraction.
mat | The right matrix operand. |
Definition at line 233 of file Matrix.cpp.
Matrix multiplication.
mat | The right matrix operand. |
Definition at line 240 of file Matrix.cpp.
bool mathkit::Matrix::operator== | ( | const Matrix & | mat) | const |
Matrix equality.
mat | The right matrix operand. |
Definition at line 249 of file Matrix.cpp.
bool mathkit::Matrix::operator!= | ( | const Matrix & | mat) | const |
Matrix inequality.
mat | The right matrix operand. |
Definition at line 253 of file Matrix.cpp.