3rdparty/Eigen/Eigen/src/Core/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 
16 namespace internal {
17 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
18 struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
19 {
20 private:
23  enum {
24  row_major_bit = _Options&RowMajor ? RowMajorBit : 0,
25  is_dynamic_size_storage = _MaxRows==Dynamic || _MaxCols==Dynamic,
26  max_size = is_dynamic_size_storage ? Dynamic : _MaxRows*_MaxCols,
28  actual_alignment = ((_Options&DontAlign)==0) ? default_alignment : 0,
30  packet_access_bit = (packet_traits<_Scalar>::Vectorizable && (EIGEN_UNALIGNED_VECTORIZE || (actual_alignment>=required_alignment))) ? PacketAccessBit : 0
31  };
32 
33 public:
34  typedef _Scalar Scalar;
35  typedef Dense StorageKind;
37  typedef MatrixXpr XprKind;
38  enum {
39  RowsAtCompileTime = _Rows,
40  ColsAtCompileTime = _Cols,
41  MaxRowsAtCompileTime = _MaxRows,
42  MaxColsAtCompileTime = _MaxCols,
44  Options = _Options,
45  InnerStrideAtCompileTime = 1,
46  OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime,
47 
48  // FIXME, the following flag in only used to define NeedsToAlign in PlainObjectBase
49  EvaluatorFlags = LinearAccessBit | DirectAccessBit | packet_access_bit | row_major_bit,
50  Alignment = actual_alignment
51  };
52 };
53 }
54 
177 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
178 class Matrix
179  : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
180 {
181  public:
182 
187 
188  enum { Options = _Options };
189 
191 
192  typedef typename Base::PlainObject PlainObject;
193 
194  using Base::base;
195  using Base::coeffRef;
196 
205  EIGEN_DEVICE_FUNC
206  EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)
207  {
208  return Base::_set(other);
209  }
210 
221  template<typename OtherDerived>
222  EIGEN_DEVICE_FUNC
224  {
225  return Base::_set(other);
226  }
227 
228  /* Here, doxygen failed to copy the brief information when using \copydoc */
229 
234  template<typename OtherDerived>
235  EIGEN_DEVICE_FUNC
237  {
238  return Base::operator=(other);
239  }
240 
241  template<typename OtherDerived>
242  EIGEN_DEVICE_FUNC
244  {
245  return Base::operator=(func);
246  }
247 
258  EIGEN_DEVICE_FUNC
260  {
261  Base::_check_template_params();
263  }
264 
265  // FIXME is it still needed
266  EIGEN_DEVICE_FUNC
268  : Base(internal::constructor_without_unaligned_array_assert())
269  { Base::_check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
270 
271 #if EIGEN_HAS_RVALUE_REFERENCES
272  EIGEN_DEVICE_FUNC
274  : Base(std::move(other))
275  {
276  Base::_check_template_params();
277  }
278  EIGEN_DEVICE_FUNC
280  {
281  other.swap(*this);
282  return *this;
283  }
284 #endif
285 
286  #ifndef EIGEN_PARSED_BY_DOXYGEN
287 
288  // This constructor is for both 1x1 matrices and dynamic vectors
289  template<typename T>
290  EIGEN_DEVICE_FUNC
291  EIGEN_STRONG_INLINE explicit Matrix(const T& x)
292  {
293  Base::_check_template_params();
294  Base::template _init1<T>(x);
295  }
296 
297  template<typename T0, typename T1>
298  EIGEN_DEVICE_FUNC
299  EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
300  {
301  Base::_check_template_params();
302  Base::template _init2<T0,T1>(x, y);
303  }
304  #else
305 
306  EIGEN_DEVICE_FUNC
307  explicit Matrix(const Scalar *data);
308 
323  Matrix(const Scalar& x);
336  EIGEN_DEVICE_FUNC
338 
340  Matrix(const Scalar& x, const Scalar& y);
341  #endif
342 
344  EIGEN_DEVICE_FUNC
345  EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
346  {
347  Base::_check_template_params();
349  m_storage.data()[0] = x;
350  m_storage.data()[1] = y;
351  m_storage.data()[2] = z;
352  }
354  EIGEN_DEVICE_FUNC
355  EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
356  {
357  Base::_check_template_params();
359  m_storage.data()[0] = x;
360  m_storage.data()[1] = y;
361  m_storage.data()[2] = z;
362  m_storage.data()[3] = w;
363  }
364 
365 
367  EIGEN_DEVICE_FUNC
368  EIGEN_STRONG_INLINE Matrix(const Matrix& other) : Base(other)
369  { }
370 
374  template<typename OtherDerived>
375  EIGEN_DEVICE_FUNC
377  : Base(other.derived())
378  { }
379 
380  EIGEN_DEVICE_FUNC inline Index innerStride() const { return 1; }
381  EIGEN_DEVICE_FUNC inline Index outerStride() const { return this->innerSize(); }
382 
384 
385  template<typename OtherDerived>
386  EIGEN_DEVICE_FUNC
388  template<typename OtherDerived>
389  EIGEN_DEVICE_FUNC
391 
392  // allow to extend Matrix outside Eigen
393  #ifdef EIGEN_MATRIX_PLUGIN
394  #include EIGEN_MATRIX_PLUGIN
395  #endif
396 
397  protected:
398  template <typename Derived, typename OtherDerived, bool IsVector>
400 
401  using Base::m_storage;
402 };
403 
424 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
425  \
426 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
427  \
428 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
429  \
430 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
431 
432 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
433  \
434 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \
435  \
436 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;
437 
438 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
439 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
440 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
441 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
442 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
443 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
444 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
445 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
446 
452 
453 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
454 #undef EIGEN_MAKE_TYPEDEFS
455 #undef EIGEN_MAKE_FIXED_TYPEDEFS
456 
457 } // end namespace Eigen
458 
459 #endif // EIGEN_MATRIX_H
find_best_packet_helper< Size, typename packet_traits< T >::type >::type type
Definition: XprHelper.h:188
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const T &x)
EIGEN_DEVICE_FUNC Matrix(internal::constructor_without_unaligned_array_assert)
internal::traits< Derived >::Scalar Scalar
#define EIGEN_STRONG_INLINE
Definition: Macros.h:494
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const Scalar &x, const Scalar &y, const Scalar &z)
Constructs an initialized 3D vector with given coefficients.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const Matrix &other)
Copy constructor.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const T0 &x, const T1 &y)
const unsigned int DirectAccessBit
Definition: Constants.h:150
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Definition: Half.h:150
const unsigned int RowMajorBit
Definition: Constants.h:61
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
const unsigned int PacketAccessBit
Definition: Constants.h:89
#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix)
#define EIGEN_NOEXCEPT_IF(x)
Definition: Macros.h:990
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix & operator=(const ReturnByValue< OtherDerived > &func)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix()
Default constructor.
EIGEN_DEVICE_FUNC Index outerStride() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
int data[]
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Common base class for compact rotation representations.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const EigenBase< OtherDerived > &other)
Copy constructor for generic expressions.
RowVector3d w
const mpreal dim(const mpreal &a, const mpreal &b, mp_rnd_t r=mpreal::get_default_rnd())
Definition: mpreal.h:2201
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:870
#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix & operator=(const DenseBase< OtherDerived > &other)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Annotation indicating that a class derives from another given type.
Definition: attr.h:42
const int Dynamic
Definition: Constants.h:21
Pose2 T1(M_PI/4.0, Point2(sqrt(0.5), sqrt(0.5)))
The matrix class, also used for vectors and row-vectors.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
PlainObjectBase< Matrix > Base
Base class typedef.
EIGEN_DEVICE_FUNC Index innerStride() const
const unsigned int LinearAccessBit
Definition: Constants.h:125
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Matrix(const Scalar &x, const Scalar &y, const Scalar &z, const Scalar &w)
Constructs an initialized 4D vector with given coefficients.
#define EIGEN_UNALIGNED_VECTORIZE
Definition: Macros.h:786
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:154


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:47