198 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const Scalar&
coeff(
Index rowId,
Index colId)
const {
200 return m_storage.data()[colId + rowId * m_storage.cols()];
202 return m_storage.data()[rowId + colId * m_storage.rows()];
209 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const Scalar&
coeff(
Index index)
const {
210 return m_storage.data()[index];
219 return m_storage.data()[colId + rowId * m_storage.cols()];
221 return m_storage.data()[rowId + colId * m_storage.rows()];
228 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Scalar&
coeffRef(
Index index) {
return m_storage.data()[index]; }
232 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const Scalar&
coeffRef(
Index rowId,
Index colId)
const {
234 return m_storage.data()[colId + rowId * m_storage.cols()];
236 return m_storage.data()[rowId + colId * m_storage.rows()];
241 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const Scalar&
coeffRef(
Index index)
const {
242 return m_storage.data()[index];
246 template <
int LoadMode>
247 EIGEN_STRONG_INLINE PacketScalar packet(
Index rowId,
Index colId)
const {
248 return internal::ploadt<PacketScalar, LoadMode>(
249 m_storage.data() + (Flags &
RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()));
253 template <
int LoadMode>
254 EIGEN_STRONG_INLINE PacketScalar packet(Index index)
const {
255 return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
259 template <
int StoreMode>
260 EIGEN_STRONG_INLINE
void writePacket(Index rowId, Index colId,
const PacketScalar& val) {
261 internal::pstoret<Scalar, PacketScalar, StoreMode>(
262 m_storage.data() + (Flags &
RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()),
267 template <
int StoreMode>
268 EIGEN_STRONG_INLINE
void writePacket(Index index,
const PacketScalar& val) {
269 internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
273 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Scalar*
data()
const {
return m_storage.data(); }
276 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar*
data() {
return m_storage.data(); }
295 eigen_assert(internal::check_implication(RowsAtCompileTime !=
Dynamic, rows == RowsAtCompileTime) &&
296 internal::check_implication(ColsAtCompileTime !=
Dynamic, cols == ColsAtCompileTime) &&
297 internal::check_implication(RowsAtCompileTime ==
Dynamic && MaxRowsAtCompileTime !=
Dynamic,
298 rows <= MaxRowsAtCompileTime) &&
299 internal::check_implication(ColsAtCompileTime ==
Dynamic && MaxColsAtCompileTime !=
Dynamic,
300 cols <= MaxColsAtCompileTime) &&
301 rows >= 0 && cols >= 0 &&
"Invalid sizes when resizing a matrix or array.");
302#ifndef EIGEN_NO_DEBUG
303 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(rows,
306#ifdef EIGEN_INITIALIZE_COEFFS
307 Index size = rows * cols;
308 bool size_changed = size != this->size();
309 m_storage.resize(size, rows, cols);
310 if (size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
312 m_storage.resize(rows * cols, rows, cols);
329 eigen_assert(((SizeAtCompileTime ==
Dynamic && (MaxSizeAtCompileTime ==
Dynamic || size <= MaxSizeAtCompileTime)) ||
330 SizeAtCompileTime == size) &&
332#ifdef EIGEN_INITIALIZE_COEFFS
333 bool size_changed = size != this->size();
335 if (RowsAtCompileTime == 1)
336 m_storage.resize(size, 1, size);
338 m_storage.resize(size, size, 1);
339#ifdef EIGEN_INITIALIZE_COEFFS
340 if (size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
352 EIGEN_DEVICE_FUNC
inline constexpr void resize(NoChange_t,
Index cols) {
resize(rows(), cols); }
362 EIGEN_DEVICE_FUNC
inline constexpr void resize(
Index rows, NoChange_t) {
resize(rows, cols()); }
371 template <
typename OtherDerived>
373 const OtherDerived& other = _other.
derived();
374#ifndef EIGEN_NO_DEBUG
375 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(
376 other.rows(), other.cols());
378 const Index othersize = other.rows() * other.cols();
379 if (RowsAtCompileTime == 1) {
380 eigen_assert(other.rows() == 1 || other.cols() == 1);
382 }
else if (ColsAtCompileTime == 1) {
383 eigen_assert(other.rows() == 1 || other.cols() == 1);
386 resize(other.rows(), other.cols());
399 internal::conservative_resize_like_impl<Derived>::run(*
this, rows, cols);
435 internal::conservative_resize_like_impl<Derived>::run(*
this, size);
447 template <
typename OtherDerived>
449 internal::conservative_resize_like_impl<Derived, OtherDerived>::run(*
this, other);
460 template <
typename OtherDerived>
462 _resize_to_match(other);
463 return Base::lazyAssign(other.
derived());
466 template <
typename OtherDerived>
467 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
operator=(
const ReturnByValue<OtherDerived>& func) {
468 resize(func.rows(), func.cols());
469 return Base::operator=(func);
475 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr PlainObjectBase() : m_storage() {
479#ifndef EIGEN_PARSED_BY_DOXYGEN
482 EIGEN_DEVICE_FUNC
constexpr explicit PlainObjectBase(internal::constructor_without_unaligned_array_assert)
483 : m_storage(internal::constructor_without_unaligned_array_assert()) {
488 EIGEN_DEVICE_FUNC
constexpr PlainObjectBase(PlainObjectBase&& other) EIGEN_NOEXCEPT
489 : m_storage(std::move(other.m_storage)) {}
491 EIGEN_DEVICE_FUNC
constexpr PlainObjectBase&
operator=(PlainObjectBase&& other) EIGEN_NOEXCEPT {
492 m_storage = std::move(other.m_storage);
498 : Base(), m_storage(other.m_storage) {}
500 : m_storage(size, rows, cols) {
513 template <
typename... ArgTypes>
514 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
PlainObjectBase(
const Scalar& a0,
const Scalar& a1,
const Scalar& a2,
515 const Scalar& a3,
const ArgTypes&... args)
517 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
PlainObjectBase,
sizeof...(args) + 4);
518 m_storage.data()[0] = a0;
519 m_storage.data()[1] = a1;
520 m_storage.data()[2] = a2;
521 m_storage.data()[3] = a3;
523 auto x = {(m_storage.data()[i++] = args, 0)...};
524 static_cast<void>(x);
531 const std::initializer_list<std::initializer_list<Scalar>>& list)
533 size_t list_size = 0;
534 if (list.begin() != list.end()) {
535 list_size = list.begin()->size();
539 if (ColsAtCompileTime == 1 && list.size() == 1) {
540 eigen_assert(list_size ==
static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime ==
Dynamic);
541 resize(list_size, ColsAtCompileTime);
542 if (list.begin()->begin() !=
nullptr) {
543 std::copy(list.begin()->begin(), list.begin()->end(), m_storage.data());
546 eigen_assert(list.size() ==
static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime ==
Dynamic);
547 eigen_assert(list_size ==
static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime ==
Dynamic);
548 resize(list.size(), list_size);
551 for (
const std::initializer_list<Scalar>& row : list) {
552 eigen_assert(list_size == row.size());
554 for (
const Scalar& e : row) {
564 template <
typename OtherDerived>
571 template <
typename OtherDerived>
577 template <
typename OtherDerived>
578 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
PlainObjectBase(
const ReturnByValue<OtherDerived>& other) {
580 resize(other.rows(), other.cols());
581 other.evalTo(this->derived());
588 template <
typename OtherDerived>
590 _resize_to_match(other);
591 Base::operator=(other.
derived());
592 return this->derived();
607 static inline ConstMapType
Map(
const Scalar*
data) {
return ConstMapType(
data); }
608 static inline MapType Map(Scalar*
data) {
return MapType(
data); }
609 static inline ConstMapType Map(
const Scalar*
data, Index size) {
return ConstMapType(
data, size); }
610 static inline MapType Map(Scalar*
data, Index size) {
return MapType(
data, size); }
611 static inline ConstMapType Map(
const Scalar*
data, Index rows, Index cols) {
return ConstMapType(
data, rows, cols); }
612 static inline MapType Map(Scalar*
data, Index rows, Index cols) {
return MapType(
data, rows, cols); }
614 static inline ConstAlignedMapType MapAligned(
const Scalar*
data) {
return ConstAlignedMapType(
data); }
615 static inline AlignedMapType MapAligned(Scalar*
data) {
return AlignedMapType(
data); }
616 static inline ConstAlignedMapType MapAligned(
const Scalar*
data, Index size) {
617 return ConstAlignedMapType(
data, size);
619 static inline AlignedMapType MapAligned(Scalar*
data, Index size) {
return AlignedMapType(
data, size); }
620 static inline ConstAlignedMapType MapAligned(
const Scalar*
data, Index rows, Index cols) {
621 return ConstAlignedMapType(
data, rows, cols);
623 static inline AlignedMapType MapAligned(Scalar*
data, Index rows, Index cols) {
624 return AlignedMapType(
data, rows, cols);
627 template <
int Outer,
int Inner>
628 static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
const Scalar*
data,
629 const Stride<Outer, Inner>& stride) {
630 return typename StridedConstMapType<Stride<Outer, Inner>>::type(
data, stride);
632 template <
int Outer,
int Inner>
633 static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(Scalar*
data,
634 const Stride<Outer, Inner>& stride) {
635 return typename StridedMapType<Stride<Outer, Inner>>::type(
data, stride);
637 template <
int Outer,
int Inner>
638 static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
const Scalar*
data, Index size,
639 const Stride<Outer, Inner>& stride) {
640 return typename StridedConstMapType<Stride<Outer, Inner>>::type(
data, size, stride);
642 template <
int Outer,
int Inner>
643 static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(Scalar*
data, Index size,
644 const Stride<Outer, Inner>& stride) {
645 return typename StridedMapType<Stride<Outer, Inner>>::type(
data, size, stride);
647 template <
int Outer,
int Inner>
648 static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
const Scalar*
data, Index rows, Index cols,
649 const Stride<Outer, Inner>& stride) {
650 return typename StridedConstMapType<Stride<Outer, Inner>>::type(
data, rows, cols, stride);
652 template <
int Outer,
int Inner>
653 static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(Scalar*
data, Index rows, Index cols,
654 const Stride<Outer, Inner>& stride) {
655 return typename StridedMapType<Stride<Outer, Inner>>::type(
data, rows, cols, stride);
658 template <
int Outer,
int Inner>
659 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
660 const Scalar*
data,
const Stride<Outer, Inner>& stride) {
661 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(
data, stride);
663 template <
int Outer,
int Inner>
664 static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
665 Scalar*
data,
const Stride<Outer, Inner>& stride) {
666 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(
data, stride);
668 template <
int Outer,
int Inner>
669 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
670 const Scalar*
data, Index size,
const Stride<Outer, Inner>& stride) {
671 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(
data, size, stride);
673 template <
int Outer,
int Inner>
674 static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
675 Scalar*
data, Index size,
const Stride<Outer, Inner>& stride) {
676 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(
data, size, stride);
678 template <
int Outer,
int Inner>
679 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
680 const Scalar*
data, Index rows, Index cols,
const Stride<Outer, Inner>& stride) {
681 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(
data, rows, cols, stride);
683 template <
int Outer,
int Inner>
684 static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
685 Scalar*
data, Index rows, Index cols,
const Stride<Outer, Inner>& stride) {
686 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(
data, rows, cols, stride);
690 using Base::setConstant;
691 EIGEN_DEVICE_FUNC Derived&
setConstant(Index size,
const Scalar& val);
692 EIGEN_DEVICE_FUNC Derived&
setConstant(Index rows, Index cols,
const Scalar& val);
693 EIGEN_DEVICE_FUNC Derived&
setConstant(NoChange_t, Index cols,
const Scalar& val);
694 EIGEN_DEVICE_FUNC Derived&
setConstant(Index rows, NoChange_t,
const Scalar& val);
697 EIGEN_DEVICE_FUNC Derived&
setZero(Index size);
698 EIGEN_DEVICE_FUNC Derived&
setZero(Index rows, Index cols);
699 EIGEN_DEVICE_FUNC Derived&
setZero(NoChange_t, Index cols);
700 EIGEN_DEVICE_FUNC Derived&
setZero(Index rows, NoChange_t);
703 EIGEN_DEVICE_FUNC Derived&
setOnes(Index size);
704 EIGEN_DEVICE_FUNC Derived&
setOnes(Index rows, Index cols);
705 EIGEN_DEVICE_FUNC Derived&
setOnes(NoChange_t, Index cols);
706 EIGEN_DEVICE_FUNC Derived&
setOnes(Index rows, NoChange_t);
708 using Base::setRandom;
710 Derived&
setRandom(Index rows, Index cols);
711 Derived&
setRandom(NoChange_t, Index cols);
712 Derived&
setRandom(Index rows, NoChange_t);
714#ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
715#include EIGEN_PLAINOBJECTBASE_PLUGIN
726 template <
typename OtherDerived>
727 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _resize_to_match(
const EigenBase<OtherDerived>& other) {
728#ifdef EIGEN_NO_AUTOMATIC_RESIZING
729 eigen_assert((this->size() == 0 || (IsVectorAtCompileTime ? (this->size() == other.size())
730 : (rows() == other.rows() && cols() == other.cols()))) &&
731 "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
732 EIGEN_ONLY_USED_FOR_DEBUG(other);
754 template <
typename OtherDerived>
756 internal::call_assignment(this->derived(), other.
derived());
757 return this->derived();
765 template <
typename OtherDerived>
772 internal::call_assignment_no_alias(this->derived(), other.
derived(),
773 internal::assign_op<Scalar, typename OtherDerived::Scalar>());
774 return this->derived();
777 template <
typename T0,
typename T1>
778 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init2(Index rows, Index cols,
779 std::enable_if_t<Base::SizeAtCompileTime != 2, T0>* = 0) {
780 EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T0>::value && internal::is_valid_index_type<T1>::value,
781 T0 AND T1 MUST BE INTEGER TYPES)
785 template <
typename T0,
typename T1>
786 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init2(
const T0& val0,
const T1& val1,
787 std::enable_if_t<Base::SizeAtCompileTime == 2, T0>* = 0) {
788 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
789 m_storage.
data()[0] = Scalar(val0);
790 m_storage.
data()[1] = Scalar(val1);
793 template <typename T0, typename T1>
794 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init2(
795 const Index& val0, const Index& val1,
796 std::enable_if_t<(!internal::is_same<Index, Scalar>::value) && (internal::is_same<T0, Index>::value) &&
797 (internal::is_same<T1, Index>::value) && Base::SizeAtCompileTime == 2,
799 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
800 m_storage.
data()[0] = Scalar(val0);
801 m_storage.
data()[1] = Scalar(val1);
806 template <typename T>
807 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
809 std::enable_if_t<(Base::SizeAtCompileTime != 1 || !internal::is_convertible<T, Scalar>::value) &&
810 ((!internal::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value ||
811 Base::SizeAtCompileTime ==
Dynamic)),
814 const bool is_integer_alike = internal::is_valid_index_type<T>::value;
815 EIGEN_UNUSED_VARIABLE(is_integer_alike);
816 EIGEN_STATIC_ASSERT(is_integer_alike, FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
822 template <
typename T>
823 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
825 std::enable_if_t<Base::SizeAtCompileTime == 1 && internal::is_convertible<T, Scalar>::value, T>* = 0) {
826 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
827 m_storage.
data()[0] = val0;
832 template <typename T>
833 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
835 std::enable_if_t<(!internal::is_same<Index, Scalar>::value) && (internal::is_same<Index, T>::value) &&
836 Base::SizeAtCompileTime == 1 && internal::is_convertible<T, Scalar>::value,
838 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
839 m_storage.
data()[0] = Scalar(val0);
843 template <typename T>
844 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(const Scalar*
data) {
845 this->_set_noalias(ConstMapType(
data));
849 template <
typename T,
typename OtherDerived>
850 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
const DenseBase<OtherDerived>& other) {
851 this->_set_noalias(other);
855 template <
typename T>
856 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
const Derived& other) {
857 this->_set_noalias(other);
861 template <
typename T,
typename OtherDerived>
862 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
const EigenBase<OtherDerived>& other) {
863 this->derived() = other;
866 template <
typename T,
typename OtherDerived>
867 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
const ReturnByValue<OtherDerived>& other) {
868 resize(other.rows(), other.cols());
869 other.evalTo(this->derived());
872 template <
typename T,
typename OtherDerived,
int ColsAtCompileTime>
873 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
const RotationBase<OtherDerived, ColsAtCompileTime>& r) {
878 template <
typename T>
879 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
881 std::enable_if_t<Base::SizeAtCompileTime !=
Dynamic && Base::SizeAtCompileTime != 1 &&
882 internal::is_convertible<T, Scalar>::value &&
883 internal::is_same<
typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
885 Base::setConstant(val0);
889 template <
typename T>
890 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void _init1(
892 std::enable_if_t<(!internal::is_same<Index, Scalar>::value) && (internal::is_same<Index, T>::value) &&
893 Base::SizeAtCompileTime !=
Dynamic && Base::SizeAtCompileTime != 1 &&
894 internal::is_convertible<T, Scalar>::value &&
895 internal::is_same<
typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
897 Base::setConstant(val0);
900 template <
typename MatrixTypeA,
typename MatrixTypeB,
bool SwapPo
inters>
901 friend struct internal::matrix_swap_impl;
904#ifndef EIGEN_PARSED_BY_DOXYGEN
909 template <
typename OtherDerived>
910 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void swap(DenseBase<OtherDerived>& other) {
911 enum {SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime ==
Dynamic};
912 internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());
918 template <
typename OtherDerived>
919 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void swap(DenseBase<OtherDerived>
const& other) {
920 Base::swap(other.derived());
923 enum {IsPlainObjectBase = 1};
928 template <
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
932#if EIGEN_MAX_ALIGN_BYTES > 0
936 friend class Eigen::Map<const Derived, AlignedMax>;
942template <
typename Derived,
typename OtherDerived,
bool IsVector>
943struct conservative_resize_like_impl {
944 static constexpr bool IsRelocatable = std::is_trivially_copyable<typename Derived::Scalar>::value;
945 static void run(DenseBase<Derived>& _this, Index rows, Index cols) {
946 if (_this.rows() == rows && _this.cols() == cols)
return;
947 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
950 ((Derived::IsRowMajor && _this.cols() == cols) ||
951 (!Derived::IsRowMajor && _this.rows() == rows)))
953#ifndef EIGEN_NO_DEBUG
954 internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime, Derived::MaxRowsAtCompileTime,
955 Derived::MaxColsAtCompileTime>::run(rows, cols);
957 _this.derived().m_storage.conservativeResize(rows * cols, rows, cols);
960 Derived tmp(rows, cols);
961 const Index common_rows = numext::mini(rows, _this.rows());
962 const Index common_cols = numext::mini(cols, _this.cols());
963 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
964 _this.derived().swap(tmp);
968 static void run(DenseBase<Derived>& _this,
const DenseBase<OtherDerived>& other) {
969 if (_this.rows() == other.rows() && _this.cols() == other.cols())
return;
976 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
977 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
980 ((Derived::IsRowMajor && _this.cols() == other.cols()) ||
981 (!Derived::IsRowMajor &&
982 _this.rows() == other.rows())))
984 const Index new_rows = other.rows() - _this.rows();
985 const Index new_cols = other.cols() - _this.cols();
986 _this.derived().m_storage.conservativeResize(other.size(), other.rows(), other.cols());
988 _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
989 else if (new_cols > 0)
990 _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
994 const Index common_rows = numext::mini(tmp.rows(), _this.rows());
995 const Index common_cols = numext::mini(tmp.cols(), _this.cols());
996 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
997 _this.derived().swap(tmp);
1004template <
typename Derived,
typename OtherDerived>
1005struct conservative_resize_like_impl<Derived, OtherDerived, true>
1006 : conservative_resize_like_impl<Derived, OtherDerived, false> {
1007 typedef conservative_resize_like_impl<Derived, OtherDerived, false> Base;
1008 using Base::IsRelocatable;
1011 static void run(DenseBase<Derived>& _this, Index size) {
1012 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : size;
1013 const Index new_cols = Derived::RowsAtCompileTime == 1 ? size : 1;
1015 _this.derived().m_storage.conservativeResize(size, new_rows, new_cols);
1017 Base::run(_this.derived(), new_rows, new_cols);
1020 static void run(DenseBase<Derived>& _this,
const DenseBase<OtherDerived>& other) {
1021 if (_this.rows() == other.rows() && _this.cols() == other.cols())
return;
1023 const Index num_new_elements = other.size() - _this.size();
1025 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : other.rows();
1026 const Index new_cols = Derived::RowsAtCompileTime == 1 ? other.cols() : 1;
1028 _this.derived().m_storage.conservativeResize(other.size(), new_rows, new_cols);
1030 Base::run(_this.derived(), new_rows, new_cols);
1032 if (num_new_elements > 0) _this.tail(num_new_elements) = other.tail(num_new_elements);
1036template <
typename MatrixTypeA,
typename MatrixTypeB,
bool SwapPo
inters>
1037struct matrix_swap_impl {
1038 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void run(MatrixTypeA& a, MatrixTypeB& b) { a.base().swap(b); }
1041template <
typename MatrixTypeA,
typename MatrixTypeB>
1042struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> {
1043 EIGEN_DEVICE_FUNC
static inline void run(MatrixTypeA& a, MatrixTypeB& b) {
1044 static_cast<typename MatrixTypeA::Base&
>(a).m_storage.swap(
static_cast<typename MatrixTypeB::Base&
>(b).m_storage);