Eigen  5.0.1
 
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
360 template <typename OtherDerived>
361 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other) {
362 const OtherDerived& other = _other.derived();
363#ifndef EIGEN_NO_DEBUG
364 internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(
365 other.rows(), other.cols());
366#endif
367 const Index othersize = other.rows() * other.cols();
368 EIGEN_IF_CONSTEXPR (RowsAtCompileTime == 1) {
369 eigen_assert(other.rows() == 1 || other.cols() == 1);
370 resize(1, othersize);
371 } else EIGEN_IF_CONSTEXPR (ColsAtCompileTime == 1) {
372 eigen_assert(other.rows() == 1 || other.cols() == 1);
373 resize(othersize, 1);
374 } else {
375 resize(other.rows(), other.cols());
376 }
377 }
378
388 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols) {
389 internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols);
390 }
391
399 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t) {
400 // Note: see the comment in conservativeResize(Index,Index)
401 conservativeResize(rows, cols());
402 }
403
411 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols) {
412 // Note: see the comment in conservativeResize(Index,Index)
413 conservativeResize(rows(), cols);
414 }
415
424 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index size) {
425 internal::conservative_resize_like_impl<Derived>::run(*this, size);
426 }
427
437 template <typename OtherDerived>
438 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other) {
439 internal::conservative_resize_like_impl<Derived, OtherDerived>::run(*this, other);
440 }
441
445 EIGEN_DEVICE_FUNC constexpr Derived& operator=(const PlainObjectBase& other) { return _set(other); }
446
448 template <typename OtherDerived>
449 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other) {
450 _resize_to_match(other);
451 return Base::lazyAssign(other.derived());
452 }
453
454 template <typename OtherDerived>
455 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue<OtherDerived>& func) {
456 resize(func.rows(), func.cols());
457 return Base::operator=(func);
458 }
459
460 // Prevent user from trying to instantiate PlainObjectBase objects
461 // by making all its constructors protected. See bug 1074.
462 protected:
463 EIGEN_DEVICE_FUNC constexpr PlainObjectBase() = default;
465 EIGEN_DEVICE_FUNC constexpr PlainObjectBase(PlainObjectBase&&) = default;
467 EIGEN_DEVICE_FUNC constexpr PlainObjectBase& operator=(PlainObjectBase&& other) noexcept {
468 m_storage = std::move(other.m_storage);
469 return *this;
470 }
471
473 EIGEN_DEVICE_FUNC constexpr PlainObjectBase(const PlainObjectBase&) = default;
474 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)
475 : m_storage(size, rows, cols) {}
476
486 template <typename... ArgTypes>
487 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const Scalar& a0, const Scalar& a1, const Scalar& a2,
488 const Scalar& a3, const ArgTypes&... args) {
489 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, sizeof...(args) + 4);
490 m_storage.data()[0] = a0;
491 m_storage.data()[1] = a1;
492 m_storage.data()[2] = a2;
493 m_storage.data()[3] = a3;
494 Index i = 4;
495 auto x = {(m_storage.data()[i++] = args, 0)...};
496 static_cast<void>(x);
497 }
498
502 EIGEN_DEVICE_FUNC explicit constexpr EIGEN_STRONG_INLINE PlainObjectBase(
503 const std::initializer_list<std::initializer_list<Scalar>>& list) {
504 size_t list_size = 0;
505 if (list.begin() != list.end()) {
506 list_size = list.begin()->size();
507 }
508
509 // This is to allow syntax like VectorXi {{1, 2, 3, 4}}
510 EIGEN_IF_CONSTEXPR (ColsAtCompileTime == 1) {
511 if (list.size() == 1) {
512 eigen_assert(list_size == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
513 resize(list_size, ColsAtCompileTime);
514 if (list.begin()->begin() != nullptr) {
515 Index index = 0;
516 for (const Scalar& e : *list.begin()) {
517 coeffRef(index++) = e;
518 }
519 }
520 return;
521 }
522 }
523
524 eigen_assert(list.size() == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
525 eigen_assert(list_size == static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime == Dynamic);
526 resize(list.size(), list_size);
527
528 Index row_index = 0;
529 for (const std::initializer_list<Scalar>& row : list) {
530 eigen_assert(list_size == row.size());
531 Index col_index = 0;
532 for (const Scalar& e : row) {
533 coeffRef(row_index, col_index) = e;
534 ++col_index;
535 }
536 ++row_index;
537 }
538 }
539
541 template <typename OtherDerived>
542 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived>& other) {
543 resizeLike(other);
544 _set_noalias(other);
545 }
546
548 template <typename OtherDerived>
549 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived>& other) {
550 resizeLike(other);
551 *this = other.derived();
552 }
553
554 template <typename OtherDerived>
555 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue<OtherDerived>& other) {
556 // FIXME this does not automatically transpose vectors if necessary
557 resize(other.rows(), other.cols());
558 other.evalTo(this->derived());
559 }
560
561 public:
565 template <typename OtherDerived>
566 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived>& other) {
567 _resize_to_match(other);
568 Base::operator=(other.derived());
569 return this->derived();
570 }
571
584 static inline ConstMapType Map(const Scalar* data) { return ConstMapType(data); }
585 static inline MapType Map(Scalar* data) { return MapType(data); }
586 static inline ConstMapType Map(const Scalar* data, Index size) { return ConstMapType(data, size); }
587 static inline MapType Map(Scalar* data, Index size) { return MapType(data, size); }
588 static inline ConstMapType Map(const Scalar* data, Index rows, Index cols) { return ConstMapType(data, rows, cols); }
589 static inline MapType Map(Scalar* data, Index rows, Index cols) { return MapType(data, rows, cols); }
590
591 static inline ConstAlignedMapType MapAligned(const Scalar* data) { return ConstAlignedMapType(data); }
592 static inline AlignedMapType MapAligned(Scalar* data) { return AlignedMapType(data); }
593 static inline ConstAlignedMapType MapAligned(const Scalar* data, Index size) {
594 return ConstAlignedMapType(data, size);
595 }
596 static inline AlignedMapType MapAligned(Scalar* data, Index size) { return AlignedMapType(data, size); }
597 static inline ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols) {
598 return ConstAlignedMapType(data, rows, cols);
599 }
600 static inline AlignedMapType MapAligned(Scalar* data, Index rows, Index cols) {
601 return AlignedMapType(data, rows, cols);
602 }
603
604 template <int Outer, int Inner>
605 static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(const Scalar* data,
606 const Stride<Outer, Inner>& stride) {
607 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, stride);
608 }
609 template <int Outer, int Inner>
610 static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(Scalar* data,
611 const Stride<Outer, Inner>& stride) {
612 return typename StridedMapType<Stride<Outer, Inner>>::type(data, stride);
613 }
614 template <int Outer, int Inner>
615 static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(const Scalar* data, Index size,
616 const Stride<Outer, Inner>& stride) {
617 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, size, stride);
618 }
619 template <int Outer, int Inner>
620 static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(Scalar* data, Index size,
621 const Stride<Outer, Inner>& stride) {
622 return typename StridedMapType<Stride<Outer, Inner>>::type(data, size, stride);
623 }
624 template <int Outer, int Inner>
625 static inline typename StridedConstMapType<Stride<Outer, Inner>>::type Map(const Scalar* data, Index rows, Index cols,
626 const Stride<Outer, Inner>& stride) {
627 return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
628 }
629 template <int Outer, int Inner>
630 static inline typename StridedMapType<Stride<Outer, Inner>>::type Map(Scalar* data, Index rows, Index cols,
631 const Stride<Outer, Inner>& stride) {
632 return typename StridedMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
633 }
634
635 template <int Outer, int Inner>
636 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
637 const Scalar* data, const Stride<Outer, Inner>& stride) {
638 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(data, stride);
639 }
640 template <int Outer, int Inner>
641 static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
642 Scalar* data, const Stride<Outer, Inner>& stride) {
643 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(data, stride);
644 }
645 template <int Outer, int Inner>
646 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
647 const Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
648 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(data, size, stride);
649 }
650 template <int Outer, int Inner>
651 static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
652 Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
653 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(data, size, stride);
654 }
655 template <int Outer, int Inner>
656 static inline typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
657 const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
658 return typename StridedConstAlignedMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
659 }
660 template <int Outer, int Inner>
661 static inline typename StridedAlignedMapType<Stride<Outer, Inner>>::type MapAligned(
662 Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
663 return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
664 }
666
667 using Base::setConstant;
668 EIGEN_DEVICE_FUNC Derived& setConstant(Index size, const Scalar& val);
669 EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, Index cols, const Scalar& val);
670 EIGEN_DEVICE_FUNC Derived& setConstant(NoChange_t, Index cols, const Scalar& val);
671 EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, NoChange_t, const Scalar& val);
672
673 using Base::setZero;
674 EIGEN_DEVICE_FUNC Derived& setZero(Index size);
675 EIGEN_DEVICE_FUNC Derived& setZero(Index rows, Index cols);
676 EIGEN_DEVICE_FUNC Derived& setZero(NoChange_t, Index cols);
677 EIGEN_DEVICE_FUNC Derived& setZero(Index rows, NoChange_t);
678
679 using Base::setOnes;
680 EIGEN_DEVICE_FUNC Derived& setOnes(Index size);
681 EIGEN_DEVICE_FUNC Derived& setOnes(Index rows, Index cols);
682 EIGEN_DEVICE_FUNC Derived& setOnes(NoChange_t, Index cols);
683 EIGEN_DEVICE_FUNC Derived& setOnes(Index rows, NoChange_t);
684
685 using Base::setRandom;
686 Derived& setRandom(Index size);
687 Derived& setRandom(Index rows, Index cols);
688 Derived& setRandom(NoChange_t, Index cols);
689 Derived& setRandom(Index rows, NoChange_t);
690
691#ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
692#include EIGEN_PLAINOBJECTBASE_PLUGIN
693#endif
694
695 protected:
703 template <typename OtherDerived>
704 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase<OtherDerived>& other) {
705#ifdef EIGEN_NO_AUTOMATIC_RESIZING
706 eigen_assert((this->size() == 0 ||
707 (IsVectorAtCompileTime ? ((other.rows() == 1 || other.cols() == 1) && this->size() == other.size())
708 : (rows() == other.rows() && cols() == other.cols()))) &&
709 "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
710 if (this->size() == 0) resizeLike(other);
711 EIGEN_ONLY_USED_FOR_DEBUG(other);
712#else
713 resizeLike(other);
714#endif
715 }
716
731 // aliasing is dealt once in internal::call_assignment
732 // so at this stage we have to assume aliasing... and resizing has to be done later.
733 template <typename OtherDerived>
734 EIGEN_DEVICE_FUNC constexpr Derived& _set(const DenseBase<OtherDerived>& other) {
735 internal::call_assignment(this->derived(), other.derived());
736 return this->derived();
737 }
738
744 template <typename OtherDerived>
745 EIGEN_DEVICE_FUNC constexpr Derived& _set_noalias(const DenseBase<OtherDerived>& other) {
746 // I don't think we need this resize call since the lazyAssign will anyways resize
747 // and lazyAssign will be called by the assign selector.
748 //_resize_to_match(other);
749 // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
750 // it wouldn't allow to copy a row-vector into a column-vector.
751 internal::call_assignment_no_alias(this->derived(), other.derived(),
752 internal::assign_op<Scalar, typename OtherDerived::Scalar>());
753 return this->derived();
754 }
755
756 template <typename T0, typename T1, std::enable_if_t<Base::SizeAtCompileTime != 2, T0>* = nullptr>
757 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(Index rows, Index cols) {
758 EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T0>::value && internal::is_valid_index_type<T1>::value,
759 T0 AND T1 MUST BE INTEGER TYPES)
760 resize(rows, cols);
761 }
762
763 template <typename T0, typename T1, std::enable_if_t<Base::SizeAtCompileTime == 2, T0>* = nullptr>
764 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1) {
765 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
766 m_storage.data()[0] = Scalar(val0);
767 m_storage.data()[1] = Scalar(val1);
768 }
769
770 template <typename T0, typename T1,
771 std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<T0, Index>::value) &&
772 (std::is_same<T1, Index>::value) && Base::SizeAtCompileTime == 2,
773 int> = 0>
774 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init2(const Index& val0, const Index& val1) {
775 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
776 m_storage.data()[0] = Scalar(val0);
777 m_storage.data()[1] = Scalar(val1);
778 }
779
780 // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,
781 // then the argument is meant to be the size of the object.
782 template <typename T,
783 std::enable_if_t<(Base::SizeAtCompileTime != 1 || !std::is_convertible<T, Scalar>::value) &&
784 ((!std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value ||
785 Base::SizeAtCompileTime == Dynamic)),
786 int> = 0>
787 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(Index size) {
788 EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T>::value, FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
789 resize(size);
790 }
791
792 // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
793 // type can be implicitly converted)
794 template <typename T,
795 std::enable_if_t<Base::SizeAtCompileTime == 1 && std::is_convertible<T, Scalar>::value, int> = 0>
796 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar& val0) {
797 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
798 m_storage.data()[0] = val0;
799 }
800
801 // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
802 // type match the index type)
803 template <typename T, std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<Index, T>::value) &&
804 Base::SizeAtCompileTime == 1 && std::is_convertible<T, Scalar>::value,
805 int> = 0>
806 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Index& val0) {
807 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
808 m_storage.data()[0] = Scalar(val0);
809 }
810
811 // Initialize a fixed size matrix from a pointer to raw data
812 template <typename T>
813 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar* data) {
814 this->_set_noalias(ConstMapType(data));
815 }
816
817 // Initialize an arbitrary matrix from a dense expression
818 template <typename T, typename OtherDerived>
819 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other) {
820 this->_set_noalias(other);
821 }
822
823 // Initialize an arbitrary matrix from an object convertible to the Derived type.
824 template <typename T>
825 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Derived& other) {
826 this->_set_noalias(other);
827 }
828
829 // Initialize an arbitrary matrix from a generic Eigen expression
830 template <typename T, typename OtherDerived>
831 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other) {
832 this->derived() = other;
833 }
834
835 template <typename T, typename OtherDerived>
836 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const ReturnByValue<OtherDerived>& other) {
837 resize(other.rows(), other.cols());
838 other.evalTo(this->derived());
839 }
840
841 template <typename T, typename OtherDerived, int ColsAtCompileTime>
842 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived, ColsAtCompileTime>& r) {
843 this->derived() = r;
844 }
845
846 // For fixed-size Array<Scalar,...>
847 template <typename T, std::enable_if_t<Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
848 std::is_convertible<T, Scalar>::value &&
849 std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
850 int> = 0>
851 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Scalar& val0) {
852 Base::setConstant(val0);
853 }
854
855 // For fixed-size Array<Index,...>
856 template <typename T, std::enable_if_t<(!std::is_same<Index, Scalar>::value) && (std::is_same<Index, T>::value) &&
857 Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
858 std::is_convertible<T, Scalar>::value &&
859 std::is_same<typename internal::traits<Derived>::XprKind, ArrayXpr>::value,
860 int> = 0>
861 EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void _init1(const Index& val0) {
862 Base::setConstant(val0);
863 }
864
865 template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
866 friend struct internal::matrix_swap_impl;
867
868 public:
869#ifndef EIGEN_PARSED_BY_DOXYGEN
874 template <typename OtherDerived>
875 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase<OtherDerived>& other) {
876 enum {SwapPointers = std::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime == Dynamic};
877 internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());
878 }
879
883 template <typename OtherDerived>
884 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase<OtherDerived> const& other) {
885 Base::swap(other.derived());
886 }
887
888 enum {IsPlainObjectBase = 1};
889#endif
890 public:
891 // These apparently need to be down here for nvcc+icc to prevent duplicate
892 // Map symbol.
893 template <typename PlainObjectType, int MapOptions, typename StrideType>
894 friend class Eigen::Map;
895 friend class Eigen::Map<Derived, Unaligned>;
896 friend class Eigen::Map<const Derived, Unaligned>;
897#if EIGEN_MAX_ALIGN_BYTES > 0
898 // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class
899 // twice.
900 friend class Eigen::Map<Derived, AlignedMax>;
901 friend class Eigen::Map<const Derived, AlignedMax>;
902#endif
903};
904
905namespace internal {
906
907template <typename Derived, typename OtherDerived, bool IsVector>
908struct conservative_resize_like_impl {
909 static constexpr bool IsRelocatable = std::is_trivially_copyable<typename Derived::Scalar>::value;
910 static void run(DenseBase<Derived>& _this, Index rows, Index cols) {
911 if (_this.rows() == rows && _this.cols() == cols) return;
912 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
913
914 EIGEN_IF_CONSTEXPR (IsRelocatable) {
915 if ((Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows
916 (!Derived::IsRowMajor && _this.rows() == rows)) // column-major and we change only the number of columns
917 {
918#ifndef EIGEN_NO_DEBUG
919 internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime, Derived::MaxRowsAtCompileTime,
920 Derived::MaxColsAtCompileTime>::run(rows, cols);
921#endif
922 _this.derived().m_storage.conservativeResize(rows * cols, rows, cols);
923 return;
924 }
925 }
926
927 // The storage order does not allow us to use reallocation.
928 Derived tmp(rows, cols);
929 const Index common_rows = numext::mini(rows, _this.rows());
930 const Index common_cols = numext::mini(cols, _this.cols());
931 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
932 _this.derived().swap(tmp);
933 }
934
935 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
936 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
937
938 // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),
939 // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
940 // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or
941 // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like
942 // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
943 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
944 EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
945
946 EIGEN_IF_CONSTEXPR (IsRelocatable) {
947 if ((Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows
948 (!Derived::IsRowMajor &&
949 _this.rows() == other.rows())) // column-major and we change only the number of columns
950 {
951 const Index new_rows = other.rows() - _this.rows();
952 const Index new_cols = other.cols() - _this.cols();
953 _this.derived().m_storage.conservativeResize(other.size(), other.rows(), other.cols());
954 if (new_rows > 0)
955 _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
956 else if (new_cols > 0)
957 _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
958 return;
959 }
960 }
961
962 // The storage order does not allow us to use reallocation.
963 Derived tmp(other);
964 const Index common_rows = numext::mini(tmp.rows(), _this.rows());
965 const Index common_cols = numext::mini(tmp.cols(), _this.cols());
966 tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
967 _this.derived().swap(tmp);
968 }
969};
970
971// Here, the specialization for vectors inherits from the general matrix case
972// to allow calling .conservativeResize(rows,cols) on vectors.
973template <typename Derived, typename OtherDerived>
974struct conservative_resize_like_impl<Derived, OtherDerived, true>
975 : conservative_resize_like_impl<Derived, OtherDerived, false> {
976 using Base = conservative_resize_like_impl<Derived, OtherDerived, false>;
977 using Base::IsRelocatable;
978 using Base::run;
979
980 static void run(DenseBase<Derived>& _this, Index size) {
981 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : size;
982 const Index new_cols = Derived::RowsAtCompileTime == 1 ? size : 1;
983 EIGEN_IF_CONSTEXPR (IsRelocatable)
984 _this.derived().m_storage.conservativeResize(size, new_rows, new_cols);
985 else
986 Base::run(_this.derived(), new_rows, new_cols);
987 }
988
989 static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
990 if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
991
992 const Index num_new_elements = other.size() - _this.size();
993
994 const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : other.rows();
995 const Index new_cols = Derived::RowsAtCompileTime == 1 ? other.cols() : 1;
996 EIGEN_IF_CONSTEXPR (IsRelocatable)
997 _this.derived().m_storage.conservativeResize(other.size(), new_rows, new_cols);
998 else
999 Base::run(_this.derived(), new_rows, new_cols);
1000
1001 if (num_new_elements > 0) _this.tail(num_new_elements) = other.tail(num_new_elements);
1002 }
1003};
1004
1005template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
1006struct matrix_swap_impl {
1007 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(MatrixTypeA& a, MatrixTypeB& b) { a.base().swap(b); }
1008};
1009
1010template <typename MatrixTypeA, typename MatrixTypeB>
1011struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> {
1012 EIGEN_DEVICE_FUNC static inline void run(MatrixTypeA& a, MatrixTypeB& b) {
1013 static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);
1014 }
1015};
1016
1017} // end namespace internal
1018
1019} // end namespace Eigen
1020
1021#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:467
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:555
constexpr void resize(NoChange_t, Index cols)
Definition PlainObjectBase.h:341
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:449
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:549
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:438
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:502
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:487
constexpr PlainObjectBase(const DenseBase< OtherDerived > &other)
Definition PlainObjectBase.h:542
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:734
constexpr PlainObjectBase(PlainObjectBase &&)=default
Move constructor.
void conservativeResize(Index rows, Index cols)
Definition PlainObjectBase.h:388
Derived & setZero(Index rows, Index cols)
Definition CwiseNullaryOp.h:552
void conservativeResize(Index size)
Definition PlainObjectBase.h:424
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:399
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:361
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:445
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:566
void conservativeResize(NoChange_t, Index cols)
Definition PlainObjectBase.h:411
@ 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