11 #ifndef EIGEN_DENSESTORAGEBASE_H
12 #define EIGEN_DENSESTORAGEBASE_H
14 #if defined(EIGEN_INITIALIZE_MATRICES_BY_ZERO)
15 # define EIGEN_INITIALIZE_COEFFS
16 # define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED for(Index i=0;i<base().size();++i) coeffRef(i)=Scalar(0);
17 #elif defined(EIGEN_INITIALIZE_MATRICES_BY_NAN)
18 # define EIGEN_INITIALIZE_COEFFS
19 # define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED for(Index i=0;i<base().size();++i) coeffRef(i)=std::numeric_limits<Scalar>::quiet_NaN();
21 # undef EIGEN_INITIALIZE_COEFFS
22 # define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
25 #include "./InternalHeaderCheck.h"
31 template<
int MaxSizeAtCompileTime>
struct check_rows_cols_for_overflow {
32 template<
typename Index>
34 static EIGEN_ALWAYS_INLINE
void run(
Index,
Index)
39 template<>
struct check_rows_cols_for_overflow<
Dynamic> {
40 template<
typename Index>
42 static EIGEN_ALWAYS_INLINE
void run(
Index rows,
Index cols)
46 Index max_index = (std::size_t(1) << (8 *
sizeof(
Index) - 1)) - 1;
47 bool error = (rows == 0 || cols == 0) ?
false
48 : (rows > max_index / cols);
50 throw_std_bad_alloc();
54 template <
typename Derived,
55 typename OtherDerived = Derived,
56 bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
57 struct conservative_resize_like_impl;
59 template<
typename MatrixTypeA,
typename MatrixTypeB,
bool SwapPo
inters>
struct matrix_swap_impl;
63 #ifdef EIGEN_PARSED_BY_DOXYGEN
75 template<
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
79 template<
typename Scalar_,
int Rows_,
int Cols_,
int Options_,
int MaxRows_,
int MaxCols_>
96 template<
typename Derived>
99 template<typename Derived>
104 enum { Options = internal::traits<Derived>::Options };
105 typedef typename internal::dense_xpr_base<Derived>::type Base;
107 typedef typename internal::traits<Derived>::StorageKind StorageKind;
108 typedef typename internal::traits<Derived>::Scalar Scalar;
110 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
112 typedef Derived DenseType;
114 using Base::RowsAtCompileTime;
115 using Base::ColsAtCompileTime;
116 using Base::SizeAtCompileTime;
117 using Base::MaxRowsAtCompileTime;
118 using Base::MaxColsAtCompileTime;
119 using Base::MaxSizeAtCompileTime;
120 using Base::IsVectorAtCompileTime;
133 DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
136 enum { NeedsToAlign = (SizeAtCompileTime !=
Dynamic) && (internal::traits<Derived>::Alignment>0) };
137 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
139 EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (
int(Options)&
RowMajor)==
RowMajor), INVALID_MATRIX_TEMPLATE_PARAMETERS)
140 EIGEN_STATIC_ASSERT(internal::check_implication(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, (
int(Options)&
RowMajor)==0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
141 EIGEN_STATIC_ASSERT((RowsAtCompileTime ==
Dynamic) || (RowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
142 EIGEN_STATIC_ASSERT((ColsAtCompileTime ==
Dynamic) || (ColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
143 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime ==
Dynamic) || (MaxRowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
144 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime ==
Dynamic) || (MaxColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
145 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==
Dynamic), INVALID_MATRIX_TEMPLATE_PARAMETERS)
146 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==
Dynamic), INVALID_MATRIX_TEMPLATE_PARAMETERS)
147 EIGEN_STATIC_ASSERT(((Options & (
DontAlign|
RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS)
150 Base& base() {
return *
static_cast<Base*
>(
this); }
152 const Base& base()
const {
return *
static_cast<const Base*
>(
this); }
154 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
155 Index rows()
const EIGEN_NOEXCEPT {
return m_storage.rows(); }
156 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
157 Index cols()
const EIGEN_NOEXCEPT {
return m_storage.cols(); }
167 return m_storage.data()[colId + rowId * m_storage.cols()];
169 return m_storage.data()[rowId + colId * m_storage.rows()];
179 return m_storage.data()[index];
190 return m_storage.data()[colId + rowId * m_storage.cols()];
192 return m_storage.data()[rowId + colId * m_storage.rows()];
202 return m_storage.data()[index];
211 return m_storage.data()[colId + rowId * m_storage.cols()];
213 return m_storage.data()[rowId + colId * m_storage.rows()];
221 return m_storage.data()[index];
225 template<
int LoadMode>
226 EIGEN_STRONG_INLINE PacketScalar packet(
Index rowId,
Index colId)
const
228 return internal::ploadt<PacketScalar, LoadMode>
230 ? colId + rowId * m_storage.cols()
231 : rowId + colId * m_storage.rows()));
235 template<
int LoadMode>
236 EIGEN_STRONG_INLINE PacketScalar packet(
Index index)
const
238 return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
242 template<
int StoreMode>
243 EIGEN_STRONG_INLINE
void writePacket(
Index rowId,
Index colId,
const PacketScalar& val)
245 internal::pstoret<Scalar, PacketScalar, StoreMode>
247 ? colId + rowId * m_storage.cols()
248 : rowId + colId * m_storage.rows()), val);
252 template<
int StoreMode>
253 EIGEN_STRONG_INLINE
void writePacket(
Index index,
const PacketScalar& val)
255 internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
259 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar *
data()
const
260 {
return m_storage.data(); }
263 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar *
data()
264 {
return m_storage.data(); }
285 eigen_assert(internal::check_implication(RowsAtCompileTime!=
Dynamic, rows==RowsAtCompileTime)
286 && internal::check_implication(ColsAtCompileTime!=
Dynamic, cols==ColsAtCompileTime)
287 && internal::check_implication(RowsAtCompileTime==
Dynamic && MaxRowsAtCompileTime!=
Dynamic, rows<=MaxRowsAtCompileTime)
288 && internal::check_implication(ColsAtCompileTime==
Dynamic && MaxColsAtCompileTime!=
Dynamic, cols<=MaxColsAtCompileTime)
289 && rows>=0 && cols>=0 &&
"Invalid sizes when resizing a matrix or array.");
290 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(rows, cols);
291 #ifdef EIGEN_INITIALIZE_COEFFS
292 Index size = rows*cols;
293 bool size_changed = size != this->size();
294 m_storage.resize(size, rows, cols);
295 if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
297 m_storage.resize(rows*cols, rows, cols);
316 eigen_assert(((SizeAtCompileTime ==
Dynamic && (MaxSizeAtCompileTime==
Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0);
317 #ifdef EIGEN_INITIALIZE_COEFFS
318 bool size_changed = size != this->size();
320 if(RowsAtCompileTime == 1)
321 m_storage.resize(size, 1, size);
323 m_storage.resize(size, size, 1);
324 #ifdef EIGEN_INITIALIZE_COEFFS
325 if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
364 template<
typename OtherDerived>
368 const OtherDerived& other = _other.
derived();
369 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(other.rows(), other.cols());
370 const Index othersize = other.rows()*other.cols();
371 if(RowsAtCompileTime == 1)
373 eigen_assert(other.rows() == 1 || other.cols() == 1);
376 else if(ColsAtCompileTime == 1)
378 eigen_assert(other.rows() == 1 || other.cols() == 1);
381 else resize(other.rows(), other.cols());
396 internal::conservative_resize_like_impl<Derived>::run(*
this, rows, cols);
438 internal::conservative_resize_like_impl<Derived>::run(*
this, size);
450 template<
typename OtherDerived>
454 internal::conservative_resize_like_impl<Derived,OtherDerived>::run(*
this, other);
467 template<
typename OtherDerived>
472 return Base::lazyAssign(other.
derived());
475 template<
typename OtherDerived>
477 EIGEN_STRONG_INLINE Derived&
operator=(
const ReturnByValue<OtherDerived>& func)
479 resize(func.rows(), func.cols());
480 return Base::operator=(func);
488 EIGEN_STRONG_INLINE PlainObjectBase() : m_storage()
493 #ifndef EIGEN_PARSED_BY_DOXYGEN
497 explicit PlainObjectBase(internal::constructor_without_unaligned_array_assert)
498 : m_storage(internal::constructor_without_unaligned_array_assert())
505 PlainObjectBase(PlainObjectBase&& other) EIGEN_NOEXCEPT
506 : m_storage( std::move(other.m_storage) )
511 PlainObjectBase&
operator=(PlainObjectBase&& other) EIGEN_NOEXCEPT
513 m_storage = std::move(other.m_storage);
520 : Base(), m_storage(other.m_storage) { }
523 : m_storage(size, rows, cols)
537 template <
typename... ArgTypes>
538 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
539 PlainObjectBase(
const Scalar& a0,
const Scalar& a1,
const Scalar& a2,
const Scalar& a3,
const ArgTypes&... args)
542 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
PlainObjectBase,
sizeof...(args) + 4);
543 m_storage.data()[0] = a0;
544 m_storage.data()[1] = a1;
545 m_storage.data()[2] = a2;
546 m_storage.data()[3] = a3;
548 auto x = {(m_storage.data()[i++] = args, 0)...};
549 static_cast<void>(x);
556 explicit EIGEN_STRONG_INLINE
PlainObjectBase(
const std::initializer_list<std::initializer_list<Scalar>>& list)
559 size_t list_size = 0;
560 if (list.begin() != list.end()) {
561 list_size = list.begin()->size();
565 if (ColsAtCompileTime == 1 && list.size() == 1) {
566 eigen_assert(list_size ==
static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime ==
Dynamic);
567 resize(list_size, ColsAtCompileTime);
568 std::copy(list.begin()->begin(), list.begin()->end(), m_storage.data());
570 eigen_assert(list.size() ==
static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime ==
Dynamic);
571 eigen_assert(list_size ==
static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime ==
Dynamic);
572 resize(list.size(), list_size);
575 for (
const std::initializer_list<Scalar>& row : list) {
576 eigen_assert(list_size == row.size());
578 for (
const Scalar& e : row) {
588 template<
typename OtherDerived>
598 template<
typename OtherDerived>
607 template<
typename OtherDerived>
612 resize(other.rows(), other.cols());
613 other.evalTo(this->derived());
621 template<
typename OtherDerived>
626 Base::operator=(other.
derived());
627 return this->derived();
668 template<
int Outer,
int Inner>
670 {
return typename StridedConstMapType<Stride<Outer, Inner> >::type(
data, stride); }
671 template<
int Outer,
int Inner>
673 {
return typename StridedMapType<Stride<Outer, Inner> >::type(
data, stride); }
674 template<
int Outer,
int Inner>
676 {
return typename StridedConstMapType<Stride<Outer, Inner> >::type(
data, size, stride); }
677 template<
int Outer,
int Inner>
679 {
return typename StridedMapType<Stride<Outer, Inner> >::type(
data, size, stride); }
680 template<
int Outer,
int Inner>
682 {
return typename StridedConstMapType<Stride<Outer, Inner> >::type(
data, rows, cols, stride); }
683 template<
int Outer,
int Inner>
685 {
return typename StridedMapType<Stride<Outer, Inner> >::type(
data, rows, cols, stride); }
687 template<
int Outer,
int Inner>
689 {
return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(
data, stride); }
690 template<
int Outer,
int Inner>
692 {
return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(
data, stride); }
693 template<
int Outer,
int Inner>
695 {
return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(
data, size, stride); }
696 template<
int Outer,
int Inner>
698 {
return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(
data, size, stride); }
699 template<
int Outer,
int Inner>
701 {
return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(
data, rows, cols, stride); }
702 template<
int Outer,
int Inner>
704 {
return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(
data, rows, cols, stride); }
707 using Base::setConstant;
710 EIGEN_DEVICE_FUNC Derived&
setConstant(NoChange_t,
Index cols,
const Scalar& val);
711 EIGEN_DEVICE_FUNC Derived&
setConstant(
Index rows, NoChange_t,
const Scalar& val);
716 EIGEN_DEVICE_FUNC Derived&
setZero(NoChange_t,
Index cols);
717 EIGEN_DEVICE_FUNC Derived&
setZero(
Index rows, NoChange_t);
722 EIGEN_DEVICE_FUNC Derived&
setOnes(NoChange_t,
Index cols);
723 EIGEN_DEVICE_FUNC Derived&
setOnes(
Index rows, NoChange_t);
725 using Base::setRandom;
731 #ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
732 #include EIGEN_PLAINOBJECTBASE_PLUGIN
743 template<
typename OtherDerived>
747 #ifdef EIGEN_NO_AUTOMATIC_RESIZING
748 eigen_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.
size())
749 : (rows() == other.
rows() && cols() == other.
cols())))
750 &&
"Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
751 EIGEN_ONLY_USED_FOR_DEBUG(other);
773 template<
typename OtherDerived>
777 internal::call_assignment(this->derived(), other.
derived());
778 return this->derived();
786 template<
typename OtherDerived>
795 internal::call_assignment_no_alias(this->derived(), other.
derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
796 return this->derived();
799 template<
typename T0,
typename T1>
801 EIGEN_STRONG_INLINE
void _init2(
Index rows,
Index cols, std::enable_if_t<Base::SizeAtCompileTime!=2,T0>* = 0)
803 const bool t0_is_integer_alike = internal::is_valid_index_type<T0>::value;
804 const bool t1_is_integer_alike = internal::is_valid_index_type<T1>::value;
805 EIGEN_STATIC_ASSERT(t0_is_integer_alike &&
807 FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
811 template<
typename T0,
typename T1>
813 EIGEN_STRONG_INLINE
void _init2(
const T0& val0,
const T1& val1, std::enable_if_t<Base::SizeAtCompileTime==2,T0>* = 0)
816 m_storage.data()[0] = Scalar(val0);
817 m_storage.data()[1] = Scalar(val1);
820 template<
typename T0,
typename T1>
823 std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
824 && (internal::is_same<T0,Index>::value)
825 && (internal::is_same<T1,Index>::value)
826 && Base::SizeAtCompileTime==2,T1>* = 0)
829 m_storage.data()[0] = Scalar(val0);
830 m_storage.data()[1] = Scalar(val1);
837 EIGEN_STRONG_INLINE
void _init1(
Index size, std::enable_if_t< (Base::SizeAtCompileTime!=1 || !internal::is_convertible<T, Scalar>::value)
838 && ((!internal::is_same<
typename internal::traits<Derived>::XprKind,
ArrayXpr>::value || Base::SizeAtCompileTime==
Dynamic)),T>* = 0)
841 const bool is_integer_alike = internal::is_valid_index_type<T>::value;
842 EIGEN_UNUSED_VARIABLE(is_integer_alike);
843 EIGEN_STATIC_ASSERT(is_integer_alike,
844 FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
851 EIGEN_STRONG_INLINE
void _init1(
const Scalar& val0, std::enable_if_t<Base::SizeAtCompileTime==1 && internal::is_convertible<T, Scalar>::value,T>* = 0)
854 m_storage.data()[0] = val0;
861 std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
862 && (internal::is_same<Index,T>::value)
863 && Base::SizeAtCompileTime==1
864 && internal::is_convertible<T, Scalar>::value,T*>* = 0)
867 m_storage.data()[0] = Scalar(val0);
878 template<
typename T,
typename OtherDerived>
887 EIGEN_STRONG_INLINE
void _init1(
const Derived& other){
892 template<
typename T,
typename OtherDerived>
895 this->derived() = other;
898 template<
typename T,
typename OtherDerived>
900 EIGEN_STRONG_INLINE
void _init1(
const ReturnByValue<OtherDerived>& other)
902 resize(other.rows(), other.cols());
903 other.evalTo(this->derived());
906 template<
typename T,
typename OtherDerived,
int ColsAtCompileTime>
916 EIGEN_STRONG_INLINE
void _init1(
const Scalar& val0,
917 std::enable_if_t< Base::SizeAtCompileTime!=
Dynamic
918 && Base::SizeAtCompileTime!=1
919 && internal::is_convertible<T, Scalar>::value
920 && internal::is_same<
typename internal::traits<Derived>::XprKind,
ArrayXpr>::value,T>* = 0)
922 Base::setConstant(val0);
929 std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
930 && (internal::is_same<Index,T>::value)
931 && Base::SizeAtCompileTime!=
Dynamic
932 && Base::SizeAtCompileTime!=1
933 && internal::is_convertible<T, Scalar>::value
934 && internal::is_same<
typename internal::traits<Derived>::XprKind,
ArrayXpr>::value,T*>* = 0)
936 Base::setConstant(val0);
939 template<
typename MatrixTypeA,
typename MatrixTypeB,
bool SwapPo
inters>
940 friend struct internal::matrix_swap_impl;
944 #ifndef EIGEN_PARSED_BY_DOXYGEN
949 template<
typename OtherDerived>
950 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
953 enum { SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime==
Dynamic };
954 internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.
derived());
960 template<
typename OtherDerived>
961 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
962 void swap(DenseBase<OtherDerived>
const & other)
963 { Base::swap(other.derived()); }
965 enum { IsPlainObjectBase = 1 };
970 template<
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
friend class Eigen::Map;
973 #if EIGEN_MAX_ALIGN_BYTES>0
976 friend class Eigen::Map<const Derived, AlignedMax>;
982 template <
typename Derived,
typename OtherDerived,
bool IsVector>
983 struct conservative_resize_like_impl
985 static constexpr
bool IsRelocatable = std::is_trivially_copyable<typename Derived::Scalar>::value;
988 if (_this.
rows() == rows && _this.
cols() == cols)
return;
989 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
992 && (( Derived::IsRowMajor && _this.
cols() == cols) ||
993 (!Derived::IsRowMajor && _this.
rows() == rows) ))
995 internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime>::run(rows, cols);
996 _this.
derived().m_storage.conservativeResize(rows*cols,rows,cols);
1001 Derived tmp(rows,cols);
1002 const Index common_rows = numext::mini(rows, _this.
rows());
1003 const Index common_cols = numext::mini(cols, _this.
cols());
1004 tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
1009 static void run(DenseBase<Derived>& _this,
const DenseBase<OtherDerived>& other)
1011 if (_this.rows() == other.rows() && _this.cols() == other.cols())
return;
1018 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
1019 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
1021 if ( IsRelocatable &&
1022 (( Derived::IsRowMajor && _this.cols() == other.cols()) ||
1023 (!Derived::IsRowMajor && _this.rows() == other.rows()) ))
1025 const Index new_rows = other.rows() - _this.rows();
1026 const Index new_cols = other.cols() - _this.cols();
1027 _this.derived().m_storage.conservativeResize(other.size(),other.rows(),other.cols());
1029 _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
1030 else if (new_cols>0)
1031 _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
1037 const Index common_rows = numext::mini(tmp.rows(), _this.rows());
1038 const Index common_cols = numext::mini(tmp.cols(), _this.cols());
1039 tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
1040 _this.derived().swap(tmp);
1047 template <
typename Derived,
typename OtherDerived>
1048 struct conservative_resize_like_impl<Derived,OtherDerived,true>
1049 : conservative_resize_like_impl<Derived,OtherDerived,false>
1051 typedef conservative_resize_like_impl<Derived,OtherDerived,false> Base;
1053 using Base::IsRelocatable;
1055 static void run(DenseBase<Derived>& _this,
Index size)
1057 const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size;
1058 const Index new_cols = Derived::RowsAtCompileTime==1 ? size : 1;
1060 _this.derived().m_storage.conservativeResize(size,new_rows,new_cols);
1062 Base::run(_this.derived(), new_rows, new_cols);
1065 static void run(DenseBase<Derived>& _this,
const DenseBase<OtherDerived>& other)
1067 if (_this.rows() == other.rows() && _this.cols() == other.cols())
return;
1069 const Index num_new_elements = other.size() - _this.size();
1071 const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows();
1072 const Index new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1;
1074 _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols);
1076 Base::run(_this.derived(), new_rows, new_cols);
1078 if (num_new_elements > 0)
1079 _this.tail(num_new_elements) = other.tail(num_new_elements);
1083 template<
typename MatrixTypeA,
typename MatrixTypeB,
bool SwapPo
inters>
1084 struct matrix_swap_impl
1087 static EIGEN_STRONG_INLINE
void run(MatrixTypeA& a, MatrixTypeB& b)
1093 template<
typename MatrixTypeA,
typename MatrixTypeB>
1094 struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true>
1097 static inline void run(MatrixTypeA& a, MatrixTypeB& b)
1099 static_cast<typename MatrixTypeA::Base&
>(a).m_storage.swap(
static_cast<typename MatrixTypeB::Base&
>(b).m_storage);
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:43
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:49
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
Derived & derived()
Definition: EigenBase.h:48
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:98
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:102
const Scalar & coeffRef(Index rowId, Index colId) const
Definition: PlainObjectBase.h:208
Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition: PlainObjectBase.h:775
void resize(NoChange_t, Index cols)
Definition: PlainObjectBase.h:338
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:681
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:672
PlainObjectBase(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition: PlainObjectBase.h:609
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:697
void _init2(Index rows, Index cols, std::enable_if_t< Base::SizeAtCompileTime!=2, T0 > *=0)
Definition: PlainObjectBase.h:801
void _resize_to_match(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:745
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:700
void _init1(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:894
void _init1(const Scalar &val0, std::enable_if_t< Base::SizeAtCompileTime!=Dynamic &&Base::SizeAtCompileTime!=1 &&internal::is_convertible< T, Scalar >::value &&internal::is_same< typename internal::traits< Derived >::XprKind, ArrayXpr >::value, T > *=0)
Definition: PlainObjectBase.h:916
void _init2(const T0 &val0, const T1 &val1, std::enable_if_t< Base::SizeAtCompileTime==2, T0 > *=0)
Definition: PlainObjectBase.h:813
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:452
void _init1(const RotationBase< OtherDerived, ColsAtCompileTime > &r)
Definition: PlainObjectBase.h:908
PlainObjectBase(const PlainObjectBase &other)
Definition: PlainObjectBase.h:519
const Scalar & coeffRef(Index index) const
Definition: PlainObjectBase.h:219
PlainObjectBase(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: PlainObjectBase.h:539
Derived & setRandom(Index size)
Definition: Random.h:152
static AlignedMapType MapAligned(Scalar *data, Index size)
Definition: PlainObjectBase.h:661
void _init1(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:880
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:469
void conservativeResize(Index rows, Index cols)
Definition: PlainObjectBase.h:394
Scalar & coeffRef(Index index)
Definition: PlainObjectBase.h:200
static ConstAlignedMapType MapAligned(const Scalar *data, Index size)
Definition: PlainObjectBase.h:659
PlainObjectBase(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:590
void conservativeResize(Index size)
Definition: PlainObjectBase.h:436
Derived & setOnes(Index size)
Definition: CwiseNullaryOp.h:716
static ConstAlignedMapType MapAligned(const Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:663
void resize(Index size)
Definition: PlainObjectBase.h:313
void conservativeResize(Index rows, NoChange_t)
Definition: PlainObjectBase.h:407
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:669
PlainObjectBase(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:600
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:694
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:164
static AlignedMapType MapAligned(Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:665
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:187
void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:283
static AlignedMapType MapAligned(Scalar *data)
Definition: PlainObjectBase.h:657
void _init1(const Scalar *data)
Definition: PlainObjectBase.h:873
void resizeLike(const EigenBase< OtherDerived > &_other)
Definition: PlainObjectBase.h:366
Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:363
void _init1(const ReturnByValue< OtherDerived > &other)
Definition: PlainObjectBase.h:900
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:688
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:678
static ConstMapType Map(const Scalar *data)
Definition: PlainObjectBase.h:642
static MapType Map(Scalar *data, Index size)
Definition: PlainObjectBase.h:648
void _init1(const Derived &other)
Definition: PlainObjectBase.h:887
void _init1(const Index &val0, std::enable_if_t<(!internal::is_same< Index, Scalar >::value) &&(internal::is_same< Index, T >::value) &&Base::SizeAtCompileTime!=Dynamic &&Base::SizeAtCompileTime!=1 &&internal::is_convertible< T, Scalar >::value &&internal::is_same< typename internal::traits< Derived >::XprKind, ArrayXpr >::value, T * > *=0)
Definition: PlainObjectBase.h:928
static MapType Map(Scalar *data)
Definition: PlainObjectBase.h:644
PlainObjectBase(const std::initializer_list< std::initializer_list< Scalar >> &list)
Constructs a Matrix or Array and initializes it by elements given by an initializer list of initializ...
Definition: PlainObjectBase.h:556
void _init1(Index size, std::enable_if_t<(Base::SizeAtCompileTime!=1||!internal::is_convertible< T, Scalar >::value) &&((!internal::is_same< typename internal::traits< Derived >::XprKind, ArrayXpr >::value||Base::SizeAtCompileTime==Dynamic)), T > *=0)
Definition: PlainObjectBase.h:837
static ConstMapType Map(const Scalar *data, Index size)
Definition: PlainObjectBase.h:646
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:691
const Scalar * data() const
Definition: PlainObjectBase.h:259
const Scalar & coeff(Index index) const
Definition: PlainObjectBase.h:177
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:564
Scalar * data()
Definition: PlainObjectBase.h:263
static MapType Map(Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:652
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:684
void _init1(const Scalar &val0, std::enable_if_t< Base::SizeAtCompileTime==1 &&internal::is_convertible< T, Scalar >::value, T > *=0)
Definition: PlainObjectBase.h:851
Derived & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition: PlainObjectBase.h:623
static ConstMapType Map(const Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:650
void resize(Index rows, NoChange_t)
Definition: PlainObjectBase.h:352
void _init1(const Index &val0, std::enable_if_t<(!internal::is_same< Index, Scalar >::value) &&(internal::is_same< Index, T >::value) &&Base::SizeAtCompileTime==1 &&internal::is_convertible< T, Scalar >::value, T * > *=0)
Definition: PlainObjectBase.h:860
static ConstAlignedMapType MapAligned(const Scalar *data)
Definition: PlainObjectBase.h:655
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:675
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:703
Derived & _set_noalias(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:788
void _init2(const Index &val0, const Index &val1, std::enable_if_t<(!internal::is_same< Index, Scalar >::value) &&(internal::is_same< T0, Index >::value) &&(internal::is_same< T1, Index >::value) &&Base::SizeAtCompileTime==2, T1 > *=0)
Definition: PlainObjectBase.h:822
Derived & operator=(const PlainObjectBase &other)
Definition: PlainObjectBase.h:461
void conservativeResize(NoChange_t, Index cols)
Definition: PlainObjectBase.h:421
Common base class for compact rotation representations.
Definition: RotationBase.h:32
Holds strides information for Map.
Definition: Stride.h:55
@ Unaligned
Definition: Constants.h:235
@ DontAlign
Definition: Constants.h:327
@ RowMajor
Definition: Constants.h:323
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: Constants.h:527
Definition: EigenBase.h:32
Derived & derived()
Definition: EigenBase.h:48
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:69
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231
Definition: PlainObjectBase.h:73