aimstil  5.0.5
SymMatrix3.h
Go to the documentation of this file.
1 #ifndef TIL_SYMMATRIX3_H
2 #define TIL_SYMMATRIX3_H
3 
4 // Local includes
5 #include "til/til_common.h"
6 #include "til/til_declarations.h"
7 #include "til/Matrix3.h"
8 #include "til/value_proxy.h"
9 
10 
11 // Ignore specific warnings
12 #ifdef _MSC_VER
13 #pragma warning (push)
14 #pragma warning (disable : 4231) // nonstandard extension used : 'extern' before template explicit instantiation
15 #endif
16 
17 // Namespace
18 namespace til {
19  //namespace linalg {
20 
22  template < typename T >
23  class SymMatrix3 : public Matrix3<T>
24  {
25  public: // typedefs
26 
28  typedef Matrix3<T> Base;
29  // TODO: this should actually be const T &. Go and check Matrix3
30  typedef T const_reference;
31  typedef const T * const_pointer;
32  private: // class
33 
34  class ValueProxy;
35 
36  public: // Constructors and destructor
37 
39  SymMatrix3() : Base() { this->reset(); }
40 
43 
45  SymMatrix3(T xx, T xy, T xz, T yy, T yz, T zz)
46  {
47  (*this)(0,0) = xx;
48  (*this)(1,0) = xy;
49  (*this)(2,0) = xz;
50  (*this)(1,1) = yy;
51  (*this)(2,1) = yz;
52  (*this)(2,2) = zz;
53  }
54 
55  public: // operators
56 
58  T operator()(std::size_t i, std::size_t j) const
59  { return this->Base::operator()(i,j); }
60 
62  ValueProxy operator()(std::size_t i, std::size_t j)
63  { return ValueProxy(i,j,*this); }
64 
67  void set(const std::pair<std::size_t, std::size_t> & i, T value)
68  {
69  this->Base::operator()(i.first, i.second) = value;
70  this->Base::operator()(i.second, i.first) = value;
71  }
72 
73  T get(const std::pair<std::size_t, std::size_t> & i)
74  { return this->Base::operator()(i.first, i.second); }
75  };
76 
77  template < typename T>
78  class SymMatrix3<T>::ValueProxy : public value_proxy<SymMatrix3<T>, std::pair<std::size_t,std::size_t> >
79  {
80  public: // typedefs
81  typedef value_proxy<SymMatrix3<T>, std::pair<std::size_t,std::size_t> > Base;
82  typedef typename Base::value_type value_type;
83  public: // constructors
84  ValueProxy(std::size_t i, std::size_t j, SymMatrix3<T> & m) :
85  Base(std::make_pair(i,j), m)
86  {
87  }
88  void operator=(typename boost::call_traits<value_type>::param_type value)
89  {
90  this->Base::operator=(value);
91  }
92  };
93 
94 
95  // EXPIMP_TEMPLATE template class TIL_API SymMatrix3<double>;
96 
97 
98 //} // namespace linalg
99 } // namespace til
100 
101 #ifdef _MSC_VER
102 #pragma warning(pop)
103 #endif
104 
105 // Package includes
106 #include "til/symmatrix3tools.h"
107 
108 #endif
109 
SymMatrix3(T xx, T xy, T xz, T yy, T yz, T zz)
Initialize with elements.
Definition: SymMatrix3.h:45
const T & operator()(std::size_t i, std::size_t j) const
Definition: Matrix3.h:136
Adds some left-value operations to const_value_proxy.
Definition: value_proxy.h:102
A class to store a 3*3 symetric matrix.
Definition: SymMatrix3.h:23
STL namespace.
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
General macros, definitions and functions.
SymMatrix3()
Empty matrix full of zeros.
Definition: SymMatrix3.h:39
This file contains forward declarations of classes defined in the TIL library.
A type used in some construtors to disable initialization.
Definition: til_common.h:85
ValueProxy operator()(std::size_t i, std::size_t j)
get non-const access to value at position (i,j).
Definition: SymMatrix3.h:62
A mathematical matrix.
Definition: Matrix3.h:90
T operator()(std::size_t i, std::size_t j) const
get value at position (i,j).
Definition: SymMatrix3.h:58
Base::value_type value_type
Definition: SymMatrix3.h:82
const T * const_pointer
Definition: SymMatrix3.h:31
value_proxy< SymMatrix3< T >, std::pair< std::size_t, std::size_t > > Base
Definition: SymMatrix3.h:81
SymMatrix3(NoInit)
No initialization.
Definition: SymMatrix3.h:42
SymMatrix3< T > Self
Definition: SymMatrix3.h:27
Matrix3< T > Base
Definition: SymMatrix3.h:28
void operator=(typename boost::call_traits< value_type >::param_type value)
Definition: SymMatrix3.h:88
ValueProxy(std::size_t i, std::size_t j, SymMatrix3< T > &m)
Definition: SymMatrix3.h:84
void reset()
Definition: Matrix3.h:151