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 for(Index i=0;i<base().size();++i) coeffRef(i)=Scalar(0);
17 #elif defined(EIGEN_INITIALIZE_MATRICES_BY_NAN)
18 # define EIGEN_INITIALIZE_COEFFS
19 # define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED for(Index i=0;i<base().size();++i) coeffRef(i)=std::numeric_limits<Scalar>::quiet_NaN();
20 #else
21 # undef EIGEN_INITIALIZE_COEFFS
22 # define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
23 #endif
24 
25 #include "./InternalHeaderCheck.h"
26 
27 namespace Eigen {
28 
29 namespace internal {
30 
31 template <int MaxSizeAtCompileTime, int MaxRowsAtCompileTime, int MaxColsAtCompileTime>
32 struct check_rows_cols_for_overflow {
33  EIGEN_STATIC_ASSERT(MaxRowsAtCompileTime * MaxColsAtCompileTime == MaxSizeAtCompileTime,YOU MADE A PROGRAMMING MISTAKE)
34  template <typename Index>
35  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index) {}
36 };
37 
38 template <int MaxRowsAtCompileTime>
39 struct check_rows_cols_for_overflow<Dynamic, MaxRowsAtCompileTime, Dynamic> {
40  template <typename Index>
41  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index, Index cols) {
42  constexpr Index MaxIndex = NumTraits<Index>::highest();
43  bool error = cols > MaxIndex / MaxRowsAtCompileTime;
44  if (error) throw_std_bad_alloc();
45  }
46 };
47 
48 template <int MaxColsAtCompileTime>
49 struct check_rows_cols_for_overflow<Dynamic, Dynamic, MaxColsAtCompileTime> {
50  template <typename Index>
51  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index) {
52  constexpr Index MaxIndex = NumTraits<Index>::highest();
53  bool error = rows > MaxIndex / MaxColsAtCompileTime;
54  if (error) throw_std_bad_alloc();
55  }
56 };
57 
58 template <>
59 struct check_rows_cols_for_overflow<Dynamic, Dynamic, Dynamic> {
60  template <typename Index>
61  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE constexpr void run(Index rows, Index cols) {
62  constexpr Index MaxIndex = NumTraits<Index>::highest();
63  bool error = cols == 0 ? false : (rows > MaxIndex / cols);
64  if (error) throw_std_bad_alloc();
65  }
66 };
67 
68 template <typename Derived,
69  typename OtherDerived = Derived,
70  bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
71 struct conservative_resize_like_impl;
72 
73 template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct matrix_swap_impl;
74 
75 } // end namespace internal
76 
77 #ifdef EIGEN_PARSED_BY_DOXYGEN
78 namespace doxygen {
79 
80 // This is a workaround to doxygen not being able to understand the inheritance logic
81 // when it is hidden by the dense_xpr_base helper struct.
82 // Moreover, doxygen fails to include members that are not documented in the declaration body of
83 // MatrixBase if we inherits MatrixBase<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >,
84 // this is why we simply inherits MatrixBase, though this does not make sense.
85 
87 template<typename Derived> struct dense_xpr_base_dispatcher;
89 template<typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
90 struct dense_xpr_base_dispatcher<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >
91  : public MatrixBase {};
93 template<typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
94 struct dense_xpr_base_dispatcher<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >
95  : public ArrayBase {};
96 
97 } // namespace doxygen
98 
110 template<typename Derived>
112 #else
113 template<typename Derived>
114 class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
115 #endif
116 {
117  public:
118  enum { Options = internal::traits<Derived>::Options };
119  typedef typename internal::dense_xpr_base<Derived>::type Base;
120 
121  typedef typename internal::traits<Derived>::StorageKind StorageKind;
122  typedef typename internal::traits<Derived>::Scalar Scalar;
123 
124  typedef typename internal::packet_traits<Scalar>::type PacketScalar;
126  typedef Derived DenseType;
127 
128  using Base::RowsAtCompileTime;
129  using Base::ColsAtCompileTime;
130  using Base::SizeAtCompileTime;
131  using Base::MaxRowsAtCompileTime;
132  using Base::MaxColsAtCompileTime;
133  using Base::MaxSizeAtCompileTime;
134  using Base::IsVectorAtCompileTime;
135  using Base::Flags;
136 
141  template<typename StrideType> struct StridedMapType { typedef Eigen::Map<Derived, Unaligned, StrideType> type; };
142  template<typename StrideType> struct StridedConstMapType { typedef Eigen::Map<const Derived, Unaligned, StrideType> type; };
143  template<typename StrideType> struct StridedAlignedMapType { typedef Eigen::Map<Derived, AlignedMax, StrideType> type; };
144  template<typename StrideType> struct StridedConstAlignedMapType { typedef Eigen::Map<const Derived, AlignedMax, StrideType> type; };
145 
146  protected:
148 
149  public:
150  enum { NeedsToAlign = (SizeAtCompileTime != Dynamic) && (internal::traits<Derived>::Alignment>0) };
152 
153  EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (int(Options)&RowMajor)==RowMajor), INVALID_MATRIX_TEMPLATE_PARAMETERS)
154  EIGEN_STATIC_ASSERT(internal::check_implication(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, (int(Options)&RowMajor)==0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
155  EIGEN_STATIC_ASSERT((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
156  EIGEN_STATIC_ASSERT((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
157  EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
158  EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
159  EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic), INVALID_MATRIX_TEMPLATE_PARAMETERS)
160  EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic), INVALID_MATRIX_TEMPLATE_PARAMETERS)
161  EIGEN_STATIC_ASSERT(((Options & (DontAlign|RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS)
162 
164  Base& base() { return *static_cast<Base*>(this); }
166  const Base& base() const { return *static_cast<const Base*>(this); }
167 
168  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
169  Index rows() const EIGEN_NOEXCEPT { return m_storage.rows(); }
170  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
171  Index cols() const EIGEN_NOEXCEPT { return m_storage.cols(); }
172 
177  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeff(Index rowId, Index colId) const {
178  if (Flags & RowMajorBit)
179  return m_storage.data()[colId + rowId * m_storage.cols()];
180  else // column-major
181  return m_storage.data()[rowId + colId * m_storage.rows()];
182  }
183 
189  EIGEN_STRONG_INLINE const Scalar& coeff(Index index) const
190  {
191  return m_storage.data()[index];
192  }
193 
198  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Scalar& coeffRef(Index rowId, Index colId) {
199  if (Flags & RowMajorBit)
200  return m_storage.data()[colId + rowId * m_storage.cols()];
201  else // column-major
202  return m_storage.data()[rowId + colId * m_storage.rows()];
203  }
204 
209  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Scalar& coeffRef(Index index) { return m_storage.data()[index]; }
210 
213  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeffRef(Index rowId, Index colId) const {
214  if (Flags & RowMajorBit)
215  return m_storage.data()[colId + rowId * m_storage.cols()];
216  else // column-major
217  return m_storage.data()[rowId + colId * m_storage.rows()];
218  }
219 
222  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr const Scalar& coeffRef(Index index) const {
223  return m_storage.data()[index];
224  }
225 
227  template<int LoadMode>
228  EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const
229  {
230  return internal::ploadt<PacketScalar, LoadMode>
231  (m_storage.data() + (Flags & RowMajorBit
232  ? colId + rowId * m_storage.cols()
233  : rowId + colId * m_storage.rows()));
234  }
235 
237  template<int LoadMode>
238  EIGEN_STRONG_INLINE PacketScalar packet(Index index) const
239  {
240  return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
241  }
242 
244  template<int StoreMode>
245  EIGEN_STRONG_INLINE void writePacket(Index rowId, Index colId, const PacketScalar& val)
246  {
247  internal::pstoret<Scalar, PacketScalar, StoreMode>
248  (m_storage.data() + (Flags & RowMajorBit
249  ? colId + rowId * m_storage.cols()
250  : rowId + colId * m_storage.rows()), val);
251  }
252 
254  template<int StoreMode>
255  EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar& val)
256  {
257  internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
258  }
259 
261  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar *data() const
262  { return m_storage.data(); }
263 
265  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar *data()
266  { return m_storage.data(); }
267 
284  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void resize(Index rows, Index cols) {
285  eigen_assert(internal::check_implication(RowsAtCompileTime!=Dynamic, rows==RowsAtCompileTime)
286  && internal::check_implication(ColsAtCompileTime!=Dynamic, cols==ColsAtCompileTime)
287  && internal::check_implication(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic, rows<=MaxRowsAtCompileTime)
288  && internal::check_implication(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic, cols<=MaxColsAtCompileTime)
289  && rows>=0 && cols>=0 && "Invalid sizes when resizing a matrix or array.");
290  internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(rows, cols);
291  #ifdef EIGEN_INITIALIZE_COEFFS
292  Index size = rows*cols;
293  bool size_changed = size != this->size();
294  m_storage.resize(size, rows, cols);
296  #else
297  m_storage.resize(rows*cols, rows, cols);
298  #endif
299  }
300 
312  EIGEN_DEVICE_FUNC inline constexpr void resize(Index size) {
314  eigen_assert(
315  ((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime == Dynamic || size <= MaxSizeAtCompileTime)) ||
316  SizeAtCompileTime == size) &&
317  size >= 0);
318 #ifdef EIGEN_INITIALIZE_COEFFS
319  bool size_changed = size != this->size();
320  #endif
321  if(RowsAtCompileTime == 1)
322  m_storage.resize(size, 1, size);
323  else
324  m_storage.resize(size, size, 1);
325  #ifdef EIGEN_INITIALIZE_COEFFS
327  #endif
328  }
329 
338  EIGEN_DEVICE_FUNC inline constexpr void resize(NoChange_t, Index cols) { resize(rows(), cols); }
339 
348  EIGEN_DEVICE_FUNC inline constexpr void resize(Index rows, NoChange_t) { resize(rows, cols()); }
349 
357  template<typename OtherDerived>
359  EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other)
360  {
361  const OtherDerived& other = _other.derived();
362  internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime>::run(other.rows(), other.cols());
363  const Index othersize = other.rows()*other.cols();
364  if(RowsAtCompileTime == 1)
365  {
366  eigen_assert(other.rows() == 1 || other.cols() == 1);
367  resize(1, othersize);
368  }
369  else if(ColsAtCompileTime == 1)
370  {
371  eigen_assert(other.rows() == 1 || other.cols() == 1);
372  resize(othersize, 1);
373  }
374  else resize(other.rows(), other.cols());
375  }
376 
387  EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols)
388  {
389  internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols);
390  }
391 
400  EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t)
401  {
402  // Note: see the comment in conservativeResize(Index,Index)
404  }
405 
414  EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols)
415  {
416  // Note: see the comment in conservativeResize(Index,Index)
418  }
419 
429  EIGEN_STRONG_INLINE void conservativeResize(Index size)
430  {
431  internal::conservative_resize_like_impl<Derived>::run(*this, size);
432  }
433 
443  template<typename OtherDerived>
445  EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other)
446  {
447  internal::conservative_resize_like_impl<Derived,OtherDerived>::run(*this, other);
448  }
449 
454  EIGEN_STRONG_INLINE Derived& operator=(const PlainObjectBase& other)
455  {
456  return _set(other);
457  }
458 
460  template<typename OtherDerived>
462  EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other)
463  {
464  _resize_to_match(other);
465  return Base::lazyAssign(other.derived());
466  }
467 
468  template<typename OtherDerived>
470  EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue<OtherDerived>& func)
471  {
472  resize(func.rows(), func.cols());
473  return Base::operator=(func);
474  }
475 
476  // Prevent user from trying to instantiate PlainObjectBase objects
477  // by making all its constructor protected. See bug 1074.
478  protected:
479 
481  EIGEN_STRONG_INLINE PlainObjectBase() : m_storage()
482  {
483 // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
484  }
485 
486 #ifndef EIGEN_PARSED_BY_DOXYGEN
487  // FIXME is it still needed ?
490  explicit PlainObjectBase(internal::constructor_without_unaligned_array_assert)
491  : m_storage(internal::constructor_without_unaligned_array_assert())
492  {
493  // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
494  }
495 #endif
496 
499  : m_storage( std::move(other.m_storage) )
500  {
501  }
502 
505  {
506  m_storage = std::move(other.m_storage);
507  return *this;
508  }
509 
512  EIGEN_STRONG_INLINE PlainObjectBase(const PlainObjectBase& other)
513  : Base(), m_storage(other.m_storage) { }
515  EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)
516  : m_storage(size, rows, cols)
517  {
518 // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
519  }
520 
530  template <typename... ArgTypes>
531  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
532  PlainObjectBase(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
533  : m_storage()
534  {
536  m_storage.data()[0] = a0;
537  m_storage.data()[1] = a1;
538  m_storage.data()[2] = a2;
539  m_storage.data()[3] = a3;
540  Index i = 4;
541  auto x = {(m_storage.data()[i++] = args, 0)...};
542  static_cast<void>(x);
543  }
544 
548  EIGEN_DEVICE_FUNC explicit constexpr EIGEN_STRONG_INLINE PlainObjectBase(
549  const std::initializer_list<std::initializer_list<Scalar>>& list)
550  : m_storage() {
551  size_t list_size = 0;
552  if (list.begin() != list.end()) {
553  list_size = list.begin()->size();
554  }
555 
556  // This is to allow syntax like VectorXi {{1, 2, 3, 4}}
557  if (ColsAtCompileTime == 1 && list.size() == 1) {
558  eigen_assert(list_size == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
559  resize(list_size, ColsAtCompileTime);
560  if (list.begin()->begin() != nullptr) {
561  std::copy(list.begin()->begin(), list.begin()->end(), m_storage.data());
562  }
563  } else {
564  eigen_assert(list.size() == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
565  eigen_assert(list_size == static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime == Dynamic);
566  resize(list.size(), list_size);
567 
568  Index row_index = 0;
569  for (const std::initializer_list<Scalar>& row : list) {
570  eigen_assert(list_size == row.size());
571  Index col_index = 0;
572  for (const Scalar& e : row) {
573  coeffRef(row_index, col_index) = e;
574  ++col_index;
575  }
576  ++row_index;
577  }
578  }
579  }
580 
582  template<typename OtherDerived>
584  EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived> &other)
585  : m_storage()
586  {
587  resizeLike(other);
588  _set_noalias(other);
589  }
590 
592  template<typename OtherDerived>
594  EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived> &other)
595  : m_storage()
596  {
597  resizeLike(other);
598  *this = other.derived();
599  }
601  template<typename OtherDerived>
603  EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue<OtherDerived>& other)
604  {
605  // FIXME this does not automatically transpose vectors if necessary
606  resize(other.rows(), other.cols());
607  other.evalTo(this->derived());
608  }
609 
610  public:
611 
615  template<typename OtherDerived>
617  EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived> &other)
618  {
619  _resize_to_match(other);
620  Base::operator=(other.derived());
621  return this->derived();
622  }
623 
636  static inline ConstMapType Map(const Scalar* data)
637  { return ConstMapType(data); }
638  static inline MapType Map(Scalar* data)
639  { return MapType(data); }
640  static inline ConstMapType Map(const Scalar* data, Index size)
641  { return ConstMapType(data, size); }
642  static inline MapType Map(Scalar* data, Index size)
643  { return MapType(data, size); }
644  static inline ConstMapType Map(const Scalar* data, Index rows, Index cols)
645  { return ConstMapType(data, rows, cols); }
646  static inline MapType Map(Scalar* data, Index rows, Index cols)
647  { return MapType(data, rows, cols); }
648 
650  { return ConstAlignedMapType(data); }
652  { return AlignedMapType(data); }
654  { return ConstAlignedMapType(data, size); }
656  { return AlignedMapType(data, size); }
658  { return ConstAlignedMapType(data, rows, cols); }
660  { return AlignedMapType(data, rows, cols); }
661 
662  template<int Outer, int Inner>
663  static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, const Stride<Outer, Inner>& stride)
664  { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, stride); }
665  template<int Outer, int Inner>
666  static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, const Stride<Outer, Inner>& stride)
667  { return typename StridedMapType<Stride<Outer, Inner> >::type(data, stride); }
668  template<int Outer, int Inner>
669  static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, Index size, const Stride<Outer, Inner>& stride)
670  { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, size, stride); }
671  template<int Outer, int Inner>
672  static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, Index size, const Stride<Outer, Inner>& stride)
673  { return typename StridedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
674  template<int Outer, int Inner>
675  static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)
676  { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
677  template<int Outer, int Inner>
678  static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)
679  { return typename StridedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
680 
681  template<int Outer, int Inner>
682  static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(const Scalar* data, const Stride<Outer, Inner>& stride)
683  { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }
684  template<int Outer, int Inner>
686  { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }
687  template<int Outer, int Inner>
689  { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
690  template<int Outer, int Inner>
692  { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
693  template<int Outer, int Inner>
695  { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
696  template<int Outer, int Inner>
698  { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
700 
701  using Base::setConstant;
702  EIGEN_DEVICE_FUNC Derived& setConstant(Index size, const Scalar& val);
703  EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, Index cols, const Scalar& val);
704  EIGEN_DEVICE_FUNC Derived& setConstant(NoChange_t, Index cols, const Scalar& val);
705  EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, NoChange_t, const Scalar& val);
706 
707  using Base::setZero;
712 
713  using Base::setOnes;
718 
719  using Base::setRandom;
720  Derived& setRandom(Index size);
721  Derived& setRandom(Index rows, Index cols);
722  Derived& setRandom(NoChange_t, Index cols);
723  Derived& setRandom(Index rows, NoChange_t);
724 
725  #ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
726  #include EIGEN_PLAINOBJECTBASE_PLUGIN
727  #endif
728 
729  protected:
737  template<typename OtherDerived>
739  EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase<OtherDerived>& other)
740  {
741  #ifdef EIGEN_NO_AUTOMATIC_RESIZING
742  eigen_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size())
743  : (rows() == other.rows() && cols() == other.cols())))
744  && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
746  #else
747  resizeLike(other);
748  #endif
749  }
750 
765  // aliasing is dealt once in internal::call_assignment
766  // so at this stage we have to assume aliasing... and resising has to be done later.
767  template<typename OtherDerived>
769  EIGEN_STRONG_INLINE Derived& _set(const DenseBase<OtherDerived>& other)
770  {
771  internal::call_assignment(this->derived(), other.derived());
772  return this->derived();
773  }
774 
780  template<typename OtherDerived>
782  EIGEN_STRONG_INLINE Derived& _set_noalias(const DenseBase<OtherDerived>& other)
783  {
784  // I don't think we need this resize call since the lazyAssign will anyways resize
785  // and lazyAssign will be called by the assign selector.
786  //_resize_to_match(other);
787  // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
788  // it wouldn't allow to copy a row-vector into a column-vector.
789  internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
790  return this->derived();
791  }
792 
793  template<typename T0, typename T1>
795  EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, std::enable_if_t<Base::SizeAtCompileTime!=2,T0>* = 0)
796  {
797  EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T0>::value &&
798  internal::is_valid_index_type<T1>::value,
799  T0 AND T1 MUST BE INTEGER TYPES)
800  resize(rows,cols);
801  }
802 
803  template<typename T0, typename T1>
805  EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1, std::enable_if_t<Base::SizeAtCompileTime==2,T0>* = 0)
806  {
808  m_storage.data()[0] = Scalar(val0);
809  m_storage.data()[1] = Scalar(val1);
810  }
811 
812  template<typename T0, typename T1>
814  EIGEN_STRONG_INLINE void _init2(const Index& val0, const Index& val1,
815  std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
816  && (internal::is_same<T0,Index>::value)
817  && (internal::is_same<T1,Index>::value)
818  && Base::SizeAtCompileTime==2,T1>* = 0)
819  {
821  m_storage.data()[0] = Scalar(val0);
822  m_storage.data()[1] = Scalar(val1);
823  }
824 
825  // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,
826  // then the argument is meant to be the size of the object.
827  template<typename T>
829  EIGEN_STRONG_INLINE void _init1(Index size, std::enable_if_t< (Base::SizeAtCompileTime!=1 || !internal::is_convertible<T, Scalar>::value)
830  && ((!internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value || Base::SizeAtCompileTime==Dynamic)),T>* = 0)
831  {
832  // NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.
833  const bool is_integer_alike = internal::is_valid_index_type<T>::value;
834  EIGEN_UNUSED_VARIABLE(is_integer_alike);
835  EIGEN_STATIC_ASSERT(is_integer_alike,
836  FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
837  resize(size);
838  }
839 
840  // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar type can be implicitly converted)
841  template<typename T>
843  EIGEN_STRONG_INLINE void _init1(const Scalar& val0, std::enable_if_t<Base::SizeAtCompileTime==1 && internal::is_convertible<T, Scalar>::value,T>* = 0)
844  {
846  m_storage.data()[0] = val0;
847  }
848 
849  // We have a 1x1 matrix/array => the argument is interpreted as the value of the unique coefficient (case where scalar type match the index type)
850  template<typename T>
852  EIGEN_STRONG_INLINE void _init1(const Index& val0,
853  std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
854  && (internal::is_same<Index,T>::value)
855  && Base::SizeAtCompileTime==1
856  && internal::is_convertible<T, Scalar>::value,T*>* = 0)
857  {
859  m_storage.data()[0] = Scalar(val0);
860  }
861 
862  // Initialize a fixed size matrix from a pointer to raw data
863  template<typename T>
865  EIGEN_STRONG_INLINE void _init1(const Scalar* data){
866  this->_set_noalias(ConstMapType(data));
867  }
868 
869  // Initialize an arbitrary matrix from a dense expression
870  template<typename T, typename OtherDerived>
872  EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other){
873  this->_set_noalias(other);
874  }
875 
876  // Initialize an arbitrary matrix from an object convertible to the Derived type.
877  template<typename T>
879  EIGEN_STRONG_INLINE void _init1(const Derived& other){
880  this->_set_noalias(other);
881  }
882 
883  // Initialize an arbitrary matrix from a generic Eigen expression
884  template<typename T, typename OtherDerived>
886  EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other){
887  this->derived() = other;
888  }
889 
890  template<typename T, typename OtherDerived>
892  EIGEN_STRONG_INLINE void _init1(const ReturnByValue<OtherDerived>& other)
893  {
894  resize(other.rows(), other.cols());
895  other.evalTo(this->derived());
896  }
897 
898  template<typename T, typename OtherDerived, int ColsAtCompileTime>
900  EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
901  {
902  this->derived() = r;
903  }
904 
905  // For fixed-size Array<Scalar,...>
906  template<typename T>
908  EIGEN_STRONG_INLINE void _init1(const Scalar& val0,
909  std::enable_if_t< Base::SizeAtCompileTime!=Dynamic
910  && Base::SizeAtCompileTime!=1
911  && internal::is_convertible<T, Scalar>::value
912  && internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T>* = 0)
913  {
914  Base::setConstant(val0);
915  }
916 
917  // For fixed-size Array<Index,...>
918  template<typename T>
920  EIGEN_STRONG_INLINE void _init1(const Index& val0,
921  std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
922  && (internal::is_same<Index,T>::value)
923  && Base::SizeAtCompileTime!=Dynamic
924  && Base::SizeAtCompileTime!=1
925  && internal::is_convertible<T, Scalar>::value
926  && internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T*>* = 0)
927  {
928  Base::setConstant(val0);
929  }
930 
931  template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
932  friend struct internal::matrix_swap_impl;
933 
934  public:
935 
936 #ifndef EIGEN_PARSED_BY_DOXYGEN
941  template<typename OtherDerived>
942  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
943  void swap(DenseBase<OtherDerived> & other)
944  {
945  enum { SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime==Dynamic };
946  internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());
947  }
948 
952  template<typename OtherDerived>
953  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
954  void swap(DenseBase<OtherDerived> const & other)
955  { Base::swap(other.derived()); }
956 
957  enum { IsPlainObjectBase = 1 };
958 #endif
959  public:
960  // These apparently need to be down here for nvcc+icc to prevent duplicate
961  // Map symbol.
962  template<typename PlainObjectType, int MapOptions, typename StrideType> friend class Eigen::Map;
963  friend class Eigen::Map<Derived, Unaligned>;
964  friend class Eigen::Map<const Derived, Unaligned>;
965 #if EIGEN_MAX_ALIGN_BYTES>0
966  // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class twice.
967  friend class Eigen::Map<Derived, AlignedMax>;
968  friend class Eigen::Map<const Derived, AlignedMax>;
969 #endif
970 };
971 
972 namespace internal {
973 
974 template <typename Derived, typename OtherDerived, bool IsVector>
975 struct conservative_resize_like_impl
976 {
977  static constexpr bool IsRelocatable = std::is_trivially_copyable<typename Derived::Scalar>::value;
978  static void run(DenseBase<Derived>& _this, Index rows, Index cols)
979  {
980  if (_this.rows() == rows && _this.cols() == cols) return;
982 
983  if ( IsRelocatable
984  && (( Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows
985  (!Derived::IsRowMajor && _this.rows() == rows) )) // column-major and we change only the number of columns
986  {
987  internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime, Derived::MaxRowsAtCompileTime, Derived::MaxColsAtCompileTime>::run(rows, cols);
988  _this.derived().m_storage.conservativeResize(rows*cols,rows,cols);
989  }
990  else
991  {
992  // The storage order does not allow us to use reallocation.
993  Derived tmp(rows,cols);
994  const Index common_rows = numext::mini(rows, _this.rows());
995  const Index common_cols = numext::mini(cols, _this.cols());
996  tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
997  _this.derived().swap(tmp);
998  }
999  }
1000 
1001  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)
1002  {
1003  if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1004 
1005  // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),
1006  // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
1007  // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or
1008  // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like
1009  // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
1011  EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
1012 
1013  if ( IsRelocatable &&
1014  (( Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows
1015  (!Derived::IsRowMajor && _this.rows() == other.rows()) )) // column-major and we change only the number of columns
1016  {
1017  const Index new_rows = other.rows() - _this.rows();
1018  const Index new_cols = other.cols() - _this.cols();
1019  _this.derived().m_storage.conservativeResize(other.size(),other.rows(),other.cols());
1020  if (new_rows>0)
1021  _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
1022  else if (new_cols>0)
1023  _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
1024  }
1025  else
1026  {
1027  // The storage order does not allow us to use reallocation.
1028  Derived tmp(other);
1029  const Index common_rows = numext::mini(tmp.rows(), _this.rows());
1030  const Index common_cols = numext::mini(tmp.cols(), _this.cols());
1031  tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
1032  _this.derived().swap(tmp);
1033  }
1034  }
1035 };
1036 
1037 // Here, the specialization for vectors inherits from the general matrix case
1038 // to allow calling .conservativeResize(rows,cols) on vectors.
1039 template <typename Derived, typename OtherDerived>
1040 struct conservative_resize_like_impl<Derived,OtherDerived,true>
1041  : conservative_resize_like_impl<Derived,OtherDerived,false>
1042 {
1043  typedef conservative_resize_like_impl<Derived,OtherDerived,false> Base;
1044  using Base::run;
1045  using Base::IsRelocatable;
1046 
1047  static void run(DenseBase<Derived>& _this, Index size)
1048  {
1049  const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size;
1050  const Index new_cols = Derived::RowsAtCompileTime==1 ? size : 1;
1051  if(IsRelocatable)
1052  _this.derived().m_storage.conservativeResize(size,new_rows,new_cols);
1053  else
1054  Base::run(_this.derived(), new_rows, new_cols);
1055  }
1056 
1057  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)
1058  {
1059  if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1060 
1061  const Index num_new_elements = other.size() - _this.size();
1062 
1063  const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows();
1064  const Index new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1;
1065  if(IsRelocatable)
1066  _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols);
1067  else
1068  Base::run(_this.derived(), new_rows, new_cols);
1069 
1070  if (num_new_elements > 0)
1071  _this.tail(num_new_elements) = other.tail(num_new_elements);
1072  }
1073 };
1074 
1075 template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
1076 struct matrix_swap_impl
1077 {
1079  static EIGEN_STRONG_INLINE void run(MatrixTypeA& a, MatrixTypeB& b)
1080  {
1081  a.base().swap(b);
1082  }
1083 };
1084 
1085 template<typename MatrixTypeA, typename MatrixTypeB>
1086 struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true>
1087 {
1089  static inline void run(MatrixTypeA& a, MatrixTypeB& b)
1090  {
1091  static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);
1092  }
1093 };
1094 
1095 } // end namespace internal
1096 
1097 } // end namespace Eigen
1098 
1099 #endif // EIGEN_DENSESTORAGEBASE_H
Array< int, 3, 1 > b
RowXpr row(Index i)
This is the const version of row(). *‍/.
MatrixXcf A
Array< double, 1, 3 > e(1./3., 0.5, 2.)
A setRandom()
#define EIGEN_ALWAYS_INLINE
Definition: Macros.h:836
#define EIGEN_NOEXCEPT
Definition: Macros.h:1260
#define EIGEN_CONSTEXPR
Definition: Macros.h:747
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:957
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:914
#define eigen_assert(x)
Definition: Macros.h:902
v setConstant(3, 5)
v setOnes(3)
v setZero(3)
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
Definition: Memory.h:917
#define EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE)
Definition: StaticAssert.h:46
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:51
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:43
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:49
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:98
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Dense storage base class for matrices and arrays.
PlainObjectBase & operator=(PlainObjectBase &&other) EIGEN_NOEXCEPT
Eigen::Map< Derived, Unaligned > MapType
Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Eigen::Map< Derived, AlignedMax > AlignedMapType
constexpr Scalar & coeffRef(Index index)
Derived & operator=(const ReturnByValue< OtherDerived > &func)
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
DenseStorage< Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options > m_storage
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, const Stride< Outer, Inner > &stride)
PlainObjectBase(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
constexpr const Scalar & coeffRef(Index rowId, Index colId) const
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
internal::packet_traits< Scalar >::type PacketScalar
void _init2(Index rows, Index cols, std::enable_if_t< Base::SizeAtCompileTime!=2, T0 > *=0)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
void _resize_to_match(const EigenBase< OtherDerived > &other)
constexpr void resize(NoChange_t, Index cols)
constexpr void resize(Index size)
NumTraits< Scalar >::Real RealScalar
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
const Eigen::Map< const Derived, AlignedMax > ConstAlignedMapType
void _init1(const EigenBase< OtherDerived > &other)
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)
void _init2(const T0 &val0, const T1 &val1, std::enable_if_t< Base::SizeAtCompileTime==2, T0 > *=0)
constexpr const Scalar & coeff(Index rowId, Index colId) const
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
void _init1(const RotationBase< OtherDerived, ColsAtCompileTime > &r)
PlainObjectBase(const PlainObjectBase &other)
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.
void writePacket(Index index, const PacketScalar &val)
Derived & setRandom(Index size)
Definition: Random.h:152
static AlignedMapType MapAligned(Scalar *data, Index size)
void _init1(const DenseBase< OtherDerived > &other)
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
void conservativeResize(Index rows, Index cols)
static ConstAlignedMapType MapAligned(const Scalar *data, Index size)
PlainObjectBase(const DenseBase< OtherDerived > &other)
PlainObjectBase(PlainObjectBase &&other) EIGEN_NOEXCEPT
void conservativeResize(Index size)
PacketScalar packet(Index index) const
internal::traits< Derived >::Scalar Scalar
Derived & setOnes(Index size)
constexpr const Scalar & coeffRef(Index index) const
static ConstAlignedMapType MapAligned(const Scalar *data, Index rows, Index cols)
void conservativeResize(Index rows, NoChange_t)
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, const Stride< Outer, Inner > &stride)
PlainObjectBase(const EigenBase< OtherDerived > &other)
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
PlainObjectBase(Index size, Index rows, Index cols)
static AlignedMapType MapAligned(Scalar *data, Index rows, Index cols)
constexpr void resize(Index rows, NoChange_t)
PacketScalar packet(Index rowId, Index colId) const
static AlignedMapType MapAligned(Scalar *data)
void _init1(const Scalar *data)
const Base & base() const
void resizeLike(const EigenBase< OtherDerived > &_other)
Derived & setConstant(Index size, const Scalar &val)
void _init1(const ReturnByValue< OtherDerived > &other)
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, const Stride< Outer, Inner > &stride)
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
static ConstMapType Map(const Scalar *data)
static MapType Map(Scalar *data, Index size)
void _init1(const Derived &other)
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)
static MapType Map(Scalar *data)
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)
void writePacket(Index rowId, Index colId, const PacketScalar &val)
static ConstMapType Map(const Scalar *data, Index size)
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, const Stride< Outer, Inner > &stride)
const Scalar * data() const
const Scalar & coeff(Index index) const
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Derived & setZero(Index size)
static MapType Map(Scalar *data, Index rows, Index cols)
EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime==1 &&MaxColsAtCompileTime!=1,(int(Options)&RowMajor)==RowMajor), INVALID_MATRIX_TEMPLATE_PARAMETERS) EIGEN_STATIC_ASSERT(internal
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
void _init1(const Scalar &val0, std::enable_if_t< Base::SizeAtCompileTime==1 &&internal::is_convertible< T, Scalar >::value, T > *=0)
Derived & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
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...
static ConstMapType Map(const Scalar *data, Index rows, Index cols)
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)
static ConstAlignedMapType MapAligned(const Scalar *data)
constexpr void resize(Index rows, Index cols)
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
constexpr Scalar & coeffRef(Index rowId, Index colId)
internal::traits< Derived >::StorageKind StorageKind
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Derived & _set_noalias(const DenseBase< OtherDerived > &other)
internal::dense_xpr_base< Derived >::type Base
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)
const Eigen::Map< const Derived, Unaligned > ConstMapType
Derived & operator=(const PlainObjectBase &other)
void conservativeResize(NoChange_t, Index cols)
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: ReturnByValue.h:66
void evalTo(Dest &dst) const
Definition: ReturnByValue.h:63
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: ReturnByValue.h:68
Common base class for compact rotation representations.
Definition: RotationBase.h:32
Holds strides information for Map.
Definition: Stride.h:55
@ Unaligned
Definition: Constants.h:235
@ AlignedMax
Definition: Constants.h:254
@ DontAlign
Definition: Constants.h:327
@ RowMajor
Definition: Constants.h:323
const unsigned int RowMajorBit
Definition: Constants.h:68
constexpr bool check_implication(bool a, bool b)
Definition: Meta.h:579
void call_assignment(Dst &dst, const Src &src)
EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
void throw_std_bad_alloc()
Definition: Memory.h:117
void swap(scoped_array< T > &a, scoped_array< T > &b)
Definition: Memory.h:788
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
: InteropHeaders
Definition: Core:139
NoChange_t
Definition: Constants.h:362
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int Dynamic
Definition: Constants.h:24
Derived & derived()
Definition: EigenBase.h:48
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:69
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231
Eigen::Map< Derived, AlignedMax, StrideType > type
Eigen::Map< const Derived, AlignedMax, StrideType > type
Eigen::Map< const Derived, Unaligned, StrideType > type
Eigen::Map< Derived, Unaligned, StrideType > type