16#include "./InternalHeaderCheck.h"
21template <
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
22struct traits<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> {
24 constexpr static int size = internal::size_at_compile_time(Rows_, Cols_);
25 using PacketScalar =
typename find_best_packet<Scalar_, size>::type;
28 is_dynamic_size_storage = MaxRows_ == Dynamic || MaxCols_ == Dynamic,
29 max_size = is_dynamic_size_storage ? Dynamic : MaxRows_ * MaxCols_,
30 default_alignment = compute_default_alignment<Scalar_, max_size>::value,
31 actual_alignment = ((Options_ &
DontAlign) == 0) ? default_alignment : 0,
32 required_alignment = unpacket_traits<PacketScalar>::alignment,
33 packet_access_bit = (packet_traits<Scalar_>::Vectorizable &&
34 (EIGEN_UNALIGNED_VECTORIZE || (int(actual_alignment) >= int(required_alignment))))
40 using Scalar = Scalar_;
41 using StorageKind = Dense;
42 using StorageIndex = Eigen::Index;
43 using XprKind = MatrixXpr;
45 RowsAtCompileTime = Rows_,
46 ColsAtCompileTime = Cols_,
47 MaxRowsAtCompileTime = MaxRows_,
48 MaxColsAtCompileTime = MaxCols_,
49 Flags = compute_matrix_flags(Options_),
51 InnerStrideAtCompileTime = 1,
52 OuterStrideAtCompileTime = (int(Options) & int(
RowMajor)) ? ColsAtCompileTime : RowsAtCompileTime,
56 Alignment = actual_alignment
187template <
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
188class Matrix :
public PlainObjectBase<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> {
193 using Base = PlainObjectBase<Matrix>;
195 enum { Options = Options_ };
197 EIGEN_DENSE_PUBLIC_INTERFACE(
Matrix)
199 using PlainObject =
typename Base::PlainObject;
202 using Base::coeffRef;
224 template <
typename OtherDerived>
226 return Base::_set(other);
233 template <
typename OtherDerived>
238 template <
typename OtherDerived>
239 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Matrix& operator=(
const ReturnByValue<OtherDerived>& func) {
240 return Base::operator=(func);
257#if defined(EIGEN_INITIALIZE_COEFFS)
258 EIGEN_DEVICE_FUNC
constexpr Matrix() { EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
260 EIGEN_DEVICE_FUNC
constexpr Matrix() =
default;
268 std::is_nothrow_move_assignable<Scalar>::value) {
269 this->m_storage = std::move(other.m_storage);
288 template <
typename... ArgTypes>
289 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Matrix(
const Scalar& a0,
const Scalar& a1,
const Scalar& a2,
const Scalar& a3,
290 const ArgTypes&... args)
291 :
Base(a0, a1, a2, a3, args...) {}
316 EIGEN_DEVICE_FUNC
explicit constexpr EIGEN_STRONG_INLINE
Matrix(
317 const std::initializer_list<std::initializer_list<Scalar>>& list)
320#ifndef EIGEN_PARSED_BY_DOXYGEN
323 template <
typename T>
324 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
explicit Matrix(
const T& x) {
325 Base::template _init1<T>(x);
328 template <
typename T0,
typename T1>
329 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE Matrix(
const T0& x,
const T1& y) {
330 Base::template _init2<T0, T1>(x, y);
349 EIGEN_STRONG_INLINE
explicit Matrix(Index dim);
365 EIGEN_DEVICE_FUNC
Matrix(Index rows, Index cols);
369 Matrix(
const Scalar& x,
const Scalar& y);
375 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
Matrix(
const Scalar& x,
const Scalar& y,
const Scalar& z) {
376 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Matrix, 3)
377 m_storage.data()[0] = x;
378 m_storage.data()[1] = y;
379 m_storage.data()[2] = z;
384 EIGEN_DEVICE_FUNC
constexpr EIGEN_STRONG_INLINE
Matrix(
const Scalar& x,
const Scalar& y,
const Scalar& z,
386 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Matrix, 4)
387 m_storage.data()[0] = x;
388 m_storage.data()[1] = y;
389 m_storage.data()[2] = z;
390 m_storage.data()[3] = w;
401 template <
typename OtherDerived,
402 std::enable_if_t<internal::is_valid_dense_conversion<Scalar, OtherDerived>::value,
int> = 0>
404 :
Base(other.derived()) {}
406 EIGEN_DEVICE_FUNC
constexpr Index innerStride() const noexcept {
return 1; }
407 EIGEN_DEVICE_FUNC
constexpr Index outerStride() const noexcept {
return this->innerSize(); }
411 template <
typename OtherDerived>
413 template <
typename OtherDerived>
417#ifdef EIGEN_MATRIX_PLUGIN
418#include EIGEN_MATRIX_PLUGIN
422 template <
typename Derived,
typename OtherDerived,
bool IsVector>
423 friend struct internal::conservative_resize_like_impl;
425 using Base::m_storage;
459#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
462 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
465 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
468 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
470#define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
473 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \
476 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix;
478#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
479 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
480 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
481 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
482 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
483 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
484 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
485 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
487EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
int, i)
488EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
float, f)
489EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
double, d)
490EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<
float>, cf)
491EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<
double>, cd)
493#undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
494#undef EIGEN_MAKE_TYPEDEFS
495#undef EIGEN_MAKE_FIXED_TYPEDEFS
497#define EIGEN_MAKE_TYPEDEFS(Size, SizeSuffix) \
500 template <typename Type> \
501 using Matrix##SizeSuffix = Matrix<Type, Size, Size>; \
504 template <typename Type> \
505 using Vector##SizeSuffix = Matrix<Type, Size, 1>; \
508 template <typename Type> \
509 using RowVector##SizeSuffix = Matrix<Type, 1, Size>;
511#define EIGEN_MAKE_FIXED_TYPEDEFS(Size) \
514 template <typename Type> \
515 using Matrix##Size##X = Matrix<Type, Size, Dynamic>; \
518 template <typename Type> \
519 using Matrix##X##Size = Matrix<Type, Dynamic, Size>;
521EIGEN_MAKE_TYPEDEFS(2, 2)
522EIGEN_MAKE_TYPEDEFS(3, 3)
523EIGEN_MAKE_TYPEDEFS(4, 4)
524EIGEN_MAKE_TYPEDEFS(Dynamic, X)
525EIGEN_MAKE_FIXED_TYPEDEFS(2)
526EIGEN_MAKE_FIXED_TYPEDEFS(3)
527EIGEN_MAKE_FIXED_TYPEDEFS(4)
531template <typename Type,
int Size>
536template <typename Type,
int Size>
539#undef EIGEN_MAKE_TYPEDEFS
540#undef EIGEN_MAKE_FIXED_TYPEDEFS
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:45
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
constexpr 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(Index dim)
Constructs a vector or row-vector with given dimension. This is only for vectors (either row-vectors ...
constexpr Matrix()=default
Default constructor.
constexpr Matrix(Matrix &&)=default
Move constructor.
constexpr Matrix(const Scalar &x, const Scalar &y, const Scalar &z, const Scalar &w)
Constructs an initialized 4D vector with given coefficients.
Definition Matrix.h:384
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)
Construct a row or column vector with fixed size from an arbitrary number of coefficients.
Definition Matrix.h:289
constexpr Matrix & operator=(Matrix &&other) noexcept(std::is_nothrow_move_assignable< Scalar >::value)
Moves the matrix into the other one.
Definition Matrix.h:267
constexpr Matrix(const EigenBase< OtherDerived > &other)
Copy constructor for generic expressions. For coefficient-wise dense expressions, implicit conversion...
Definition Matrix.h:403
constexpr Matrix(const Scalar &x, const Scalar &y, const Scalar &z)
Constructs an initialized 3D vector with given coefficients.
Definition Matrix.h:375
PlainObjectBase< Matrix > Base
Definition Matrix.h:193
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.
Matrix(const RotationBase< OtherDerived, ColsAtCompileTime > &r)
Constructs a Dim x Dim rotation matrix from the rotation r.
Definition RotationBase.h:149
constexpr Matrix & operator=(const Matrix &other)
Assigns matrices to each other.
Definition Matrix.h:212
Matrix(const Scalar &x, const Scalar &y)
Constructs an initialized 2D vector with given coefficients.
Matrix & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition Matrix.h:234
constexpr Matrix(const Matrix &)=default
Copy constructor.
constexpr Matrix & _set(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:734
constexpr const Scalar * data() const
Definition PlainObjectBase.h:261
constexpr Matrix & operator=(const PlainObjectBase &other)
Definition PlainObjectBase.h:445
Common base class for compact rotation representations.
Definition RotationBase.h:33
@ DontAlign
Definition Constants.h:325
@ RowMajor
Definition Constants.h:321
constexpr unsigned int PacketAccessBit
Definition Constants.h:98
constexpr unsigned int DirectAccessBit
Definition Constants.h:160
constexpr unsigned int LinearAccessBit
Definition Constants.h:134
constexpr unsigned int RowMajorBit
Definition Constants.h:71
Matrix< Type, 1, Size > RowVector
1×Size vector of type Type.
Definition Matrix.h:537
Matrix< Type, Size, 1 > Vector
Size×1 vector of type Type.
Definition Matrix.h:532
Definition EigenBase.h:34