Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
PlainObjectBase.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2009 Gael Guennebaud <[email protected]>
5// Copyright (C) 2006-2008 Benoit Jacob <[email protected]>
6//
7// This Source Code Form is subject to the terms of the Mozilla
8// Public License v. 2.0. If a copy of the MPL was not distributed
9// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
11#ifndef EIGEN_DENSESTORAGEBASE_H
12#define EIGEN_DENSESTORAGEBASE_H
13
14#if defined(EIGEN_INITIALIZE_MATRICES_BY_ZERO)
15#define EIGEN_INITIALIZE_COEFFS
16#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED \
17 for (Index i = 0; i < base().size(); ++i) coeffRef(i) = Scalar(0);
18#elif defined(EIGEN_INITIALIZE_MATRICES_BY_NAN)
19#define EIGEN_INITIALIZE_COEFFS
20#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED \
21 for (Index i = 0; i < base().size(); ++i) coeffRef(i) = std::numeric_limits<Scalar>::quiet_NaN();
22#else
23#undef EIGEN_INITIALIZE_COEFFS
24#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
25#endif
26
27// IWYU pragma: private
28#include "./InternalHeaderCheck.h"
29
30namespace Eigen {
31
32namespace internal {
33
34#ifndef EIGEN_NO_DEBUG
35template <int MaxSizeAtCompileTime, int MaxRowsAtCompileTime, int MaxColsAtCompileTime>
36struct check_rows_cols_for_overflow {
37 EIGEN_STATIC_ASSERT(MaxRowsAtCompileTime* MaxColsAtCompileTime == MaxSizeAtCompileTime,
38 YOU MADE A PROGRAMMING MISTAKE)
39 template <typename Index>
40 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index) {}
41};
42
43template <int MaxRowsAtCompileTime>
44struct check_rows_cols_for_overflow<Dynamic, MaxRowsAtCompileTime, Dynamic> {
45 template <typename Index>
46 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index cols) {
47 constexpr Index MaxIndex = NumTraits<Index>::highest();
48 bool error = cols > (MaxIndex / MaxRowsAtCompileTime);
49 if (error) throw_std_bad_alloc();
50 }
51};
52
53template <int MaxColsAtCompileTime>
54struct check_rows_cols_for_overflow<Dynamic, Dynamic, MaxColsAtCompileTime> {
55 template <typename Index>
56 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index) {
57 constexpr Index MaxIndex = NumTraits<Index>::highest();
58 bool error = rows > (MaxIndex / MaxColsAtCompileTime);
59 if (error) throw_std_bad_alloc();
60 }
61};
62
63template <>
64struct check_rows_cols_for_overflow<Dynamic, Dynamic, Dynamic> {
65 template <typename Index>
66 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index cols) {
67 constexpr Index MaxIndex = NumTraits<Index>::highest();
68 bool error = cols == 0 ? false : (rows > (MaxIndex / cols));
69 if (error) throw_std_bad_alloc();
70 }
71};
72#endif
73
74template <typename Derived, typename OtherDerived = Derived,
75 bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
76struct conservative_resize_like_impl;
77
78template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
79struct matrix_swap_impl;
80
81} // end namespace internal
82
83#ifdef EIGEN_PARSED_BY_DOXYGEN
84namespace doxygen {
85
86// This is a workaround to doxygen not being able to understand the inheritance logic
87// when it is hidden by the dense_xpr_base helper struct.
88// Moreover, doxygen fails to include members that are not documented in the declaration body of
89// MatrixBase if we inherits MatrixBase<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >,
90// this is why we simply inherits MatrixBase, though this does not make sense.
91
93template <typename Derived>
96template <typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
97struct dense_xpr_base_dispatcher<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> : public MatrixBase {};
99template <typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
100struct dense_xpr_base_dispatcher<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> : public ArrayBase {};
101
102} // namespace doxygen
103
115template <typename Derived>
117#else
118template <typename Derived>
119class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
120#endif
121{
122 public:
123 enum { Options = internal::traits<Derived>::Options };
124 typedef typename internal::dense_xpr_base<Derived>::type Base;
125
126 typedef typename internal::traits<Derived>::StorageKind StorageKind;
127 typedef typename internal::traits<Derived>::Scalar Scalar;
128
129 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
130 typedef typename NumTraits<Scalar>::Real RealScalar;
131 typedef Derived DenseType;
132
133 using Base::ColsAtCompileTime;
134 using Base::Flags;
135 using Base::IsVectorAtCompileTime;
136 using Base::MaxColsAtCompileTime;
137 using Base::MaxRowsAtCompileTime;
138 using Base::MaxSizeAtCompileTime;
139 using Base::RowsAtCompileTime;
140 using Base::SizeAtCompileTime;
141
146 template <typename StrideType>
147 struct StridedMapType {
149 };
150 template <typename StrideType>
151 struct StridedConstMapType {
153 };
154 template <typename StrideType>
155 struct StridedAlignedMapType {
157 };
158 template <typename StrideType>
159 struct StridedConstAlignedMapType {
161 };
162
163 protected:
164 DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
165
166 public:
167 enum { NeedsToAlign = (SizeAtCompileTime != Dynamic) && (internal::traits<Derived>::Alignment > 0) };
168 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
169
170 EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1,
171 (int(Options) & RowMajor) == RowMajor),
172 INVALID_MATRIX_TEMPLATE_PARAMETERS)
173 EIGEN_STATIC_ASSERT(internal::check_implication(MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1,
174 (int(Options) & RowMajor) == 0),
175 INVALID_MATRIX_TEMPLATE_PARAMETERS)
176 EIGEN_STATIC_ASSERT((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
177 EIGEN_STATIC_ASSERT((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
178 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0),
179 INVALID_MATRIX_TEMPLATE_PARAMETERS)
180 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0),
181 INVALID_MATRIX_TEMPLATE_PARAMETERS)
182 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime == Dynamic),
183 INVALID_MATRIX_TEMPLATE_PARAMETERS)
184 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime == Dynamic),
185 INVALID_MATRIX_TEMPLATE_PARAMETERS)
186 EIGEN_STATIC_ASSERT(((Options & (DontAlign | RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS)
187
188 EIGEN_DEVICE_FUNC Base& base() { return *static_cast<Base*>(this); }
189 EIGEN_DEVICE_FUNC const Base& base() const { return *static_cast<const Base*>(this); }
190
191 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_storage.rows(); }
192 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_storage.cols(); }
193
198 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeff(Index rowId, Index colId) const {
199 if (Flags & RowMajorBit)
200 return m_storage.data()[colId + rowId * m_storage.cols()];
201 else // column-major
202 return m_storage.data()[rowId + colId * m_storage.rows()];
203 }
204
209 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeff(Index index) const {
210 return m_storage.data()[index];
211 }
212
217 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Scalar& coeffRef(Index rowId, Index colId) {
218 if (Flags & RowMajorBit)
219 return m_storage.data()[colId + rowId * m_storage.cols()];
220 else // column-major
221 return m_storage.data()[rowId + colId * m_storage.rows()];
222 }
223
228 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Scalar& coeffRef(Index index) { return m_storage.data()[index]; }
229
232 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeffRef(Index rowId, Index colId) const {
233 if (Flags & RowMajorBit)
234 return m_storage.data()[colId + rowId * m_storage.cols()];
235 else // column-major
236 return m_storage.data()[rowId + colId * m_storage.rows()];
237 }
238
241 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeffRef(Index index) const {
242 return m_storage.data()[index];
243 }
244
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()));
250 }
251
253 template <int LoadMode>
254 EIGEN_STRONG_INLINE PacketScalar packet(Index index) const {
255 return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
256 }
257
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()),
263 val);
264 }
265
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);
270 }
271
273 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar* data() const { return m_storage.data(); }
274
276 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar* data() { return m_storage.data(); }
277
294 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void resize(Index rows, Index cols) {
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,
304 cols);
305#endif
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
311#else
312 m_storage.resize(rows * cols, rows, cols);
313#endif
314 }
315
327 EIGEN_DEVICE_FUNC inline constexpr void resize(Index size) {
328 EIGEN_STATIC_ASSERT_VECTOR_ONLY(PlainObjectBase)
329 eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime == Dynamic || size <= MaxSizeAtCompileTime)) ||
330 SizeAtCompileTime == size) &&
331 size >= 0);
332#ifdef EIGEN_INITIALIZE_COEFFS
333 bool size_changed = size != this->size();
334#endif
335 if (RowsAtCompileTime == 1)
336 m_storage.resize(size, 1, size);
337 else
338 m_storage.resize(size, size, 1);
339#ifdef EIGEN_INITIALIZE_COEFFS
340 if (size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
341#endif
342 }
343
352 EIGEN_DEVICE_FUNC inline constexpr void resize(NoChange_t, Index cols) { resize(rows(), cols); }
353
362 EIGEN_DEVICE_FUNC inline constexpr void resize(Index rows, NoChange_t) { resize(rows, cols()); }
363
371 template <typename OtherDerived>
372 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other) {
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());
377#endif
378 const Index othersize = other.rows() * other.cols();
379 if (RowsAtCompileTime == 1) {
380 eigen_assert(other.rows() == 1 || other.cols() == 1);
381 resize(1, othersize);
382 } else if (ColsAtCompileTime == 1) {
383 eigen_assert(other.rows() == 1 || other.cols() == 1);
384 resize(othersize, 1);
385 } else
386 resize(other.rows(), other.cols());
387 }
388
398 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols) {
399 internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols);
400 }
401
409 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t) {
410 // Note: see the comment in conservativeResize(Index,Index)
411 conservativeResize(rows, cols());
412 }
413
421 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols) {
422 // Note: see the comment in conservativeResize(Index,Index)
423 conservativeResize(rows(), cols);
424 }
425
434 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index size) {
435 internal::conservative_resize_like_impl<Derived>::run(*this, size);
436 }
437
447 template <typename OtherDerived>
448 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other) {
449 internal::conservative_resize_like_impl<Derived, OtherDerived>::run(*this, other);
450 }
451
455 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Derived& operator=(const PlainObjectBase& other) {
456 return _set(other);
457 }
458
460 template <typename OtherDerived>
461 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other) {
462 _resize_to_match(other);
463 return Base::lazyAssign(other.derived());
464 }
465
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);
470 }
471
472 // Prevent user from trying to instantiate PlainObjectBase objects
473 // by making all its constructor protected. See bug 1074.
474 protected:
475 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr PlainObjectBase() : m_storage() {
476 // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
477 }
478
479#ifndef EIGEN_PARSED_BY_DOXYGEN
480 // FIXME is it still needed ?
482 EIGEN_DEVICE_FUNC constexpr explicit PlainObjectBase(internal::constructor_without_unaligned_array_assert)
483 : m_storage(internal::constructor_without_unaligned_array_assert()) {
484 // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
485 }
486#endif
487
488 EIGEN_DEVICE_FUNC constexpr PlainObjectBase(PlainObjectBase&& other) EIGEN_NOEXCEPT
489 : m_storage(std::move(other.m_storage)) {}
490
491 EIGEN_DEVICE_FUNC constexpr PlainObjectBase& operator=(PlainObjectBase&& other) EIGEN_NOEXCEPT {
492 m_storage = std::move(other.m_storage);
493 return *this;
494 }
495
497 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr PlainObjectBase(const PlainObjectBase& other)
498 : Base(), m_storage(other.m_storage) {}
499 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)
500 : m_storage(size, rows, cols) {
501 // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
502 }
503
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)
516 : m_storage() {
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;
522 Index i = 4;
523 auto x = {(m_storage.data()[i++] = args, 0)...};
524 static_cast<void>(x);
525 }
526
530 EIGEN_DEVICE_FUNC explicit constexpr EIGEN_STRONG_INLINE PlainObjectBase(
531 const std::initializer_list<std::initializer_list<Scalar>>& list)
532 : m_storage() {
533 size_t list_size = 0;
534 if (list.begin() != list.end()) {
535 list_size = list.begin()->size();
536 }
537
538 // This is to allow syntax like VectorXi {{1, 2, 3, 4}}
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());
544 }
545 } else {
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);
549
550 Index row_index = 0;
551 for (const std::initializer_list<Scalar>& row : list) {
552 eigen_assert(list_size == row.size());
553 Index col_index = 0;
554 for (const Scalar& e : row) {
555 coeffRef(row_index, col_index) = e;
556 ++col_index;
557 }
558 ++row_index;
559 }
560 }
561 }
562
564 template <typename OtherDerived>
565 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived>& other) : m_storage() {
566 resizeLike(other);
567 _set_noalias(other);
568 }
569
571 template <typename OtherDerived>
572 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived>& other) : m_storage() {
573 resizeLike(other);
574 *this = other.derived();
575 }
577 template <typename OtherDerived>
578 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue<OtherDerived>& other) {
579 // FIXME this does not automatically transpose vectors if necessary
580 resize(other.rows(), other.cols());
581 other.evalTo(this->derived());
582 }
583
584 public:
588 template <typename OtherDerived>
589 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived>& other) {
590 _resize_to_match(other);
591 Base::operator=(other.derived());
592 return this->derived();
593 }
594
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); }
613
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);
618 }
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);
622 }
623 static inline AlignedMapType MapAligned(Scalar* data, Index rows, Index cols) {
624 return AlignedMapType(data, rows, cols);
625 }
626
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);
631 }
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);
636 }
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);
641 }
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);
646 }
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);
651 }
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);
656 }
657
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);
662 }
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);
667 }
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);
672 }
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);
677 }
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);
682 }
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);
687 }
689
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);
695
696 using Base::setZero;
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);
701
702 using Base::setOnes;
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);
707
708 using Base::setRandom;
709 Derived& setRandom(Index size);
710 Derived& setRandom(Index rows, Index cols);
711 Derived& setRandom(NoChange_t, Index cols);
712 Derived& setRandom(Index rows, NoChange_t);
713
714#ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
715#include EIGEN_PLAINOBJECTBASE_PLUGIN
716#endif
717
718 protected:
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);
733#else
734 resizeLike(other);
735#endif
736 }
737
752 // aliasing is dealt once in internal::call_assignment
753 // so at this stage we have to assume aliasing... and resising has to be done later.
754 template <typename OtherDerived>
755 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Derived& _set(const DenseBase<OtherDerived>& other) {
756 internal::call_assignment(this->derived(), other.derived());
757 return this->derived();
758 }
759
765 template <typename OtherDerived>
766 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Derived& _set_noalias(const DenseBase<OtherDerived>& other) {
767 // I don't think we need this resize call since the lazyAssign will anyways resize
768 // and lazyAssign will be called by the assign selector.
769 //_resize_to_match(other);
770 // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
771 // it wouldn't allow to copy a row-vector into a column-vector.
772 internal::call_assignment_no_alias(this->derived(), other.derived(),
773 internal::assign_op<Scalar, typename OtherDerived::Scalar>());
774 return this->derived();
775 }
776
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)
782 resize(rows, cols);
783 }
784
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);
791 }
792
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,
798 T1>* = 0) {
799 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
800 m_storage.data()[0] = Scalar(val0);
801 m_storage.data()[1] = Scalar(val1);
802 }
803
804 // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,
805 // then the argument is meant to be the size of the object.
806 template <typename T>
807 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(
808 Index size,
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)),
812 T>* = 0) {
813 // NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.
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)
817 resize(size);
818 }
819
820 // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
821 // type can be implicitly converted)
822 template <typename T>
823 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(
824 const Scalar& val0,
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;
828 }
829
830 // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
831 // type match the index type)
832 template <typename T>
833 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(
834 const Index& val0,
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,
837 T*>* = 0) {
838 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
839 m_storage.data()[0] = Scalar(val0);
840 }
841
842 // Initialize a fixed size matrix from a pointer to raw data
843 template <typename T>
844 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Scalar* data) {
845 this->_set_noalias(ConstMapType(data));
846 }
847
848 // Initialize an arbitrary matrix from a dense expression
849 template <typename T, typename OtherDerived>
850 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other) {
851 this->_set_noalias(other);
852 }
853
854 // Initialize an arbitrary matrix from an object convertible to the Derived type.
855 template <typename T>
856 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Derived& other) {
857 this->_set_noalias(other);
858 }
859
860 // Initialize an arbitrary matrix from a generic Eigen expression
861 template <typename T, typename OtherDerived>
862 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other) {
863 this->derived() = other;
864 }
865
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());
870 }
871
872 template <typename T, typename OtherDerived, int ColsAtCompileTime>
873 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived, ColsAtCompileTime>& r) {
874 this->derived() = r;
875 }
876
877 // For fixed-size Array<Scalar,...>
878 template <typename T>
879 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(
880 const Scalar& val0,
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,
884 T>* = 0) {
885 Base::setConstant(val0);
886 }
887
888 // For fixed-size Array<Index,...>
889 template <typename T>
890 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(
891 const Index& val0,
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,
896 T*>* = 0) {
897 Base::setConstant(val0);
898 }
899
900 template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
901 friend struct internal::matrix_swap_impl;
902
903 public:
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());
913 }
914
918 template <typename OtherDerived>
919 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase<OtherDerived> const& other) {
920 Base::swap(other.derived());
921 }
922
923 enum {IsPlainObjectBase = 1};
924#endif
925 public:
926 // These apparently need to be down here for nvcc+icc to prevent duplicate
927 // Map symbol.
928 template <typename PlainObjectType, int MapOptions, typename StrideType>
929 friend class Eigen::Map;
930 friend class Eigen::Map<Derived, Unaligned>;
931 friend class Eigen::Map<const Derived, Unaligned>;
932#if EIGEN_MAX_ALIGN_BYTES > 0
933 // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class
934 // twice.
935 friend class Eigen::Map<Derived, AlignedMax>;
936 friend class Eigen::Map<const Derived, AlignedMax>;
937#endif
938};
939
940namespace internal {
941
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)
948
949 if (IsRelocatable &&
950 ((Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows
951 (!Derived::IsRowMajor && _this.rows() == rows))) // column-major and we change only the number of columns
952 {
953#ifndef EIGEN_NO_DEBUG
954 internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime, Derived::MaxRowsAtCompileTime,
955 Derived::MaxColsAtCompileTime>::run(rows, cols);
956#endif
957 _this.derived().m_storage.conservativeResize(rows * cols, rows, cols);
958 } else {
959 // The storage order does not allow us to use reallocation.
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);
965 }
966 }
967
968 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
969 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
970
971 // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),
972 // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
973 // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or
974 // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like
975 // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
976 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
977 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
978
979 if (IsRelocatable &&
980 ((Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows
981 (!Derived::IsRowMajor &&
982 _this.rows() == other.rows()))) // column-major and we change only the number of columns
983 {
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());
987 if (new_rows > 0)
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);
991 } else {
992 // The storage order does not allow us to use reallocation.
993 Derived tmp(other);
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);
998 }
999 }
1000};
1001
1002// Here, the specialization for vectors inherits from the general matrix case
1003// to allow calling .conservativeResize(rows,cols) on vectors.
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;
1009 using Base::run;
1010
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;
1014 if (IsRelocatable)
1015 _this.derived().m_storage.conservativeResize(size, new_rows, new_cols);
1016 else
1017 Base::run(_this.derived(), new_rows, new_cols);
1018 }
1019
1020 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
1021 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1022
1023 const Index num_new_elements = other.size() - _this.size();
1024
1025 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : other.rows();
1026 const Index new_cols = Derived::RowsAtCompileTime == 1 ? other.cols() : 1;
1027 if (IsRelocatable)
1028 _this.derived().m_storage.conservativeResize(other.size(), new_rows, new_cols);
1029 else
1030 Base::run(_this.derived(), new_rows, new_cols);
1031
1032 if (num_new_elements > 0) _this.tail(num_new_elements) = other.tail(num_new_elements);
1033 }
1034};
1035
1036template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
1037struct matrix_swap_impl {
1038 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(MatrixTypeA& a, MatrixTypeB& b) { a.base().swap(b); }
1039};
1040
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);
1045 }
1046};
1047
1048} // end namespace internal
1049
1050} // end namespace Eigen
1051
1052#endif // EIGEN_DENSESTORAGEBASE_H
Base class for all 1D and 2D array, and related expressions.
Definition ArrayBase.h:44
General-purpose arrays with easy API for coefficient-wise operations.
Definition Array.h:48
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:44
Derived & derived()
Definition EigenBase.h:49
A matrix or vector expression mapping an existing array of data.
Definition Map.h:96
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:186
Dense storage base class for matrices and arrays.
Definition PlainObjectBase.h:121
constexpr Scalar & coeffRef(Index index)
Definition PlainObjectBase.h:228
constexpr const Scalar & coeff(Index index) const
Definition PlainObjectBase.h:209
constexpr PlainObjectBase(const PlainObjectBase &other)
Definition PlainObjectBase.h:497
PlainObjectBase(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition PlainObjectBase.h:578
constexpr void resize(NoChange_t, Index cols)
Definition PlainObjectBase.h:352
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:461
constexpr void resize(Index size)
Definition PlainObjectBase.h:327
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:448
constexpr 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:530
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:514
Derived & setRandom(Index size)
Definition Random.h:147
constexpr const Scalar & coeff(Index rowId, Index colId) const
Definition PlainObjectBase.h:198
constexpr Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition PlainObjectBase.h:755
void conservativeResize(Index rows, Index cols)
Definition PlainObjectBase.h:398
PlainObjectBase(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:565
void conservativeResize(Index size)
Definition PlainObjectBase.h:434
constexpr const Scalar & coeffRef(Index index) const
Definition PlainObjectBase.h:241
Derived & setOnes(Index size)
Definition CwiseNullaryOp.h:702
constexpr const Scalar & coeffRef(Index rowId, Index colId) const
Definition PlainObjectBase.h:232
Scalar * data()
Definition PlainObjectBase.h:276
void conservativeResize(Index rows, NoChange_t)
Definition PlainObjectBase.h:409
PlainObjectBase(const EigenBase< OtherDerived > &other)
Definition PlainObjectBase.h:572
constexpr void resize(Index rows, NoChange_t)
Definition PlainObjectBase.h:362
void resizeLike(const EigenBase< OtherDerived > &_other)
Definition PlainObjectBase.h:372
Derived & setConstant(Index size, const Scalar &val)
Definition CwiseNullaryOp.h:360
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:563
constexpr Derived & operator=(const PlainObjectBase &other)
Definition PlainObjectBase.h:455
constexpr Scalar & coeffRef(Index rowId, Index colId)
Definition PlainObjectBase.h:217
constexpr void resize(Index rows, Index cols)
Definition PlainObjectBase.h:294
const Scalar * data() const
Definition PlainObjectBase.h:273
Derived & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition PlainObjectBase.h:589
void conservativeResize(NoChange_t, Index cols)
Definition PlainObjectBase.h:421
@ Unaligned
Definition Constants.h:235
@ DontAlign
Definition Constants.h:324
@ RowMajor
Definition Constants.h:320
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83
const int Dynamic
Definition Constants.h:25
Definition EigenBase.h:33
Derived & derived()
Definition EigenBase.h:49
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition Meta.h:523
Definition PlainObjectBase.h:94