ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
bool operator==(const Matrix &) const
Overload operator==.
Definition: matrix.cpp:462
friend std::ostream & operator<<(std::ostream &os, const Matrix &matrix)
Overload operator&lt;&lt;.
Definition: matrix.cpp:524
bool IsIdentity(const double tolerance)
Check for identity matrix.
Definition: matrix.cpp:247
Matrix & operator/=(const double)
Overload operator/=.
Definition: matrix.cpp:406
void Get(cpl_size row, cpl_size col, double *value) const
Get value of an element in the matrix.
Definition: matrix.cpp:74
Matrix & operator+=(const double)
Overload operator+=.
Definition: matrix.cpp:364
Matrix & Sqrt(const Matrix &matrix)
It computes the sqrt of each element in the matrix.
Definition: matrix.cpp:509
cpl_size GetNumCols() const
Get number of matrix columns.
cpl_matrix * m_cpl_matrix
Definition: matrix.hpp:515
cpl_size GetNumRows() const
Get number of rows.
void SetCplMatrix(cpl_matrix *matrix)
Set CPL image.
Matrix & operator*(const double)
Overload operator*.
Definition: matrix.cpp:343
void SolveNormal(const Matrix &, Matrix *solved)
Solution of overdetermined linear equations in a least squares sense.
Definition: matrix.cpp:185
std::string GetSize() const
Get the size of the matrix in the format [row]x[col].
Definition: matrix.cpp:114
This class is C++ wrapper for a CPL matrix object. It provides a simplified interface that allows to ...
Definition: matrix.hpp:38
Matrix & operator/(const double)
Overload operator/.
Definition: matrix.cpp:323
This class handle the errors produced by the calling of image processing routines.
Definition: error.hpp:34
Matrix()
Class constructor.
Definition: matrix.cpp:23
void Invert(Matrix *inverse)
Find a matrix inverse.
Definition: matrix.cpp:203
void * GetMatrixPtr() const
Get pointer to matrix data.
void Append(const Matrix &matrix, int mode)
Append a matrix to another.
Definition: matrix.cpp:220
virtual ~Matrix()
Class destructor.
Definition: matrix.cpp:60
Matrix & operator-(const double)
Overload operator-.
Definition: matrix.cpp:303
void Transpose(Matrix *transpose)
Create transposed matrix.
Definition: matrix.cpp:149
Matrix & operator=(const Matrix &)
Overload operator=.
Definition: matrix.cpp:449
Error class header file.
void Product(const Matrix &, Matrix *product)
Rows-by-columns product of two matrices.
Definition: matrix.cpp:124
bool IsMatrix() const
Check is CPL matrix is not null.
Matrix & operator-=(const double)
Overload operator-=.
Definition: matrix.cpp:385
bool operator!=(const Matrix &) const
Overload operator !=.
Definition: matrix.cpp:485
bool IsDiagonal(const double tolerance)
Check if the matrix is diagonal.
Definition: matrix.cpp:233
Matrix & operator*=(const double)
Overload operator*=.
Definition: matrix.cpp:427
bool IsZero(const double tolerance)
Check for zero matrix.
Definition: matrix.cpp:260
Matrix & operator+(const double)
Overload operator+.
Definition: matrix.cpp:280
cpl_matrix * GetCplMatrix() const
Get CPL matrix pointer.
void Solve(const Matrix &, Matrix *solved)
Solution of linear system .
Definition: matrix.cpp:167
void Set(cpl_size row, cpl_size col, double value)
Set an element value in the matrix.
Definition: matrix.cpp:103