11 #ifndef EIGEN_MATRIX_H
12 #define EIGEN_MATRIX_H
14 #include "./InternalHeaderCheck.h"
19 template<
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
20 struct traits<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >
23 constexpr
static int size = internal::size_at_compile_time(Rows_,Cols_);
24 typedef typename find_best_packet<Scalar_,size>::type PacketScalar;
28 max_size = is_dynamic_size_storage ?
Dynamic : MaxRows_*MaxCols_,
29 default_alignment = compute_default_alignment<Scalar_,max_size>::value,
30 actual_alignment = ((Options_&
DontAlign)==0) ? default_alignment : 0,
31 required_alignment = unpacket_traits<PacketScalar>::alignment,
32 packet_access_bit = (packet_traits<Scalar_>::Vectorizable && (EIGEN_UNALIGNED_VECTORIZE || (actual_alignment>=required_alignment))) ?
PacketAccessBit : 0
36 typedef Scalar_ Scalar;
37 typedef Dense StorageKind;
39 typedef MatrixXpr XprKind;
41 RowsAtCompileTime = Rows_,
42 ColsAtCompileTime = Cols_,
43 MaxRowsAtCompileTime = MaxRows_,
44 MaxColsAtCompileTime = MaxCols_,
45 Flags = compute_matrix_flags(Options_),
47 InnerStrideAtCompileTime = 1,
48 OuterStrideAtCompileTime = (Options&
RowMajor) ? ColsAtCompileTime : RowsAtCompileTime,
52 Alignment = actual_alignment
179 template<
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
181 :
public PlainObjectBase<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >
190 enum { Options = Options_ };
192 EIGEN_DENSE_PUBLIC_INTERFACE(
Matrix)
194 typedef typename Base::PlainObject PlainObject;
223 template<
typename OtherDerived>
236 template<
typename OtherDerived>
243 template<
typename OtherDerived>
245 EIGEN_STRONG_INLINE
Matrix&
operator=(
const ReturnByValue<OtherDerived>& func)
260 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
263 EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
267 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
268 explicit Matrix(internal::constructor_without_unaligned_array_assert)
269 :
Base(internal::constructor_without_unaligned_array_assert())
270 { EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
272 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
273 Matrix(
Matrix&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value)
274 :
Base(std::move(other)) {}
275 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
289 template <
typename... ArgTypes>
290 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
292 : Base(a0, a1, a2, a3, args...) {}
316 explicit EIGEN_STRONG_INLINE
Matrix(
const std::initializer_list<std::initializer_list<Scalar>>& list) : Base(list) {}
318 #ifndef EIGEN_PARSED_BY_DOXYGEN
322 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
325 Base::template _init1<T>(
x);
328 template<
typename T0,
typename T1>
329 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
332 Base::template _init2<T0,T1>(
x,
y);
383 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Matrix, 3)
384 m_storage.data()[0] =
x;
385 m_storage.data()[1] =
y;
386 m_storage.data()[2] =
z;
394 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Matrix, 4)
395 m_storage.data()[0] =
x;
396 m_storage.data()[1] =
y;
397 m_storage.data()[2] =
z;
398 m_storage.data()[3] =
w;
410 template<
typename OtherDerived>
416 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
417 inline Index innerStride() const EIGEN_NOEXCEPT {
return 1; }
418 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
419 inline Index outerStride() const EIGEN_NOEXCEPT {
return this->
innerSize(); }
423 template<
typename OtherDerived>
425 explicit Matrix(
const RotationBase<OtherDerived,ColsAtCompileTime>& r);
426 template<
typename OtherDerived>
428 Matrix&
operator=(
const RotationBase<OtherDerived,ColsAtCompileTime>& r);
431 #ifdef EIGEN_MATRIX_PLUGIN
432 #include EIGEN_MATRIX_PLUGIN
436 template <
typename Derived,
typename OtherDerived,
bool IsVector>
437 friend struct internal::conservative_resize_like_impl;
439 using Base::m_storage;
471 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
474 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
477 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
480 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
482 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
485 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \
488 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;
490 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
491 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
492 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
493 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
494 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
495 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
496 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
497 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
499 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
int, i)
500 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
float, f)
501 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
double, d)
502 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<
float>, cf)
503 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<
double>, cd)
505 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
506 #undef EIGEN_MAKE_TYPEDEFS
507 #undef EIGEN_MAKE_FIXED_TYPEDEFS
509 #define EIGEN_MAKE_TYPEDEFS(Size, SizeSuffix) \
512 template <typename Type> \
513 using Matrix##SizeSuffix = Matrix<Type, Size, Size>; \
516 template <typename Type> \
517 using Vector##SizeSuffix = Matrix<Type, Size, 1>; \
520 template <typename Type> \
521 using RowVector##SizeSuffix = Matrix<Type, 1, Size>;
523 #define EIGEN_MAKE_FIXED_TYPEDEFS(Size) \
526 template <typename Type> \
527 using Matrix##Size##X = Matrix<Type, Size, Dynamic>; \
530 template <typename Type> \
531 using Matrix##X##Size = Matrix<Type, Dynamic, Size>;
533 EIGEN_MAKE_TYPEDEFS(2, 2)
534 EIGEN_MAKE_TYPEDEFS(3, 3)
535 EIGEN_MAKE_TYPEDEFS(4, 4)
537 EIGEN_MAKE_FIXED_TYPEDEFS(2)
538 EIGEN_MAKE_FIXED_TYPEDEFS(3)
539 EIGEN_MAKE_FIXED_TYPEDEFS(4)
543 template <typename Type,
int Size>
548 template <typename Type,
int Size>
551 #undef EIGEN_MAKE_TYPEDEFS
552 #undef EIGEN_MAKE_FIXED_TYPEDEFS
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
EIGEN_CONSTEXPR Index innerSize() const
Definition: DenseBase.h:224
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
Derived & derived()
Definition: EigenBase.h:48
Scalar & z()
Definition: DenseCoeffsBase.h:453
Scalar & x()
Definition: DenseCoeffsBase.h:437
Scalar & w()
Definition: DenseCoeffsBase.h:463
Scalar & y()
Definition: DenseCoeffsBase.h:443
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Matrix(const std::initializer_list< std::initializer_list< Scalar >> &list)
Constructs a Matrix and initializes it from the coefficients given as initializer-lists grouped by ro...
Definition: Matrix.h:316
Matrix(const Scalar &x, const Scalar &y, const Scalar &z)
Constructs an initialized 3D vector with given coefficients.
Definition: Matrix.h:381
Matrix(Index dim)
Constructs a vector or row-vector with given dimension. This is only for vectors (either row-vectors ...
Matrix & operator=(const Matrix &other)
Assigns matrices to each other.
Definition: Matrix.h:208
Matrix & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition: Matrix.h:238
Matrix(const EigenBase< OtherDerived > &other)
Copy constructor for generic expressions.
Definition: Matrix.h:412
Matrix()
Default constructor.
Definition: Matrix.h:261
Matrix(Index rows, Index cols)
Constructs an uninitialized matrix with rows rows and cols columns.
Matrix(const Scalar &a0, const Scalar &a1, const Scalar &a2, const Scalar &a3, const ArgTypes &... args)
Definition: Matrix.h:291
Matrix(const Scalar &x, const Scalar &y, const Scalar &z, const Scalar &w)
Constructs an initialized 4D vector with given coefficients.
Definition: Matrix.h:392
Matrix(const Matrix &other)
Copy constructor.
Definition: Matrix.h:404
Matrix(const Scalar &x)
Constructs an initialized 1x1 matrix with the given coefficient.
Matrix(const Scalar *data)
Constructs a fixed-sized matrix initialized with coefficients starting at data.
PlainObjectBase< Matrix > Base
Base class typedef.
Definition: Matrix.h:188
Matrix(const Scalar &x, const Scalar &y)
Constructs an initialized 2D vector with given coefficients.
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:102
Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition: PlainObjectBase.h:775
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:187
const Scalar * data() const
Definition: PlainObjectBase.h:259
Derived & operator=(const PlainObjectBase &other)
Definition: PlainObjectBase.h:461
@ DontAlign
Definition: Constants.h:327
@ RowMajor
Definition: Constants.h:323
const unsigned int PacketAccessBit
Definition: Constants.h:96
const unsigned int LinearAccessBit
Definition: Constants.h:132
const unsigned int DirectAccessBit
Definition: Constants.h:157
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
const int Dynamic
Definition: Constants.h:24
Definition: EigenBase.h:32
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41