5 #include "boost/array.hpp" 16 #pragma warning (push) 17 #pragma warning (disable : 4231) // nonstandard extension used : 'extern' before template explicit instantiation 27 template <
typename TStorage >
35 typedef typename TStorage::range
range;
47 const TStorage &
data()
const {
return m_data; }
48 TStorage &
data() {
return m_data; }
53 const_range
whole_range()
const {
return m_data.whole_range(); }
70 template <
typename TStorage >
72 operator<< (std::ostream & os, const matrix<TStorage> & m)
80 template < std::
size_t D,
typename TPrec >
89 template <
typename T>
110 Matrix3(T xx, T xy, T xz, T yx, T yy, T yz, T zx, T zy, T zz)
140 return m_values[i+3*j];
147 return m_values[i+3*j];
151 void reset() {
for (std::size_t i=0; i<3*3; ++i) m_values[i] = T(); }
153 iterator
begin() {
return m_values.begin(); }
154 iterator
end() {
return m_values.end(); }
155 const_iterator
begin()
const {
return m_values.begin(); }
156 const_iterator
end()
const {
return m_values.end(); }
162 for (
int j = 0; j < 3; ++j)
163 for (
int i = 0; i < 3; ++i)
165 (*this)(i,j) += mat(i,j);
171 for (
int j = 0; j < 3; ++j)
172 for (
int i = 0; i < 3; ++i)
174 (*this)(i,j) -= mat(i,j);
185 template <
typename T >
190 for (
int j = 0; j < 3; ++j)
191 for (
int i = 0; i < 3; ++i)
193 res(i,j) = -mat(i,j);
204 template <
typename T1,
typename T2 >
209 for (std::size_t j = 0; j < 3; ++j)
211 res[j] = m(0,j) * v[0];
212 for (std::size_t i = 1; i < 3; ++i)
214 res[j] += m(i,j) * v[i];
222 template <
typename T1,
typename T2 >
226 for (std::size_t j = 0; j < 3; ++j)
228 res[j] = m(0,j) * v[0];
229 for (std::size_t i = 1; i < 3; ++i)
231 res[j] += m(i,j) * v[i];
239 template <
typename T >
240 inline std::ostream &
241 operator<< (std::ostream & os, const Matrix3<T> & m)
243 for (
int i = 0; i < 3; ++i)
245 os << (i == 0?
"[ " :
" ");
246 for (
int j = 0; j < 3; ++j)
250 os << (i == 2?
"]\n":
"\n");
const_iterator end() const
T & operator()(std::size_t i, std::size_t j)
matrix(const TStorage &data)
Initialization from container.
numeric_array< std::size_t, 2 > dims() const
Returns matrix size.
Data::const_iterator const_iterator
Matrix3< T > operator-(Matrix3< T > const &mat)
const T & operator()(std::size_t i, std::size_t j) const
void operator-=(Self const &mat)
const TStorage & data() const
void operator+=(Self const &mat)
Belongs to package Box Do not include directly, include til/Box.h instead.
const_iterator begin() const
Matrix3(T xx, T xy, T xz, T yx, T yy, T yz, T zx, T zy, T zz)
Initialize with elements.
General macros, definitions and functions.
matrix()
Default contructor.
reference operator()(const numeric_array< std::size_t, 2 > &pos)
TStorage::const_range const_range
boost::array< T, 3 *3 > Data
TStorage::reference reference
const_reference operator()(const numeric_array< std::size_t, 2 > &pos) const
A type used in some construtors to disable initialization.
INLINE numeric_array< typename combine< T1, T2 >::type, 3 > operator*(const Affine< T1 > &a, const numeric_array< T2, 3 > &v)
Multiplication between a 3D affine transform and a 3D vector.
Matrix3()
Empty matrix of zeros.
boost::array< T, 3 > row_type
boost::array< std::size_t, 2 > dims() const
A full, square matrix whose size is known at compile time.
TStorage::value_type value_type
matrix(numeric_array< std::size_t, 2 > dims, value_type v)
Initialization with size and fill value.
matrix(numeric_array< std::size_t, 2 > dims)
Initialization with size.
TStorage::const_reference const_reference
Matrix3(NoInit)
No initialization.
const_range whole_range() const
matrix< multi_array< numeric_array< TPrec, D *D >, D > > type