ifw-odp  2.0.0
matrix.hpp
Go to the documentation of this file.
1 
9 #ifndef ODP_MATRIX_HPP
10 #define ODP_MATRIX_HPP
11 
12 #ifndef __cplusplus
13 #error This is a C++ include file and cannot be used from plain C
14 #endif
15 
16 // System header files
17 #include <iostream>
18 
19 // CPL header files
20 #include "cpl_matrix.h"
21 
22 // Local header files
23 #include "cppcpl/error.hpp"
24 
25 
26 namespace odp {
38  class Matrix : virtual public odp::Error
39  {
40  public:
47  Matrix();
48 
56  explicit Matrix(const Matrix &matrix);
57 
66  explicit Matrix(cpl_size rows, cpl_size cols);
67 
74  virtual ~Matrix();
75 
81  inline bool IsMatrix() const;
82 
90  void GetMatrixPtr(void **data_ptr) const;
91 
97  inline void* GetMatrixPtr() const;
98 
104  inline cpl_matrix* GetCplMatrix() const;
105 
112  inline void SetCplMatrix(cpl_matrix *matrix);
113 
119  inline cpl_size GetNumCols() const;
120 
126  inline cpl_size GetNumRows() const;
127 
139  void Get(cpl_size row,
140  cpl_size col,
141  double *value) const;
142 
153  double Get(cpl_size row,
154  cpl_size col);
155 
167  void Set(cpl_size row,
168  cpl_size col,
169  double value);
170 
178  std::string GetSize() const;
179 
186  Matrix& Sqrt(const Matrix& matrix);
187 
198  void Product(const Matrix&, Matrix *product);
199 
209  void Transpose(Matrix *transpose);
210 
224  void Solve(const Matrix&, Matrix *solved);
225 
239  void SolveNormal(const Matrix&, Matrix *solved);
240 
252  void Invert(Matrix *inverse);
253 
269  void Append(const Matrix& matrix, int mode);
270 
285  bool IsDiagonal(const double tolerance);
286 
302  bool IsIdentity(const double tolerance);
303 
322  bool IsZero(const double tolerance);
323 
324  // Object operators
325 
333  Matrix& operator+(const double);
334 
342  Matrix& operator+(const Matrix&);
343 
351  Matrix& operator-(const double);
352 
360  Matrix& operator-(const Matrix&);
361 
369  Matrix& operator/(const double);
370 
378  Matrix& operator/(const Matrix&);
379 
387  Matrix& operator*(const double);
388 
396  Matrix& operator*(const Matrix&);
397 
405  Matrix& operator+=(const double);
406 
414  Matrix& operator+=(const Matrix&);
415 
423  Matrix& operator-=(const double);
424 
432  Matrix& operator-=(const Matrix&);
433 
441  Matrix& operator/=(const double);
442 
450  Matrix& operator/=(const Matrix&);
451 
459  Matrix& operator*=(const double);
460 
468  Matrix& operator*=(const Matrix&);
469 
476  Matrix& operator=(const Matrix&);
477 
485  bool operator==(const Matrix&) const;
486 
493  bool operator!=(const Matrix&) const;
494 
502  friend std::ostream& operator<<(std::ostream &os, const Matrix &matrix);
503 
504  private:
512  void Delete();
513 
514  protected:
515  cpl_matrix *m_cpl_matrix;
516 
517  };
518 
519 }
520 #include "matrix.ipp"
521 
522 #endif
odp::Matrix::SetCplMatrix
void SetCplMatrix(cpl_matrix *matrix)
Set CPL image.
odp::Matrix::GetNumRows
cpl_size GetNumRows() const
Get number of rows.
odp::Matrix
This class is C++ wrapper for a CPL matrix object. It provides a simplified interface that allows to ...
Definition: matrix.hpp:39
odp::Matrix::operator-
Matrix & operator-(const double)
Overload operator-.
Definition: matrix.cpp:303
odp::Matrix::~Matrix
virtual ~Matrix()
Class destructor.
Definition: matrix.cpp:60
odp::Matrix::operator==
bool operator==(const Matrix &) const
Overload operator==.
Definition: matrix.cpp:462
odp::Matrix::Invert
void Invert(Matrix *inverse)
Find a matrix inverse.
Definition: matrix.cpp:203
odp::Matrix::operator!=
bool operator!=(const Matrix &) const
Overload operator !=.
Definition: matrix.cpp:485
odp::Matrix::IsMatrix
bool IsMatrix() const
Check is CPL matrix is not null.
odp::Error
This class handle the errors produced by the calling of image processing routines.
Definition: error.hpp:35
odp
Definition: array.cpp:17
odp::Matrix::IsDiagonal
bool IsDiagonal(const double tolerance)
Check if the matrix is diagonal.
Definition: matrix.cpp:233
odp::Matrix::GetSize
std::string GetSize() const
Get the size of the matrix in the format [row]x[col].
Definition: matrix.cpp:114
odp::Matrix::GetCplMatrix
cpl_matrix * GetCplMatrix() const
Get CPL matrix pointer.
odp::Matrix::Product
void Product(const Matrix &, Matrix *product)
Rows-by-columns product of two matrices.
Definition: matrix.cpp:124
odp::Matrix::Sqrt
Matrix & Sqrt(const Matrix &matrix)
It computes the sqrt of each element in the matrix.
Definition: matrix.cpp:509
odp::Matrix::GetMatrixPtr
void * GetMatrixPtr() const
Get pointer to matrix data.
odp::Matrix::operator/
Matrix & operator/(const double)
Overload operator/.
Definition: matrix.cpp:323
odp::Matrix::operator*
Matrix & operator*(const double)
Overload operator*.
Definition: matrix.cpp:343
odp::Matrix::Matrix
Matrix()
Class constructor.
Definition: matrix.cpp:23
odp::Matrix::Transpose
void Transpose(Matrix *transpose)
Create transposed matrix.
Definition: matrix.cpp:149
odp::Matrix::SolveNormal
void SolveNormal(const Matrix &, Matrix *solved)
Solution of overdetermined linear equations in a least squares sense.
Definition: matrix.cpp:185
odp::Matrix::Solve
void Solve(const Matrix &, Matrix *solved)
Solution of linear system .
Definition: matrix.cpp:167
odp::Matrix::operator+=
Matrix & operator+=(const double)
Overload operator+=.
Definition: matrix.cpp:364
odp::Matrix::operator/=
Matrix & operator/=(const double)
Overload operator/=.
Definition: matrix.cpp:406
odp::Matrix::Append
void Append(const Matrix &matrix, int mode)
Append a matrix to another.
Definition: matrix.cpp:220
odp::Matrix::m_cpl_matrix
cpl_matrix * m_cpl_matrix
Definition: matrix.hpp:515
odp::Matrix::GetNumCols
cpl_size GetNumCols() const
Get number of matrix columns.
odp::Matrix::operator*=
Matrix & operator*=(const double)
Overload operator*=.
Definition: matrix.cpp:427
odp::Matrix::operator=
Matrix & operator=(const Matrix &)
Overload operator=.
Definition: matrix.cpp:449
odp::Matrix::operator<<
friend std::ostream & operator<<(std::ostream &os, const Matrix &matrix)
Overload operator<<.
Definition: matrix.cpp:524
odp::Matrix::operator-=
Matrix & operator-=(const double)
Overload operator-=.
Definition: matrix.cpp:385
odp::Matrix::IsIdentity
bool IsIdentity(const double tolerance)
Check for identity matrix.
Definition: matrix.cpp:247
odp::Matrix::operator+
Matrix & operator+(const double)
Overload operator+.
Definition: matrix.cpp:280
odp::Matrix::Get
void Get(cpl_size row, cpl_size col, double *value) const
Get value of an element in the matrix.
Definition: matrix.cpp:74
odp::Matrix::Set
void Set(cpl_size row, cpl_size col, double value)
Set an element value in the matrix.
Definition: matrix.cpp:103
error.hpp
Error class header file.
odp::Matrix::IsZero
bool IsZero(const double tolerance)
Check for zero matrix.
Definition: matrix.cpp:260