DGtal  1.1.0
SimpleMatrix.h
1
17 #pragma once
18
31 #if defined(SimpleMatrix_RECURSES)
32 #error Recursive header files inclusion detected in SimpleMatrix.h
33 #else // defined(SimpleMatrix_RECURSES)
34
35 #define SimpleMatrix_RECURSES
36
37 #if !defined SimpleMatrix_h
38
39 #define SimpleMatrix_h
40
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/kernel/CEuclideanRing.h"
46 #include "DGtal/kernel/PointVector.h"
47 #include "DGtal/kernel/NumberTraits.h"
48 #include <array>
50
51 namespace DGtal
52 {
53
55  // template class SimpleMatrix
74  template <typename TComponent, DGtal::Dimension TM, DGtal::Dimension TN>
76  {
77
78  public:
79  typedef TComponent Component;
80  static const DGtal::Dimension M = TM;
81  static const DGtal::Dimension N = TN;
82
85
87
89  typedef Dimension Index;
90  typedef Component Scalar;
91
95
103
114  SimpleMatrix( std::initializer_list<TComponent> values );
115
121  SimpleMatrix ( const Self & other );
122
128  SimpleMatrix &operator=( const Self & other ) = default;
129
130  // ----------------------- Standard services ------------------------------
131
136  void clear();
137
138
144  void constant(const Component &aScalar);
145
151  void identity();
152  inline void setIdentity() { identity(); }
153
161
166  inline Index rows() const { return M; }
167
175
180  inline Index cols() const { return N; }
181
193  const Component & aValue);
194
203
212
213  // ----------------------- SimpleMatrix computations ------------------------------
214
215
222  bool operator==(const Self & aMatrix) const;
223
233  template<typename TComponentOther>
235
243  Self operator+(const Self & aMatrix) const;
244
252  Self & operator+=(const Self & aMatrix);
253
254
262  Self operator-(const Self & aMatrix) const;
263
271  Self & operator-=(const Self & aMatrix);
272
280  Self operator*(const Component & aScalar) const;
281
289  Self & operator*=(const Component & aScalar);
290
298  Self operator/(const Component & aScalar) const;
299
307  Self & operator/=(const Component & aScalar) ;
308
318  operator*(const SimpleMatrix<Component,N,M> & aMatrix) const;
319
320
329  ColumnVector operator*(const RowVector & aVector) const;
330
331
338
339
347  const DGtal::Dimension j) const;
348
349
356  Self cofactor() const;
357
371  const DGtal::Dimension j) const;
372
373
384
392
393
398
399  // ----------------------- Interface --------------------------------------
400  public:
401
406  void selfDisplay ( std::ostream & out ) const;
407
412  bool isValid() const;
413
414  // ------------------------- Protected Datas ------------------------------
415  private:
416
417
418  // ------------------------- Private Datas --------------------------------
419  private:
420
422  std::array< Component, M*N> myValues;
423
426  std::array< Component, M*N> myCofactorCoefs;
427
428  // ------------------------- Hidden services ------------------------------
429  protected:
430
431  }; // end of class SimpleMatrix
432
439  template <typename T, DGtal::Dimension M, DGtal::Dimension N>
440  std::ostream&
441  operator<< ( std::ostream & out, const SimpleMatrix<T,M,N> & object );
442
443
447  template <typename TComponent, DGtal::Dimension TM, DGtal::Dimension TN>
449  operator* ( const TComponent& scalar, const SimpleMatrix<TComponent, TM, TN>& matrix);
450
451 } // namespace DGtal
452
453
455 // Includes inline functions.
456 #include "DGtal/math/linalg/SimpleMatrixSpecializations.h"
457 #include "DGtal/math/linalg/SimpleMatrix.ih"
458
459 // //
461
462 #endif // !defined SimpleMatrix_h
463
464 #undef SimpleMatrix_RECURSES
465 #endif // else defined(SimpleMatrix_RECURSES)
DGtal::SimpleMatrix::operator*
SimpleMatrix< Component, TM, TM > operator*(const SimpleMatrix< Component, N, M > &aMatrix) const
DGtal::SimpleMatrix::RowVector
PointVector< N, Component > RowVector
Definition: SimpleMatrix.h:83
DGtal::SimpleMatrix::operator()
Component operator()(const DGtal::Dimension i, const DGtal::Dimension j) const
DGtal::SimpleMatrix::operator()
Component & operator()(const DGtal::Dimension i, const DGtal::Dimension j)
DGtal::SimpleMatrix::isValid
bool isValid() const
DGtal::SimpleMatrix::operator+=
Self & operator+=(const Self &aMatrix)
DGtal::SimpleMatrix::cols
Index cols() const
Definition: SimpleMatrix.h:180
DGtal::SimpleMatrix::transpose
SimpleMatrix< Component, TN, TM > transpose() const
DGtal::SimpleMatrix::operator*
ColumnVector operator*(const RowVector &aVector) const
DGtal::SimpleMatrix::minorDeterminant
Component minorDeterminant(const DGtal::Dimension i, const DGtal::Dimension j) const
DGtal::SimpleMatrix::rows
Index rows() const
Definition: SimpleMatrix.h:166
DGtal::SimpleMatrix::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT(TM > 0)
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:133
DGtal::SimpleMatrix::setComponent
void setComponent(const DGtal::Dimension i, const DGtal::Dimension j, const Component &aValue)
DGtal::SimpleMatrix::operator-
Self operator-(const Self &aMatrix) const
DGtal::SimpleMatrix::operator*=
Self & operator*=(const Component &aScalar)
DGtal::SimpleMatrix::cofactor
Component cofactor(const DGtal::Dimension i, const DGtal::Dimension j) const
DGtal::SimpleMatrix::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CEuclideanRing< TComponent >))
DGtal::SimpleMatrix::inverse
SimpleMatrix< Component, TM, TN > inverse() const
DGtal::SimpleMatrix::SimpleMatrix
SimpleMatrix(const Self &other)
DGtal::SimpleMatrix::operator/
Self operator/(const Component &aScalar) const
DGtal::SimpleMatrix::setIdentity
void setIdentity()
Definition: SimpleMatrix.h:152
DGtal::SimpleMatrix::column
ColumnVector column(const DGtal::Dimension j) const
DGtal::SimpleMatrix
Aim: implements basic MxN Matrix services (M,N>=1).
Definition: SimpleMatrix.h:76
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::SimpleMatrix::N
static const DGtal::Dimension N
Definition: SimpleMatrix.h:81
DGtal::SimpleMatrix::operator+
Self operator+(const Self &aMatrix) const
DGtal::SimpleMatrix::identity
void identity()
DGtal::SimpleMatrix::myCofactorCoefs
std::array< Component, M *N > myCofactorCoefs
Definition: SimpleMatrix.h:426
DGtal::SimpleMatrix::operator*
Self operator*(const Component &aScalar) const
DGtal::concepts::CEuclideanRing
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...
Definition: CEuclideanRing.h:88
DGtal::SimpleMatrix::SimpleMatrix
SimpleMatrix(std::initializer_list< TComponent > values)
DGtal::SimpleMatrix::row
RowVector row(const DGtal::Dimension i) const
DGtal::SimpleMatrix::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::SimpleMatrix::myValues
std::array< Component, M *N > myValues
Matrix values containers.
Definition: SimpleMatrix.h:422
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::SimpleMatrix::operator=
Self & operator=(const SimpleMatrix< TComponentOther, M, N > &aMatrix)
DGtal::SimpleMatrix::clear
void clear()
DGtal::SimpleMatrix::operator=
SimpleMatrix & operator=(const Self &other)=default
DGtal::SimpleMatrix::Component
TComponent Component
Definition: SimpleMatrix.h:79
DGtal::SimpleMatrix::SimpleMatrix
SimpleMatrix()
DGtal::SimpleMatrix::~SimpleMatrix
~SimpleMatrix()
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal::SimpleMatrix::Self
SimpleMatrix< Component, TM, TN > Self
Definition: SimpleMatrix.h:86
DGtal::SimpleMatrix::determinant
Component determinant() const
DGtal::operator*
KForm< Calculus, order, duality > operator*(const typename Calculus::Scalar &scalar, const KForm< Calculus, order, duality > &form)
DGtal::SimpleMatrix::cofactor
Self cofactor() const
DGtal::SimpleMatrix::Scalar
Component Scalar
Definition: SimpleMatrix.h:90
DGtal::SimpleMatrix::operator/=
Self & operator/=(const Component &aScalar)
DGtal::SimpleMatrix::M
static const DGtal::Dimension M
Definition: SimpleMatrix.h:80
DGtal::SimpleMatrix::ColumnVector
PointVector< M, Component > ColumnVector
Definition: SimpleMatrix.h:84
DGtal::SimpleMatrix::operator==
bool operator==(const Self &aMatrix) const
DGtal::SimpleMatrix::Index
Dimension Index
Types needed by CLinearAlgebraContainer.
Definition: SimpleMatrix.h:89
DGtal::SimpleMatrix::operator-=
Self & operator-=(const Self &aMatrix)
DGtal::SimpleMatrix::constant
void constant(const Component &aScalar)