DGtal 2.1.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
219 void swapRows( const DGtal::Dimension i1, const DGtal::Dimension i2 );
220
221 // ----------------------- SimpleMatrix computations ------------------------------
222
223
230 bool operator==(const Self & aMatrix) const;
231
241 template<typename TComponentOther>
243
251 Self operator+(const Self & aMatrix) const;
252
260 Self & operator+=(const Self & aMatrix);
261
262
270 Self operator-(const Self & aMatrix) const;
271
279 Self & operator-=(const Self & aMatrix);
280
288 Self operator*(const Component & aScalar) const;
289
297 Self & operator*=(const Component & aScalar);
298
306 Self operator/(const Component & aScalar) const;
307
315 Self & operator/=(const Component & aScalar) ;
316
327
328
337 ColumnVector operator*(const RowVector & aVector) const;
338
339
346
347
355 const DGtal::Dimension j) const;
356
357
364 Self cofactor() const;
365
379 const DGtal::Dimension j) const;
380
381
392
400
401
406
407 // ----------------------- Interface --------------------------------------
408 public:
409
414 void selfDisplay ( std::ostream & out ) const;
415
420 bool isValid() const;
421
422 // ------------------------- Protected Datas ------------------------------
423 private:
424
425
426 // ------------------------- Private Datas --------------------------------
427 private:
428
430 std::array< Component, M*N> myValues;
431
434 std::array< Component, M*N> myCofactorCoefs;
435
436 // ------------------------- Hidden services ------------------------------
437 protected:
438
439 }; // end of class SimpleMatrix
440
447 template <typename T, DGtal::Dimension M, DGtal::Dimension N>
448 std::ostream&
449 operator<< ( std::ostream & out, const SimpleMatrix<T,M,N> & object );
450
451
459 template <typename TComponent, DGtal::Dimension TM, DGtal::Dimension TN>
461 operator* ( const TComponent& scalar, const SimpleMatrix<TComponent, TM, TN>& matrix);
462
463} // namespace DGtal
464
465
467// Includes inline functions.
468#include "DGtal/math/linalg/SimpleMatrixSpecializations.h"
469#include "DGtal/math/linalg/SimpleMatrix.ih"
470
471// //
473
474#endif // !defined SimpleMatrix_h
475
476#undef SimpleMatrix_RECURSES
477#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
void swapRows(const DGtal::Dimension i1, const DGtal::Dimension i2)
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:119
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...