ifw-odp
2.0.0-alpha
|
This class is C++ wrapper for a CPL matrix object. It provides a simplified interface that allows to call CPL routines from INS applications. More...
#include <matrix.hpp>
Public Member Functions | |
Matrix () | |
Class constructor. More... | |
Matrix (const Matrix &matrix) | |
Copy constructor. More... | |
Matrix (cpl_size rows, cpl_size cols) | |
Class constructor. More... | |
virtual | ~Matrix () |
Class destructor. More... | |
bool | IsMatrix () const |
Check is CPL matrix is not null. More... | |
void | GetMatrixPtr (void **data_ptr) const |
Get pointer to CPL matrix data. More... | |
void * | GetMatrixPtr () const |
Get pointer to matrix data. More... | |
cpl_matrix * | GetCplMatrix () const |
Get CPL matrix pointer. More... | |
void | SetCplMatrix (cpl_matrix *matrix) |
Set CPL image. More... | |
cpl_size | GetNumCols () const |
Get number of matrix columns. More... | |
cpl_size | GetNumRows () const |
Get number of rows. More... | |
void | Get (cpl_size row, cpl_size col, double *value) const |
Get value of an element in the matrix. More... | |
double | Get (cpl_size row, cpl_size col) |
Get value of an element in the matrix. More... | |
void | Set (cpl_size row, cpl_size col, double value) |
Set an element value in the matrix. More... | |
std::string | GetSize () const |
Get the size of the matrix in the format [row]x[col]. More... | |
Matrix & | Sqrt (const Matrix &matrix) |
It computes the sqrt of each element in the matrix. More... | |
void | Product (const Matrix &, Matrix *product) |
Rows-by-columns product of two matrices. More... | |
void | Transpose (Matrix *transpose) |
Create transposed matrix. More... | |
void | Solve (const Matrix &, Matrix *solved) |
Solution of linear system . More... | |
void | SolveNormal (const Matrix &, Matrix *solved) |
Solution of overdetermined linear equations in a least squares sense. More... | |
void | Invert (Matrix *inverse) |
Find a matrix inverse. More... | |
void | Append (const Matrix &matrix, int mode) |
Append a matrix to another. More... | |
bool | IsDiagonal (const double tolerance) |
Check if the matrix is diagonal. More... | |
bool | IsIdentity (const double tolerance) |
Check for identity matrix. More... | |
bool | IsZero (const double tolerance) |
Check for zero matrix. More... | |
Matrix & | operator+ (const double) |
Overload operator+. More... | |
Matrix & | operator+ (const Matrix &) |
Overload operator+. More... | |
Matrix & | operator- (const double) |
Overload operator-. More... | |
Matrix & | operator- (const Matrix &) |
Overload operator-. More... | |
Matrix & | operator/ (const double) |
Overload operator/. More... | |
Matrix & | operator/ (const Matrix &) |
Overload operator/. More... | |
Matrix & | operator* (const double) |
Overload operator*. More... | |
Matrix & | operator* (const Matrix &) |
Overload operator*. More... | |
Matrix & | operator+= (const double) |
Overload operator+=. More... | |
Matrix & | operator+= (const Matrix &) |
Overload operator+=. More... | |
Matrix & | operator-= (const double) |
Overload operator-=. More... | |
Matrix & | operator-= (const Matrix &) |
Overload operator-=. More... | |
Matrix & | operator/= (const double) |
Overload operator/=. More... | |
Matrix & | operator/= (const Matrix &) |
Overload operator/=. More... | |
Matrix & | operator*= (const double) |
Overload operator*=. More... | |
Matrix & | operator*= (const Matrix &) |
Overload operator*=. More... | |
Matrix & | operator= (const Matrix &) |
Overload operator=. More... | |
bool | operator== (const Matrix &) const |
Overload operator==. More... | |
bool | operator!= (const Matrix &) const |
Overload operator !=. More... | |
Public Member Functions inherited from odp::Error | |
Error () | |
Class constructor. More... | |
virtual | ~Error () |
Class destructor. More... | |
void | ResetCplError () |
Reset CPL error and internal error flag. More... | |
bool | CheckCplError () const |
Check if there is an error in CPL. More... | |
Protected Attributes | |
cpl_matrix * | m_cpl_matrix |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Matrix &matrix) |
Overload operator<<. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from odp::Error | |
void | AddCplError () const |
Add CPL error to the error stack. More... | |
std::string | GetErrorMsg () const |
Get CPL error message. More... | |
Static Protected Member Functions inherited from odp::Error | |
static void | DumpError (unsigned self, unsigned first, unsigned last) |
Dump current CPL error. More... | |
This class is C++ wrapper for a CPL matrix object. It provides a simplified interface that allows to call CPL routines from INS applications.
Matrix - CPL matrix wrapper class
odp::Matrix::Matrix | ( | ) |
Class constructor.
|
explicit |
Copy constructor.
[in] | matrix | Reference to the matrix to be copied |
|
explicit |
Class constructor.
[in] | rows | Number of matrix rows |
[in] | cols | Number of matrix columns |
|
virtual |
Class destructor.
void odp::Matrix::Append | ( | const Matrix & | matrix, |
int | mode | ||
) |
Append a matrix to another.
[in] | matrix | Reference to the matrix to be added |
[in] | mode | Append mode |
If mode is set to 0, the matrices must have the same number of rows, and are connected horizontally with the first matrix on the left. If mode is set to 1, the matrices must have the same number of columns, and are connected vertically with the first matrix on top.
void odp::Matrix::Get | ( | cpl_size | row, |
cpl_size | col, | ||
double * | value | ||
) | const |
Get value of an element in the matrix.
[in] | row | Row identifier. |
[in] | col | Column identifier. |
[out] | value | Value of the element. |
double odp::Matrix::Get | ( | cpl_size | row, |
cpl_size | col | ||
) |
Get value of an element in the matrix.
[in] | row | Row identifier. |
[in] | col | Column identifier. |
|
inline |
Get CPL matrix pointer.
void odp::Matrix::GetMatrixPtr | ( | void ** | data_ptr | ) | const |
Get pointer to CPL matrix data.
[out] | data_ptr | Pointer to the matrix data. |
|
inline |
Get pointer to matrix data.
|
inline |
Get number of matrix columns.
|
inline |
Get number of rows.
std::string odp::Matrix::GetSize | ( | ) | const |
Get the size of the matrix in the format [row]x[col].
A matrix with 2 rows and 3 columns would return a string 2x3.
void odp::Matrix::Invert | ( | Matrix * | inverse | ) |
Find a matrix inverse.
[out] | inverse | Pointer to the inverse matrix. |
The input must be a square matrix.
bool odp::Matrix::IsDiagonal | ( | const double | tolerance | ) |
Check if the matrix is diagonal.
[out] | tolerance | Max tolerated rounding to zero. |
A threshold may be specified to consider zero any number that is close enough to zero. If the specified tolerance is negative, a default of DBL_EPSILON is used. A zero tolerance may also be specified. No error is set if the input matrix is not square.
bool odp::Matrix::IsIdentity | ( | const double | tolerance | ) |
Check for identity matrix.
[out] | tolerance | Max tolerated rounding to zero, or to one. |
A threshold may be specified to consider zero any number that is close enough to zero, and 1 any number that is close enough to 1. If the specified tolerance is negative, a default of DBL_EPSILON is used. A zero tolerance may also be specified. No error is set if the input matrix is not square.
|
inline |
Check is CPL matrix is not null.
bool odp::Matrix::IsZero | ( | const double | tolerance | ) |
Check for zero matrix.
[out] | tolerance | Max tolerated rounding to zero. |
After specific manipulations of a matrix some of its elements may theoretically be expected to be zero. However, because of numerical noise, such elements may turn out not to be exactly zero. In this specific case, if any of the matrix element is not exactly zero, the matrix would not be classified as a null matrix. A threshold may be specified to consider zero any number that is close enough to zero. If the specified tolerance is negative, a default of DBL_EPSILON is used. A zero tolerance may also be specified.
bool odp::Matrix::operator!= | ( | const Matrix & | matrix | ) | const |
Overload operator !=.
[in] | matrix | Input matrix to be compared |
Matrix & odp::Matrix::operator* | ( | const double | scalar | ) |
Overload operator*.
[in] | scalar | Input scalar to be multiplied |
Overload operator*.
[in] | matrix | Input matrix to be multiplied |
Matrix & odp::Matrix::operator*= | ( | const double | scalar | ) |
Overload operator*=.
[in] | scalar | Input scalar to be multiplied |
Overload operator*=.
[in] | matrix | Input matrix to be multiplied |
Matrix & odp::Matrix::operator+ | ( | const double | scalar | ) |
Overload operator+.
[in] | scalar | Input number to be added. |
Overload operator+.
[in] | matrix | Input matrix to be added |
Matrix & odp::Matrix::operator+= | ( | const double | scalar | ) |
Overload operator+=.
[in] | scalar | Input scalar to be added |
Overload operator+=.
[in] | matrix | Input matrix to be added |
Matrix & odp::Matrix::operator- | ( | const double | scalar | ) |
Overload operator-.
[in] | scalar | Input number to be subtracted. |
Overload operator-.
[in] | matrix | Input matrix to be subtracted |
Matrix & odp::Matrix::operator-= | ( | const double | scalar | ) |
Overload operator-=.
[in] | scalar | Input scalar to be subtracted |
Overload operator-=.
[in] | matrix | Input matrix to be subtracted |
Matrix & odp::Matrix::operator/ | ( | const double | scalar | ) |
Overload operator/.
[in] | scalar | Input number to be divided |
Overload operator/.
[in] | matrix | Input matrix to be divided |
Matrix & odp::Matrix::operator/= | ( | const double | scalar | ) |
Overload operator/=.
[in] | scalar | Input scalar to be divided |
Overload operator/=.
[in] | matrix | Input matrix to be divided |
Overload operator=.
[in] | matrix | Input matrix to be compared |
bool odp::Matrix::operator== | ( | const Matrix & | matrix | ) | const |
Overload operator==.
[in] | matrix | Input matrix to be compared |
Rows-by-columns product of two matrices.
[in] | matrix | Input matrix to be operated to obtain the product. |
[out] | product | Pointer to the output product of the two matrices. |
void odp::Matrix::Set | ( | cpl_size | row, |
cpl_size | col, | ||
double | value | ||
) |
Set an element value in the matrix.
[in] | row | Row identifier. |
[in] | col | Column identifier. |
[in] | value | Value of the element. |
|
inline |
Set CPL image.
[in] | matrix | CPL matrix |
Solution of linear system .
[in] | rhs | An N by M matrix containing K right-hand-sides. |
[out] | solved | Pointer to the transposed matrix. |
It is assumed that self object is a N by M matrix of coefficients, where N >= M.
Solution of overdetermined linear equations in a least squares sense.
[in] | rhs | An N by M matrix containing K right-hand-sides. |
[out] | solved | Pointer to the transposed matrix. |
It is assumed that self object is a N by M matrix of coefficients, where N >= M.
It computes the sqrt of each element in the matrix.
[in] | matrix | Input matrix to find the square root |
void odp::Matrix::Transpose | ( | Matrix * | transpose | ) |
Create transposed matrix.
[out] | transpose | Pointer to the transposed matrix. |
|
friend |
Overload operator<<.
[in] | os | Output stream |
[in] | matrix | Matrix to be dumped into the output stream. |
|
protected |