Matrix.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_MATRIX_H
12 #define EIGEN_MATRIX_H
13 
14 namespace Eigen {
15 
104 namespace internal {
105 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
106 struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
107 {
108  typedef _Scalar Scalar;
110  typedef DenseIndex Index;
112  enum {
113  RowsAtCompileTime = _Rows,
114  ColsAtCompileTime = _Cols,
115  MaxRowsAtCompileTime = _MaxRows,
116  MaxColsAtCompileTime = _MaxCols,
119  Options = _Options,
120  InnerStrideAtCompileTime = 1,
121  OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime
122  };
123 };
124 }
125 
126 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
127 class Matrix
128  : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
129 {
130  public:
131 
136 
137  enum { Options = _Options };
138 
140 
141  typedef typename Base::PlainObject PlainObject;
142 
143  using Base::base;
144  using Base::coeffRef;
145 
154  EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)
155  {
156  return Base::_set(other);
157  }
158 
169  template<typename OtherDerived>
171  {
172  return Base::_set(other);
173  }
174 
175  /* Here, doxygen failed to copy the brief information when using \copydoc */
176 
181  template<typename OtherDerived>
183  {
184  return Base::operator=(other);
185  }
186 
187  template<typename OtherDerived>
189  {
190  return Base::operator=(func);
191  }
192 
204  {
205  Base::_check_template_params();
207  }
208 
209  // FIXME is it still needed
211  : Base(internal::constructor_without_unaligned_array_assert())
212  { Base::_check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
213 
221  : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
222  {
223  Base::_check_template_params();
225  eigen_assert(dim >= 0);
226  eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
228  }
229 
230  #ifndef EIGEN_PARSED_BY_DOXYGEN
231  template<typename T0, typename T1>
232  EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
233  {
234  Base::_check_template_params();
235  Base::template _init2<T0,T1>(x, y);
236  }
237  #else
238 
243  Matrix(Index rows, Index cols);
245  Matrix(const Scalar& x, const Scalar& y);
246  #endif
247 
249  EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
250  {
251  Base::_check_template_params();
253  m_storage.data()[0] = x;
254  m_storage.data()[1] = y;
255  m_storage.data()[2] = z;
256  }
258  EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
259  {
260  Base::_check_template_params();
262  m_storage.data()[0] = x;
263  m_storage.data()[1] = y;
264  m_storage.data()[2] = z;
265  m_storage.data()[3] = w;
266  }
267 
268  explicit Matrix(const Scalar *data);
269 
271  template<typename OtherDerived>
273  : Base(other.rows() * other.cols(), other.rows(), other.cols())
274  {
275  // This test resides here, to bring the error messages closer to the user. Normally, these checks
276  // are performed deeply within the library, thus causing long and scary error traces.
278  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
279 
280  Base::_check_template_params();
281  Base::_set_noalias(other);
282  }
284  EIGEN_STRONG_INLINE Matrix(const Matrix& other)
285  : Base(other.rows() * other.cols(), other.rows(), other.cols())
286  {
287  Base::_check_template_params();
288  Base::_set_noalias(other);
289  }
291  template<typename OtherDerived>
293  {
294  Base::_check_template_params();
295  Base::resize(other.rows(), other.cols());
296  other.evalTo(*this);
297  }
298 
302  template<typename OtherDerived>
304  : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
305  {
306  Base::_check_template_params();
307  Base::resize(other.rows(), other.cols());
308  // FIXME/CHECK: isn't *this = other.derived() more efficient. it allows to
309  // go for pure _set() implementations, right?
310  *this = other;
311  }
312 
317  template<typename OtherDerived>
318  void swap(MatrixBase<OtherDerived> const & other)
319  { this->_swap(other.derived()); }
320 
321  inline Index innerStride() const { return 1; }
322  inline Index outerStride() const { return this->innerSize(); }
323 
325 
326  template<typename OtherDerived>
327  explicit Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
328  template<typename OtherDerived>
329  Matrix& operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r);
330 
331  #ifdef EIGEN2_SUPPORT
332  template<typename OtherDerived>
333  explicit Matrix(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
334  template<typename OtherDerived>
335  Matrix& operator=(const eigen2_RotationBase<OtherDerived,ColsAtCompileTime>& r);
336  #endif
337 
338  // allow to extend Matrix outside Eigen
339  #ifdef EIGEN_MATRIX_PLUGIN
340  #include EIGEN_MATRIX_PLUGIN
341  #endif
342 
343  protected:
344  template <typename Derived, typename OtherDerived, bool IsVector>
346 
347  using Base::m_storage;
348 };
349 
370 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
371  \
372 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
373  \
374 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
375  \
376 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
377 
378 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
379  \
380 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \
381  \
382 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;
383 
384 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
385 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
386 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
387 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
388 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
389 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
390 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
391 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
392 
396 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
397 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
398 
399 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
400 #undef EIGEN_MAKE_TYPEDEFS
401 #undef EIGEN_MAKE_FIXED_TYPEDEFS
402 
403 } // end namespace Eigen
404 
405 #endif // EIGEN_MATRIX_H
internal::traits< Derived >::Scalar Scalar
#define EIGEN_STRONG_INLINE
EIGEN_STRONG_INLINE Matrix(const MatrixBase< OtherDerived > &other)
Constructor copying the value of the expression other.
Definition: Matrix.h:272
Index innerStride() const
Definition: Matrix.h:321
Index outerStride() const
Definition: Matrix.h:322
void swap(MatrixBase< OtherDerived > const &other)
Definition: Matrix.h:318
internal::traits< Derived >::Index Index
Definition: LDLT.h:16
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:111
Index rows() const
Definition: EigenBase.h:44
EIGEN_STRONG_INLINE Matrix(Index dim)
Constructs a vector or row-vector with given dimension. .
Definition: Matrix.h:220
EIGEN_STRONG_INLINE Matrix(const T0 &x, const T1 &y)
Definition: Matrix.h:232
Index cols() const
Definition: ReturnByValue.h:63
EIGEN_STRONG_INLINE Matrix(const Scalar &x, const Scalar &y, const Scalar &z)
Constructs an initialized 3D vector with given coefficients.
Definition: Matrix.h:249
Index rows() const
Definition: ReturnByValue.h:62
EIGEN_STRONG_INLINE Matrix(const Matrix &other)
Copy constructor.
Definition: Matrix.h:284
Matrix(internal::constructor_without_unaligned_array_assert)
Definition: Matrix.h:210
EIGEN_STRONG_INLINE Matrix()
Default constructor.
Definition: Matrix.h:203
EIGEN_STRONG_INLINE Matrix(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition: Matrix.h:292
Dense storage base class for matrices and arrays.
Common base class for compact rotation representations.
TFSIMD_FORCE_INLINE const tfScalar & x() const
EIGEN_STRONG_INLINE Matrix(const Scalar &x, const Scalar &y, const Scalar &z, const Scalar &w)
Constructs an initialized 4D vector with given coefficients.
Definition: Matrix.h:258
EIGEN_STRONG_INLINE Matrix(const EigenBase< OtherDerived > &other)
Copy constructor for generic expressions.
Definition: Matrix.h:303
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: XprHelper.h:27
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Index cols() const
Definition: EigenBase.h:46
const Scalar & y
EIGEN_STRONG_INLINE Matrix & operator=(const MatrixBase< OtherDerived > &other)
Definition: Matrix.h:170
#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
const int Dynamic
Definition: Constants.h:21
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
#define eigen_assert(x)
EIGEN_STRONG_INLINE Matrix & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition: Matrix.h:182
#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix)
Definition: Matrix.h:384
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:126
void evalTo(Dest &dst) const
Definition: ReturnByValue.h:60
PlainObjectBase< Matrix > Base
Base class typedef.
Definition: Matrix.h:135
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
EIGEN_STRONG_INLINE Matrix & operator=(const ReturnByValue< OtherDerived > &func)
Definition: Matrix.h:188
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:141


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:53