ifw-odp 5.0.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends | List of all members
ifw::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 ifw::odp::Matrix:
ifw::odp::Error ifw::odp::MatrixWrapper

Public Member Functions

 Matrix ()
 Class constructor.
 
 Matrix (const Matrix &matrix)
 Copy constructor.
 
 Matrix (cpl_size rows, cpl_size cols)
 Class constructor.
 
virtual ~Matrix ()
 Class destructor.
 
bool IsMatrix () const
 Check is CPL matrix is not null.
 
void GetMatrixPtr (void **data_ptr) const
 Get pointer to CPL matrix data.
 
void * GetMatrixPtr () const
 Get pointer to matrix data.
 
cpl_matrix * GetCplMatrix () const
 Get CPL matrix pointer.
 
void SetCplMatrix (cpl_matrix *matrix)
 Set CPL image.
 
cpl_size GetNumCols () const
 Get number of matrix columns.
 
cpl_size GetNumRows () const
 Get number of rows.
 
void Get (cpl_size row, cpl_size col, double *value) const
 Get value of an element in the matrix.
 
double Get (cpl_size row, cpl_size col)
 Get value of an element in the matrix.
 
void Set (cpl_size row, cpl_size col, double value)
 Set an element value in the matrix.
 
std::string GetSize () const
 Get the size of the matrix in the format [row]x[col].
 
MatrixSqrt (const Matrix &matrix)
 It computes the sqrt of each element in the matrix.
 
void Product (const Matrix &, Matrix *product)
 Rows-by-columns product of two matrices.
 
void Transpose (Matrix *transpose)
 Create transposed matrix.
 
void Solve (const Matrix &, Matrix *solved)
 Solution of linear system .
 
void SolveNormal (const Matrix &, Matrix *solved)
 Solution of overdetermined linear equations in a least squares sense.
 
void Invert (Matrix *inverse)
 Find a matrix inverse.
 
void Append (const Matrix &matrix, int mode)
 Append a matrix to another.
 
bool IsDiagonal (const double tolerance)
 Check if the matrix is diagonal.
 
bool IsIdentity (const double tolerance)
 Check for identity matrix.
 
bool IsZero (const double tolerance)
 Check for zero matrix.
 
Matrixoperator+ (const double)
 Overload operator+.
 
Matrixoperator+ (const Matrix &)
 Overload operator+.
 
Matrixoperator- (const double)
 Overload operator-.
 
Matrixoperator- (const Matrix &)
 Overload operator-.
 
Matrixoperator/ (const double)
 Overload operator/.
 
Matrixoperator/ (const Matrix &)
 Overload operator/.
 
Matrixoperator* (const double)
 Overload operator*.
 
Matrixoperator* (const Matrix &)
 Overload operator*.
 
Matrixoperator+= (const double)
 Overload operator+=.
 
Matrixoperator+= (const Matrix &)
 Overload operator+=.
 
Matrixoperator-= (const double)
 Overload operator-=.
 
Matrixoperator-= (const Matrix &)
 Overload operator-=.
 
Matrixoperator/= (const double)
 Overload operator/=.
 
Matrixoperator/= (const Matrix &)
 Overload operator/=.
 
Matrixoperator*= (const double)
 Overload operator*=.
 
Matrixoperator*= (const Matrix &)
 Overload operator*=.
 
Matrixoperator= (const Matrix &)
 Overload operator=.
 
bool operator== (const Matrix &) const
 Overload operator==.
 
bool operator!= (const Matrix &) const
 Overload operator !=.
 
- Public Member Functions inherited from ifw::odp::Error
 Error ()
 Class constructor.
 
virtual ~Error ()
 Class destructor.
 
void ResetCplError ()
 Reset CPL error and internal error flag.
 
bool CheckCplError () const
 Check if there is an error in CPL.
 

Protected Attributes

cpl_matrix * m_cpl_matrix
 

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from ifw::odp::Error
std::string GetErrorMsg () const
 Get CPL error message.
 

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

◆ Matrix() [1/3]

ifw::odp::Matrix::Matrix ( )

Class constructor.

Returns
none

◆ Matrix() [2/3]

ifw::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

◆ Matrix() [3/3]

ifw::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

◆ ~Matrix()

ifw::odp::Matrix::~Matrix ( )
virtual

Class destructor.

Returns
none

Member Function Documentation

◆ Append()

void ifw::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()

◆ Get() [1/2]

double ifw::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

◆ Get() [2/2]

void ifw::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

◆ GetCplMatrix()

cpl_matrix * ifw::odp::Matrix::GetCplMatrix ( ) const
inline

Get CPL matrix pointer.

Returns
CPL matrix pointer

◆ GetMatrixPtr() [1/2]

void * ifw::odp::Matrix::GetMatrixPtr ( ) const
inline

Get pointer to matrix data.

Returns
Pointer to the matrix data

◆ GetMatrixPtr() [2/2]

void ifw::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

◆ GetNumCols()

cpl_size ifw::odp::Matrix::GetNumCols ( ) const
inline

Get number of matrix columns.

Returns
Number of columns

◆ GetNumRows()

cpl_size ifw::odp::Matrix::GetNumRows ( ) const
inline

Get number of rows.

Returns
Number of rows

◆ GetSize()

std::string ifw::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.

◆ Invert()

void ifw::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()

◆ IsDiagonal()

bool ifw::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()

◆ IsIdentity()

bool ifw::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()

◆ IsMatrix()

bool ifw::odp::Matrix::IsMatrix ( ) const
inline

Check is CPL matrix is not null.

Returns
TRUE is CPL matrix is not null, FALSE otherwise.

◆ IsZero()

bool ifw::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()

◆ operator!=()

bool ifw::odp::Matrix::operator!= ( const Matrix & matrix) const

Overload operator !=.

Parameters
[in]matrixInput matrix to be compared
Returns
Reference to the object

◆ operator*() [1/2]

Matrix & ifw::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

◆ operator*() [2/2]

Matrix & ifw::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

◆ operator*=() [1/2]

Matrix & ifw::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

◆ operator*=() [2/2]

Matrix & ifw::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

◆ operator+() [1/2]

Matrix & ifw::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

◆ operator+() [2/2]

Matrix & ifw::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

◆ operator+=() [1/2]

Matrix & ifw::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

◆ operator+=() [2/2]

Matrix & ifw::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

◆ operator-() [1/2]

Matrix & ifw::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

◆ operator-() [2/2]

Matrix & ifw::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

◆ operator-=() [1/2]

Matrix & ifw::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

◆ operator-=() [2/2]

Matrix & ifw::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

◆ operator/() [1/2]

Matrix & ifw::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

◆ operator/() [2/2]

Matrix & ifw::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

◆ operator/=() [1/2]

Matrix & ifw::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

◆ operator/=() [2/2]

Matrix & ifw::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

◆ operator=()

Matrix & ifw::odp::Matrix::operator= ( const Matrix & matrix)

Overload operator=.

Parameters
[in]matrixInput matrix to be compared
Returns
Reference to the object

◆ operator==()

bool ifw::odp::Matrix::operator== ( const Matrix & matrix) const

Overload operator==.

Parameters
[in]matrixInput matrix to be compared
Returns
Reference to the object

◆ Product()

void ifw::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

◆ Set()

void ifw::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

◆ SetCplMatrix()

void ifw::odp::Matrix::SetCplMatrix ( cpl_matrix * matrix)
inline

Set CPL image.

Parameters
[in]matrixCPL matrix
Returns
none

◆ Solve()

void ifw::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

◆ SolveNormal()

void ifw::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

◆ Sqrt()

Matrix & ifw::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

◆ Transpose()

void ifw::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 Symbol Documentation

◆ operator<<

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

◆ m_cpl_matrix

cpl_matrix* ifw::odp::Matrix::m_cpl_matrix
protected

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