ifw-odp 5.0.0
Loading...
Searching...
No Matches
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
24
25
26namespace ifw::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
This class handle the errors produced by the calling of image processing routines.
Definition error.hpp:35
This class is C++ wrapper for a CPL matrix object. It provides a simplified interface that allows to ...
Definition matrix.hpp:39
Matrix & operator-(const double)
Overload operator-.
Definition matrix.cpp:277
bool IsDiagonal(const double tolerance)
Check if the matrix is diagonal.
Definition matrix.cpp:212
friend std::ostream & operator<<(std::ostream &os, const Matrix &matrix)
Overload operator<<.
Definition matrix.cpp:483
Matrix & operator*(const double)
Overload operator*.
Definition matrix.cpp:313
Matrix & operator-=(const double)
Overload operator-=.
Definition matrix.cpp:351
void Invert(Matrix *inverse)
Find a matrix inverse.
Definition matrix.cpp:186
void Solve(const Matrix &, Matrix *solved)
Solution of linear system .
Definition matrix.cpp:154
void Transpose(Matrix *transpose)
Create transposed matrix.
Definition matrix.cpp:138
Matrix & operator*=(const double)
Overload operator*=.
Definition matrix.cpp:389
std::string GetSize() const
Get the size of the matrix in the format [row]x[col].
Definition matrix.cpp:106
Matrix & Sqrt(const Matrix &matrix)
It computes the sqrt of each element in the matrix.
Definition matrix.cpp:468
void Product(const Matrix &, Matrix *product)
Rows-by-columns product of two matrices.
Definition matrix.cpp:116
Matrix & operator=(const Matrix &)
Overload operator=.
Definition matrix.cpp:409
virtual ~Matrix()
Class destructor.
Definition matrix.cpp:56
cpl_size GetNumRows() const
Get number of rows.
cpl_matrix * GetCplMatrix() const
Get CPL matrix pointer.
Matrix & operator+=(const double)
Overload operator+=.
Definition matrix.cpp:332
bool IsMatrix() const
Check is CPL matrix is not null.
bool IsIdentity(const double tolerance)
Check for identity matrix.
Definition matrix.cpp:225
Matrix & operator/=(const double)
Overload operator/=.
Definition matrix.cpp:370
void Append(const Matrix &matrix, int mode)
Append a matrix to another.
Definition matrix.cpp:201
void SetCplMatrix(cpl_matrix *matrix)
Set CPL image.
void SolveNormal(const Matrix &, Matrix *solved)
Solution of overdetermined linear equations in a least squares sense.
Definition matrix.cpp:170
void Set(cpl_size row, cpl_size col, double value)
Set an element value in the matrix.
Definition matrix.cpp:96
Matrix()
Class constructor.
Definition matrix.cpp:22
Matrix & operator/(const double)
Overload operator/.
Definition matrix.cpp:295
cpl_size GetNumCols() const
Get number of matrix columns.
bool operator==(const Matrix &) const
Overload operator==.
Definition matrix.cpp:421
cpl_matrix * m_cpl_matrix
Definition matrix.hpp:515
bool operator!=(const Matrix &) const
Overload operator !=.
Definition matrix.cpp:444
Matrix & operator+(const double)
Overload operator+.
Definition matrix.cpp:256
void * GetMatrixPtr() const
Get pointer to matrix data.
void Get(cpl_size row, cpl_size col, double *value) const
Get value of an element in the matrix.
Definition matrix.cpp:69
bool IsZero(const double tolerance)
Check for zero matrix.
Definition matrix.cpp:237
Error class header file.
Definition array.cpp:16