DGtal 1.4.0
Loading...
Searching...
No Matches
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)
35#define SimpleMatrix_RECURSES
36
37#if !defined SimpleMatrix_h
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
51namespace 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
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
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)
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: implements basic MxN Matrix services (M,N>=1).
SimpleMatrix(std::initializer_list< TComponent > values)
Self & operator*=(const Component &aScalar)
std::array< Component, M *N > myCofactorCoefs
Component minorDeterminant(const DGtal::Dimension i, const DGtal::Dimension j) const
Component & operator()(const DGtal::Dimension i, const DGtal::Dimension j)
Index rows() const
SimpleMatrix< Component, TM, TN > inverse() const
Component determinant() const
SimpleMatrix< Component, TM, TN > Self
static const DGtal::Dimension M
ColumnVector column(const DGtal::Dimension j) const
Self cofactor() const
ColumnVector operator*(const RowVector &aVector) const
Self & operator=(const SimpleMatrix< TComponentOther, M, N > &aMatrix)
SimpleMatrix< Component, TN, TM > transpose() const
Self operator+(const Self &aMatrix) const
Self & operator-=(const Self &aMatrix)
Component operator()(const DGtal::Dimension i, const DGtal::Dimension j) const
Self operator/(const Component &aScalar) const
SimpleMatrix & operator=(const Self &other)=default
RowVector row(const DGtal::Dimension i) const
static const DGtal::Dimension N
Self & operator+=(const Self &aMatrix)
void selfDisplay(std::ostream &out) const
Component cofactor(const DGtal::Dimension i, const DGtal::Dimension j) const
void setComponent(const DGtal::Dimension i, const DGtal::Dimension j, const Component &aValue)
bool isValid() const
void constant(const Component &aScalar)
Self operator*(const Component &aScalar) const
std::array< Component, M *N > myValues
Matrix values containers.
SimpleMatrix(const Self &other)
SimpleMatrix< Component, TM, TM > operator*(const SimpleMatrix< Component, N, M > &aMatrix) const
Index cols() const
PointVector< M, Component > ColumnVector
BOOST_CONCEPT_ASSERT((concepts::CEuclideanRing< TComponent >))
Dimension Index
Types needed by CLinearAlgebraContainer.
Self operator-(const Self &aMatrix) const
Self & operator/=(const Component &aScalar)
bool operator==(const Self &aMatrix) const
BOOST_STATIC_ASSERT(TM > 0)
PointVector< N, Component > RowVector
DGtal is the top-level namespace which contains all DGtal functions and types.
KForm< Calculus, order, duality > operator*(const typename Calculus::Scalar &scalar, const KForm< Calculus, order, duality > &form)
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::uint32_t Dimension
Definition Common.h:136
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...