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) = std::numeric_limits<Scalar>::quiet_NaN();
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
35// Dense coefficient assignment requires scalar compatibility; evalTo expressions may
36// implement their own conversion instead.
37template <typename Scalar, typename OtherDerived, bool = std::is_base_of<DenseBase<OtherDerived>, OtherDerived>::value>
38struct is_valid_dense_conversion : std::true_type {};
39
40template <typename Scalar, typename OtherDerived>
41struct is_valid_dense_conversion<Scalar, OtherDerived, true>
42 : bool_constant<has_ReturnType<ScalarBinaryOpTraits<Scalar, typename OtherDerived::Scalar,
43 assign_op<Scalar, typename OtherDerived::Scalar>>>::value &&
44 std::is_assignable<Scalar&, const typename OtherDerived::Scalar&>::value> {};
45
46template <typename Scalar, typename OtherDerived>
47struct is_valid_dense_conversion<Scalar, ReturnByValue<OtherDerived>, true> : std::true_type {};
48
49#ifndef EIGEN_NO_DEBUG
50template <int MaxSizeAtCompileTime, int MaxRowsAtCompileTime, int MaxColsAtCompileTime>
51struct check_rows_cols_for_overflow {
52 EIGEN_STATIC_ASSERT(MaxRowsAtCompileTime* MaxColsAtCompileTime == MaxSizeAtCompileTime,
53 YOU MADE A PROGRAMMING MISTAKE)
54 template <typename Index>
55 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index) {}
56};
57
58template <int MaxRowsAtCompileTime>
59struct check_rows_cols_for_overflow<Dynamic, MaxRowsAtCompileTime, Dynamic> {
60 template <typename Index>
61 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index cols) {
62 constexpr Index MaxIndex = NumTraits<Index>::highest();
63 bool error = cols > (MaxIndex / MaxRowsAtCompileTime);
64 if (error) throw_std_bad_alloc();
65 }
66};
67
68template <int MaxColsAtCompileTime>
69struct check_rows_cols_for_overflow<Dynamic, Dynamic, MaxColsAtCompileTime> {
70 template <typename Index>
71 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index) {
72 constexpr Index MaxIndex = NumTraits<Index>::highest();
73 bool error = rows > (MaxIndex / MaxColsAtCompileTime);
74 if (error) throw_std_bad_alloc();
75 }
76};
77
78template <>
79struct check_rows_cols_for_overflow<Dynamic, Dynamic, Dynamic> {
80 template <typename Index>
81 EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index cols) {
82 constexpr Index MaxIndex = NumTraits<Index>::highest();
83 bool error = cols == 0 ? false : (rows > (MaxIndex / cols));
84 if (error) throw_std_bad_alloc();
85 }
86};
87#endif
88
89template <typename Derived, typename OtherDerived = Derived,
90 bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
91struct conservative_resize_like_impl;
92
93template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
94struct matrix_swap_impl;
95
96} // end namespace internal
97
109template <typename Derived>
110class PlainObjectBase : public internal::dense_xpr_base<Derived>::type {
111 public:
112 enum { Options = internal::traits<Derived>::Options };
113 using Base = typename internal::dense_xpr_base<Derived>::type;
114
115 using StorageKind = typename internal::traits<Derived>::StorageKind;
116 using Scalar = typename internal::traits<Derived>::Scalar;
117
118 using PacketScalar = typename internal::packet_traits<Scalar>::type;
119 using RealScalar = typename NumTraits<Scalar>::Real;
120 using DenseType = Derived;
121
122 using Base::ColsAtCompileTime;
123 using Base::Flags;
124 using Base::IsVectorAtCompileTime;
125 using Base::MaxColsAtCompileTime;
126 using Base::MaxRowsAtCompileTime;
127 using Base::MaxSizeAtCompileTime;
128 using Base::RowsAtCompileTime;
129 using Base::SizeAtCompileTime;
130
131 using MapType = Eigen::Map<Derived, Unaligned>;
132 using ConstMapType = const Eigen::Map<const Derived, Unaligned>;
133 using AlignedMapType = Eigen::Map<Derived, AlignedMax>;
134 using ConstAlignedMapType = const Eigen::Map<const Derived, AlignedMax>;
135 template <typename StrideType>
136 struct StridedMapType {
138 };
139 template <typename StrideType>
140 struct StridedConstMapType {
142 };
143 template <typename StrideType>
144 struct StridedAlignedMapType {
146 };
147 template <typename StrideType>
148 struct StridedConstAlignedMapType {
150 };
151
152 protected:
153 DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
154
155 public:
156 enum { NeedsToAlign = (SizeAtCompileTime != Dynamic) && (internal::traits<Derived>::Alignment > 0) };
157 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
158
159 EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1,
160 (int(Options) & RowMajor) == RowMajor),
161 INVALID_MATRIX_TEMPLATE_PARAMETERS)
162 EIGEN_STATIC_ASSERT(internal::check_implication(MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1,
163 (int(Options) & RowMajor) == 0),
164 INVALID_MATRIX_TEMPLATE_PARAMETERS)
165 EIGEN_STATIC_ASSERT((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
166 EIGEN_STATIC_ASSERT((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
167 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0),
168 INVALID_MATRIX_TEMPLATE_PARAMETERS)
169 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0),
170 INVALID_MATRIX_TEMPLATE_PARAMETERS)
171 EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime == Dynamic),
172 INVALID_MATRIX_TEMPLATE_PARAMETERS)
173 EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime == Dynamic),
174 INVALID_MATRIX_TEMPLATE_PARAMETERS)
175 EIGEN_STATIC_ASSERT(((Options & (DontAlign | RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS)
176
177 EIGEN_DEVICE_FUNC constexpr Base& base() { return *static_cast<Base*>(this); }
178 EIGEN_DEVICE_FUNC constexpr const Base& base() const { return *static_cast<const Base*>(this); }
179
180 EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_storage.rows(); }
181 EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_storage.cols(); }
182
187 EIGEN_DEVICE_FUNC constexpr const Scalar& coeff(Index rowId, Index colId) const {
188 EIGEN_IF_CONSTEXPR (Flags & RowMajorBit) {
189 return m_storage.data()[colId + rowId * m_storage.cols()];
190 } else { // column-major
191 return m_storage.data()[rowId + colId * m_storage.rows()];
192 }
193 }
194
199 EIGEN_DEVICE_FUNC constexpr const Scalar& coeff(Index index) const { return m_storage.data()[index]; }
200
202 * provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.
203 *
204 * See DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,Index) const for details. */
205 EIGEN_DEVICE_FUNC constexpr Scalar& coeffRef(Index rowId, Index colId) {
206 EIGEN_IF_CONSTEXPR (Flags & RowMajorBit) {
207 return m_storage.data()[colId + rowId * m_storage.cols()];
208 } else { // column-major
209 return m_storage.data()[rowId + colId * m_storage.rows()];
210 }
211 }
212
217 EIGEN_DEVICE_FUNC constexpr Scalar& coeffRef(Index index) { return m_storage.data()[index]; }
218
221 EIGEN_DEVICE_FUNC constexpr const Scalar& coeffRef(Index rowId, Index colId) const {
222 EIGEN_IF_CONSTEXPR (Flags & RowMajorBit) {
223 return m_storage.data()[colId + rowId * m_storage.cols()];
224 } else { // column-major
225 return m_storage.data()[rowId + colId * m_storage.rows()];
226 }
227 }
228
231 EIGEN_DEVICE_FUNC constexpr const Scalar& coeffRef(Index index) const { return m_storage.data()[index]; }
232
234 template <int LoadMode>
235 EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const {
236 return internal::ploadt<PacketScalar, LoadMode>(
237 m_storage.data() + (Flags & RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()));
238 }
239
241 template <int LoadMode>
242 EIGEN_STRONG_INLINE PacketScalar packet(Index index) const {
243 return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
244 }
245
247 template <int StoreMode>
248 EIGEN_STRONG_INLINE void writePacket(Index rowId, Index colId, const PacketScalar& val) {
249 internal::pstoret<Scalar, PacketScalar, StoreMode>(
250 m_storage.data() + (Flags & RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()),
251 val);
252 }
253
255 template <int StoreMode>
256 EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar& val) {
257 internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
258 }
259
261 EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_storage.data(); }
262
264 EIGEN_DEVICE_FUNC constexpr Scalar* data() { return m_storage.data(); }
265
282 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void resize(Index rows, Index cols) {
283 eigen_assert(internal::check_implication(RowsAtCompileTime != Dynamic, rows == RowsAtCompileTime) &&
284 internal::check_implication(ColsAtCompileTime != Dynamic, cols == ColsAtCompileTime) &&
285 internal::check_implication(RowsAtCompileTime == Dynamic && MaxRowsAtCompileTime != Dynamic,
286 rows <= MaxRowsAtCompileTime) &&
287 internal::check_implication(ColsAtCompileTime == Dynamic && MaxColsAtCompileTime != Dynamic,
288 cols <= MaxColsAtCompileTime) &&
289 rows >= 0 && cols >= 0 && "Invalid sizes when resizing a matrix or array.");
290#ifndef EIGEN_NO_DEBUG
291 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(rows,
292 cols);
293#endif
294#ifdef EIGEN_INITIALIZE_COEFFS
295 Index size = rows * cols;
296 bool size_changed = size != this->size();
297 m_storage.resize(size, rows, cols);
298 if (size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
299#else
300 m_storage.resize(rows * cols, rows, cols);
301#endif
302 }
303
315 EIGEN_DEVICE_FUNC constexpr void resize(Index size) {
316 EIGEN_STATIC_ASSERT_VECTOR_ONLY(PlainObjectBase)
317 eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime == Dynamic || size <= MaxSizeAtCompileTime)) ||
318 SizeAtCompileTime == size) &&
319 size >= 0);
320#ifdef EIGEN_INITIALIZE_COEFFS
321 bool size_changed = size != this->size();
322#endif
323 EIGEN_IF_CONSTEXPR (RowsAtCompileTime == 1) {
324 m_storage.resize(size, 1, size);
325 } else {
326 m_storage.resize(size, size, 1);
327 }
328#ifdef EIGEN_INITIALIZE_COEFFS
329 if (size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
330#endif
331 }
332
341 EIGEN_DEVICE_FUNC constexpr void resize(NoChange_t, Index cols) { resize(rows(), cols); }
342
351 EIGEN_DEVICE_FUNC constexpr void resize(Index rows, NoChange_t) { resize(rows, cols()); }
352
363 template <typename OtherDerived>
364 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other) {
365 const OtherDerived& other = _other.derived();
366 EIGEN_INTERNAL_ASSERT_VECTOR_IF(IsVectorAtCompileTime, other);
367#ifndef EIGEN_NO_DEBUG
368 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(
369 other.rows(), other.cols());
370#endif
371 const Index othersize = other.rows() * other.cols();
372 EIGEN_IF_CONSTEXPR (RowsAtCompileTime == 1) {
373 resize(1, othersize);
374 } else EIGEN_IF_CONSTEXPR (ColsAtCompileTime == 1) {
375 resize(othersize, 1);
376 } else {
377 resize(other.rows(), other.cols());
378 }
379 }
380
390 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols) {
391 eigen_assert(internal::check_implication(MaxRowsAtCompileTime != Dynamic, rows <= MaxRowsAtCompileTime) &&
392 internal::check_implication(MaxColsAtCompileTime != Dynamic, cols <= MaxColsAtCompileTime) &&
393 "Invalid sizes when resizing a matrix or array.");
394 internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols);
395 }
396
404 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t) {
405 // Note: see the comment in conservativeResize(Index,Index)
406 conservativeResize(rows, cols());
407 }
408
416 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols) {
417 // Note: see the comment in conservativeResize(Index,Index)
418 conservativeResize(rows(), cols);
419 }
420
429 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index size) {
430 eigen_assert((MaxSizeAtCompileTime == Dynamic || size <= MaxSizeAtCompileTime) &&
431 "Invalid sizes when resizing a matrix or array.");
432 internal::conservative_resize_like_impl<Derived>::run(*this, size);
433 }
434
444 template <typename OtherDerived>
445 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other) {
446 // A vector resized like a vector takes other's size, whatever its orientation.
447 eigen_assert(
448 (IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime
449 ? MaxSizeAtCompileTime == Dynamic || other.size() <= MaxSizeAtCompileTime
450 : internal::check_implication(MaxRowsAtCompileTime != Dynamic, other.rows() <= MaxRowsAtCompileTime) &&
451 internal::check_implication(MaxColsAtCompileTime != Dynamic,
452 other.cols() <= MaxColsAtCompileTime)) &&
453 "Invalid sizes when resizing a matrix or array.");
454 internal::conservative_resize_like_impl<Derived, OtherDerived>::run(*this, other);
455 }
456
460 EIGEN_DEVICE_FUNC constexpr Derived& operator=(const PlainObjectBase& other) { return _set(other); }
461
463 template <typename OtherDerived>
464 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other) {
465 _resize_to_match(other);
466 return Base::lazyAssign(other.derived());
467 }
468
469 template <typename OtherDerived>
470 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue<OtherDerived>& func) {
471 resize(func.rows(), func.cols());
472 return Base::operator=(func);
473 }
474
475 // Prevent user from trying to instantiate PlainObjectBase objects
476 // by making all its constructors protected. See bug 1074.
477 protected:
478 EIGEN_DEVICE_FUNC constexpr PlainObjectBase() = default;
480 EIGEN_DEVICE_FUNC constexpr PlainObjectBase(PlainObjectBase&&) = default;
482 EIGEN_DEVICE_FUNC constexpr PlainObjectBase& operator=(PlainObjectBase&& other) noexcept {
483 m_storage = std::move(other.m_storage);
484 return *this;
485 }
486
488 EIGEN_DEVICE_FUNC constexpr PlainObjectBase(const PlainObjectBase&) = default;
489 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)
490 : m_storage(size, rows, cols) {}
491
501 template <typename... ArgTypes>
502 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const Scalar& a0, const Scalar& a1, const Scalar& a2,
503 const Scalar& a3, const ArgTypes&... args) {
504 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, sizeof...(args) + 4);
505 m_storage.data()[0] = a0;
506 m_storage.data()[1] = a1;
507 m_storage.data()[2] = a2;
508 m_storage.data()[3] = a3;
509 Index i = 4;
510 auto x = {(m_storage.data()[i++] = args, 0)...};
511 static_cast<void>(x);
512 }
513
517 EIGEN_DEVICE_FUNC explicit constexpr EIGEN_STRONG_INLINE PlainObjectBase(
518 const std::initializer_list<std::initializer_list<Scalar>>& list) {
519 size_t list_size = 0;
520 if (list.begin() != list.end()) {
521 list_size = list.begin()->size();
522 }
523
524 // This is to allow syntax like VectorXi {{1, 2, 3, 4}}
525 EIGEN_IF_CONSTEXPR (ColsAtCompileTime == 1) {
526 if (list.size() == 1) {
527 eigen_assert(list_size == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
528 resize(list_size, ColsAtCompileTime);
529 if (list.begin()->begin() != nullptr) {
530 Index index = 0;
531 for (const Scalar& e : *list.begin()) {
532 coeffRef(index++) = e;
533 }
534 }
535 return;
536 }
537 }
538
539 eigen_assert(list.size() == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
540 eigen_assert(list_size == static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime == Dynamic);
541 resize(list.size(), list_size);
542
543 Index row_index = 0;
544 for (const std::initializer_list<Scalar>& row : list) {
545 eigen_assert(list_size == row.size());
546 Index col_index = 0;
547 for (const Scalar& e : row) {
548 coeffRef(row_index, col_index) = e;
549 ++col_index;
550 }
551 ++row_index;
552 }
553 }
554
556 template <typename OtherDerived>
557 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived>& other) {
558 resizeLike(other);
559 _set_noalias(other);
560 }
561
563 template <typename OtherDerived>
564 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived>& other) {
565 resizeLike(other);
566 *this = other.derived();
567 }
568
569 template <typename OtherDerived>
570 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue<OtherDerived>& other) {
571 // FIXME this does not automatically transpose vectors if necessary
572 resize(other.rows(), other.cols());
573 other.evalTo(this->derived());
574 }
575
576 public:
580 template <typename OtherDerived>
581 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived>& other) {
582 _resize_to_match(other);
583 Base::operator=(other.derived());
584 return this->derived();
585 }
586
599 EIGEN_DEVICE_FUNC static inline ConstMapType Map(const Scalar* data) { return ConstMapType(data); }
600 EIGEN_DEVICE_FUNC static inline MapType Map(Scalar* data) { return MapType(data); }
601 EIGEN_DEVICE_FUNC static inline ConstMapType Map(const Scalar* data, Index size) { return ConstMapType(data, size); }
602 EIGEN_DEVICE_FUNC static inline MapType Map(Scalar* data, Index size) { return MapType(data, size); }
603 EIGEN_DEVICE_FUNC static inline ConstMapType Map(const Scalar* data, Index rows, Index cols) {
604 return ConstMapType(data, rows, cols);
605 }
606 EIGEN_DEVICE_FUNC static inline MapType Map(Scalar* data, Index rows, Index cols) {
607 return MapType(data, rows, cols);
608 }
609
610 EIGEN_DEVICE_FUNC static inline ConstAlignedMapType MapAligned(const Scalar* data) {
611 return ConstAlignedMapType(data);
612 }
613 EIGEN_DEVICE_FUNC static inline AlignedMapType MapAligned(Scalar* data) { return AlignedMapType(data); }
614 EIGEN_DEVICE_FUNC static inline ConstAlignedMapType MapAligned(const Scalar* data, Index size) {
615 return ConstAlignedMapType(data, size);
616 }
617 EIGEN_DEVICE_FUNC static inline AlignedMapType MapAligned(Scalar* data, Index size) {
618 return AlignedMapType(data, size);
619 }
620 EIGEN_DEVICE_FUNC static inline ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols) {
621 return ConstAlignedMapType(data, rows, cols);
622 }
623 EIGEN_DEVICE_FUNC 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 EIGEN_DEVICE_FUNC static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
629 const Scalar* data, const Stride<Outer, Inner>& stride) {
630 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, stride);
631 }
632 template <int Outer, int Inner>
633 EIGEN_DEVICE_FUNC static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(
634 Scalar* data, const Stride<Outer, Inner>& stride) {
635 return typename StridedMapType<Stride<Outer, Inner>>::type(data, stride);
636 }
637 template <int Outer, int Inner>
638 EIGEN_DEVICE_FUNC static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
639 const Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
640 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, size, stride);
641 }
642 template <int Outer, int Inner>
643 EIGEN_DEVICE_FUNC static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(
644 Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
645 return typename StridedMapType<Stride<Outer, Inner>>::type(data, size, stride);
646 }
647 template <int Outer, int Inner>
648 EIGEN_DEVICE_FUNC static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(
649 const Scalar* data, Index rows, Index cols, 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 EIGEN_DEVICE_FUNC static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(
654 Scalar* data, Index rows, Index cols, 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 EIGEN_DEVICE_FUNC 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 EIGEN_DEVICE_FUNC 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 EIGEN_DEVICE_FUNC 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 EIGEN_DEVICE_FUNC 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 EIGEN_DEVICE_FUNC 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 EIGEN_DEVICE_FUNC 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 constexpr bool shape_is_proven = IsVectorAtCompileTime ? (internal::vector_dimensions<OtherDerived>::Proven &&
730 internal::matching_sizes<Derived, OtherDerived>::Proven)
731 : internal::matching_shapes<Derived, OtherDerived>::Proven;
732 EIGEN_INTERNAL_SHAPE_ASSERT(
733 shape_is_proven,
734 (this->size() == 0 ||
735 (IsVectorAtCompileTime ? ((other.rows() == 1 || other.cols() == 1) && this->size() == other.size())
736 : (rows() == other.rows() && cols() == other.cols()))) &&
737 "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
738 if (this->size() == 0) resizeLike(other);
739 EIGEN_ONLY_USED_FOR_DEBUG(other);
740#else
741 resizeLike(other);
742#endif
743 }
744
759 // aliasing is dealt once in internal::call_assignment
760 // so at this stage we have to assume aliasing... and resizing has to be done later.
761 template <typename OtherDerived>
762 EIGEN_DEVICE_FUNC constexpr Derived& _set(const DenseBase<OtherDerived>& other) {
763 internal::call_assignment(this->derived(), other.derived());
764 return this->derived();
765 }
766
772 template <typename OtherDerived>
773 EIGEN_DEVICE_FUNC constexpr Derived& _set_noalias(const DenseBase<OtherDerived>& other) {
774 // I don't think we need this resize call since the lazyAssign will anyways resize
775 // and lazyAssign will be called by the assign selector.
776 //_resize_to_match(other);
777 // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
778 // it wouldn't allow to copy a row-vector into a column-vector.
779 internal::call_assignment_no_alias(this->derived(), other.derived(),
780 internal::assign_op<Scalar, typename OtherDerived::Scalar>());
781 return this->derived();
782 }
783
784 template <typename T0, typename T1, std::enable_if_t<Base::SizeAtCompileTime != 2, T0>* = nullptr>
785 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(Index rows, Index cols) {
786 EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T0>::value && internal::is_valid_index_type<T1>::value,
787 T0 AND T1 MUST BE INTEGER TYPES)
788 resize(rows, cols);
789 }
790
791 template <typename T0, typename T1, std::enable_if_t<Base::SizeAtCompileTime == 2, T0>* = nullptr>
792 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1) {
793 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
794 m_storage.data()[0] = Scalar(val0);
795 m_storage.data()[1] = Scalar(val1);
796 }
797
798 template <typename T0, typename T1,
799 std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<T0, Index>::value) &&
800 (std::is_same<T1, Index>::value) && Base::SizeAtCompileTime == 2,
801 int> = 0>
802 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(const Index& val0, const Index& val1) {
803 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
804 m_storage.data()[0] = Scalar(val0);
805 m_storage.data()[1] = Scalar(val1);
806 }
807
808 // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,
809 // then the argument is meant to be the size of the object.
810 template <typename T,
811 std::enable_if_t<(Base::SizeAtCompileTime != 1 || !std::is_convertible<T, Scalar>::value) &&
812 ((!std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value ||
813 Base::SizeAtCompileTime == Dynamic)),
814 int> = 0>
815 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(Index size) {
816 EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T>::value, 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 std::enable_if_t<Base::SizeAtCompileTime == 1 && std::is_convertible<T, Scalar>::value, int> = 0>
824 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar& val0) {
825 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
826 m_storage.data()[0] = val0;
827 }
828
829 // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
830 // type match the index type)
831 template <typename T, std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<Index, T>::value) &&
832 Base::SizeAtCompileTime == 1 && std::is_convertible<T, Scalar>::value,
833 int> = 0>
834 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Index& val0) {
835 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
836 m_storage.data()[0] = Scalar(val0);
837 }
838
839 // Initialize a fixed size matrix from a pointer to raw data
840 template <typename T>
841 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar* data) {
842 this->_set_noalias(ConstMapType(data));
843 }
844
845 // Initialize an arbitrary matrix from a dense expression
846 template <typename T, typename OtherDerived>
847 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other) {
848 this->_set_noalias(other);
849 }
850
851 // Initialize an arbitrary matrix from an object convertible to the Derived type.
852 template <typename T>
853 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Derived& other) {
854 this->_set_noalias(other);
855 }
856
857 // Initialize an arbitrary matrix from a generic Eigen expression
858 template <typename T, typename OtherDerived>
859 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other) {
860 this->derived() = other;
861 }
862
863 template <typename T, typename OtherDerived>
864 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const ReturnByValue<OtherDerived>& other) {
865 resize(other.rows(), other.cols());
866 other.evalTo(this->derived());
867 }
868
869 template <typename T, typename OtherDerived, int ColsAtCompileTime>
870 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived, ColsAtCompileTime>& r) {
871 this->derived() = r;
872 }
873
874 // For fixed-size Array<Scalar,...>
875 template <typename T, std::enable_if_t<Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
876 std::is_convertible<T, Scalar>::value &&
877 std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
878 int> = 0>
879 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar& val0) {
880 Base::setConstant(val0);
881 }
882
883 // For fixed-size Array<Index,...>
884 template <typename T, std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<Index, T>::value) &&
885 Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
886 std::is_convertible<T, Scalar>::value &&
887 std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
888 int> = 0>
889 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Index& val0) {
890 Base::setConstant(val0);
891 }
892
893 template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
894 friend struct internal::matrix_swap_impl;
895
896 public:
897#ifndef EIGEN_PARSED_BY_DOXYGEN
902 template <typename OtherDerived>
903 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase<OtherDerived>& other) {
904 enum {SwapPointers = std::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime == Dynamic};
905 internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());
906 }
907
911 template <typename OtherDerived>
912 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase<OtherDerived> const& other) {
913 Base::swap(other.derived());
914 }
915
916 enum {IsPlainObjectBase = 1};
917#endif
918 public:
919 // These apparently need to be down here for nvcc+icc to prevent duplicate
920 // Map symbol.
921 template <typename PlainObjectType, int MapOptions, typename StrideType>
922 friend class Eigen::Map;
923 friend class Eigen::Map<Derived, Unaligned>;
924 friend class Eigen::Map<const Derived, Unaligned>;
925#if EIGEN_MAX_ALIGN_BYTES > 0
926 // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class
927 // twice.
928 friend class Eigen::Map<Derived, AlignedMax>;
929 friend class Eigen::Map<const Derived, AlignedMax>;
930#endif
931};
932
933namespace internal {
934
935template <typename Derived, typename OtherDerived, bool IsVector>
936struct conservative_resize_like_impl {
937 // Fixed-capacity storage only changes its dimensions; its coefficients never relocate.
938 static constexpr bool IsRelocatable =
939 Derived::MaxSizeAtCompileTime != Dynamic || std::is_trivially_copyable<typename Derived::Scalar>::value;
940#ifdef EIGEN_INITIALIZE_COEFFS
941 // In-place reallocation leaves appended coefficients uninitialized, so under the initialization macros a resize that
942 // appends coefficients without assigning them copies into a new, initialized object instead.
943 static constexpr bool MustInitializeAppended = true;
944#else
945 static constexpr bool MustInitializeAppended = false;
946#endif
947 static void run(DenseBase<Derived>& _this, Index rows, Index cols) {
948 if (_this.rows() == rows && _this.cols() == cols) return;
949 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
950
951 EIGEN_IF_CONSTEXPR (IsRelocatable) {
952 if (((Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows
953 (!Derived::IsRowMajor && _this.rows() == rows)) && // column-major and we change only the number of columns
954 !(MustInitializeAppended && (Derived::IsRowMajor ? rows > _this.rows() : cols > _this.cols()))) {
955#ifndef EIGEN_NO_DEBUG
956 internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime, Derived::MaxRowsAtCompileTime,
957 Derived::MaxColsAtCompileTime>::run(rows, cols);
958#endif
959 _this.derived().m_storage.conservativeResize(rows * cols, rows, cols);
960 return;
961 }
962 }
963
964 // The storage order does not allow us to use reallocation.
965 Derived tmp(rows, cols);
966 const Index common_rows = numext::mini(rows, _this.rows());
967 const Index common_cols = numext::mini(cols, _this.cols());
968 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
969 _this.derived().swap(tmp);
970 }
971
972 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
973 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
974
975 // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),
976 // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
977 // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or
978 // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like
979 // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
980 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
981 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
982
983 EIGEN_IF_CONSTEXPR (IsRelocatable) {
984 if ((Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows
985 (!Derived::IsRowMajor &&
986 _this.rows() == other.rows())) // column-major and we change only the number of columns
987 {
988 const Index new_rows = other.rows() - _this.rows();
989 const Index new_cols = other.cols() - _this.cols();
990 _this.derived().m_storage.conservativeResize(other.size(), other.rows(), other.cols());
991 if (new_rows > 0)
992 _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
993 else if (new_cols > 0)
994 _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
995 return;
996 }
997 }
998
999 // The storage order does not allow us to use reallocation.
1000 Derived tmp(other);
1001 const Index common_rows = numext::mini(tmp.rows(), _this.rows());
1002 const Index common_cols = numext::mini(tmp.cols(), _this.cols());
1003 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
1004 _this.derived().swap(tmp);
1005 }
1006};
1007
1008// Vectors preserve their linear layout when their length changes.
1009template <typename Derived, typename OtherDerived>
1010struct conservative_resize_like_impl<Derived, OtherDerived, true>
1011 : conservative_resize_like_impl<Derived, OtherDerived, false> {
1012 using Base = conservative_resize_like_impl<Derived, OtherDerived, false>;
1013 using Base::IsRelocatable;
1014 using Base::MustInitializeAppended;
1015
1016 static void run(DenseBase<Derived>& _this, Index rows, Index cols) {
1017 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
1018 const Index size = Derived::RowsAtCompileTime == 1 ? cols : rows;
1019 eigen_assert((Derived::RowsAtCompileTime == 1 ? rows == 1 : cols == 1) &&
1020 "Invalid sizes when resizing a vector.");
1021 run(_this, size);
1022 }
1023
1024 static void run(DenseBase<Derived>& _this, Index size) {
1025 eigen_assert(size >= 0 && "Invalid sizes when resizing a vector.");
1026 if (_this.size() == size) return;
1027 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : size;
1028 const Index new_cols = Derived::RowsAtCompileTime == 1 ? size : 1;
1029 EIGEN_IF_CONSTEXPR (IsRelocatable) {
1030 if (!(MustInitializeAppended && size > _this.size())) {
1031 _this.derived().m_storage.conservativeResize(size, new_rows, new_cols);
1032 return;
1033 }
1034 }
1035 Base::run(_this.derived(), new_rows, new_cols);
1036 }
1037
1038 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
1039 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1040
1041 const Index num_new_elements = other.size() - _this.size();
1042
1043 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : other.size();
1044 const Index new_cols = Derived::RowsAtCompileTime == 1 ? other.size() : 1;
1045 EIGEN_IF_CONSTEXPR (IsRelocatable)
1046 _this.derived().m_storage.conservativeResize(other.size(), new_rows, new_cols);
1047 else
1048 Base::run(_this.derived(), new_rows, new_cols);
1049
1050 if (num_new_elements > 0) _this.tail(num_new_elements) = other.tail(num_new_elements);
1051 }
1052};
1053
1054template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
1055struct matrix_swap_impl {
1056 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(MatrixTypeA& a, MatrixTypeB& b) { a.base().swap(b); }
1057};
1058
1059template <typename MatrixTypeA, typename MatrixTypeB>
1060struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> {
1061 EIGEN_DEVICE_FUNC static inline void run(MatrixTypeA& a, MatrixTypeB& b) {
1062 static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);
1063 }
1064};
1065
1066} // end namespace internal
1067
1068} // end namespace Eigen
1069
1070#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:217
constexpr PlainObjectBase & operator=(PlainObjectBase &&other) noexcept
Move assignment operator.
Definition PlainObjectBase.h:482
constexpr const Scalar & coeff(Index index) const
Definition PlainObjectBase.h:199
PlainObjectBase(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition PlainObjectBase.h:570
constexpr void resize(NoChange_t, Index cols)
Definition PlainObjectBase.h:341
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:464
constexpr Scalar * data()
Definition PlainObjectBase.h:264
constexpr void resize(Index size)
Definition PlainObjectBase.h:315
Derived & setOnes(NoChange_t, Index cols)
Definition CwiseNullaryOp.h:716
constexpr PlainObjectBase(const EigenBase< OtherDerived > &other)
Definition PlainObjectBase.h:564
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:445
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:517
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:502
constexpr PlainObjectBase(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:557
Derived & setRandom(Index size)
Definition Random.h:148
constexpr const Scalar & coeff(Index rowId, Index colId) const
Definition PlainObjectBase.h:187
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:762
constexpr PlainObjectBase(PlainObjectBase &&)=default
Move constructor.
void conservativeResize(Index rows, Index cols)
Definition PlainObjectBase.h:390
Derived & setZero(Index rows, Index cols)
Definition CwiseNullaryOp.h:552
void conservativeResize(Index size)
Definition PlainObjectBase.h:429
constexpr const Scalar & coeffRef(Index index) const
Definition PlainObjectBase.h:231
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:221
void conservativeResize(Index rows, NoChange_t)
Definition PlainObjectBase.h:404
constexpr void resize(Index rows, NoChange_t)
Definition PlainObjectBase.h:351
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:364
constexpr const Scalar * data() const
Definition PlainObjectBase.h:261
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:460
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:205
constexpr void resize(Index rows, Index cols)
Definition PlainObjectBase.h:282
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:581
void conservativeResize(NoChange_t, Index cols)
Definition PlainObjectBase.h:416
@ 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