Eigen  5.0.1-dev+master
 
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 <gael.guennebaud@inria.fr>
5// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
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// SPDX-License-Identifier: MPL-2.0
11
12#ifndef EIGEN_DENSESTORAGEBASE_H
13#define EIGEN_DENSESTORAGEBASE_H
14
15#if defined(EIGEN_INITIALIZE_MATRICES_BY_ZERO)
16#define EIGEN_INITIALIZE_COEFFS
17#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED \
18 for (Index i = 0; i < base().size(); ++i) coeffRef(i) = Scalar(0);
19#elif defined(EIGEN_INITIALIZE_MATRICES_BY_NAN)
20#define EIGEN_INITIALIZE_COEFFS
21#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED \
22 for (Index i = 0; i < base().size(); ++i) coeffRef(i) = ::Eigen::internal::initialization_nan<Scalar>::run();
23#else
24#undef EIGEN_INITIALIZE_COEFFS
25#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
26#endif
27
28// IWYU pragma: private
29#include "./InternalHeaderCheck.h"
30
31namespace Eigen {
32
33namespace internal {
34
37template <typename Scalar>
38struct initialization_nan {
39 EIGEN_DEVICE_FUNC static constexpr Scalar run() { return std::numeric_limits<Scalar>::quiet_NaN(); }
40};
41template <typename RealScalar>
42struct initialization_nan<std::complex<RealScalar>> {
43 EIGEN_DEVICE_FUNC static constexpr std::complex<RealScalar> run() {
44 return std::complex<RealScalar>(NumTraits<RealScalar>::quiet_NaN(), NumTraits<RealScalar>::quiet_NaN());
45 }
46};
47
48// Dense coefficient assignment requires scalar compatibility; evalTo expressions may
49// implement their own conversion instead.
50template <typename Scalar, typename OtherDerived, bool = std::is_base_of<DenseBase<OtherDerived>, OtherDerived>::value>
51struct is_valid_dense_conversion : std::true_type {};
52
53template <typename Scalar, typename OtherDerived>
54struct is_valid_dense_conversion<Scalar, OtherDerived, true>
55 : bool_constant<has_ReturnType<ScalarBinaryOpTraits<Scalar, typename OtherDerived::Scalar,
56 assign_op<Scalar, typename OtherDerived::Scalar>>>::value &&
57 std::is_assignable<Scalar&, const typename OtherDerived::Scalar&>::value> {};
58
59template <typename Scalar, typename OtherDerived>
60struct is_valid_dense_conversion<Scalar, ReturnByValue<OtherDerived>, true> : std::true_type {};
61
62#ifndef EIGEN_NO_DEBUG
63template <int MaxSizeAtCompileTime, int MaxRowsAtCompileTime, int MaxColsAtCompileTime>
64struct check_rows_cols_for_overflow {
65 EIGEN_STATIC_ASSERT(MaxRowsAtCompileTime* MaxColsAtCompileTime == MaxSizeAtCompileTime,
66 YOU MADE A PROGRAMMING MISTAKE)
67 template <typename Index>
68 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index) {}
69};
70
71template <int MaxRowsAtCompileTime>
72struct check_rows_cols_for_overflow<Dynamic, MaxRowsAtCompileTime, Dynamic> {
73 template <typename Index>
74 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index cols) {
75 constexpr Index MaxIndex = NumTraits<Index>::highest();
76 bool error = cols > (MaxIndex / MaxRowsAtCompileTime);
77 if (error) throw_std_bad_alloc();
78 }
79};
80
81template <int MaxColsAtCompileTime>
82struct check_rows_cols_for_overflow<Dynamic, Dynamic, MaxColsAtCompileTime> {
83 template <typename Index>
84 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index) {
85 constexpr Index MaxIndex = NumTraits<Index>::highest();
86 bool error = rows > (MaxIndex / MaxColsAtCompileTime);
87 if (error) throw_std_bad_alloc();
88 }
89};
90
91template <>
92struct check_rows_cols_for_overflow<Dynamic, Dynamic, Dynamic> {
93 template <typename Index>
94 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index cols) {
95 constexpr Index MaxIndex = NumTraits<Index>::highest();
96 bool error = cols == 0 ? false : (rows > (MaxIndex / cols));
97 if (error) throw_std_bad_alloc();
98 }
99};
100#endif
101
102template <typename Derived, typename OtherDerived = Derived,
103 bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
104struct conservative_resize_like_impl;
105
106template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
107struct matrix_swap_impl;
108
109} // end namespace internal
110
122template <typename Derived>
123class PlainObjectBase : public internal::dense_xpr_base<Derived>::type {
124 public:
125 enum { Options = internal::traits<Derived>::Options };
126 using Base = typename internal::dense_xpr_base<Derived>::type;
127
128 using StorageKind = typename internal::traits<Derived>::StorageKind;
129 using Scalar = typename internal::traits<Derived>::Scalar;
130
131 using PacketScalar = typename internal::packet_traits<Scalar>::type;
132 using RealScalar = typename NumTraits<Scalar>::Real;
133 using DenseType = Derived;
134
135 using Base::ColsAtCompileTime;
136 using Base::Flags;
137 using Base::IsVectorAtCompileTime;
138 using Base::MaxColsAtCompileTime;
139 using Base::MaxRowsAtCompileTime;
140 using Base::MaxSizeAtCompileTime;
141 using Base::RowsAtCompileTime;
142 using Base::SizeAtCompileTime;
143
144 using MapType = Eigen::Map<Derived, Unaligned>;
145 using ConstMapType = const Eigen::Map<const Derived, Unaligned>;
146 using AlignedMapType = Eigen::Map<Derived, AlignedMax>;
147 using ConstAlignedMapType = const Eigen::Map<const Derived, AlignedMax>;
148 template <typename StrideType>
149 struct StridedMapType {
151 };
152 template <typename StrideType>
153 struct StridedConstMapType {
155 };
156 template <typename StrideType>
157 struct StridedAlignedMapType {
159 };
160 template <typename StrideType>
161 struct StridedConstAlignedMapType {
163 };
164
165 protected:
166 DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
167
168 public:
169 enum { NeedsToAlign = (SizeAtCompileTime != Dynamic) && (internal::traits<Derived>::Alignment > 0) };
170 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
171
172 EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1,
173 (int(Options) & RowMajor) == RowMajor),
174 INVALID_MATRIX_TEMPLATE_PARAMETERS)
175 EIGEN_STATIC_ASSERT(internal::check_implication(MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1,
176 (int(Options) & RowMajor) == 0),
177 INVALID_MATRIX_TEMPLATE_PARAMETERS)
178 EIGEN_STATIC_ASSERT((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
179 EIGEN_STATIC_ASSERT((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
180 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0),
181 INVALID_MATRIX_TEMPLATE_PARAMETERS)
182 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0),
183 INVALID_MATRIX_TEMPLATE_PARAMETERS)
184 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime == Dynamic),
185 INVALID_MATRIX_TEMPLATE_PARAMETERS)
186 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime == Dynamic),
187 INVALID_MATRIX_TEMPLATE_PARAMETERS)
188 EIGEN_STATIC_ASSERT(((Options & (DontAlign | RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS)
189
190 EIGEN_DEVICE_FUNC constexpr Base& base() { return *static_cast<Base*>(this); }
191 EIGEN_DEVICE_FUNC constexpr const Base& base() const { return *static_cast<const Base*>(this); }
192
193 EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_storage.rows(); }
194 EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_storage.cols(); }
195
200 EIGEN_DEVICE_FUNC constexpr const Scalar& coeff(Index rowId, Index colId) const {
201 EIGEN_IF_CONSTEXPR (Flags & RowMajorBit) {
202 return m_storage.data()[colId + rowId * m_storage.cols()];
203 } else { // column-major
204 return m_storage.data()[rowId + colId * m_storage.rows()];
205 }
206 }
207
212 EIGEN_DEVICE_FUNC constexpr const Scalar& coeff(Index index) const { return m_storage.data()[index]; }
213
218 EIGEN_DEVICE_FUNC constexpr Scalar& coeffRef(Index rowId, Index colId) {
219 EIGEN_IF_CONSTEXPR (Flags & RowMajorBit) {
220 return m_storage.data()[colId + rowId * m_storage.cols()];
221 } else { // column-major
222 return m_storage.data()[rowId + colId * m_storage.rows()];
223 }
224 }
225
230 EIGEN_DEVICE_FUNC constexpr Scalar& coeffRef(Index index) { return m_storage.data()[index]; }
231
234 EIGEN_DEVICE_FUNC constexpr const Scalar& coeffRef(Index rowId, Index colId) const {
235 EIGEN_IF_CONSTEXPR (Flags & RowMajorBit) {
236 return m_storage.data()[colId + rowId * m_storage.cols()];
237 } else { // column-major
238 return m_storage.data()[rowId + colId * m_storage.rows()];
239 }
240 }
241
244 EIGEN_DEVICE_FUNC constexpr const Scalar& coeffRef(Index index) const { return m_storage.data()[index]; }
245
247 template <int LoadMode>
248 EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const {
249 return internal::ploadt<PacketScalar, LoadMode>(
250 m_storage.data() + (Flags & RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()));
251 }
252
254 template <int LoadMode>
255 EIGEN_STRONG_INLINE PacketScalar packet(Index index) const {
256 return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
257 }
258
260 template <int StoreMode>
261 EIGEN_STRONG_INLINE void writePacket(Index rowId, Index colId, const PacketScalar& val) {
262 internal::pstoret<Scalar, PacketScalar, StoreMode>(
263 m_storage.data() + (Flags & RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()),
264 val);
265 }
266
268 template <int StoreMode>
269 EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar& val) {
270 internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
271 }
272
274 EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_storage.data(); }
275
277 EIGEN_DEVICE_FUNC constexpr Scalar* data() { return m_storage.data(); }
278
295 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void resize(Index rows, Index cols) {
296 eigen_assert(internal::check_implication(RowsAtCompileTime != Dynamic, rows == RowsAtCompileTime) &&
297 internal::check_implication(ColsAtCompileTime != Dynamic, cols == ColsAtCompileTime) &&
298 internal::check_implication(RowsAtCompileTime == Dynamic && MaxRowsAtCompileTime != Dynamic,
299 rows <= MaxRowsAtCompileTime) &&
300 internal::check_implication(ColsAtCompileTime == Dynamic && MaxColsAtCompileTime != Dynamic,
301 cols <= MaxColsAtCompileTime) &&
302 rows >= 0 && cols >= 0 && "Invalid sizes when resizing a matrix or array.");
303#ifndef EIGEN_NO_DEBUG
304 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(rows,
305 cols);
306#endif
307#ifdef EIGEN_INITIALIZE_COEFFS
308 Index size = rows * cols;
309 bool size_changed = size != this->size();
310 m_storage.resize(size, rows, cols);
311 if (size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
312#else
313 m_storage.resize(rows * cols, rows, cols);
314#endif
315 }
316
328 EIGEN_DEVICE_FUNC constexpr void resize(Index size) {
329 EIGEN_STATIC_ASSERT_VECTOR_ONLY(PlainObjectBase)
330 eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime == Dynamic || size <= MaxSizeAtCompileTime)) ||
331 SizeAtCompileTime == size) &&
332 size >= 0);
333#ifdef EIGEN_INITIALIZE_COEFFS
334 bool size_changed = size != this->size();
335#endif
336 EIGEN_IF_CONSTEXPR (RowsAtCompileTime == 1) {
337 m_storage.resize(size, 1, size);
338 } else {
339 m_storage.resize(size, size, 1);
340 }
341#ifdef EIGEN_INITIALIZE_COEFFS
342 if (size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
343#endif
344 }
345
354 EIGEN_DEVICE_FUNC constexpr void resize(NoChange_t, Index cols) { resize(rows(), cols); }
355
364 EIGEN_DEVICE_FUNC constexpr void resize(Index rows, NoChange_t) { resize(rows, cols()); }
365
376 template <typename OtherDerived>
377 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other) {
378 const OtherDerived& other = _other.derived();
379 EIGEN_INTERNAL_ASSERT_VECTOR_IF(IsVectorAtCompileTime, other);
380#ifndef EIGEN_NO_DEBUG
381 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(
382 other.rows(), other.cols());
383#endif
384 const Index othersize = other.rows() * other.cols();
385 EIGEN_IF_CONSTEXPR (RowsAtCompileTime == 1) {
386 resize(1, othersize);
387 } else EIGEN_IF_CONSTEXPR (ColsAtCompileTime == 1) {
388 resize(othersize, 1);
389 } else {
390 resize(other.rows(), other.cols());
391 }
392 }
393
403 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols) {
404 eigen_assert(internal::check_implication(MaxRowsAtCompileTime != Dynamic, rows <= MaxRowsAtCompileTime) &&
405 internal::check_implication(MaxColsAtCompileTime != Dynamic, cols <= MaxColsAtCompileTime) &&
406 "Invalid sizes when resizing a matrix or array.");
407 internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols);
408 }
409
417 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t) {
418 // Note: see the comment in conservativeResize(Index,Index)
419 conservativeResize(rows, cols());
420 }
421
429 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols) {
430 // Note: see the comment in conservativeResize(Index,Index)
431 conservativeResize(rows(), cols);
432 }
433
442 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index size) {
443 eigen_assert((MaxSizeAtCompileTime == Dynamic || size <= MaxSizeAtCompileTime) &&
444 "Invalid sizes when resizing a matrix or array.");
445 internal::conservative_resize_like_impl<Derived>::run(*this, size);
446 }
447
457 template <typename OtherDerived>
458 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other) {
459 // A vector resized like a vector takes other's size, whatever its orientation.
460 eigen_assert(
461 (IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime
462 ? MaxSizeAtCompileTime == Dynamic || other.size() <= MaxSizeAtCompileTime
463 : internal::check_implication(MaxRowsAtCompileTime != Dynamic, other.rows() <= MaxRowsAtCompileTime) &&
464 internal::check_implication(MaxColsAtCompileTime != Dynamic,
465 other.cols() <= MaxColsAtCompileTime)) &&
466 "Invalid sizes when resizing a matrix or array.");
467 internal::conservative_resize_like_impl<Derived, OtherDerived>::run(*this, other);
468 }
469
473 EIGEN_DEVICE_FUNC constexpr Derived& operator=(const PlainObjectBase& other) { return _set(other); }
474
476 template <typename OtherDerived>
477 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other) {
478 _resize_to_match(other);
479 return Base::lazyAssign(other.derived());
480 }
481
482 template <typename OtherDerived>
483 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue<OtherDerived>& func) {
484 resize(func.rows(), func.cols());
485 return Base::operator=(func);
486 }
487
488 // Prevent user from trying to instantiate PlainObjectBase objects
489 // by making all its constructors protected. See bug 1074.
490 protected:
491 EIGEN_DEVICE_FUNC constexpr PlainObjectBase() = default;
493 EIGEN_DEVICE_FUNC constexpr PlainObjectBase(PlainObjectBase&&) = default;
495 EIGEN_DEVICE_FUNC constexpr PlainObjectBase& operator=(PlainObjectBase&& other) noexcept {
496 m_storage = std::move(other.m_storage);
497 return *this;
498 }
499
501 EIGEN_DEVICE_FUNC constexpr PlainObjectBase(const PlainObjectBase&) = default;
502 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)
503 : m_storage(size, rows, cols) {}
504
514 template <typename... ArgTypes>
515 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const Scalar& a0, const Scalar& a1, const Scalar& a2,
516 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;
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 size_t list_size = 0;
533 if (list.begin() != list.end()) {
534 list_size = list.begin()->size();
535 }
536
537 // This is to allow syntax like VectorXi {{1, 2, 3, 4}}
538 EIGEN_IF_CONSTEXPR (ColsAtCompileTime == 1) {
539 if (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 Index index = 0;
544 for (const Scalar& e : *list.begin()) {
545 coeffRef(index++) = e;
546 }
547 }
548 return;
549 }
550 }
551
552 eigen_assert(list.size() == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
553 eigen_assert(list_size == static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime == Dynamic);
554 resize(list.size(), list_size);
555
556 Index row_index = 0;
557 for (const std::initializer_list<Scalar>& row : list) {
558 eigen_assert(list_size == row.size());
559 Index col_index = 0;
560 for (const Scalar& e : row) {
561 coeffRef(row_index, col_index) = e;
562 ++col_index;
563 }
564 ++row_index;
565 }
566 }
567
569 template <typename OtherDerived>
570 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived>& other) {
571 resizeLike(other);
572 _set_noalias(other);
573 }
574
576 template <typename OtherDerived>
577 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived>& other) {
578 resizeLike(other);
579 *this = other.derived();
580 }
581
582 template <typename OtherDerived>
583 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue<OtherDerived>& other) {
584 // FIXME this does not automatically transpose vectors if necessary
585 resize(other.rows(), other.cols());
586 other.evalTo(this->derived());
587 }
588
589 public:
593 template <typename OtherDerived>
594 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived>& other) {
595 _resize_to_match(other);
596 Base::operator=(other.derived());
597 return this->derived();
598 }
599
612 EIGEN_DEVICE_FUNC static inline ConstMapType Map(const Scalar* data) { return ConstMapType(data); }
613 EIGEN_DEVICE_FUNC static inline MapType Map(Scalar* data) { return MapType(data); }
614 EIGEN_DEVICE_FUNC static inline ConstMapType Map(const Scalar* data, Index size) { return ConstMapType(data, size); }
615 EIGEN_DEVICE_FUNC static inline MapType Map(Scalar* data, Index size) { return MapType(data, size); }
616 EIGEN_DEVICE_FUNC static inline ConstMapType Map(const Scalar* data, Index rows, Index cols) {
617 return ConstMapType(data, rows, cols);
618 }
619 EIGEN_DEVICE_FUNC static inline MapType Map(Scalar* data, Index rows, Index cols) {
620 return MapType(data, rows, cols);
621 }
622
623 EIGEN_DEVICE_FUNC static inline ConstAlignedMapType MapAligned(const Scalar* data) {
624 return ConstAlignedMapType(data);
625 }
626 EIGEN_DEVICE_FUNC static inline AlignedMapType MapAligned(Scalar* data) { return AlignedMapType(data); }
627 EIGEN_DEVICE_FUNC static inline ConstAlignedMapType MapAligned(const Scalar* data, Index size) {
628 return ConstAlignedMapType(data, size);
629 }
630 EIGEN_DEVICE_FUNC static inline AlignedMapType MapAligned(Scalar* data, Index size) {
631 return AlignedMapType(data, size);
632 }
633 EIGEN_DEVICE_FUNC static inline ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols) {
634 return ConstAlignedMapType(data, rows, cols);
635 }
636 EIGEN_DEVICE_FUNC static inline AlignedMapType MapAligned(Scalar* data, Index rows, Index cols) {
637 return AlignedMapType(data, rows, cols);
638 }
639
640 template <int Outer, int Inner>
641 EIGEN_DEVICE_FUNC static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
642 const Scalar* data, const Stride<Outer, Inner>& stride) {
643 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, stride);
644 }
645 template <int Outer, int Inner>
646 EIGEN_DEVICE_FUNC static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(
647 Scalar* data, const Stride<Outer, Inner>& stride) {
648 return typename StridedMapType<Stride<Outer, Inner>>::type(data, stride);
649 }
650 template <int Outer, int Inner>
651 EIGEN_DEVICE_FUNC static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
652 const Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
653 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, size, stride);
654 }
655 template <int Outer, int Inner>
656 EIGEN_DEVICE_FUNC static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(
657 Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
658 return typename StridedMapType<Stride<Outer, Inner>>::type(data, size, stride);
659 }
660 template <int Outer, int Inner>
661 EIGEN_DEVICE_FUNC static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
662 const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
663 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
664 }
665 template <int Outer, int Inner>
666 EIGEN_DEVICE_FUNC static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(
667 Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
668 return typename StridedMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
669 }
670
671 template <int Outer, int Inner>
672 EIGEN_DEVICE_FUNC static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
673 const Scalar* data, const Stride<Outer, Inner>& stride) {
674 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(data, stride);
675 }
676 template <int Outer, int Inner>
677 EIGEN_DEVICE_FUNC static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
678 Scalar* data, const Stride<Outer, Inner>& stride) {
679 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(data, stride);
680 }
681 template <int Outer, int Inner>
682 EIGEN_DEVICE_FUNC static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
683 const Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
684 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(data, size, stride);
685 }
686 template <int Outer, int Inner>
687 EIGEN_DEVICE_FUNC static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
688 Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
689 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(data, size, stride);
690 }
691 template <int Outer, int Inner>
692 EIGEN_DEVICE_FUNC static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
693 const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
694 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
695 }
696 template <int Outer, int Inner>
697 EIGEN_DEVICE_FUNC static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
698 Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
699 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
700 }
702
703 using Base::setConstant;
704 EIGEN_DEVICE_FUNC Derived& setConstant(Index size, const Scalar& val);
705 EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, Index cols, const Scalar& val);
706 EIGEN_DEVICE_FUNC Derived& setConstant(NoChange_t, Index cols, const Scalar& val);
707 EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, NoChange_t, const Scalar& val);
708
709 using Base::setZero;
710 EIGEN_DEVICE_FUNC Derived& setZero(Index size);
711 EIGEN_DEVICE_FUNC Derived& setZero(Index rows, Index cols);
712 EIGEN_DEVICE_FUNC Derived& setZero(NoChange_t, Index cols);
713 EIGEN_DEVICE_FUNC Derived& setZero(Index rows, NoChange_t);
714
715 using Base::setOnes;
716 EIGEN_DEVICE_FUNC Derived& setOnes(Index size);
717 EIGEN_DEVICE_FUNC Derived& setOnes(Index rows, Index cols);
718 EIGEN_DEVICE_FUNC Derived& setOnes(NoChange_t, Index cols);
719 EIGEN_DEVICE_FUNC Derived& setOnes(Index rows, NoChange_t);
720
721 using Base::setRandom;
722 Derived& setRandom(Index size);
723 Derived& setRandom(Index rows, Index cols);
724 Derived& setRandom(NoChange_t, Index cols);
725 Derived& setRandom(Index rows, NoChange_t);
726
727#ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
728#include EIGEN_PLAINOBJECTBASE_PLUGIN
729#endif
730
731 protected:
739 template <typename OtherDerived>
740 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase<OtherDerived>& other) {
741#ifdef EIGEN_NO_AUTOMATIC_RESIZING
742 constexpr bool shape_is_proven = IsVectorAtCompileTime ? (internal::vector_dimensions<OtherDerived>::Proven &&
743 internal::matching_sizes<Derived, OtherDerived>::Proven)
744 : internal::matching_shapes<Derived, OtherDerived>::Proven;
745 EIGEN_INTERNAL_SHAPE_ASSERT(
746 shape_is_proven,
747 (this->size() == 0 ||
748 (IsVectorAtCompileTime ? ((other.rows() == 1 || other.cols() == 1) && 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 if (this->size() == 0) resizeLike(other);
752 EIGEN_ONLY_USED_FOR_DEBUG(other);
753#else
754 resizeLike(other);
755#endif
756 }
757
772 // aliasing is dealt once in internal::call_assignment
773 // so at this stage we have to assume aliasing... and resizing has to be done later.
774 template <typename OtherDerived>
775 EIGEN_DEVICE_FUNC constexpr Derived& _set(const DenseBase<OtherDerived>& other) {
776 internal::call_assignment(this->derived(), other.derived());
777 return this->derived();
778 }
779
785 template <typename OtherDerived>
786 EIGEN_DEVICE_FUNC constexpr Derived& _set_noalias(const DenseBase<OtherDerived>& other) {
787 // I don't think we need this resize call since the lazyAssign will anyways resize
788 // and lazyAssign will be called by the assign selector.
789 //_resize_to_match(other);
790 // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
791 // it wouldn't allow to copy a row-vector into a column-vector.
792 internal::call_assignment_no_alias(this->derived(), other.derived(),
793 internal::assign_op<Scalar, typename OtherDerived::Scalar>());
794 return this->derived();
795 }
796
797 template <typename T0, typename T1, std::enable_if_t<Base::SizeAtCompileTime != 2, T0>* = nullptr>
798 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(Index rows, Index cols) {
799 EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T0>::value && internal::is_valid_index_type<T1>::value,
800 T0 AND T1 MUST BE INTEGER TYPES)
801 resize(rows, cols);
802 }
803
804 template <typename T0, typename T1, std::enable_if_t<Base::SizeAtCompileTime == 2, T0>* = nullptr>
805 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1) {
806 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
807 m_storage.data()[0] = Scalar(val0);
808 m_storage.data()[1] = Scalar(val1);
809 }
810
811 template <typename T0, typename T1,
812 std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<T0, Index>::value) &&
813 (std::is_same<T1, Index>::value) && Base::SizeAtCompileTime == 2,
814 int> = 0>
815 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(const Index& val0, const Index& val1) {
816 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
817 m_storage.data()[0] = Scalar(val0);
818 m_storage.data()[1] = Scalar(val1);
819 }
820
821 // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,
822 // then the argument is meant to be the size of the object.
823 template <typename T,
824 std::enable_if_t<(Base::SizeAtCompileTime != 1 || !std::is_convertible<T, Scalar>::value) &&
825 ((!std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value ||
826 Base::SizeAtCompileTime == Dynamic)),
827 int> = 0>
828 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(Index size) {
829 EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T>::value, FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
830 resize(size);
831 }
832
833 // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
834 // type can be implicitly converted)
835 template <typename T,
836 std::enable_if_t<Base::SizeAtCompileTime == 1 && std::is_convertible<T, Scalar>::value, int> = 0>
837 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar& val0) {
838 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
839 m_storage.data()[0] = val0;
840 }
841
842 // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
843 // type match the index type)
844 template <typename T, std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<Index, T>::value) &&
845 Base::SizeAtCompileTime == 1 && std::is_convertible<T, Scalar>::value,
846 int> = 0>
847 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Index& val0) {
848 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
849 m_storage.data()[0] = Scalar(val0);
850 }
851
852 // Initialize a fixed size matrix from a pointer to raw data
853 template <typename T>
854 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar* data) {
855 this->_set_noalias(ConstMapType(data));
856 }
857
858 // Initialize an arbitrary matrix from a dense expression
859 template <typename T, typename OtherDerived>
860 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other) {
861 this->_set_noalias(other);
862 }
863
864 // Initialize an arbitrary matrix from an object convertible to the Derived type.
865 template <typename T>
866 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Derived& other) {
867 this->_set_noalias(other);
868 }
869
870 // Initialize an arbitrary matrix from a generic Eigen expression
871 template <typename T, typename OtherDerived>
872 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other) {
873 this->derived() = other;
874 }
875
876 template <typename T, typename OtherDerived>
877 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const ReturnByValue<OtherDerived>& other) {
878 resize(other.rows(), other.cols());
879 other.evalTo(this->derived());
880 }
881
882 template <typename T, typename OtherDerived, int ColsAtCompileTime>
883 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived, ColsAtCompileTime>& r) {
884 this->derived() = r;
885 }
886
887 // For fixed-size Array<Scalar,...>
888 template <typename T, std::enable_if_t<Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
889 std::is_convertible<T, Scalar>::value &&
890 std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
891 int> = 0>
892 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar& val0) {
893 Base::setConstant(val0);
894 }
895
896 // For fixed-size Array<Index,...>
897 template <typename T, std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<Index, T>::value) &&
898 Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
899 std::is_convertible<T, Scalar>::value &&
900 std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
901 int> = 0>
902 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Index& val0) {
903 Base::setConstant(val0);
904 }
905
906 template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
907 friend struct internal::matrix_swap_impl;
908
909 public:
910#ifndef EIGEN_PARSED_BY_DOXYGEN
915 template <typename OtherDerived>
916 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase<OtherDerived>& other) {
917 enum {SwapPointers = std::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime == Dynamic};
918 internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());
919 }
920
924 template <typename OtherDerived>
925 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase<OtherDerived> const& other) {
926 Base::swap(other.derived());
927 }
928
929 enum {IsPlainObjectBase = 1};
930#endif
931 public:
932 // These apparently need to be down here for nvcc+icc to prevent duplicate
933 // Map symbol.
934 template <typename PlainObjectType, int MapOptions, typename StrideType>
935 friend class Eigen::Map;
936 friend class Eigen::Map<Derived, Unaligned>;
937 friend class Eigen::Map<const Derived, Unaligned>;
938#if EIGEN_MAX_ALIGN_BYTES > 0
939 // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class
940 // twice.
941 friend class Eigen::Map<Derived, AlignedMax>;
942 friend class Eigen::Map<const Derived, AlignedMax>;
943#endif
944};
945
946namespace internal {
947
948template <typename Derived, typename OtherDerived, bool IsVector>
949struct conservative_resize_like_impl {
950 // Fixed-capacity storage only changes its dimensions; its coefficients never relocate.
951 static constexpr bool IsRelocatable =
952 Derived::MaxSizeAtCompileTime != Dynamic || std::is_trivially_copyable<typename Derived::Scalar>::value;
953#ifdef EIGEN_INITIALIZE_COEFFS
954 // In-place reallocation leaves appended coefficients uninitialized, so under the initialization macros a resize that
955 // appends coefficients without assigning them copies into a new, initialized object instead.
956 static constexpr bool MustInitializeAppended = true;
957#else
958 static constexpr bool MustInitializeAppended = false;
959#endif
960 static void run(DenseBase<Derived>& _this, Index rows, Index cols) {
961 if (_this.rows() == rows && _this.cols() == cols) return;
962 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
963
964 EIGEN_IF_CONSTEXPR (IsRelocatable) {
965 if (((Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows
966 (!Derived::IsRowMajor && _this.rows() == rows)) && // column-major and we change only the number of columns
967 !(MustInitializeAppended && (Derived::IsRowMajor ? rows > _this.rows() : cols > _this.cols()))) {
968#ifndef EIGEN_NO_DEBUG
969 internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime, Derived::MaxRowsAtCompileTime,
970 Derived::MaxColsAtCompileTime>::run(rows, cols);
971#endif
972 _this.derived().m_storage.conservativeResize(rows * cols, rows, cols);
973 return;
974 }
975 }
976
977 // The storage order does not allow us to use reallocation.
978 Derived tmp(rows, cols);
979 const Index common_rows = numext::mini(rows, _this.rows());
980 const Index common_cols = numext::mini(cols, _this.cols());
981 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
982 _this.derived().swap(tmp);
983 }
984
985 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
986 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
987
988 // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),
989 // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
990 // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or
991 // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like
992 // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
993 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
994 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
995
996 EIGEN_IF_CONSTEXPR (IsRelocatable) {
997 if ((Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows
998 (!Derived::IsRowMajor &&
999 _this.rows() == other.rows())) // column-major and we change only the number of columns
1000 {
1001 const Index new_rows = other.rows() - _this.rows();
1002 const Index new_cols = other.cols() - _this.cols();
1003 _this.derived().m_storage.conservativeResize(other.size(), other.rows(), other.cols());
1004 if (new_rows > 0)
1005 _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
1006 else if (new_cols > 0)
1007 _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
1008 return;
1009 }
1010 }
1011
1012 // The storage order does not allow us to use reallocation.
1013 Derived tmp(other);
1014 const Index common_rows = numext::mini(tmp.rows(), _this.rows());
1015 const Index common_cols = numext::mini(tmp.cols(), _this.cols());
1016 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
1017 _this.derived().swap(tmp);
1018 }
1019};
1020
1021// Vectors preserve their linear layout when their length changes.
1022template <typename Derived, typename OtherDerived>
1023struct conservative_resize_like_impl<Derived, OtherDerived, true>
1024 : conservative_resize_like_impl<Derived, OtherDerived, false> {
1025 using Base = conservative_resize_like_impl<Derived, OtherDerived, false>;
1026 using Base::IsRelocatable;
1027 using Base::MustInitializeAppended;
1028
1029 static void run(DenseBase<Derived>& _this, Index rows, Index cols) {
1030 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
1031 const Index size = Derived::RowsAtCompileTime == 1 ? cols : rows;
1032 eigen_assert((Derived::RowsAtCompileTime == 1 ? rows == 1 : cols == 1) &&
1033 "Invalid sizes when resizing a vector.");
1034 run(_this, size);
1035 }
1036
1037 static void run(DenseBase<Derived>& _this, Index size) {
1038 eigen_assert(size >= 0 && "Invalid sizes when resizing a vector.");
1039 if (_this.size() == size) return;
1040 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : size;
1041 const Index new_cols = Derived::RowsAtCompileTime == 1 ? size : 1;
1042 EIGEN_IF_CONSTEXPR (IsRelocatable) {
1043 if (!(MustInitializeAppended && size > _this.size())) {
1044 _this.derived().m_storage.conservativeResize(size, new_rows, new_cols);
1045 return;
1046 }
1047 }
1048 Base::run(_this.derived(), new_rows, new_cols);
1049 }
1050
1051 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
1052 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1053
1054 const Index num_new_elements = other.size() - _this.size();
1055
1056 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : other.size();
1057 const Index new_cols = Derived::RowsAtCompileTime == 1 ? other.size() : 1;
1058 EIGEN_IF_CONSTEXPR (IsRelocatable)
1059 _this.derived().m_storage.conservativeResize(other.size(), new_rows, new_cols);
1060 else
1061 Base::run(_this.derived(), new_rows, new_cols);
1062
1063 if (num_new_elements > 0) _this.tail(num_new_elements) = other.tail(num_new_elements);
1064 }
1065};
1066
1067template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
1068struct matrix_swap_impl {
1069 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(MatrixTypeA& a, MatrixTypeB& b) { a.base().swap(b); }
1070};
1071
1072template <typename MatrixTypeA, typename MatrixTypeB>
1073struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> {
1074 EIGEN_DEVICE_FUNC static inline void run(MatrixTypeA& a, MatrixTypeB& b) {
1075 static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);
1076 }
1077};
1078
1079} // end namespace internal
1080
1081} // end namespace Eigen
1082
1083#endif // EIGEN_DENSESTORAGEBASE_H
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:45
A matrix or vector expression mapping an existing array of data.
Definition Map.h:97
constexpr Scalar & coeffRef(Index index)
Definition PlainObjectBase.h:230
constexpr PlainObjectBase & operator=(PlainObjectBase &&other) noexcept
Move assignment operator.
Definition PlainObjectBase.h:495
constexpr const Scalar & coeff(Index index) const
Definition PlainObjectBase.h:212
PlainObjectBase(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition PlainObjectBase.h:583
constexpr void resize(NoChange_t, Index cols)
Definition PlainObjectBase.h:354
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:477
constexpr Scalar * data()
Definition PlainObjectBase.h:277
constexpr void resize(Index size)
Definition PlainObjectBase.h:328
Derived & setOnes(NoChange_t, Index cols)
Definition CwiseNullaryOp.h:716
constexpr PlainObjectBase(const EigenBase< OtherDerived > &other)
Definition PlainObjectBase.h:577
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:458
Derived & setConstant(NoChange_t, Index cols, const Scalar &val)
Definition CwiseNullaryOp.h:381
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 or column vector with fixed size from an arbitrary number of coefficients.
Definition PlainObjectBase.h:515
constexpr PlainObjectBase(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:570
Derived & setRandom(Index size)
Definition Random.h:148
constexpr const Scalar & coeff(Index rowId, Index colId) const
Definition PlainObjectBase.h:200
Derived & setRandom(NoChange_t, Index cols)
Definition Random.h:186
constexpr Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition PlainObjectBase.h:775
constexpr PlainObjectBase(PlainObjectBase &&)=default
Move constructor.
void conservativeResize(Index rows, Index cols)
Definition PlainObjectBase.h:403
Derived & setZero(Index rows, Index cols)
Definition CwiseNullaryOp.h:552
void conservativeResize(Index size)
Definition PlainObjectBase.h:442
constexpr const Scalar & coeffRef(Index index) const
Definition PlainObjectBase.h:244
Derived & setOnes(Index size)
Definition CwiseNullaryOp.h:675
Derived & setRandom(Index rows, Index cols)
Definition Random.h:169
constexpr const Scalar & coeffRef(Index rowId, Index colId) const
Definition PlainObjectBase.h:234
void conservativeResize(Index rows, NoChange_t)
Definition PlainObjectBase.h:417
constexpr void resize(Index rows, NoChange_t)
Definition PlainObjectBase.h:364
Derived & setConstant(Index size, const Scalar &val)
Definition CwiseNullaryOp.h:349
Derived & setOnes(Index rows, NoChange_t)
Definition CwiseNullaryOp.h:704
constexpr PlainObjectBase(const PlainObjectBase &)=default
constexpr void resizeLike(const EigenBase< OtherDerived > &_other)
Definition PlainObjectBase.h:377
constexpr const Scalar * data() const
Definition PlainObjectBase.h:274
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:536
Derived & setOnes(Index rows, Index cols)
Definition CwiseNullaryOp.h:691
constexpr Derived & operator=(const PlainObjectBase &other)
Definition PlainObjectBase.h:473
Derived & setConstant(Index rows, NoChange_t, const Scalar &val)
Definition CwiseNullaryOp.h:394
Derived & setRandom(Index rows, NoChange_t)
Definition Random.h:202
constexpr Scalar & coeffRef(Index rowId, Index colId)
Definition PlainObjectBase.h:218
constexpr void resize(Index rows, Index cols)
Definition PlainObjectBase.h:295
Derived & setZero(Index rows, NoChange_t)
Definition CwiseNullaryOp.h:577
Derived & setZero(NoChange_t, Index cols)
Definition CwiseNullaryOp.h:565
Derived & setConstant(Index rows, Index cols, const Scalar &val)
Definition CwiseNullaryOp.h:367
Derived & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition PlainObjectBase.h:594
void conservativeResize(NoChange_t, Index cols)
Definition PlainObjectBase.h:429
@ Unaligned
Definition Constants.h:236
@ DontAlign
Definition Constants.h:325
@ RowMajor
Definition Constants.h:321
constexpr unsigned int RowMajorBit
Definition Constants.h:71
Definition EigenBase.h:34
constexpr Index cols() const noexcept
Definition EigenBase.h:62
constexpr Derived & derived()
Definition EigenBase.h:50
constexpr Index rows() const noexcept
Definition EigenBase.h:60
constexpr Index size() const noexcept
Definition EigenBase.h:65