DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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"
49 
50 namespace DGtal
51 {
52 
54  // template class SimpleMatrix
71  template <typename TComponent, DGtal::Dimension TM, DGtal::Dimension TN>
73  {
74 
75  public:
76  typedef TComponent Component;
77  static const DGtal::Dimension M = TM;
78  static const DGtal::Dimension N = TN;
79 
82 
84 
86  BOOST_STATIC_ASSERT(TM > 0 );
87  BOOST_STATIC_ASSERT(TM > 0 );
88 
95  SimpleMatrix();
96 
102  SimpleMatrix ( const Self & other );
103 
104  // ----------------------- Standard services ------------------------------
105 
110  void clear();
111 
112 
118  void constant(const Component &aScalar);
119 
125  void identity();
126 
133  RowVector row(const DGtal::Dimension i) const;
134 
141  ColumnVector column(const DGtal::Dimension j) const;
142 
151  void setComponent(const DGtal::Dimension i, const DGtal::Dimension j,
152  const Component & aValue);
153 
161  Component operator()(const DGtal::Dimension i, const DGtal::Dimension j) const;
162 
163  // ----------------------- SimpleMatrix computations ------------------------------
164 
165 
172  bool operator==(const Self & aMatrix) const;
173 
183  template<typename TComponentOther>
185 
193  Self operator+(const Self & aMatrix) const;
194 
202  Self & operator+=(const Self & aMatrix);
203 
204 
212  Self operator-(const Self & aMatrix) const;
213 
221  Self & operator-=(const Self & aMatrix);
222 
230  Self operator*(const Component & aScalar) const;
231 
239  Self & operator*=(const Component & aScalar);
240 
248  Self operator/(const Component & aScalar) const;
249 
257  Self & operator/=(const Component & aScalar) ;
258 
268  operator*(const SimpleMatrix<Component,N,M> & aMatrix) const;
269 
270 
279  ColumnVector operator*(const RowVector & aVector) const;
280 
281 
288 
289 
297  const DGtal::Dimension j) const;
298 
299 
306  Self cofactor() const;
307 
321  const DGtal::Dimension j) const;
322 
323 
333  Component determinant() const;
334 
342 
343 
347  ~SimpleMatrix();
348 
349  // ----------------------- Interface --------------------------------------
350  public:
351 
356  void selfDisplay ( std::ostream & out ) const;
357 
362  bool isValid() const;
363 
364  // ------------------------- Protected Datas ------------------------------
365  private:
366 
367 
368  // ------------------------- Private Datas --------------------------------
369  private:
370 
371 #ifdef CPP11_ARRAY
372 
373  std::array< Component, M*N> myValues;
374 
377  std::array< Component, M*N> myCofactorCoefs;
378 #else
379 
380  boost::array< Component, M*N> myValues;
381 
384  boost::array< Component, M*N> myCofactorCoefs;
385 #endif
386  // ------------------------- Hidden services ------------------------------
387  protected:
388 
389  }; // end of class SimpleMatrix
390 
397  template <typename T, DGtal::Dimension M, DGtal::Dimension N>
398  std::ostream&
399  operator<< ( std::ostream & out, const SimpleMatrix<T,M,N> & object );
400 
401 } // namespace DGtal
402 
403 
405 // Includes inline functions.
406 #include "DGtal/kernel/SimpleMatrixSpecializations.h"
407 #include "DGtal/kernel/SimpleMatrix.ih"
408 
409 // //
411 
412 #endif // !defined SimpleMatrix_h
413 
414 #undef SimpleMatrix_RECURSES
415 #endif // else defined(SimpleMatrix_RECURSES)