11 #ifndef EIGEN_MATRIX_H 12 #define EIGEN_MATRIX_H 15 #include "./InternalHeaderCheck.h" 20 template <
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
21 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;
27 is_dynamic_size_storage = MaxRows_ ==
Dynamic || MaxCols_ ==
Dynamic,
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 &&
33 (EIGEN_UNALIGNED_VECTORIZE || (int(actual_alignment) >= int(required_alignment))))
39 typedef Scalar_ Scalar;
40 typedef Dense StorageKind;
42 typedef MatrixXpr XprKind;
44 RowsAtCompileTime = Rows_,
45 ColsAtCompileTime = Cols_,
46 MaxRowsAtCompileTime = MaxRows_,
47 MaxColsAtCompileTime = MaxCols_,
48 Flags = compute_matrix_flags(Options_),
50 InnerStrideAtCompileTime = 1,
51 OuterStrideAtCompileTime = (int(Options) & int(
RowMajor)) ? ColsAtCompileTime : RowsAtCompileTime,
55 Alignment = actual_alignment
185 template <
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
193 enum { Options = Options_ };
195 EIGEN_DENSE_PUBLIC_INTERFACE(
Matrix)
197 typedef typename Base::PlainObject PlainObject;
222 template <
typename OtherDerived>
231 template <
typename OtherDerived>
236 template <
typename OtherDerived>
237 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Matrix&
operator=(
const ReturnByValue<OtherDerived>& func) {
251 #if defined(EIGEN_INITIALIZE_COEFFS) 252 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr
Matrix() { EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
254 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr
Matrix() =
default;
257 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr
Matrix(
Matrix&&) =
default;
262 std::is_nothrow_move_assignable<Scalar>::value) {
282 template <
typename... ArgTypes>
283 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Matrix(
const Scalar& a0,
const Scalar& a1,
const Scalar& a2,
const Scalar& a3,
284 const ArgTypes&... args)
285 : Base(a0, a1, a2, a3, args...) {}
311 EIGEN_DEVICE_FUNC
explicit constexpr EIGEN_STRONG_INLINE
Matrix(
312 const std::initializer_list<std::initializer_list<Scalar>>& list)
315 #ifndef EIGEN_PARSED_BY_DOXYGEN 318 template <
typename T>
319 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
explicit Matrix(
const T& x) {
320 Base::template _init1<T>(x);
323 template <
typename T0,
typename T1>
324 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Matrix(
const T0& x,
const T1& y) {
325 Base::template _init2<T0, T1>(x, y);
330 EIGEN_DEVICE_FUNC
explicit Matrix(
const Scalar*
data);
364 Matrix(
const Scalar& x,
const Scalar& y);
365 #endif // end EIGEN_PARSED_BY_DOXYGEN 370 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Matrix(
const Scalar& x,
const Scalar& y,
const Scalar& z) {
371 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Matrix, 3)
372 m_storage.data()[0] = x;
373 m_storage.data()[1] = y;
374 m_storage.data()[2] = z;
379 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Matrix(
const Scalar& x,
const Scalar& y,
const Scalar& z,
const Scalar& w) {
380 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
Matrix, 4)
381 m_storage.data()[0] = x;
382 m_storage.data()[1] = y;
383 m_storage.data()[2] = z;
384 m_storage.data()[3] = w;
388 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr
Matrix(
const Matrix&) =
default;
393 template <
typename OtherDerived>
396 EIGEN_DEVICE_FUNC constexpr
Index innerStride() const noexcept {
return 1; }
397 EIGEN_DEVICE_FUNC constexpr
Index outerStride() const noexcept {
return this->innerSize(); }
401 template <
typename OtherDerived>
402 EIGEN_DEVICE_FUNC
explicit Matrix(
const RotationBase<OtherDerived, ColsAtCompileTime>& r);
403 template <
typename OtherDerived>
404 EIGEN_DEVICE_FUNC
Matrix&
operator=(
const RotationBase<OtherDerived, ColsAtCompileTime>& r);
407 #ifdef EIGEN_MATRIX_PLUGIN 408 #include EIGEN_MATRIX_PLUGIN 412 template <
typename Derived,
typename OtherDerived,
bool IsVector>
413 friend struct internal::conservative_resize_like_impl;
415 using Base::m_storage;
449 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ 452 typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \ 455 typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \ 458 typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix; 460 #define EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \ 463 typedef Matrix<Type, Size, Dynamic> Matrix##Size##X##TypeSuffix; \ 466 typedef Matrix<Type, Dynamic, Size> Matrix##X##Size##TypeSuffix; 468 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ 469 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ 470 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ 471 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ 472 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \ 473 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \ 474 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \ 475 EIGEN_MAKE_FIXED_TYPEDEFS(Type, TypeSuffix, 4) 477 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
int, i)
478 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
float, f)
479 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
double, d)
480 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
std::complex<
float>, cf)
481 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
std::complex<
double>, cd)
483 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES 484 #undef EIGEN_MAKE_TYPEDEFS 485 #undef EIGEN_MAKE_FIXED_TYPEDEFS 487 #define EIGEN_MAKE_TYPEDEFS(Size, SizeSuffix) \ 490 template <typename Type> \ 491 using Matrix##SizeSuffix = Matrix<Type, Size, Size>; \ 494 template <typename Type> \ 495 using Vector##SizeSuffix = Matrix<Type, Size, 1>; \ 498 template <typename Type> \ 499 using RowVector##SizeSuffix = Matrix<Type, 1, Size>; 501 #define EIGEN_MAKE_FIXED_TYPEDEFS(Size) \ 504 template <typename Type> \ 505 using Matrix##Size##X = Matrix<Type, Size, Dynamic>; \ 508 template <typename Type> \ 509 using Matrix##X##Size = Matrix<Type, Dynamic, Size>; 511 EIGEN_MAKE_TYPEDEFS(2, 2)
512 EIGEN_MAKE_TYPEDEFS(3, 3)
513 EIGEN_MAKE_TYPEDEFS(4, 4)
515 EIGEN_MAKE_FIXED_TYPEDEFS(2)
516 EIGEN_MAKE_FIXED_TYPEDEFS(3)
517 EIGEN_MAKE_FIXED_TYPEDEFS(4)
521 template <typename Type,
int Size>
526 template <typename Type,
int Size>
529 #undef EIGEN_MAKE_TYPEDEFS 530 #undef EIGEN_MAKE_FIXED_TYPEDEFS 534 #endif // EIGEN_MATRIX_H Matrix & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition: Matrix.h:232
Matrix(const Scalar &x, const Scalar &y, const Scalar &z, const Scalar &w)
Constructs an initialized 4D vector with given coefficients.
Definition: Matrix.h:379
Definition: Constants.h:324
constexpr Matrix()=default
Default constructor.
const unsigned int DirectAccessBit
Definition: Constants.h:159
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
Matrix(const Scalar &a0, const Scalar &a1, const Scalar &a2, const Scalar &a3, const ArgTypes &... args)
Construct a row of column vector with fixed size from an arbitrary number of coefficients.
Definition: Matrix.h:283
Definition: BFloat16.h:231
constexpr Derived & operator=(const PlainObjectBase &other)
Definition: PlainObjectBase.h:429
constexpr const Scalar * data() const
Definition: PlainObjectBase.h:247
const unsigned int RowMajorBit
Definition: Constants.h:70
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:38
const unsigned int PacketAccessBit
Definition: Constants.h:97
constexpr Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:191
Definition: EigenBase.h:33
PlainObjectBase< Matrix > Base
Base class typedef.
Definition: Matrix.h:191
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:95
Matrix(const Scalar &x, const Scalar &y, const Scalar &z)
Constructs an initialized 3D vector with given coefficients.
Definition: Matrix.h:370
constexpr Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition: PlainObjectBase.h:717
constexpr Matrix & operator=(const Matrix &other)
Assigns matrices to each other.
Definition: Matrix.h:210
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:311
constexpr Matrix & operator=(Matrix &&other) noexcept(std::is_nothrow_move_assignable< Scalar >::value)
Moves the matrix into the other one.
Definition: Matrix.h:261
Definition: Constants.h:320
Matrix(const EigenBase< OtherDerived > &other)
Copy constructor for generic expressions.
Definition: Matrix.h:394
const int Dynamic
Definition: Constants.h:25
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:186
const unsigned int LinearAccessBit
Definition: Constants.h:133