Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
PlainObjectBase.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
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> struct check_rows_cols_for_overflow {
32  template<typename Index>
33  EIGEN_DEVICE_FUNC
34  static EIGEN_ALWAYS_INLINE void run(Index, Index)
35  {
36  }
37 };
38 
39 template<> struct check_rows_cols_for_overflow<Dynamic> {
40  template<typename Index>
41  EIGEN_DEVICE_FUNC
42  static EIGEN_ALWAYS_INLINE void run(Index rows, Index cols)
43  {
44  // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242
45  // we assume Index is signed
46  Index max_index = (std::size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed
47  bool error = (rows == 0 || cols == 0) ? false
48  : (rows > max_index / cols);
49  if (error)
50  throw_std_bad_alloc();
51  }
52 };
53 
54 template <typename Derived,
55  typename OtherDerived = Derived,
56  bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
57 struct conservative_resize_like_impl;
58 
59 template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct matrix_swap_impl;
60 
61 } // end namespace internal
62 
63 #ifdef EIGEN_PARSED_BY_DOXYGEN
64 namespace doxygen {
65 
66 // This is a workaround to doxygen not being able to understand the inheritance logic
67 // when it is hidden by the dense_xpr_base helper struct.
68 // Moreover, doxygen fails to include members that are not documented in the declaration body of
69 // MatrixBase if we inherits MatrixBase<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >,
70 // this is why we simply inherits MatrixBase, though this does not make sense.
71 
73 template<typename Derived> struct dense_xpr_base_dispatcher;
75 template<typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
76 struct dense_xpr_base_dispatcher<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >
77  : public MatrixBase {};
79 template<typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
80 struct dense_xpr_base_dispatcher<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_> >
81  : public ArrayBase {};
82 
83 } // namespace doxygen
84 
96 template<typename Derived>
98 #else
99 template<typename Derived>
100 class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
101 #endif
102 {
103  public:
104  enum { Options = internal::traits<Derived>::Options };
105  typedef typename internal::dense_xpr_base<Derived>::type Base;
106 
107  typedef typename internal::traits<Derived>::StorageKind StorageKind;
108  typedef typename internal::traits<Derived>::Scalar Scalar;
109 
110  typedef typename internal::packet_traits<Scalar>::type PacketScalar;
111  typedef typename NumTraits<Scalar>::Real RealScalar;
112  typedef Derived DenseType;
113 
114  using Base::RowsAtCompileTime;
115  using Base::ColsAtCompileTime;
116  using Base::SizeAtCompileTime;
117  using Base::MaxRowsAtCompileTime;
118  using Base::MaxColsAtCompileTime;
119  using Base::MaxSizeAtCompileTime;
120  using Base::IsVectorAtCompileTime;
121  using Base::Flags;
122 
127  template<typename StrideType> struct StridedMapType { typedef Eigen::Map<Derived, Unaligned, StrideType> type; };
128  template<typename StrideType> struct StridedConstMapType { typedef Eigen::Map<const Derived, Unaligned, StrideType> type; };
129  template<typename StrideType> struct StridedAlignedMapType { typedef Eigen::Map<Derived, AlignedMax, StrideType> type; };
130  template<typename StrideType> struct StridedConstAlignedMapType { typedef Eigen::Map<const Derived, AlignedMax, StrideType> type; };
131 
132  protected:
133  DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
134 
135  public:
136  enum { NeedsToAlign = (SizeAtCompileTime != Dynamic) && (internal::traits<Derived>::Alignment>0) };
137  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
138 
139  EIGEN_STATIC_ASSERT(internal::check_implication(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (int(Options)&RowMajor)==RowMajor), INVALID_MATRIX_TEMPLATE_PARAMETERS)
140  EIGEN_STATIC_ASSERT(internal::check_implication(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, (int(Options)&RowMajor)==0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
141  EIGEN_STATIC_ASSERT((RowsAtCompileTime == Dynamic) || (RowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
142  EIGEN_STATIC_ASSERT((ColsAtCompileTime == Dynamic) || (ColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
143  EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == Dynamic) || (MaxRowsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
144  EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == Dynamic) || (MaxColsAtCompileTime >= 0), INVALID_MATRIX_TEMPLATE_PARAMETERS)
145  EIGEN_STATIC_ASSERT((MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic), INVALID_MATRIX_TEMPLATE_PARAMETERS)
146  EIGEN_STATIC_ASSERT((MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic), INVALID_MATRIX_TEMPLATE_PARAMETERS)
147  EIGEN_STATIC_ASSERT(((Options & (DontAlign|RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS)
148 
149  EIGEN_DEVICE_FUNC
150  Base& base() { return *static_cast<Base*>(this); }
151  EIGEN_DEVICE_FUNC
152  const Base& base() const { return *static_cast<const Base*>(this); }
153 
154  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
155  Index rows() const EIGEN_NOEXCEPT { return m_storage.rows(); }
156  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
157  Index cols() const EIGEN_NOEXCEPT { return m_storage.cols(); }
158 
163  EIGEN_DEVICE_FUNC
164  EIGEN_STRONG_INLINE const Scalar& coeff(Index rowId, Index colId) const
165  {
166  if(Flags & RowMajorBit)
167  return m_storage.data()[colId + rowId * m_storage.cols()];
168  else // column-major
169  return m_storage.data()[rowId + colId * m_storage.rows()];
170  }
171 
176  EIGEN_DEVICE_FUNC
177  EIGEN_STRONG_INLINE const Scalar& coeff(Index index) const
178  {
179  return m_storage.data()[index];
180  }
181 
186  EIGEN_DEVICE_FUNC
187  EIGEN_STRONG_INLINE Scalar& coeffRef(Index rowId, Index colId)
188  {
189  if(Flags & RowMajorBit)
190  return m_storage.data()[colId + rowId * m_storage.cols()];
191  else // column-major
192  return m_storage.data()[rowId + colId * m_storage.rows()];
193  }
194 
199  EIGEN_DEVICE_FUNC
200  EIGEN_STRONG_INLINE Scalar& coeffRef(Index index)
201  {
202  return m_storage.data()[index];
203  }
204 
207  EIGEN_DEVICE_FUNC
208  EIGEN_STRONG_INLINE const Scalar& coeffRef(Index rowId, Index colId) const
209  {
210  if(Flags & RowMajorBit)
211  return m_storage.data()[colId + rowId * m_storage.cols()];
212  else // column-major
213  return m_storage.data()[rowId + colId * m_storage.rows()];
214  }
215 
218  EIGEN_DEVICE_FUNC
219  EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const
220  {
221  return m_storage.data()[index];
222  }
223 
225  template<int LoadMode>
226  EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const
227  {
228  return internal::ploadt<PacketScalar, LoadMode>
229  (m_storage.data() + (Flags & RowMajorBit
230  ? colId + rowId * m_storage.cols()
231  : rowId + colId * m_storage.rows()));
232  }
233 
235  template<int LoadMode>
236  EIGEN_STRONG_INLINE PacketScalar packet(Index index) const
237  {
238  return internal::ploadt<PacketScalar, LoadMode>(m_storage.data() + index);
239  }
240 
242  template<int StoreMode>
243  EIGEN_STRONG_INLINE void writePacket(Index rowId, Index colId, const PacketScalar& val)
244  {
245  internal::pstoret<Scalar, PacketScalar, StoreMode>
246  (m_storage.data() + (Flags & RowMajorBit
247  ? colId + rowId * m_storage.cols()
248  : rowId + colId * m_storage.rows()), val);
249  }
250 
252  template<int StoreMode>
253  EIGEN_STRONG_INLINE void writePacket(Index index, const PacketScalar& val)
254  {
255  internal::pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, val);
256  }
257 
259  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar *data() const
260  { return m_storage.data(); }
261 
263  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar *data()
264  { return m_storage.data(); }
265 
282  EIGEN_DEVICE_FUNC
283  EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
284  {
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>::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);
295  if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
296  #else
297  m_storage.resize(rows*cols, rows, cols);
298  #endif
299  }
300 
312  EIGEN_DEVICE_FUNC
313  inline void resize(Index size)
314  {
315  EIGEN_STATIC_ASSERT_VECTOR_ONLY(PlainObjectBase)
316  eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime==Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0);
317  #ifdef EIGEN_INITIALIZE_COEFFS
318  bool size_changed = size != this->size();
319  #endif
320  if(RowsAtCompileTime == 1)
321  m_storage.resize(size, 1, size);
322  else
323  m_storage.resize(size, size, 1);
324  #ifdef EIGEN_INITIALIZE_COEFFS
325  if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
326  #endif
327  }
328 
337  EIGEN_DEVICE_FUNC
338  inline void resize(NoChange_t, Index cols)
339  {
340  resize(rows(), cols);
341  }
342 
351  EIGEN_DEVICE_FUNC
352  inline void resize(Index rows, NoChange_t)
353  {
354  resize(rows, cols());
355  }
356 
364  template<typename OtherDerived>
365  EIGEN_DEVICE_FUNC
366  EIGEN_STRONG_INLINE void resizeLike(const EigenBase<OtherDerived>& _other)
367  {
368  const OtherDerived& other = _other.derived();
369  internal::check_rows_cols_for_overflow<MaxSizeAtCompileTime>::run(other.rows(), other.cols());
370  const Index othersize = other.rows()*other.cols();
371  if(RowsAtCompileTime == 1)
372  {
373  eigen_assert(other.rows() == 1 || other.cols() == 1);
374  resize(1, othersize);
375  }
376  else if(ColsAtCompileTime == 1)
377  {
378  eigen_assert(other.rows() == 1 || other.cols() == 1);
379  resize(othersize, 1);
380  }
381  else resize(other.rows(), other.cols());
382  }
383 
393  EIGEN_DEVICE_FUNC
394  EIGEN_STRONG_INLINE void conservativeResize(Index rows, Index cols)
395  {
396  internal::conservative_resize_like_impl<Derived>::run(*this, rows, cols);
397  }
398 
406  EIGEN_DEVICE_FUNC
407  EIGEN_STRONG_INLINE void conservativeResize(Index rows, NoChange_t)
408  {
409  // Note: see the comment in conservativeResize(Index,Index)
410  conservativeResize(rows, cols());
411  }
412 
420  EIGEN_DEVICE_FUNC
421  EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, Index cols)
422  {
423  // Note: see the comment in conservativeResize(Index,Index)
424  conservativeResize(rows(), cols);
425  }
426 
435  EIGEN_DEVICE_FUNC
436  EIGEN_STRONG_INLINE void conservativeResize(Index size)
437  {
438  internal::conservative_resize_like_impl<Derived>::run(*this, size);
439  }
440 
450  template<typename OtherDerived>
451  EIGEN_DEVICE_FUNC
452  EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other)
453  {
454  internal::conservative_resize_like_impl<Derived,OtherDerived>::run(*this, other);
455  }
456 
460  EIGEN_DEVICE_FUNC
461  EIGEN_STRONG_INLINE Derived& operator=(const PlainObjectBase& other)
462  {
463  return _set(other);
464  }
465 
467  template<typename OtherDerived>
468  EIGEN_DEVICE_FUNC
469  EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other)
470  {
471  _resize_to_match(other);
472  return Base::lazyAssign(other.derived());
473  }
474 
475  template<typename OtherDerived>
476  EIGEN_DEVICE_FUNC
477  EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue<OtherDerived>& func)
478  {
479  resize(func.rows(), func.cols());
480  return Base::operator=(func);
481  }
482 
483  // Prevent user from trying to instantiate PlainObjectBase objects
484  // by making all its constructor protected. See bug 1074.
485  protected:
486 
487  EIGEN_DEVICE_FUNC
488  EIGEN_STRONG_INLINE PlainObjectBase() : m_storage()
489  {
490 // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
491  }
492 
493 #ifndef EIGEN_PARSED_BY_DOXYGEN
494  // FIXME is it still needed ?
496  EIGEN_DEVICE_FUNC
497  explicit PlainObjectBase(internal::constructor_without_unaligned_array_assert)
498  : m_storage(internal::constructor_without_unaligned_array_assert())
499  {
500  // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
501  }
502 #endif
503 
504  EIGEN_DEVICE_FUNC
505  PlainObjectBase(PlainObjectBase&& other) EIGEN_NOEXCEPT
506  : m_storage( std::move(other.m_storage) )
507  {
508  }
509 
510  EIGEN_DEVICE_FUNC
511  PlainObjectBase& operator=(PlainObjectBase&& other) EIGEN_NOEXCEPT
512  {
513  m_storage = std::move(other.m_storage);
514  return *this;
515  }
516 
518  EIGEN_DEVICE_FUNC
519  EIGEN_STRONG_INLINE PlainObjectBase(const PlainObjectBase& other)
520  : Base(), m_storage(other.m_storage) { }
521  EIGEN_DEVICE_FUNC
522  EIGEN_STRONG_INLINE PlainObjectBase(Index size, Index rows, Index cols)
523  : m_storage(size, rows, cols)
524  {
525 // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
526  }
527 
537  template <typename... ArgTypes>
538  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
539  PlainObjectBase(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
540  : m_storage()
541  {
542  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, sizeof...(args) + 4);
543  m_storage.data()[0] = a0;
544  m_storage.data()[1] = a1;
545  m_storage.data()[2] = a2;
546  m_storage.data()[3] = a3;
547  Index i = 4;
548  auto x = {(m_storage.data()[i++] = args, 0)...};
549  static_cast<void>(x);
550  }
551 
555  EIGEN_DEVICE_FUNC
556  explicit EIGEN_STRONG_INLINE PlainObjectBase(const std::initializer_list<std::initializer_list<Scalar>>& list)
557  : m_storage()
558  {
559  size_t list_size = 0;
560  if (list.begin() != list.end()) {
561  list_size = list.begin()->size();
562  }
563 
564  // This is to allow syntax like VectorXi {{1, 2, 3, 4}}
565  if (ColsAtCompileTime == 1 && list.size() == 1) {
566  eigen_assert(list_size == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
567  resize(list_size, ColsAtCompileTime);
568  std::copy(list.begin()->begin(), list.begin()->end(), m_storage.data());
569  } else {
570  eigen_assert(list.size() == static_cast<size_t>(RowsAtCompileTime) || RowsAtCompileTime == Dynamic);
571  eigen_assert(list_size == static_cast<size_t>(ColsAtCompileTime) || ColsAtCompileTime == Dynamic);
572  resize(list.size(), list_size);
573 
574  Index row_index = 0;
575  for (const std::initializer_list<Scalar>& row : list) {
576  eigen_assert(list_size == row.size());
577  Index col_index = 0;
578  for (const Scalar& e : row) {
579  coeffRef(row_index, col_index) = e;
580  ++col_index;
581  }
582  ++row_index;
583  }
584  }
585  }
586 
588  template<typename OtherDerived>
589  EIGEN_DEVICE_FUNC
590  EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived> &other)
591  : m_storage()
592  {
593  resizeLike(other);
594  _set_noalias(other);
595  }
596 
598  template<typename OtherDerived>
599  EIGEN_DEVICE_FUNC
600  EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived> &other)
601  : m_storage()
602  {
603  resizeLike(other);
604  *this = other.derived();
605  }
607  template<typename OtherDerived>
608  EIGEN_DEVICE_FUNC
609  EIGEN_STRONG_INLINE PlainObjectBase(const ReturnByValue<OtherDerived>& other)
610  {
611  // FIXME this does not automatically transpose vectors if necessary
612  resize(other.rows(), other.cols());
613  other.evalTo(this->derived());
614  }
615 
616  public:
617 
621  template<typename OtherDerived>
622  EIGEN_DEVICE_FUNC
623  EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived> &other)
624  {
625  _resize_to_match(other);
626  Base::operator=(other.derived());
627  return this->derived();
628  }
629 
642  static inline ConstMapType Map(const Scalar* data)
643  { return ConstMapType(data); }
644  static inline MapType Map(Scalar* data)
645  { return MapType(data); }
646  static inline ConstMapType Map(const Scalar* data, Index size)
647  { return ConstMapType(data, size); }
648  static inline MapType Map(Scalar* data, Index size)
649  { return MapType(data, size); }
650  static inline ConstMapType Map(const Scalar* data, Index rows, Index cols)
651  { return ConstMapType(data, rows, cols); }
652  static inline MapType Map(Scalar* data, Index rows, Index cols)
653  { return MapType(data, rows, cols); }
654 
655  static inline ConstAlignedMapType MapAligned(const Scalar* data)
656  { return ConstAlignedMapType(data); }
657  static inline AlignedMapType MapAligned(Scalar* data)
658  { return AlignedMapType(data); }
659  static inline ConstAlignedMapType MapAligned(const Scalar* data, Index size)
660  { return ConstAlignedMapType(data, size); }
661  static inline AlignedMapType MapAligned(Scalar* data, Index size)
662  { return AlignedMapType(data, size); }
663  static inline ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols)
664  { return ConstAlignedMapType(data, rows, cols); }
665  static inline AlignedMapType MapAligned(Scalar* data, Index rows, Index cols)
666  { return AlignedMapType(data, rows, cols); }
667 
668  template<int Outer, int Inner>
669  static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, const Stride<Outer, Inner>& stride)
670  { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, stride); }
671  template<int Outer, int Inner>
672  static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, const Stride<Outer, Inner>& stride)
673  { return typename StridedMapType<Stride<Outer, Inner> >::type(data, stride); }
674  template<int Outer, int Inner>
675  static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, Index size, const Stride<Outer, Inner>& stride)
676  { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, size, stride); }
677  template<int Outer, int Inner>
678  static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, Index size, const Stride<Outer, Inner>& stride)
679  { return typename StridedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
680  template<int Outer, int Inner>
681  static inline typename StridedConstMapType<Stride<Outer, Inner> >::type Map(const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)
682  { return typename StridedConstMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
683  template<int Outer, int Inner>
684  static inline typename StridedMapType<Stride<Outer, Inner> >::type Map(Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)
685  { return typename StridedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
686 
687  template<int Outer, int Inner>
688  static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(const Scalar* data, const Stride<Outer, Inner>& stride)
689  { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }
690  template<int Outer, int Inner>
691  static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar* data, const Stride<Outer, Inner>& stride)
692  { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, stride); }
693  template<int Outer, int Inner>
694  static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(const Scalar* data, Index size, const Stride<Outer, Inner>& stride)
695  { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
696  template<int Outer, int Inner>
697  static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar* data, Index size, const Stride<Outer, Inner>& stride)
698  { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, size, stride); }
699  template<int Outer, int Inner>
700  static inline typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type MapAligned(const Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)
701  { return typename StridedConstAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
702  template<int Outer, int Inner>
703  static inline typename StridedAlignedMapType<Stride<Outer, Inner> >::type MapAligned(Scalar* data, Index rows, Index cols, const Stride<Outer, Inner>& stride)
704  { return typename StridedAlignedMapType<Stride<Outer, Inner> >::type(data, rows, cols, stride); }
706 
707  using Base::setConstant;
708  EIGEN_DEVICE_FUNC Derived& setConstant(Index size, const Scalar& val);
709  EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, Index cols, const Scalar& val);
710  EIGEN_DEVICE_FUNC Derived& setConstant(NoChange_t, Index cols, const Scalar& val);
711  EIGEN_DEVICE_FUNC Derived& setConstant(Index rows, NoChange_t, const Scalar& val);
712 
713  using Base::setZero;
714  EIGEN_DEVICE_FUNC Derived& setZero(Index size);
715  EIGEN_DEVICE_FUNC Derived& setZero(Index rows, Index cols);
716  EIGEN_DEVICE_FUNC Derived& setZero(NoChange_t, Index cols);
717  EIGEN_DEVICE_FUNC Derived& setZero(Index rows, NoChange_t);
718 
719  using Base::setOnes;
720  EIGEN_DEVICE_FUNC Derived& setOnes(Index size);
721  EIGEN_DEVICE_FUNC Derived& setOnes(Index rows, Index cols);
722  EIGEN_DEVICE_FUNC Derived& setOnes(NoChange_t, Index cols);
723  EIGEN_DEVICE_FUNC Derived& setOnes(Index rows, NoChange_t);
724 
725  using Base::setRandom;
726  Derived& setRandom(Index size);
727  Derived& setRandom(Index rows, Index cols);
728  Derived& setRandom(NoChange_t, Index cols);
729  Derived& setRandom(Index rows, NoChange_t);
730 
731  #ifdef EIGEN_PLAINOBJECTBASE_PLUGIN
732  #include EIGEN_PLAINOBJECTBASE_PLUGIN
733  #endif
734 
735  protected:
743  template<typename OtherDerived>
744  EIGEN_DEVICE_FUNC
745  EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase<OtherDerived>& other)
746  {
747  #ifdef EIGEN_NO_AUTOMATIC_RESIZING
748  eigen_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size())
749  : (rows() == other.rows() && cols() == other.cols())))
750  && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
751  EIGEN_ONLY_USED_FOR_DEBUG(other);
752  #else
753  resizeLike(other);
754  #endif
755  }
756 
771  // aliasing is dealt once in internal::call_assignment
772  // so at this stage we have to assume aliasing... and resising has to be done later.
773  template<typename OtherDerived>
774  EIGEN_DEVICE_FUNC
775  EIGEN_STRONG_INLINE Derived& _set(const DenseBase<OtherDerived>& other)
776  {
777  internal::call_assignment(this->derived(), other.derived());
778  return this->derived();
779  }
780 
786  template<typename OtherDerived>
787  EIGEN_DEVICE_FUNC
788  EIGEN_STRONG_INLINE Derived& _set_noalias(const DenseBase<OtherDerived>& other)
789  {
790  // I don't think we need this resize call since the lazyAssign will anyways resize
791  // and lazyAssign will be called by the assign selector.
792  //_resize_to_match(other);
793  // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
794  // it wouldn't allow to copy a row-vector into a column-vector.
795  internal::call_assignment_no_alias(this->derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
796  return this->derived();
797  }
798 
799  template<typename T0, typename T1>
800  EIGEN_DEVICE_FUNC
801  EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, std::enable_if_t<Base::SizeAtCompileTime!=2,T0>* = 0)
802  {
803  const bool t0_is_integer_alike = internal::is_valid_index_type<T0>::value;
804  const bool t1_is_integer_alike = internal::is_valid_index_type<T1>::value;
805  EIGEN_STATIC_ASSERT(t0_is_integer_alike &&
806  t1_is_integer_alike,
807  FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
808  resize(rows,cols);
809  }
810 
811  template<typename T0, typename T1>
812  EIGEN_DEVICE_FUNC
813  EIGEN_STRONG_INLINE void _init2(const T0& val0, const T1& val1, std::enable_if_t<Base::SizeAtCompileTime==2,T0>* = 0)
814  {
815  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
816  m_storage.data()[0] = Scalar(val0);
817  m_storage.data()[1] = Scalar(val1);
818  }
819 
820  template<typename T0, typename T1>
821  EIGEN_DEVICE_FUNC
822  EIGEN_STRONG_INLINE void _init2(const Index& val0, const Index& val1,
823  std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
824  && (internal::is_same<T0,Index>::value)
825  && (internal::is_same<T1,Index>::value)
826  && Base::SizeAtCompileTime==2,T1>* = 0)
827  {
828  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 2)
829  m_storage.data()[0] = Scalar(val0);
830  m_storage.data()[1] = Scalar(val1);
831  }
832 
833  // The argument is convertible to the Index type and we either have a non 1x1 Matrix, or a dynamic-sized Array,
834  // then the argument is meant to be the size of the object.
835  template<typename T>
836  EIGEN_DEVICE_FUNC
837  EIGEN_STRONG_INLINE void _init1(Index size, std::enable_if_t< (Base::SizeAtCompileTime!=1 || !internal::is_convertible<T, Scalar>::value)
838  && ((!internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value || Base::SizeAtCompileTime==Dynamic)),T>* = 0)
839  {
840  // NOTE MSVC 2008 complains if we directly put bool(NumTraits<T>::IsInteger) as the EIGEN_STATIC_ASSERT argument.
841  const bool is_integer_alike = internal::is_valid_index_type<T>::value;
842  EIGEN_UNUSED_VARIABLE(is_integer_alike);
843  EIGEN_STATIC_ASSERT(is_integer_alike,
844  FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
845  resize(size);
846  }
847 
848  // 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)
849  template<typename T>
850  EIGEN_DEVICE_FUNC
851  EIGEN_STRONG_INLINE void _init1(const Scalar& val0, std::enable_if_t<Base::SizeAtCompileTime==1 && internal::is_convertible<T, Scalar>::value,T>* = 0)
852  {
853  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
854  m_storage.data()[0] = val0;
855  }
856 
857  // 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)
858  template<typename T>
859  EIGEN_DEVICE_FUNC
860  EIGEN_STRONG_INLINE void _init1(const Index& val0,
861  std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
862  && (internal::is_same<Index,T>::value)
863  && Base::SizeAtCompileTime==1
864  && internal::is_convertible<T, Scalar>::value,T*>* = 0)
865  {
866  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1)
867  m_storage.data()[0] = Scalar(val0);
868  }
869 
870  // Initialize a fixed size matrix from a pointer to raw data
871  template<typename T>
872  EIGEN_DEVICE_FUNC
873  EIGEN_STRONG_INLINE void _init1(const Scalar* data){
874  this->_set_noalias(ConstMapType(data));
875  }
876 
877  // Initialize an arbitrary matrix from a dense expression
878  template<typename T, typename OtherDerived>
879  EIGEN_DEVICE_FUNC
880  EIGEN_STRONG_INLINE void _init1(const DenseBase<OtherDerived>& other){
881  this->_set_noalias(other);
882  }
883 
884  // Initialize an arbitrary matrix from an object convertible to the Derived type.
885  template<typename T>
886  EIGEN_DEVICE_FUNC
887  EIGEN_STRONG_INLINE void _init1(const Derived& other){
888  this->_set_noalias(other);
889  }
890 
891  // Initialize an arbitrary matrix from a generic Eigen expression
892  template<typename T, typename OtherDerived>
893  EIGEN_DEVICE_FUNC
894  EIGEN_STRONG_INLINE void _init1(const EigenBase<OtherDerived>& other){
895  this->derived() = other;
896  }
897 
898  template<typename T, typename OtherDerived>
899  EIGEN_DEVICE_FUNC
900  EIGEN_STRONG_INLINE void _init1(const ReturnByValue<OtherDerived>& other)
901  {
902  resize(other.rows(), other.cols());
903  other.evalTo(this->derived());
904  }
905 
906  template<typename T, typename OtherDerived, int ColsAtCompileTime>
907  EIGEN_DEVICE_FUNC
908  EIGEN_STRONG_INLINE void _init1(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
909  {
910  this->derived() = r;
911  }
912 
913  // For fixed-size Array<Scalar,...>
914  template<typename T>
915  EIGEN_DEVICE_FUNC
916  EIGEN_STRONG_INLINE void _init1(const Scalar& val0,
917  std::enable_if_t< Base::SizeAtCompileTime!=Dynamic
918  && Base::SizeAtCompileTime!=1
919  && internal::is_convertible<T, Scalar>::value
920  && internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T>* = 0)
921  {
922  Base::setConstant(val0);
923  }
924 
925  // For fixed-size Array<Index,...>
926  template<typename T>
927  EIGEN_DEVICE_FUNC
928  EIGEN_STRONG_INLINE void _init1(const Index& val0,
929  std::enable_if_t< (!internal::is_same<Index,Scalar>::value)
930  && (internal::is_same<Index,T>::value)
931  && Base::SizeAtCompileTime!=Dynamic
932  && Base::SizeAtCompileTime!=1
933  && internal::is_convertible<T, Scalar>::value
934  && internal::is_same<typename internal::traits<Derived>::XprKind,ArrayXpr>::value,T*>* = 0)
935  {
936  Base::setConstant(val0);
937  }
938 
939  template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
940  friend struct internal::matrix_swap_impl;
941 
942  public:
943 
944 #ifndef EIGEN_PARSED_BY_DOXYGEN
949  template<typename OtherDerived>
950  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
951  void swap(DenseBase<OtherDerived> & other)
952  {
953  enum { SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime==Dynamic };
954  internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived());
955  }
956 
960  template<typename OtherDerived>
961  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
962  void swap(DenseBase<OtherDerived> const & other)
963  { Base::swap(other.derived()); }
964 
965  enum { IsPlainObjectBase = 1 };
966 #endif
967  public:
968  // These apparently need to be down here for nvcc+icc to prevent duplicate
969  // Map symbol.
970  template<typename PlainObjectType, int MapOptions, typename StrideType> friend class Eigen::Map;
971  friend class Eigen::Map<Derived, Unaligned>;
972  friend class Eigen::Map<const Derived, Unaligned>;
973 #if EIGEN_MAX_ALIGN_BYTES>0
974  // for EIGEN_MAX_ALIGN_BYTES==0, AlignedMax==Unaligned, and many compilers generate warnings for friend-ing a class twice.
975  friend class Eigen::Map<Derived, AlignedMax>;
976  friend class Eigen::Map<const Derived, AlignedMax>;
977 #endif
978 };
979 
980 namespace internal {
981 
982 template <typename Derived, typename OtherDerived, bool IsVector>
983 struct conservative_resize_like_impl
984 {
985  static constexpr bool IsRelocatable = std::is_trivially_copyable<typename Derived::Scalar>::value;
986  static void run(DenseBase<Derived>& _this, Index rows, Index cols)
987  {
988  if (_this.rows() == rows && _this.cols() == cols) return;
989  EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
990 
991  if ( IsRelocatable
992  && (( Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows
993  (!Derived::IsRowMajor && _this.rows() == rows) )) // column-major and we change only the number of columns
994  {
995  internal::check_rows_cols_for_overflow<Derived::MaxSizeAtCompileTime>::run(rows, cols);
996  _this.derived().m_storage.conservativeResize(rows*cols,rows,cols);
997  }
998  else
999  {
1000  // The storage order does not allow us to use reallocation.
1001  Derived tmp(rows,cols);
1002  const Index common_rows = numext::mini(rows, _this.rows());
1003  const Index common_cols = numext::mini(cols, _this.cols());
1004  tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
1005  _this.derived().swap(tmp);
1006  }
1007  }
1008 
1009  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)
1010  {
1011  if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1012 
1013  // Note: Here is space for improvement. Basically, for conservativeResize(Index,Index),
1014  // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
1015  // dimensions is dynamic, one could use either conservativeResize(Index rows, NoChange_t) or
1016  // conservativeResize(NoChange_t, Index cols). For these methods new static asserts like
1017  // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
1018  EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
1019  EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
1020 
1021  if ( IsRelocatable &&
1022  (( Derived::IsRowMajor && _this.cols() == other.cols()) || // row-major and we change only the number of rows
1023  (!Derived::IsRowMajor && _this.rows() == other.rows()) )) // column-major and we change only the number of columns
1024  {
1025  const Index new_rows = other.rows() - _this.rows();
1026  const Index new_cols = other.cols() - _this.cols();
1027  _this.derived().m_storage.conservativeResize(other.size(),other.rows(),other.cols());
1028  if (new_rows>0)
1029  _this.bottomRightCorner(new_rows, other.cols()) = other.bottomRows(new_rows);
1030  else if (new_cols>0)
1031  _this.bottomRightCorner(other.rows(), new_cols) = other.rightCols(new_cols);
1032  }
1033  else
1034  {
1035  // The storage order does not allow us to use reallocation.
1036  Derived tmp(other);
1037  const Index common_rows = numext::mini(tmp.rows(), _this.rows());
1038  const Index common_cols = numext::mini(tmp.cols(), _this.cols());
1039  tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
1040  _this.derived().swap(tmp);
1041  }
1042  }
1043 };
1044 
1045 // Here, the specialization for vectors inherits from the general matrix case
1046 // to allow calling .conservativeResize(rows,cols) on vectors.
1047 template <typename Derived, typename OtherDerived>
1048 struct conservative_resize_like_impl<Derived,OtherDerived,true>
1049  : conservative_resize_like_impl<Derived,OtherDerived,false>
1050 {
1051  typedef conservative_resize_like_impl<Derived,OtherDerived,false> Base;
1052  using Base::run;
1053  using Base::IsRelocatable;
1054 
1055  static void run(DenseBase<Derived>& _this, Index size)
1056  {
1057  const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size;
1058  const Index new_cols = Derived::RowsAtCompileTime==1 ? size : 1;
1059  if(IsRelocatable)
1060  _this.derived().m_storage.conservativeResize(size,new_rows,new_cols);
1061  else
1062  Base::run(_this.derived(), new_rows, new_cols);
1063  }
1064 
1065  static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)
1066  {
1067  if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
1068 
1069  const Index num_new_elements = other.size() - _this.size();
1070 
1071  const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows();
1072  const Index new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1;
1073  if(IsRelocatable)
1074  _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols);
1075  else
1076  Base::run(_this.derived(), new_rows, new_cols);
1077 
1078  if (num_new_elements > 0)
1079  _this.tail(num_new_elements) = other.tail(num_new_elements);
1080  }
1081 };
1082 
1083 template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
1084 struct matrix_swap_impl
1085 {
1086  EIGEN_DEVICE_FUNC
1087  static EIGEN_STRONG_INLINE void run(MatrixTypeA& a, MatrixTypeB& b)
1088  {
1089  a.base().swap(b);
1090  }
1091 };
1092 
1093 template<typename MatrixTypeA, typename MatrixTypeB>
1094 struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true>
1095 {
1096  EIGEN_DEVICE_FUNC
1097  static inline void run(MatrixTypeA& a, MatrixTypeB& b)
1098  {
1099  static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);
1100  }
1101 };
1102 
1103 } // end namespace internal
1104 
1105 } // end namespace Eigen
1106 
1107 #endif // EIGEN_DENSESTORAGEBASE_H
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
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
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.
Definition: PlainObjectBase.h:102
const Scalar & coeffRef(Index rowId, Index colId) const
Definition: PlainObjectBase.h:208
Derived & _set(const DenseBase< OtherDerived > &other)
Copies the value of the expression other into *this with automatic resizing.
Definition: PlainObjectBase.h:775
void resize(NoChange_t, Index cols)
Definition: PlainObjectBase.h:338
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:681
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:672
PlainObjectBase(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition: PlainObjectBase.h:609
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:697
void _init2(Index rows, Index cols, std::enable_if_t< Base::SizeAtCompileTime!=2, T0 > *=0)
Definition: PlainObjectBase.h:801
void _resize_to_match(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:745
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:700
void _init1(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:894
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:916
void _init2(const T0 &val0, const T1 &val1, std::enable_if_t< Base::SizeAtCompileTime==2, T0 > *=0)
Definition: PlainObjectBase.h:813
void conservativeResizeLike(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:452
void _init1(const RotationBase< OtherDerived, ColsAtCompileTime > &r)
Definition: PlainObjectBase.h:908
PlainObjectBase(const PlainObjectBase &other)
Definition: PlainObjectBase.h:519
const Scalar & coeffRef(Index index) const
Definition: PlainObjectBase.h:219
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:539
Derived & setRandom(Index size)
Definition: Random.h:152
static AlignedMapType MapAligned(Scalar *data, Index size)
Definition: PlainObjectBase.h:661
void _init1(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:880
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:469
void conservativeResize(Index rows, Index cols)
Definition: PlainObjectBase.h:394
Scalar & coeffRef(Index index)
Definition: PlainObjectBase.h:200
static ConstAlignedMapType MapAligned(const Scalar *data, Index size)
Definition: PlainObjectBase.h:659
PlainObjectBase(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:590
void conservativeResize(Index size)
Definition: PlainObjectBase.h:436
Derived & setOnes(Index size)
Definition: CwiseNullaryOp.h:716
static ConstAlignedMapType MapAligned(const Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:663
void resize(Index size)
Definition: PlainObjectBase.h:313
void conservativeResize(Index rows, NoChange_t)
Definition: PlainObjectBase.h:407
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:669
PlainObjectBase(const EigenBase< OtherDerived > &other)
Definition: PlainObjectBase.h:600
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:694
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:164
static AlignedMapType MapAligned(Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:665
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:187
void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:283
static AlignedMapType MapAligned(Scalar *data)
Definition: PlainObjectBase.h:657
void _init1(const Scalar *data)
Definition: PlainObjectBase.h:873
void resizeLike(const EigenBase< OtherDerived > &_other)
Definition: PlainObjectBase.h:366
Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:363
void _init1(const ReturnByValue< OtherDerived > &other)
Definition: PlainObjectBase.h:900
static StridedConstAlignedMapType< Stride< Outer, Inner > >::type MapAligned(const Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:688
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:678
static ConstMapType Map(const Scalar *data)
Definition: PlainObjectBase.h:642
static MapType Map(Scalar *data, Index size)
Definition: PlainObjectBase.h:648
void _init1(const Derived &other)
Definition: PlainObjectBase.h:887
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:928
static MapType Map(Scalar *data)
Definition: PlainObjectBase.h:644
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:556
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:837
static ConstMapType Map(const Scalar *data, Index size)
Definition: PlainObjectBase.h:646
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:691
const Scalar * data() const
Definition: PlainObjectBase.h:259
const Scalar & coeff(Index index) const
Definition: PlainObjectBase.h:177
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:564
Scalar * data()
Definition: PlainObjectBase.h:263
static MapType Map(Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:652
static StridedMapType< Stride< Outer, Inner > >::type Map(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:684
void _init1(const Scalar &val0, std::enable_if_t< Base::SizeAtCompileTime==1 &&internal::is_convertible< T, Scalar >::value, T > *=0)
Definition: PlainObjectBase.h:851
Derived & operator=(const EigenBase< OtherDerived > &other)
Copies the generic expression other into *this.
Definition: PlainObjectBase.h:623
static ConstMapType Map(const Scalar *data, Index rows, Index cols)
Definition: PlainObjectBase.h:650
void resize(Index rows, NoChange_t)
Definition: PlainObjectBase.h:352
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:860
static ConstAlignedMapType MapAligned(const Scalar *data)
Definition: PlainObjectBase.h:655
static StridedConstMapType< Stride< Outer, Inner > >::type Map(const Scalar *data, Index size, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:675
static StridedAlignedMapType< Stride< Outer, Inner > >::type MapAligned(Scalar *data, Index rows, Index cols, const Stride< Outer, Inner > &stride)
Definition: PlainObjectBase.h:703
Derived & _set_noalias(const DenseBase< OtherDerived > &other)
Definition: PlainObjectBase.h:788
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:822
Derived & operator=(const PlainObjectBase &other)
Definition: PlainObjectBase.h:461
void conservativeResize(NoChange_t, Index cols)
Definition: PlainObjectBase.h:421
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
@ DontAlign
Definition: Constants.h:327
@ RowMajor
Definition: Constants.h:323
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
const int Dynamic
Definition: Constants.h:24
Definition: Constants.h:527
Definition: EigenBase.h:32
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
Definition: PlainObjectBase.h:73