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(int 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(int 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
29 template<
int MaxSizeAtCompileTime>
struct check_rows_cols_for_overflow {
30 template<
typename Index>
31 static EIGEN_ALWAYS_INLINE
void run(Index, Index)
36 template<>
struct check_rows_cols_for_overflow<Dynamic> {
37 template<
typename Index>
38 static EIGEN_ALWAYS_INLINE
void run(Index rows, Index cols)
42 Index max_index = (size_t(1) << (8 *
sizeof(Index) - 1)) - 1;
43 bool error = (rows == 0 || cols == 0) ?
false
44 : (rows > max_index / cols);
46 throw_std_bad_alloc();
50 template <
typename Derived,
51 typename OtherDerived = Derived,
52 bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
53 struct conservative_resize_like_impl;
55 template<
typename MatrixTypeA,
typename MatrixTypeB,
bool SwapPo
inters>
struct matrix_swap_impl;
67 #ifdef EIGEN_PARSED_BY_DOXYGEN
72 template<
typename Derived>
struct dense_xpr_base_dispatcher_for_doxygen;
74 template<
typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols>
75 struct dense_xpr_base_dispatcher_for_doxygen<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
76 :
public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > {};
78 template<
typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols>
79 struct dense_xpr_base_dispatcher_for_doxygen<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
80 :
public ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > {};
84 template<
typename Derived>
85 class PlainObjectBase :
public internal::dense_xpr_base_dispatcher_for_doxygen<Derived>
87 template<typename Derived>
92 enum { Options = internal::traits<Derived>::Options };
93 typedef typename internal::dense_xpr_base<Derived>::type Base;
95 typedef typename internal::traits<Derived>::StorageKind StorageKind;
96 typedef typename internal::traits<Derived>::Index Index;
97 typedef typename internal::traits<Derived>::Scalar Scalar;
98 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
100 typedef Derived DenseType;
102 using Base::RowsAtCompileTime;
103 using Base::ColsAtCompileTime;
104 using Base::SizeAtCompileTime;
105 using Base::MaxRowsAtCompileTime;
106 using Base::MaxColsAtCompileTime;
107 using Base::MaxSizeAtCompileTime;
108 using Base::IsVectorAtCompileTime;
111 template<
typename PlainObjectType,
int MapOptions,
typename Str
ideType>
friend class Eigen::Map;
114 friend class Eigen::Map<const Derived, Unaligned>;
118 friend class Eigen::Map<const Derived, Aligned>;
126 DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
129 enum { NeedsToAlign = SizeAtCompileTime != Dynamic && (internal::traits<Derived>::Flags &
AlignedBit) != 0 };
130 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
132 Base& base() {
return *
static_cast<Base*
>(
this); }
133 const Base& base()
const {
return *
static_cast<const Base*
>(
this); }
135 EIGEN_STRONG_INLINE Index rows()
const {
return m_storage.rows(); }
136 EIGEN_STRONG_INLINE Index cols()
const {
return m_storage.cols(); }
138 EIGEN_STRONG_INLINE
const Scalar& coeff(Index rowId, Index colId)
const
141 return m_storage.data()[colId + rowId * m_storage.cols()];
143 return m_storage.data()[rowId + colId * m_storage.rows()];
146 EIGEN_STRONG_INLINE
const Scalar& coeff(Index index)
const
148 return m_storage.data()[index];
151 EIGEN_STRONG_INLINE Scalar& coeffRef(Index rowId, Index colId)
154 return m_storage.data()[colId + rowId * m_storage.cols()];
156 return m_storage.data()[rowId + colId * m_storage.rows()];
159 EIGEN_STRONG_INLINE Scalar& coeffRef(Index index)
161 return m_storage.data()[index];
164 EIGEN_STRONG_INLINE
const Scalar& coeffRef(Index rowId, Index colId)
const
167 return m_storage.data()[colId + rowId * m_storage.cols()];
169 return m_storage.data()[rowId + colId * m_storage.rows()];
172 EIGEN_STRONG_INLINE
const Scalar& coeffRef(Index index)
const
174 return m_storage.data()[index];
178 template<
int LoadMode>
179 EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId)
const
181 return internal::ploadt<PacketScalar, LoadMode>
183 ? colId + rowId * m_storage.cols()
184 : rowId + colId * m_storage.rows()));
188 template<
int LoadMode>
189 EIGEN_STRONG_INLINE PacketScalar packet(Index index)
const
191 return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
195 template<
int StoreMode>
196 EIGEN_STRONG_INLINE
void writePacket(Index rowId, Index colId,
const PacketScalar& val)
198 internal::pstoret<Scalar, PacketScalar, StoreMode>
200 ? colId + rowId * m_storage.cols()
201 : rowId + colId * m_storage.rows()), val);
205 template<
int StoreMode>
206 EIGEN_STRONG_INLINE
void writePacket(Index index,
const PacketScalar& val)
208 internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
212 EIGEN_STRONG_INLINE
const Scalar *
data()
const
213 {
return m_storage.data(); }
216 EIGEN_STRONG_INLINE Scalar *
data()
217 {
return m_storage.data(); }
235 EIGEN_STRONG_INLINE
void resize(Index nbRows, Index nbCols)
237 eigen_assert( EIGEN_IMPLIES(RowsAtCompileTime!=Dynamic,nbRows==RowsAtCompileTime)
238 && EIGEN_IMPLIES(ColsAtCompileTime!=Dynamic,nbCols==ColsAtCompileTime)
239 && EIGEN_IMPLIES(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic,nbRows<=MaxRowsAtCompileTime)
240 && EIGEN_IMPLIES(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic,nbCols<=MaxColsAtCompileTime)
241 && nbRows>=0 && nbCols>=0 &&
"Invalid sizes when resizing a matrix or array.");
242 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(nbRows, nbCols);
243 #ifdef EIGEN_INITIALIZE_COEFFS
244 Index size = nbRows*nbCols;
245 bool size_changed = size != this->size();
246 m_storage.resize(size, nbRows, nbCols);
247 if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
249 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(nbRows, nbCols);
250 m_storage.resize(nbRows*nbCols, nbRows, nbCols);
268 eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime==Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0);
269 #ifdef EIGEN_INITIALIZE_COEFFS
270 bool size_changed = size != this->size();
272 if(RowsAtCompileTime == 1)
273 m_storage.resize(size, 1, size);
275 m_storage.resize(size, size, 1);
276 #ifdef EIGEN_INITIALIZE_COEFFS
277 if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
289 inline void resize(NoChange_t, Index nbCols)
302 inline void resize(Index nbRows, NoChange_t)
314 template<
typename OtherDerived>
317 const OtherDerived& other = _other.
derived();
318 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(other.rows(), other.cols());
319 const Index othersize = other.rows()*other.cols();
320 if(RowsAtCompileTime == 1)
322 eigen_assert(other.rows() == 1 || other.cols() == 1);
325 else if(ColsAtCompileTime == 1)
327 eigen_assert(other.rows() == 1 || other.cols() == 1);
330 else resize(other.rows(), other.cols());
344 internal::conservative_resize_like_impl<Derived>::run(*
this, nbRows, nbCols);
383 internal::conservative_resize_like_impl<Derived>::run(*
this, size);
395 template<
typename OtherDerived>
398 internal::conservative_resize_like_impl<Derived,OtherDerived>::run(*
this, other);
410 template<
typename OtherDerived>
413 _resize_to_match(other);
414 return Base::lazyAssign(other.derived());
417 template<
typename OtherDerived>
418 EIGEN_STRONG_INLINE Derived&
operator=(
const ReturnByValue<OtherDerived>& func)
420 resize(func.rows(), func.cols());
421 return Base::operator=(func);
424 EIGEN_STRONG_INLINE PlainObjectBase() : m_storage()
430 #ifndef EIGEN_PARSED_BY_DOXYGEN
433 PlainObjectBase(internal::constructor_without_unaligned_array_assert)
434 : m_storage(
internal::constructor_without_unaligned_array_assert())
444 _check_template_params();
448 template<
typename OtherDerived>
452 _check_template_params();
456 EIGEN_STRONG_INLINE PlainObjectBase(Index a_size, Index nbRows, Index nbCols)
457 : m_storage(a_size, nbRows, nbCols)
465 template<
typename OtherDerived>
468 _resize_to_match(other);
469 Base::operator=(other.
derived());
470 return this->derived();
474 template<
typename OtherDerived>
476 : m_storage(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
478 _check_template_params();
479 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(other.
derived().rows(), other.
derived().cols());
480 Base::operator=(other.
derived());
491 static inline ConstMapType
Map(
const Scalar*
data)
492 {
return ConstMapType(data); }
493 static inline MapType Map(Scalar*
data)
494 {
return MapType(data); }
495 static inline ConstMapType Map(
const Scalar*
data, Index size)
496 {
return ConstMapType(data, size); }
497 static inline MapType Map(Scalar*
data, Index size)
498 {
return MapType(data, size); }
499 static inline ConstMapType Map(
const Scalar*
data, Index rows, Index cols)
500 {
return ConstMapType(data, rows, cols); }
501 static inline MapType Map(Scalar*
data, Index rows, Index cols)
502 {
return MapType(data, rows, cols); }
504 static inline ConstAlignedMapType MapAligned(
const Scalar*
data)
505 {
return ConstAlignedMapType(data); }
506 static inline AlignedMapType MapAligned(Scalar*
data)
507 {
return AlignedMapType(data); }
508 static inline ConstAlignedMapType MapAligned(
const Scalar*
data, Index size)
509 {
return ConstAlignedMapType(data, size); }
510 static inline AlignedMapType MapAligned(Scalar*
data, Index size)
511 {
return AlignedMapType(data, size); }
512 static inline ConstAlignedMapType MapAligned(
const Scalar*
data, Index rows, Index cols)
513 {
return ConstAlignedMapType(data, rows, cols); }
514 static inline AlignedMapType MapAligned(Scalar*
data, Index rows, Index cols)
515 {
return AlignedMapType(data, rows, cols); }
517 template<
int Outer,
int Inner>
518 static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(
const Scalar*
data,
const Stride<Outer, Inner>& stride)
519 {
return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, stride); }
520 template<
int Outer,
int Inner>
521 static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar*
data,
const Stride<Outer, Inner>& stride)
522 {
return typename StridedMapType<Stride<Outer, Inner> >::type(data, stride); }
523 template<
int Outer,
int Inner>
524 static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(
const Scalar*
data, Index size,
const Stride<Outer, Inner>& stride)
525 {
return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, size, stride); }
526 template<
int Outer,
int Inner>
527 static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar*
data, Index size,
const Stride<Outer, Inner>& stride)
528 {
return typename StridedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
529 template<
int Outer,
int Inner>
530 static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(
const Scalar*
data, Index rows, Index cols,
const Stride<Outer, Inner>& stride)
531 {
return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
532 template<
int Outer,
int Inner>
533 static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar*
data, Index rows, Index cols,
const Stride<Outer, Inner>& stride)
534 {
return typename StridedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
536 template<
int Outer,
int Inner>
537 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(
const Scalar*
data,
const Stride<Outer, Inner>& stride)
538 {
return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }
539 template<
int Outer,
int Inner>
540 static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar*
data,
const Stride<Outer, Inner>& stride)
541 {
return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }
542 template<
int Outer,
int Inner>
543 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(
const Scalar*
data, Index size,
const Stride<Outer, Inner>& stride)
544 {
return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
545 template<
int Outer,
int Inner>
546 static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar*
data, Index size,
const Stride<Outer, Inner>& stride)
547 {
return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
548 template<
int Outer,
int Inner>
549 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(
const Scalar*
data, Index rows, Index cols,
const Stride<Outer, Inner>& stride)
550 {
return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
551 template<
int Outer,
int Inner>
552 static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar*
data, Index rows, Index cols,
const Stride<Outer, Inner>& stride)
553 {
return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
556 using Base::setConstant;
557 Derived&
setConstant(Index size,
const Scalar& value);
558 Derived&
setConstant(Index rows, Index cols,
const Scalar& value);
562 Derived&
setZero(Index rows, Index cols);
566 Derived&
setOnes(Index rows, Index cols);
568 using Base::setRandom;
570 Derived&
setRandom(Index rows, Index cols);
572 #ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
573 #include EIGEN_PLAINOBJECTBASE_PLUGIN
584 template<
typename OtherDerived>
585 EIGEN_STRONG_INLINE
void _resize_to_match(
const EigenBase<OtherDerived>& other)
587 #ifdef EIGEN_NO_AUTOMATIC_RESIZING
588 eigen_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size())
589 : (rows() == other.rows() && cols() == other.cols())))
590 &&
"Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
591 EIGEN_ONLY_USED_FOR_DEBUG(other);
613 template<
typename OtherDerived>
616 _set_selector(other.derived(),
typename internal::conditional<static_cast<bool>(int(OtherDerived::Flags) &
EvalBeforeAssigningBit), internal::true_type, internal::false_type>::type());
617 return this->derived();
620 template<
typename OtherDerived>
621 EIGEN_STRONG_INLINE
void _set_selector(
const OtherDerived& other,
const internal::true_type&) { _set_noalias(other.eval()); }
623 template<
typename OtherDerived>
624 EIGEN_STRONG_INLINE
void _set_selector(
const OtherDerived& other,
const internal::false_type&) { _set_noalias(other); }
631 template<
typename OtherDerived>
632 EIGEN_STRONG_INLINE Derived& _set_noalias(
const DenseBase<OtherDerived>& other)
639 return internal::assign_selector<Derived,OtherDerived,false>::run(this->derived(), other.derived());
642 template<
typename T0,
typename T1>
643 EIGEN_STRONG_INLINE
void _init2(Index nbRows, Index nbCols,
typename internal::enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
645 EIGEN_STATIC_ASSERT(
bool(NumTraits<T0>::IsInteger) &&
646 bool(NumTraits<T1>::IsInteger),
647 FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
650 template<typename T0, typename T1>
651 EIGEN_STRONG_INLINE
void _init2(const Scalar& val0, const Scalar& val1, typename
internal::enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)
653 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
654 m_storage.
data()[0] = val0;
655 m_storage.
data()[1] = val1;
658 template<typename MatrixTypeA, typename MatrixTypeB,
bool SwapPointers>
659 friend struct
internal::matrix_swap_impl;
664 template<typename OtherDerived>
665 void _swap(DenseBase<OtherDerived> const & other)
667 enum { SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime==Dynamic };
668 internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.const_cast_derived());
672 #ifndef EIGEN_PARSED_BY_DOXYGEN
673 static EIGEN_STRONG_INLINE
void _check_template_params()
675 EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (Options&
RowMajor)==RowMajor)
676 && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, (Options&RowMajor)==0)
677 && ((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0))
678 && ((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0))
679 && ((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0))
680 && ((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0))
681 && (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic)
682 && (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic)
683 && (Options & (
DontAlign|RowMajor)) == Options),
684 INVALID_MATRIX_TEMPLATE_PARAMETERS)
689 enum { ThisConstantIsPrivateInPlainObjectBase };
694 template <
typename Derived,
typename OtherDerived,
bool IsVector>
695 struct conservative_resize_like_impl
697 typedef typename Derived::Index Index;
698 static void run(DenseBase<Derived>& _this, Index rows, Index cols)
700 if (_this.rows() == rows && _this.cols() == cols)
return;
701 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
703 if ( ( Derived::IsRowMajor && _this.cols() == cols) ||
704 (!Derived::IsRowMajor && _this.rows() == rows) )
706 internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime>::run(rows, cols);
707 _this.derived().m_storage.conservativeResize(rows*cols,rows,cols);
712 typename Derived::PlainObject tmp(rows,cols);
713 const Index common_rows = (std::min)(rows, _this.rows());
714 const Index common_cols = (std::min)(cols, _this.cols());
715 tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
716 _this.derived().swap(tmp);
720 static void run(DenseBase<Derived>& _this,
const DenseBase<OtherDerived>& other)
722 if (_this.rows() == other.rows() && _this.cols() == other.cols())
return;
729 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
730 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
732 if ( ( Derived::IsRowMajor && _this.cols() == other.cols()) ||
733 (!Derived::IsRowMajor && _this.rows() == other.rows()) )
735 const Index new_rows = other.rows() - _this.rows();
736 const Index new_cols = other.cols() - _this.cols();
737 _this.derived().m_storage.conservativeResize(other.size(),other.rows(),other.cols());
739 _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
741 _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
746 typename Derived::PlainObject tmp(other);
747 const Index common_rows = (std::min)(tmp.rows(), _this.rows());
748 const Index common_cols = (std::min)(tmp.cols(), _this.cols());
749 tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
750 _this.derived().swap(tmp);
757 template <
typename Derived,
typename OtherDerived>
758 struct conservative_resize_like_impl<Derived,OtherDerived,true>
759 : conservative_resize_like_impl<Derived,OtherDerived,false>
761 using conservative_resize_like_impl<Derived,OtherDerived,false>::run;
763 typedef typename Derived::Index Index;
764 static void run(DenseBase<Derived>& _this, Index size)
766 const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size;
767 const Index new_cols = Derived::RowsAtCompileTime==1 ? size : 1;
768 _this.derived().m_storage.conservativeResize(size,new_rows,new_cols);
771 static void run(DenseBase<Derived>& _this,
const DenseBase<OtherDerived>& other)
773 if (_this.rows() == other.rows() && _this.cols() == other.cols())
return;
775 const Index num_new_elements = other.size() - _this.size();
777 const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows();
778 const Index new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1;
779 _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols);
781 if (num_new_elements > 0)
782 _this.tail(num_new_elements) = other.tail(num_new_elements);
786 template<
typename MatrixTypeA,
typename MatrixTypeB,
bool SwapPo
inters>
787 struct matrix_swap_impl
789 static inline void run(MatrixTypeA& a, MatrixTypeB& b)
795 template<
typename MatrixTypeA,
typename MatrixTypeB>
796 struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true>
798 static inline void run(MatrixTypeA& a, MatrixTypeB& b)
800 static_cast<typename MatrixTypeA::Base&
>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);
808 #endif // EIGEN_DENSESTORAGEBASE_H
Definition: Constants.h:270
Derived & setOnes(Index size)
Definition: CwiseNullaryOp.h:641
const Scalar * data() const
Definition: PlainObjectBase.h:212
Derived & operator=(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:466
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:411
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:104
void conservativeResize(Index size)
Definition: PlainObjectBase.h:381
PlainObjectBase(const PlainObjectBase &other)
Definition: PlainObjectBase.h:441
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
void resize(Index size)
Definition: PlainObjectBase.h:265
Scalar * data()
Definition: PlainObjectBase.h:216
Definition: EigenBase.h:26
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:396
void conservativeResize(Index nbRows, Index nbCols)
Definition: PlainObjectBase.h:342
Derived & setRandom(Index size)
Definition: Random.h:126
void resize(Index nbRows, NoChange_t)
Definition: PlainObjectBase.h:302
Derived & derived()
Definition: EigenBase.h:34
void conservativeResize(Index nbRows, NoChange_t)
Definition: PlainObjectBase.h:354
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:85
Derived & setConstant(Index size, const Scalar &value)
Definition: CwiseNullaryOp.h:348
Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition: PlainObjectBase.h:614
Definition: Eigen_Colamd.h:54
const unsigned int EvalBeforeAssigningBit
Definition: Constants.h:63
Derived & operator=(const PlainObjectBase &other)
Definition: PlainObjectBase.h:404
Definition: Constants.h:266
const unsigned int RowMajorBit
Definition: Constants.h:53
void resize(Index nbRows, Index nbCols)
Definition: PlainObjectBase.h:235
void resizeLike(const EigenBase< OtherDerived > &_other)
Definition: PlainObjectBase.h:315
const unsigned int AlignedBit
Definition: Constants.h:147
void resize(NoChange_t, Index nbCols)
Definition: PlainObjectBase.h:289
PlainObjectBase(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:475
void conservativeResize(NoChange_t, Index nbCols)
Definition: PlainObjectBase.h:367
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:515