PlainObjectBase.h
Go to the documentation of this file.
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 
11 #ifndef EIGEN_DENSESTORAGEBASE_H
12 #define EIGEN_DENSESTORAGEBASE_H
13 
14 #if defined(EIGEN_INITIALIZE_MATRICES_BY_ZERO)
15 #define EIGEN_INITIALIZE_COEFFS
16 #define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED \
17  for (Index i = 0; i < base().size(); ++i) coeffRef(i) = Scalar(0);
18 #elif defined(EIGEN_INITIALIZE_MATRICES_BY_NAN)
19 #define EIGEN_INITIALIZE_COEFFS
20 #define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED \
21  for (Index i = 0; i < base().size(); ++i) coeffRef(i) = std::numeric_limits<Scalar>::quiet_NaN();
22 #else
23 #undef EIGEN_INITIALIZE_COEFFS
24 #define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
25 #endif
26 
27 // IWYU pragma: private
28 #include "./InternalHeaderCheck.h"
29 
30 namespace Eigen {
31 
32 namespace internal {
33 
34 #ifndef EIGEN_NO_DEBUG
35 template <int MaxSizeAtCompileTime, int MaxRowsAtCompileTime, int MaxColsAtCompileTime>
37  EIGEN_STATIC_ASSERT(MaxRowsAtCompileTime* MaxColsAtCompileTime == MaxSizeAtCompileTime,
38  YOU MADE A PROGRAMMING MISTAKE)
39  template <typename Index>
40  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index) {}
41 };
42 
43 template <int MaxRowsAtCompileTime>
44 struct check_rows_cols_for_overflow<Dynamic, MaxRowsAtCompileTime, Dynamic> {
45  template <typename Index>
47  constexpr Index MaxIndex = NumTraits<Index>::highest();
48  bool error = cols > (MaxIndex / MaxRowsAtCompileTime);
50  }
51 };
52 
53 template <int MaxColsAtCompileTime>
54 struct check_rows_cols_for_overflow<Dynamic, Dynamic, MaxColsAtCompileTime> {
55  template <typename Index>
57  constexpr Index MaxIndex = NumTraits<Index>::highest();
58  bool error = rows > (MaxIndex / MaxColsAtCompileTime);
60  }
61 };
62 
63 template <>
65  template <typename Index>
67  constexpr Index MaxIndex = NumTraits<Index>::highest();
68  bool error = cols == 0 ? false : (rows > (MaxIndex / cols));
70  }
71 };
72 #endif
73 
74 template <typename Derived, typename OtherDerived = Derived,
75  bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
76 struct conservative_resize_like_impl;
77 
78 template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
79 struct matrix_swap_impl;
80 
81 } // end namespace internal
82 
83 #ifdef EIGEN_PARSED_BY_DOXYGEN
84 namespace doxygen {
85 
86 // This is a workaround to doxygen not being able to understand the inheritance logic
87 // when it is hidden by the dense_xpr_base helper struct.
88 // Moreover, doxygen fails to include members that are not documented in the declaration body of
89 // MatrixBase if we inherits MatrixBase<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >,
90 // this is why we simply inherits MatrixBase, though this does not make sense.
91 
93 template <typename Derived>
94 struct dense_xpr_base_dispatcher;
96 template <typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
97 struct dense_xpr_base_dispatcher<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> : public MatrixBase {};
99 template <typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
100 struct dense_xpr_base_dispatcher<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> : public ArrayBase {};
101 
102 } // namespace doxygen
103 
115 template <typename Derived>
116 class PlainObjectBase : public doxygen::dense_xpr_base_dispatcher<Derived>
117 #else
118 template <typename Derived>
120 #endif
121 {
122  public:
125 
128 
131  typedef Derived DenseType;
132 
133  using Base::ColsAtCompileTime;
134  using Base::Flags;
135  using Base::IsVectorAtCompileTime;
136  using Base::MaxColsAtCompileTime;
137  using Base::MaxRowsAtCompileTime;
138  using Base::MaxSizeAtCompileTime;
139  using Base::RowsAtCompileTime;
140  using Base::SizeAtCompileTime;
141 
146  template <typename StrideType>
147  struct StridedMapType {
149  };
150  template <typename StrideType>
153  };
154  template <typename StrideType>
157  };
158  template <typename StrideType>
161  };
162 
163  protected:
165 
166  public:
167  enum { NeedsToAlign = (SizeAtCompileTime != Dynamic) && (internal::traits<Derived>::Alignment > 0) };
169 
170  EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1,
171  (int(Options) & RowMajor) == RowMajor),
172  INVALID_MATRIX_TEMPLATE_PARAMETERS)
173  EIGEN_STATIC_ASSERT(internal::check_implication(MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1,
174  (int(Options) & RowMajor) == 0),
175  INVALID_MATRIX_TEMPLATE_PARAMETERS)
176  EIGEN_STATIC_ASSERT((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
177  EIGEN_STATIC_ASSERT((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
178  EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0),
179  INVALID_MATRIX_TEMPLATE_PARAMETERS)
180  EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0),
181  INVALID_MATRIX_TEMPLATE_PARAMETERS)
182  EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime == Dynamic),
183  INVALID_MATRIX_TEMPLATE_PARAMETERS)
184  EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime == Dynamic),
185  INVALID_MATRIX_TEMPLATE_PARAMETERS)
186  EIGEN_STATIC_ASSERT(((Options & (DontAlign | RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS)
187 
188  EIGEN_DEVICE_FUNC Base& base() { return *static_cast<Base*>(this); }
189  EIGEN_DEVICE_FUNC const Base& base() const { return *static_cast<const Base*>(this); }
190 
193 
198  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeff(Index rowId, Index colId) const {
200  return m_storage.data()[colId + rowId * m_storage.cols()];
201  else // column-major
202  return m_storage.data()[rowId + colId * m_storage.rows()];
203  }
204 
209  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeff(Index index) const {
210  return m_storage.data()[index];
211  }
212 
218  if (Flags & RowMajorBit)
219  return m_storage.data()[colId + rowId * m_storage.cols()];
220  else // column-major
221  return m_storage.data()[rowId + colId * m_storage.rows()];
222  }
223 
228  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Scalar& coeffRef(Index index) { return m_storage.data()[index]; }
229 
232  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeffRef(Index rowId, Index colId) const {
233  if (Flags & RowMajorBit)
234  return m_storage.data()[colId + rowId * m_storage.cols()];
235  else // column-major
236  return m_storage.data()[rowId + colId * m_storage.rows()];
237  }
238 
242  return m_storage.data()[index];
243  }
244 
246  template <int LoadMode>
248  return internal::ploadt<PacketScalar, LoadMode>(
249  m_storage.data() + (Flags & RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()));
250  }
251 
253  template <int LoadMode>
255  return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
256  }
257 
259  template <int StoreMode>
261  internal::pstoret<Scalar, PacketScalar, StoreMode>(
262  m_storage.data() + (Flags & RowMajorBit ? colId + rowId * m_storage.cols() : rowId + colId * m_storage.rows()),
263  val);
264  }
265 
267  template <int StoreMode>
269  internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
270  }
271 
273  EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_storage.data(); }
274 
276  EIGEN_DEVICE_FUNC constexpr Scalar* data() { return m_storage.data(); }
277 
295  eigen_assert(internal::check_implication(RowsAtCompileTime != Dynamic, rows == RowsAtCompileTime) &&
296  internal::check_implication(ColsAtCompileTime != Dynamic, cols == ColsAtCompileTime) &&
297  internal::check_implication(RowsAtCompileTime == Dynamic && MaxRowsAtCompileTime != Dynamic,
298  rows <= MaxRowsAtCompileTime) &&
299  internal::check_implication(ColsAtCompileTime == Dynamic && MaxColsAtCompileTime != Dynamic,
300  cols <= MaxColsAtCompileTime) &&
301  rows >= 0 && cols >= 0 && "Invalid sizes when resizing a matrix or array.");
302 #ifndef EIGEN_NO_DEBUG
304  cols);
305 #endif
306 #ifdef EIGEN_INITIALIZE_COEFFS
307  Index size = rows * cols;
308  bool size_changed = size != this->size();
309  m_storage.resize(size, rows, cols);
311 #else
313 #endif
314  }
315 
327  EIGEN_DEVICE_FUNC inline constexpr void resize(Index size) {
329  eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime == Dynamic || size <= MaxSizeAtCompileTime)) ||
330  SizeAtCompileTime == size) &&
331  size >= 0);
332 #ifdef EIGEN_INITIALIZE_COEFFS
333  bool size_changed = size != this->size();
334 #endif
335  if (RowsAtCompileTime == 1)
336  m_storage.resize(size, 1, size);
337  else
338  m_storage.resize(size, size, 1);
339 #ifdef EIGEN_INITIALIZE_COEFFS
341 #endif
342  }
343 
352  EIGEN_DEVICE_FUNC inline constexpr void resize(NoChange_t, Index cols) { resize(rows(), cols); }
353 
362  EIGEN_DEVICE_FUNC inline constexpr void resize(Index rows, NoChange_t) { resize(rows, cols()); }
363 
371  template <typename OtherDerived>
373  const OtherDerived& other = _other.derived();
374 #ifndef EIGEN_NO_DEBUG
376  other.rows(), other.cols());
377 #endif
378  const Index othersize = other.rows() * other.cols();
379  if (RowsAtCompileTime == 1) {
380  eigen_assert(other.rows() == 1 || other.cols() == 1);
381  resize(1, othersize);
382  } else if (ColsAtCompileTime == 1) {
383  eigen_assert(other.rows() == 1 || other.cols() == 1);
384  resize(othersize, 1);
385  } else
386  resize(other.rows(), other.cols());
387  }
388 
400  }
401 
410  // Note: see the comment in conservativeResize(Index,Index)
412  }
413 
422  // Note: see the comment in conservativeResize(Index,Index)
424  }
425 
436  }
437 
447  template <typename OtherDerived>
450  }
451 
456  return _set(other);
457  }
458 
460  template <typename OtherDerived>
462  _resize_to_match(other);
463  return Base::lazyAssign(other.derived());
464  }
465 
466  template <typename OtherDerived>
468  resize(func.rows(), func.cols());
469  return Base::operator=(func);
470  }
471 
472  // Prevent user from trying to instantiate PlainObjectBase objects
473  // by making all its constructor protected. See bug 1074.
474  protected:
480  m_storage = std::move(other.m_storage);
481  return *this;
482  }
483 
487  : m_storage(size, rows, cols) {}
488 
498  template <typename... ArgTypes>
500  const Scalar& a3, const ArgTypes&... args)
501  : m_storage() {
503  m_storage.data()[0] = a0;
504  m_storage.data()[1] = a1;
505  m_storage.data()[2] = a2;
506  m_storage.data()[3] = a3;
507  Index i = 4;
508  auto x = {(m_storage.data()[i++] = args, 0)...};
509  static_cast<void>(x);
510  }
511 
516  const std::initializer_list<std::initializer_list<Scalar>>& list)
517  : m_storage() {
518  size_t list_size = 0;
519  if (list.begin() != list.end()) {
520  list_size = list.begin()->size();
521  }
522 
523  // This is to allow syntax like VectorXi {{1, 2, 3, 4}}
524  if (ColsAtCompileTime == 1 && list.size() == 1) {
525  eigen_assert(list_size == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
526  resize(list_size, ColsAtCompileTime);
527  if (list.begin()->begin() != nullptr) {
528  Index index = 0;
529  for (const Scalar& e : *list.begin()) {
530  coeffRef(index++) = e;
531  }
532  }
533  } else {
534  eigen_assert(list.size() == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
535  eigen_assert(list_size == static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime == Dynamic);
536  resize(list.size(), list_size);
537 
538  Index row_index = 0;
539  for (const std::initializer_list<Scalar>& row : list) {
540  eigen_assert(list_size == row.size());
541  Index col_index = 0;
542  for (const Scalar& e : row) {
543  coeffRef(row_index, col_index) = e;
544  ++col_index;
545  }
546  ++row_index;
547  }
548  }
549  }
550 
552  template <typename OtherDerived>
554  resizeLike(other);
555  _set_noalias(other);
556  }
557 
559  template <typename OtherDerived>
561  resizeLike(other);
562  *this = other.derived();
563  }
565  template <typename OtherDerived>
567  // FIXME this does not automatically transpose vectors if necessary
568  resize(other.rows(), other.cols());
569  other.evalTo(this->derived());
570  }
571 
572  public:
576  template <typename OtherDerived>
578  _resize_to_match(other);
579  Base::operator=(other.derived());
580  return this->derived();
581  }
582 
595  static inline ConstMapType Map(const Scalar* data) { return ConstMapType(data); }
596  static inline MapType Map(Scalar* data) { return MapType(data); }
597  static inline ConstMapType Map(const Scalar* data, Index size) { return ConstMapType(data, size); }
598  static inline MapType Map(Scalar* data, Index size) { return MapType(data, size); }
599  static inline ConstMapType Map(const Scalar* data, Index rows, Index cols) { return ConstMapType(data, rows, cols); }
600  static inline MapType Map(Scalar* data, Index rows, Index cols) { return MapType(data, rows, cols); }
601 
605  return ConstAlignedMapType(data, size);
606  }
609  return ConstAlignedMapType(data, rows, cols);
610  }
612  return AlignedMapType(data, rows, cols);
613  }
614 
615  template <int Outer, int Inner>
617  const Stride<Outer, Inner>& stride) {
618  return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, stride);
619  }
620  template <int Outer, int Inner>
622  const Stride<Outer, Inner>& stride) {
623  return typename StridedMapType<Stride<Outer, Inner>>::type(data, stride);
624  }
625  template <int Outer, int Inner>
627  const Stride<Outer, Inner>& stride) {
628  return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, size, stride);
629  }
630  template <int Outer, int Inner>
632  const Stride<Outer, Inner>& stride) {
633  return typename StridedMapType<Stride<Outer, Inner>>::type(data, size, stride);
634  }
635  template <int Outer, int Inner>
637  const Stride<Outer, Inner>& stride) {
638  return typename StridedConstMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
639  }
640  template <int Outer, int Inner>
642  const Stride<Outer, Inner>& stride) {
643  return typename StridedMapType<Stride<Outer, Inner>>::type(data, rows, cols, stride);
644  }
645 
646  template <int Outer, int Inner>
648  const Scalar* data, const Stride<Outer, Inner>& stride) {
650  }
651  template <int Outer, int Inner>
653  Scalar* data, const Stride<Outer, Inner>& stride) {
654  return typename StridedAlignedMapType<Stride<Outer, Inner>>::type(data, stride);
655  }
656  template <int Outer, int Inner>
658  const Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
660  }
661  template <int Outer, int Inner>
663  Scalar* data, Index size, const Stride<Outer, Inner>& stride) {
665  }
666  template <int Outer, int Inner>
668  const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
670  }
671  template <int Outer, int Inner>
673  Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride) {
675  }
677 
678  using Base::setConstant;
679  EIGEN_DEVICE_FUNC Derived& setConstant(Index size, const Scalar& val);
683 
684  using Base::setZero;
689 
690  using Base::setOnes;
695 
696  using Base::setRandom;
697  Derived& setRandom(Index size);
698  Derived& setRandom(Index rows, Index cols);
699  Derived& setRandom(NoChange_t, Index cols);
700  Derived& setRandom(Index rows, NoChange_t);
701 
702 #ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
703 #include EIGEN_PLAINOBJECTBASE_PLUGIN
704 #endif
705 
706  protected:
714  template <typename OtherDerived>
716 #ifdef EIGEN_NO_AUTOMATIC_RESIZING
717  eigen_assert((this->size() == 0 || (IsVectorAtCompileTime ? (this->size() == other.size())
718  : (rows() == other.rows() && cols() == other.cols()))) &&
719  "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
721 #else
722  resizeLike(other);
723 #endif
724  }
725 
740  // aliasing is dealt once in internal::call_assignment
741  // so at this stage we have to assume aliasing... and resising has to be done later.
742  template <typename OtherDerived>
744  internal::call_assignment(this->derived(), other.derived());
745  return this->derived();
746  }
747 
753  template <typename OtherDerived>
755  // I don't think we need this resize call since the lazyAssign will anyways resize
756  // and lazyAssign will be called by the assign selector.
757  //_resize_to_match(other);
758  // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
759  // it wouldn't allow to copy a row-vector into a column-vector.
760  internal::call_assignment_no_alias(this->derived(), other.derived(),
762  return this->derived();
763  }
764 
765  template <typename T0, typename T1>
767  std::enable_if_t<Base::SizeAtCompileTime != 2, T0>* = 0) {
769  T0 AND T1 MUST BE INTEGER TYPES)
770  resize(rows, cols);
771  }
772 
773  template <typename T0, typename T1>
774  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1,
775  std::enable_if_t<Base::SizeAtCompileTime == 2, T0>* = 0) {
777  m_storage.data()[0] = Scalar(val0);
778  m_storage.data()[1] = Scalar(val1);
779  }
780 
781  template <typename T0, typename T1>
783  const Index& val0, const Index& val1,
785  (internal::is_same<T1, Index>::value) && Base::SizeAtCompileTime == 2,
786  T1>* = 0) {
788  m_storage.data()[0] = Scalar(val0);
789  m_storage.data()[1] = Scalar(val1);
790  }
791 
792  // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,
793  // then the argument is meant to be the size of the object.
794  template <typename T>
796  Index size,
797  std::enable_if_t<(Base::SizeAtCompileTime != 1 || !internal::is_convertible<T, Scalar>::value) &&
799  Base::SizeAtCompileTime == Dynamic)),
800  T>* = 0) {
801  // NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.
802  const bool is_integer_alike = internal::is_valid_index_type<T>::value;
803  EIGEN_UNUSED_VARIABLE(is_integer_alike);
804  EIGEN_STATIC_ASSERT(is_integer_alike, FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
805  resize(size);
806  }
807 
808  // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
809  // type can be implicitly converted)
810  template <typename T>
812  const Scalar& val0,
813  std::enable_if_t<Base::SizeAtCompileTime == 1 && internal::is_convertible<T, Scalar>::value, T>* = 0) {
815  m_storage.data()[0] = val0;
816  }
817 
818  // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar
819  // type match the index type)
820  template <typename T>
822  const Index& val0,
824  Base::SizeAtCompileTime == 1 && internal::is_convertible<T, Scalar>::value,
825  T*>* = 0) {
827  m_storage.data()[0] = Scalar(val0);
828  }
829 
830  // Initialize a fixed size matrix from a pointer to raw data
831  template <typename T>
833  this->_set_noalias(ConstMapType(data));
834  }
835 
836  // Initialize an arbitrary matrix from a dense expression
837  template <typename T, typename OtherDerived>
839  this->_set_noalias(other);
840  }
841 
842  // Initialize an arbitrary matrix from an object convertible to the Derived type.
843  template <typename T>
844  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Derived& other) {
845  this->_set_noalias(other);
846  }
847 
848  // Initialize an arbitrary matrix from a generic Eigen expression
849  template <typename T, typename OtherDerived>
851  this->derived() = other;
852  }
853 
854  template <typename T, typename OtherDerived>
856  resize(other.rows(), other.cols());
857  other.evalTo(this->derived());
858  }
859 
860  template <typename T, typename OtherDerived, int ColsAtCompileTime>
862  this->derived() = r;
863  }
864 
865  // For fixed-size Array<Scalar,...>
866  template <typename T>
868  const Scalar& val0,
869  std::enable_if_t<Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
872  T>* = 0) {
873  Base::setConstant(val0);
874  }
875 
876  // For fixed-size Array<Index,...>
877  template <typename T>
879  const Index& val0,
881  Base::SizeAtCompileTime != Dynamic && Base::SizeAtCompileTime != 1 &&
884  T*>* = 0) {
885  Base::setConstant(val0);
886  }
887 
888  template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
890 
891  public:
892 #ifndef EIGEN_PARSED_BY_DOXYGEN
897  template <typename OtherDerived>
899  enum {SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime == Dynamic};
900  internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());
901  }
902 
906  template <typename OtherDerived>
908  Base::swap(other.derived());
909  }
910 
911  enum {IsPlainObjectBase = 1};
912 #endif
913  public:
914  // These apparently need to be down here for nvcc+icc to prevent duplicate
915  // Map symbol.
916  template <typename PlainObjectType, int MapOptions, typename StrideType>
917  friend class Eigen::Map;
918  friend class Eigen::Map<Derived, Unaligned>;
919  friend class Eigen::Map<const Derived, Unaligned>;
920 #if EIGEN_MAX_ALIGN_BYTES > 0
921  // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class
922  // twice.
923  friend class Eigen::Map<Derived, AlignedMax>;
924  friend class Eigen::Map<const Derived, AlignedMax>;
925 #endif
926 };
927 
928 namespace internal {
929 
930 template <typename Derived, typename OtherDerived, bool IsVector>
933  static void run(DenseBase<Derived>& _this, Index rows, Index cols) {
934  if (_this.rows() == rows && _this.cols() == cols) return;
936 
937  if (IsRelocatable &&
938  ((Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows
939  (!Derived::IsRowMajor && _this.rows() == rows))) // column-major and we change only the number of columns
940  {
941 #ifndef EIGEN_NO_DEBUG
942  internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime, Derived::MaxRowsAtCompileTime,
943  Derived::MaxColsAtCompileTime>::run(rows, cols);
944 #endif
945  _this.derived().m_storage.conservativeResize(rows * cols, rows, cols);
946  } else {
947  // The storage order does not allow us to use reallocation.
948  Derived tmp(rows, cols);
949  const Index common_rows = numext::mini(rows, _this.rows());
950  const Index common_cols = numext::mini(cols, _this.cols());
951  tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
952  _this.derived().swap(tmp);
953  }
954  }
955 
956  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
957  if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
958 
959  // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),
960  // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
961  // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or
962  // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like
963  // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
966 
967  if (IsRelocatable &&
968  ((Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows
969  (!Derived::IsRowMajor &&
970  _this.rows() == other.rows()))) // column-major and we change only the number of columns
971  {
972  const Index new_rows = other.rows() - _this.rows();
973  const Index new_cols = other.cols() - _this.cols();
974  _this.derived().m_storage.conservativeResize(other.size(), other.rows(), other.cols());
975  if (new_rows > 0)
976  _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
977  else if (new_cols > 0)
978  _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
979  } else {
980  // The storage order does not allow us to use reallocation.
981  Derived tmp(other);
982  const Index common_rows = numext::mini(tmp.rows(), _this.rows());
983  const Index common_cols = numext::mini(tmp.cols(), _this.cols());
984  tmp.block(0, 0, common_rows, common_cols) = _this.block(0, 0, common_rows, common_cols);
985  _this.derived().swap(tmp);
986  }
987  }
988 };
989 
990 // Here, the specialization for vectors inherits from the general matrix case
991 // to allow calling .conservativeResize(rows,cols) on vectors.
992 template <typename Derived, typename OtherDerived>
993 struct conservative_resize_like_impl<Derived, OtherDerived, true>
994  : conservative_resize_like_impl<Derived, OtherDerived, false> {
996  using Base::IsRelocatable;
997  using Base::run;
998 
999  static void run(DenseBase<Derived>& _this, Index size) {
1000  const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : size;
1001  const Index new_cols = Derived::RowsAtCompileTime == 1 ? size : 1;
1002  if (IsRelocatable)
1003  _this.derived().m_storage.conservativeResize(size, new_rows, new_cols);
1004  else
1005  Base::run(_this.derived(), new_rows, new_cols);
1006  }
1007 
1008  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other) {
1009  if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1010 
1011  const Index num_new_elements = other.size() - _this.size();
1012 
1013  const Index new_rows = Derived::RowsAtCompileTime == 1 ? 1 : other.rows();
1014  const Index new_cols = Derived::RowsAtCompileTime == 1 ? other.cols() : 1;
1015  if (IsRelocatable)
1016  _this.derived().m_storage.conservativeResize(other.size(), new_rows, new_cols);
1017  else
1018  Base::run(_this.derived(), new_rows, new_cols);
1019 
1020  if (num_new_elements > 0) _this.tail(num_new_elements) = other.tail(num_new_elements);
1021  }
1022 };
1023 
1024 template <typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
1026  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(MatrixTypeA& a, MatrixTypeB& b) { a.base().swap(b); }
1027 };
1028 
1029 template <typename MatrixTypeA, typename MatrixTypeB>
1030 struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true> {
1031  EIGEN_DEVICE_FUNC static inline void run(MatrixTypeA& a, MatrixTypeB& b) {
1032  static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);
1033  }
1034 };
1035 
1036 } // end namespace internal
1037 
1038 } // end namespace Eigen
1039 
1040 #endif // EIGEN_DENSESTORAGEBASE_H
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
A setRandom()
#define EIGEN_ALWAYS_INLINE
Definition: Macros.h:845
#define EIGEN_NOEXCEPT
Definition: Macros.h:1267
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:966
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:922
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
m row(1)
v setConstant(3, 5)
v setOnes(3)
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
Definition: Memory.h:876
#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
Definition: PlainObjectBase.h:24
#define EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE)
Definition: StaticAssert.h:45
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:50
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:44
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(const DenseBase< OtherDerived > &other)
Definition: DenseBase.h:392
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Definition: PlainObjectBase.h:121
Eigen::Map< Derived, Unaligned > MapType
Definition: PlainObjectBase.h:142
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:217
Eigen::Map< Derived, AlignedMax > AlignedMapType
Definition: PlainObjectBase.h:144
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(PlainObjectBase &&)=default
Move constructor.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator=(const ReturnByValue< OtherDerived > &func)
Definition: PlainObjectBase.h:467
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:850
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:636
DenseStorage< Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options > m_storage
Definition: PlainObjectBase.h:164
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)
Definition: PlainObjectBase.h:486
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:621
EIGEN_DEVICE_FUNC Derived & setOnes(Index size)
Definition: CwiseNullaryOp.h:708
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived & _set_noalias(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:754
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:662
internal::packet_traits< Scalar >::type PacketScalar
Definition: PlainObjectBase.h:129
@ Options
Definition: PlainObjectBase.h:123
constexpr EIGEN_DEVICE_FUNC void resize(Index rows, NoChange_t)
Definition: PlainObjectBase.h:362
@ NeedsToAlign
Definition: PlainObjectBase.h:167
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:560
EIGEN_DEVICE_FUNC const Base & base() const
Definition: PlainObjectBase.h:189
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols)
Definition: PlainObjectBase.h:421
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:198
NumTraits< Scalar >::Real RealScalar
Definition: PlainObjectBase.h:130
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:667
const Eigen::Map< const Derived, AlignedMax > ConstAlignedMapType
Definition: PlainObjectBase.h:145
constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 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:515
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, std::enable_if_t< Base::SizeAtCompileTime !=2, T0 > *=0)
Definition: PlainObjectBase.h:766
constexpr EIGEN_DEVICE_FUNC const Scalar * data() const
Definition: PlainObjectBase.h:273
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t)
Definition: PlainObjectBase.h:409
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index size)
Definition: PlainObjectBase.h:434
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols)
Definition: PlainObjectBase.h:398
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:461
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:838
constexpr EIGEN_DEVICE_FUNC void resize(NoChange_t, Index cols)
Definition: PlainObjectBase.h:352
static AlignedMapType MapAligned(Scalar *data, Index size)
Definition: PlainObjectBase.h:607
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar & coeffRef(Index index)
Definition: PlainObjectBase.h:228
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition: PlainObjectBase.h:577
static ConstAlignedMapType MapAligned(const Scalar *data, Index size)
Definition: PlainObjectBase.h:604
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:192
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:448
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Scalar &val0, std::enable_if_t< Base::SizeAtCompileTime !=Dynamic &&Base::SizeAtCompileTime !=1 &&internal::is_convertible< T, Scalar >::value &&internal::is_same< typename internal::traits< Derived >::XprKind, ArrayXpr >::value, T > *=0)
Definition: PlainObjectBase.h:867
internal::traits< Derived >::Scalar Scalar
Definition: PlainObjectBase.h:127
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition: PlainObjectBase.h:743
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:553
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Index &val0, std::enable_if_t<(!internal::is_same< Index, Scalar >::value) &&(internal::is_same< Index, T >::value) &&Base::SizeAtCompileTime==1 &&internal::is_convertible< T, Scalar >::value, T * > *=0)
Definition: PlainObjectBase.h:821
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase(const PlainObjectBase &)=default
EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const
Definition: PlainObjectBase.h:247
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > const &other)
const version forwarded to DenseBase::swap
Definition: PlainObjectBase.h:907
static ConstAlignedMapType MapAligned(const Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:608
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Scalar &val0, std::enable_if_t< Base::SizeAtCompileTime==1 &&internal::is_convertible< T, Scalar >::value, T > *=0)
Definition: PlainObjectBase.h:811
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:616
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:657
static AlignedMapType MapAligned(Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:611
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE PlainObjectBase()=default
@ IsPlainObjectBase
Definition: PlainObjectBase.h:911
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived & operator=(const PlainObjectBase &other)
Definition: PlainObjectBase.h:455
static AlignedMapType MapAligned(Scalar *data)
Definition: PlainObjectBase.h:603
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:647
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:631
static ConstMapType Map(const Scalar *data)
Definition: PlainObjectBase.h:595
static MapType Map(Scalar *data, Index size)
Definition: PlainObjectBase.h:598
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const Scalar &a0, const Scalar &a1, const Scalar &a2, const Scalar &a3, const ArgTypes &... args)
Construct a row of column vector with fixed size from an arbitrary number of coefficients.
Definition: PlainObjectBase.h:499
static MapType Map(Scalar *data)
Definition: PlainObjectBase.h:596
constexpr EIGEN_DEVICE_FUNC PlainObjectBase & operator=(PlainObjectBase &&other) EIGEN_NOEXCEPT
Move assignment operator.
Definition: PlainObjectBase.h:479
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition: PlainObjectBase.h:566
static ConstMapType Map(const Scalar *data, Index size)
Definition: PlainObjectBase.h:597
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:652
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:569
Derived DenseType
Definition: PlainObjectBase.h:131
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init2(const T0 &val0, const T1 &val1, std::enable_if_t< Base::SizeAtCompileTime==2, T0 > *=0)
Definition: PlainObjectBase.h:774
constexpr EIGEN_DEVICE_FUNC Scalar * data()
Definition: PlainObjectBase.h:276
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:715
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeff(Index index) const
Definition: PlainObjectBase.h:209
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const RotationBase< OtherDerived, ColsAtCompileTime > &r)
Definition: PlainObjectBase.h:861
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:365
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const ReturnByValue< OtherDerived > &other)
Definition: PlainObjectBase.h:855
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resizeLike(const EigenBase< OtherDerived > &_other)
Definition: PlainObjectBase.h:372
constexpr EIGEN_DEVICE_FUNC void resize(Index size)
Definition: PlainObjectBase.h:327
EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar &val)
Definition: PlainObjectBase.h:268
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Index &val0, std::enable_if_t<(!internal::is_same< Index, Scalar >::value) &&(internal::is_same< Index, T >::value) &&Base::SizeAtCompileTime !=Dynamic &&Base::SizeAtCompileTime !=1 &&internal::is_convertible< T, Scalar >::value &&internal::is_same< typename internal::traits< Derived >::XprKind, ArrayXpr >::value, T * > *=0)
Definition: PlainObjectBase.h:878
static MapType Map(Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:600
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:641
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init2(const Index &val0, const Index &val1, std::enable_if_t<(!internal::is_same< Index, Scalar >::value) &&(internal::is_same< T0, Index >::value) &&(internal::is_same< T1, Index >::value) &&Base::SizeAtCompileTime==2, T1 > *=0)
Definition: PlainObjectBase.h:782
EIGEN_STRONG_INLINE void writePacket(Index rowId, Index colId, const PacketScalar &val)
Definition: PlainObjectBase.h:260
EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime==1 &&MaxColsAtCompileTime !=1,(int(Options) &RowMajor)==RowMajor), INVALID_MATRIX_TEMPLATE_PARAMETERS) EIGEN_STATIC_ASSERT(internal
Definition: PlainObjectBase.h:170
static ConstMapType Map(const Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:599
static ConstAlignedMapType MapAligned(const Scalar *data)
Definition: PlainObjectBase.h:602
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:626
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Derived &other)
Definition: PlainObjectBase.h:844
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(const Scalar *data)
Definition: PlainObjectBase.h:832
Derived & setRandom(Index size)
Definition: Random.h:147
internal::traits< Derived >::StorageKind StorageKind
Definition: PlainObjectBase.h:126
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:672
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:294
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeffRef(Index rowId, Index colId) const
Definition: PlainObjectBase.h:232
internal::dense_xpr_base< Derived >::type Base
Definition: PlainObjectBase.h:124
const Eigen::Map< const Derived, Unaligned > ConstMapType
Definition: PlainObjectBase.h:143
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > &other)
Override DenseBase::swap() since for dynamic-sized matrices of same type it is enough to swap the dat...
Definition: PlainObjectBase.h:898
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void _init1(Index size, std::enable_if_t<(Base::SizeAtCompileTime !=1||!internal::is_convertible< T, Scalar >::value) &&((!internal::is_same< typename internal::traits< Derived >::XprKind, ArrayXpr >::value||Base::SizeAtCompileTime==Dynamic)), T > *=0)
Definition: PlainObjectBase.h:795
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeffRef(Index index) const
Definition: PlainObjectBase.h:241
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:191
EIGEN_STRONG_INLINE PacketScalar packet(Index index) const
Definition: PlainObjectBase.h:254
Definition: ReturnByValue.h:50
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: ReturnByValue.h:61
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: ReturnByValue.h:64
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition: ReturnByValue.h:58
Common base class for compact rotation representations.
Definition: RotationBase.h:32
Holds strides information for Map.
Definition: Stride.h:55
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void swap(DenseStorage_impl &other)
Definition: DenseStorage.h:113
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index cols() const
Definition: DenseStorage.h:120
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index size() const
Definition: DenseStorage.h:121
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE void resize(Index, Index, Index)
Definition: DenseStorage.h:118
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index rows() const
Definition: DenseStorage.h:119
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE T * data()
Definition: DenseStorage.h:122
@ Unaligned
Definition: Constants.h:235
@ AlignedMax
Definition: Constants.h:254
@ DontAlign
Definition: Constants.h:324
@ RowMajor
Definition: Constants.h:320
const unsigned int RowMajorBit
Definition: Constants.h:70
EIGEN_BLAS_FUNC() swap(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:117
const Scalar * a
Definition: level2_cplx_impl.h:32
res setZero()
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
constexpr bool check_implication(bool a, bool b)
Definition: Meta.h:740
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment(Dst &dst, const Src &src)
Definition: AssignEvaluator.h:781
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:812
EIGEN_DEVICE_FUNC void throw_std_bad_alloc()
Definition: Memory.h:110
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
Definition: MathFunctions.h:920
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
auto run(Kernel kernel, Args &&... args) -> decltype(kernel(args...))
Definition: gpu_test_helper.h:414
squared absolute value
Definition: GlobalFunctions.h:87
NoChange_t
Definition: Constants.h:359
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
r
Definition: UniformPSDSelfTest.py:20
val
Definition: calibrate.py:119
int error
Definition: calibrate.py:297
args
Definition: compute_granudrum_aor.py:143
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28
#define AND(a, b)
Definition: oomph_metis_from_parmetis_3.1.1/macros.h:24
Definition: Constants.h:537
Definition: EigenBase.h:33
constexpr EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:49
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:61
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:64
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:59
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: PlainObjectBase.h:155
Eigen::Map< Derived, AlignedMax, StrideType > type
Definition: PlainObjectBase.h:156
Eigen::Map< const Derived, AlignedMax, StrideType > type
Definition: PlainObjectBase.h:160
Definition: PlainObjectBase.h:151
Eigen::Map< const Derived, Unaligned, StrideType > type
Definition: PlainObjectBase.h:152
Definition: PlainObjectBase.h:147
Eigen::Map< Derived, Unaligned, StrideType > type
Definition: PlainObjectBase.h:148
Template functor for scalar/packet assignment.
Definition: AssignmentFunctors.h:25
static EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE void run(Index rows, Index cols)
Definition: PlainObjectBase.h:66
static EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE void run(Index rows, Index)
Definition: PlainObjectBase.h:56
static EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE void run(Index, Index cols)
Definition: PlainObjectBase.h:46
Definition: PlainObjectBase.h:36
EIGEN_STATIC_ASSERT(MaxRowsAtCompileTime *MaxColsAtCompileTime==MaxSizeAtCompileTime, YOU MADE A PROGRAMMING MISTAKE) template< typename Index > EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE const expr void run(Index
conservative_resize_like_impl< Derived, OtherDerived, false > Base
Definition: PlainObjectBase.h:995
static void run(DenseBase< Derived > &_this, Index size)
Definition: PlainObjectBase.h:999
static void run(DenseBase< Derived > &_this, const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:1008
Definition: PlainObjectBase.h:931
static constexpr bool IsRelocatable
Definition: PlainObjectBase.h:932
static void run(DenseBase< Derived > &_this, Index rows, Index cols)
Definition: PlainObjectBase.h:933
static void run(DenseBase< Derived > &_this, const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:956
Definition: XprHelper.h:558
Definition: Meta.h:205
Definition: XprHelper.h:69
static EIGEN_DEVICE_FUNC void run(MatrixTypeA &a, MatrixTypeB &b)
Definition: PlainObjectBase.h:1031
Definition: PlainObjectBase.h:1025
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(MatrixTypeA &a, MatrixTypeB &b)
Definition: PlainObjectBase.h:1026
Definition: ForwardDeclarations.h:21
Definition: benchGeometry.cpp:21
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317