ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | Friends | List of all members
odp::Matrix Class Reference

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>

Inheritance diagram for odp::Matrix:
odp::Error odp::MatrixWrapper

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...
 
MatrixSqrt (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...
 
Matrixoperator+ (const double)
 Overload operator+. More...
 
Matrixoperator+ (const Matrix &)
 Overload operator+. More...
 
Matrixoperator- (const double)
 Overload operator-. More...
 
Matrixoperator- (const Matrix &)
 Overload operator-. More...
 
Matrixoperator/ (const double)
 Overload operator/. More...
 
Matrixoperator/ (const Matrix &)
 Overload operator/. More...
 
Matrixoperator* (const double)
 Overload operator*. More...
 
Matrixoperator* (const Matrix &)
 Overload operator*. More...
 
Matrixoperator+= (const double)
 Overload operator+=. More...
 
Matrixoperator+= (const Matrix &)
 Overload operator+=. More...
 
Matrixoperator-= (const double)
 Overload operator-=. More...
 
Matrixoperator-= (const Matrix &)
 Overload operator-=. More...
 
Matrixoperator/= (const double)
 Overload operator/=. More...
 
Matrixoperator/= (const Matrix &)
 Overload operator/=. More...
 
Matrixoperator*= (const double)
 Overload operator*=. More...
 
Matrixoperator*= (const Matrix &)
 Overload operator*=. More...
 
Matrixoperator= (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...
 

Detailed Description

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

See Also
CPL Reference: http://www.eso.org/observing/cpl/reference_3.0/ or above

Constructor & Destructor Documentation

odp::Matrix::Matrix ( )

Class constructor.

Returns
none
odp::Matrix::Matrix ( const Matrix matrix)
explicit

Copy constructor.

Parameters
[in]matrixReference to the matrix to be copied
Returns
none
See Also
CPL function: cpl_matrix_duplicate
odp::Matrix::Matrix ( cpl_size  rows,
cpl_size  cols 
)
explicit

Class constructor.

Parameters
[in]rowsNumber of matrix rows
[in]colsNumber of matrix columns
Returns
none
See Also
CPL function: cpl_matrix_new
odp::Matrix::~Matrix ( )
virtual

Class destructor.

Returns
none

Member Function Documentation

void odp::Matrix::Append ( const Matrix matrix,
int  mode 
)

Append a matrix to another.

Parameters
[in]matrixReference to the matrix to be added
[in]modeAppend mode
Returns
none

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.

See Also
CPL function: cpl_matrix_append()
void odp::Matrix::Get ( cpl_size  row,
cpl_size  col,
double *  value 
) const

Get value of an element in the matrix.

Parameters
[in]rowRow identifier.
[in]colColumn identifier.
[out]valueValue of the element.
Returns
none
See Also
CPL function: cpl_matrix_get
double odp::Matrix::Get ( cpl_size  row,
cpl_size  col 
)

Get value of an element in the matrix.

Parameters
[in]rowRow identifier.
[in]colColumn identifier.
Returns
value of an element in the matrix
See Also
CPL function: cpl_matrix_get
cpl_matrix* odp::Matrix::GetCplMatrix ( ) const
inline

Get CPL matrix pointer.

Returns
CPL matrix pointer
void odp::Matrix::GetMatrixPtr ( void **  data_ptr) const

Get pointer to CPL matrix data.

Parameters
[out]data_ptrPointer to the matrix data.
Returns
false in case of error, true otherwise.
See Also
CPL function: cpl_matrix_get_data
void* odp::Matrix::GetMatrixPtr ( ) const
inline

Get pointer to matrix data.

Returns
Pointer to the matrix data
cpl_size odp::Matrix::GetNumCols ( ) const
inline

Get number of matrix columns.

Returns
Number of columns
cpl_size odp::Matrix::GetNumRows ( ) const
inline

Get number of rows.

Returns
Number of rows
std::string odp::Matrix::GetSize ( ) const

Get the size of the matrix in the format [row]x[col].

Returns
string with the size of the matrix.

A matrix with 2 rows and 3 columns would return a string 2x3.

void odp::Matrix::Invert ( Matrix inverse)

Find a matrix inverse.

Parameters
[out]inversePointer to the inverse matrix.
Returns
none

The input must be a square matrix.

See Also
CPL function: cpl_matrix_invert_create()
bool odp::Matrix::IsDiagonal ( const double  tolerance)

Check if the matrix is diagonal.

Parameters
[out]toleranceMax tolerated rounding to zero.
Returns
True in case of diagonal matrix, FALSE otherwise or if matrix is not square

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.

See Also
CPL function: cpl_matrix_is_diagonal()
bool odp::Matrix::IsIdentity ( const double  tolerance)

Check for identity matrix.

Parameters
[out]toleranceMax tolerated rounding to zero, or to one.
Returns
True in case of identity matrix, FALSE otherwise or if matrix is not square

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.

See Also
CPL function: cpl_matrix_is_identity()
bool odp::Matrix::IsMatrix ( ) const
inline

Check is CPL matrix is not null.

Returns
TRUE is CPL matrix is not null, FALSE otherwise.
bool odp::Matrix::IsZero ( const double  tolerance)

Check for zero matrix.

Parameters
[out]toleranceMax tolerated rounding to zero.
Returns
True in case of zero matrix, FALSE otherwise or if matrix is not square

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.

See Also
CPL function: cpl_matrix_is_zero()
bool odp::Matrix::operator!= ( const Matrix matrix) const

Overload operator !=.

Parameters
[in]matrixInput matrix to be compared
Returns
Reference to the object
Matrix & odp::Matrix::operator* ( const double  scalar)

Overload operator*.

Parameters
[in]scalarInput scalar to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_matrix_multiply_scalar
Matrix & odp::Matrix::operator* ( const Matrix matrix)

Overload operator*.

Parameters
[in]matrixInput matrix to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_matrix_multiply
Matrix & odp::Matrix::operator*= ( const double  scalar)

Overload operator*=.

Parameters
[in]scalarInput scalar to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_matrix_multiply_scalar
Matrix & odp::Matrix::operator*= ( const Matrix matrix)

Overload operator*=.

Parameters
[in]matrixInput matrix to be multiplied
Returns
Reference to the object
See Also
CPL function: cpl_matrix_multiply
Matrix & odp::Matrix::operator+ ( const double  scalar)

Overload operator+.

Parameters
[in]scalarInput number to be added.
Returns
Reference to the object
See Also
CPL function: cpl_matrix_add_scalar
Matrix & odp::Matrix::operator+ ( const Matrix matrix)

Overload operator+.

Parameters
[in]matrixInput matrix to be added
Returns
Reference to the object
See Also
CPL function: cpl_matrix_add
Matrix & odp::Matrix::operator+= ( const double  scalar)

Overload operator+=.

Parameters
[in]scalarInput scalar to be added
Returns
Reference to the object
See Also
CPL function: cpl_matrix_add_scalar
Matrix & odp::Matrix::operator+= ( const Matrix matrix)

Overload operator+=.

Parameters
[in]matrixInput matrix to be added
Returns
Reference to the object
See Also
CPL function: cpl_matrix_add
Matrix & odp::Matrix::operator- ( const double  scalar)

Overload operator-.

Parameters
[in]scalarInput number to be subtracted.
Returns
Reference to the object
See Also
CPL function: cpl_matrix_subtract_scalar
Matrix & odp::Matrix::operator- ( const Matrix matrix)

Overload operator-.

Parameters
[in]matrixInput matrix to be subtracted
Returns
Reference to the object
See Also
CPL function: cpl_matrix_subtract
Matrix & odp::Matrix::operator-= ( const double  scalar)

Overload operator-=.

Parameters
[in]scalarInput scalar to be subtracted
Returns
Reference to the object
See Also
CPL function: cpl_matrix_subtract_scalar
Matrix & odp::Matrix::operator-= ( const Matrix matrix)

Overload operator-=.

Parameters
[in]matrixInput matrix to be subtracted
Returns
Reference to the object
See Also
CPL function: cpl_matrix_subtract
Matrix & odp::Matrix::operator/ ( const double  scalar)

Overload operator/.

Parameters
[in]scalarInput number to be divided
Returns
Reference to the object
See Also
CPL function: cpl_matrix_divide_scalar
Matrix & odp::Matrix::operator/ ( const Matrix matrix)

Overload operator/.

Parameters
[in]matrixInput matrix to be divided
Returns
Reference to the object
See Also
CPL function: cpl_matrix_divide
Matrix & odp::Matrix::operator/= ( const double  scalar)

Overload operator/=.

Parameters
[in]scalarInput scalar to be divided
Returns
Reference to the object
See Also
CPL function: cpl_matrix_divide_scalar
Matrix & odp::Matrix::operator/= ( const Matrix matrix)

Overload operator/=.

Parameters
[in]matrixInput matrix to be divided
Returns
Reference to the object
See Also
CPL function: cpl_matrix_divide
Matrix & odp::Matrix::operator= ( const Matrix matrix)

Overload operator=.

Parameters
[in]matrixInput matrix to be compared
Returns
Reference to the object
bool odp::Matrix::operator== ( const Matrix matrix) const

Overload operator==.

Parameters
[in]matrixInput matrix to be compared
Returns
Reference to the object
void odp::Matrix::Product ( const Matrix matrix,
Matrix product 
)

Rows-by-columns product of two matrices.

Parameters
[in]matrixInput matrix to be operated to obtain the product.
[out]productPointer to the output product of the two matrices.
Returns
none
See Also
CPL function: cpl_matrix_product_create
void odp::Matrix::Set ( cpl_size  row,
cpl_size  col,
double  value 
)

Set an element value in the matrix.

Parameters
[in]rowRow identifier.
[in]colColumn identifier.
[in]valueValue of the element.
Returns
none
See Also
CPL function: cpl_matrix_set
void odp::Matrix::SetCplMatrix ( cpl_matrix *  matrix)
inline

Set CPL image.

Parameters
[in]matrixCPL matrix
Returns
none
void odp::Matrix::Solve ( const Matrix rhs,
Matrix solved 
)

Solution of linear system .

Parameters
[in]rhsAn N by M matrix containing K right-hand-sides.
[out]solvedPointer to the transposed matrix.
Returns
none

It is assumed that self object is a N by M matrix of coefficients, where N >= M.

See Also
CPL function: cpl_matrix_solve
void odp::Matrix::SolveNormal ( const Matrix rhs,
Matrix solved 
)

Solution of overdetermined linear equations in a least squares sense.

Parameters
[in]rhsAn N by M matrix containing K right-hand-sides.
[out]solvedPointer to the transposed matrix.
Returns
none

It is assumed that self object is a N by M matrix of coefficients, where N >= M.

See Also
CPL function: cpl_matrix_solve_normal
Matrix & odp::Matrix::Sqrt ( const Matrix matrix)

It computes the sqrt of each element in the matrix.

Parameters
[in]matrixInput matrix to find the square root
Returns
Reference to the object
void odp::Matrix::Transpose ( Matrix transpose)

Create transposed matrix.

Parameters
[out]transposePointer to the transposed matrix.
Returns
none
See Also
CPL function: cpl_matrix_transpose_create

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Matrix matrix 
)
friend

Overload operator<<.

Parameters
[in]osOutput stream
[in]matrixMatrix to be dumped into the output stream.
Returns
Reference to the output stream

Member Data Documentation

cpl_matrix* odp::Matrix::m_cpl_matrix
protected

The documentation for this class was generated from the following files: