Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
ArrayBase.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_ARRAYBASE_H
11 #define EIGEN_ARRAYBASE_H
12 
13 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
17 template<typename ExpressionType> class MatrixWrapper;
18 
41 template<typename Derived> class ArrayBase
42  : public DenseBase<Derived>
43 {
44  public:
45 #ifndef EIGEN_PARSED_BY_DOXYGEN
47  typedef ArrayBase StorageBaseType;
48 
49  typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl;
50 
51  typedef typename internal::traits<Derived>::StorageKind StorageKind;
52  typedef typename internal::traits<Derived>::Scalar Scalar;
53  typedef typename internal::packet_traits<Scalar>::type PacketScalar;
54  typedef typename NumTraits<Scalar>::Real RealScalar;
55 
56  typedef DenseBase<Derived> Base;
57  using Base::RowsAtCompileTime;
58  using Base::ColsAtCompileTime;
59  using Base::SizeAtCompileTime;
60  using Base::MaxRowsAtCompileTime;
61  using Base::MaxColsAtCompileTime;
62  using Base::MaxSizeAtCompileTime;
63  using Base::IsVectorAtCompileTime;
64  using Base::Flags;
65 
66  using Base::derived;
67  using Base::const_cast_derived;
68  using Base::rows;
69  using Base::cols;
70  using Base::size;
71  using Base::coeff;
72  using Base::coeffRef;
73  using Base::lazyAssign;
74  using Base::operator-;
75  using Base::operator=;
76  using Base::operator+=;
77  using Base::operator-=;
78  using Base::operator*=;
79  using Base::operator/=;
80 
81  typedef typename Base::CoeffReturnType CoeffReturnType;
82 
83 #endif // not EIGEN_PARSED_BY_DOXYGEN
84 
85 #ifndef EIGEN_PARSED_BY_DOXYGEN
86  typedef typename Base::PlainObject PlainObject;
87 
90 #endif // not EIGEN_PARSED_BY_DOXYGEN
91 
92 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
93 #define EIGEN_DOC_UNARY_ADDONS(X,Y)
94 # include "../plugins/MatrixCwiseUnaryOps.h"
95 # include "../plugins/ArrayCwiseUnaryOps.h"
96 # include "../plugins/CommonCwiseBinaryOps.h"
97 # include "../plugins/MatrixCwiseBinaryOps.h"
98 # include "../plugins/ArrayCwiseBinaryOps.h"
99 # ifdef EIGEN_ARRAYBASE_PLUGIN
100 # include EIGEN_ARRAYBASE_PLUGIN
101 # endif
102 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
103 #undef EIGEN_DOC_UNARY_ADDONS
104 
108  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
109  Derived& operator=(const ArrayBase& other)
110  {
111  internal::call_assignment(derived(), other.derived());
112  return derived();
113  }
114 
117  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
118  Derived& operator=(const Scalar &value)
119  { Base::setConstant(value); return derived(); }
120 
121  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
122  Derived& operator+=(const Scalar& scalar);
123  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
124  Derived& operator-=(const Scalar& scalar);
125 
126  template<typename OtherDerived>
127  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
128  Derived& operator+=(const ArrayBase<OtherDerived>& other);
129  template<typename OtherDerived>
130  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
131  Derived& operator-=(const ArrayBase<OtherDerived>& other);
132 
133  template<typename OtherDerived>
134  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
135  Derived& operator*=(const ArrayBase<OtherDerived>& other);
136 
137  template<typename OtherDerived>
138  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
139  Derived& operator/=(const ArrayBase<OtherDerived>& other);
140 
141  public:
142  EIGEN_DEVICE_FUNC
143  ArrayBase<Derived>& array() { return *this; }
144  EIGEN_DEVICE_FUNC
145  const ArrayBase<Derived>& array() const { return *this; }
146 
149  EIGEN_DEVICE_FUNC
151  EIGEN_DEVICE_FUNC
153 
154 // template<typename Dest>
155 // inline void evalTo(Dest& dst) const { dst = matrix(); }
156 
157  protected:
158  EIGEN_DEFAULT_COPY_CONSTRUCTOR(ArrayBase)
159  EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(ArrayBase)
160 
161  private:
162  explicit ArrayBase(Index);
163  ArrayBase(Index,Index);
164  template<typename OtherDerived> explicit ArrayBase(const ArrayBase<OtherDerived>&);
165  protected:
166  // mixing arrays and matrices is not legal
167  template<typename OtherDerived> Derived& operator+=(const MatrixBase<OtherDerived>& )
168  {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
169  // mixing arrays and matrices is not legal
170  template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& )
171  {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
172 };
173 
178 template<typename Derived>
179 template<typename OtherDerived>
180 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
182 {
183  call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
184  return derived();
185 }
186 
191 template<typename Derived>
192 template<typename OtherDerived>
193 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
195 {
196  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
197  return derived();
198 }
199 
204 template<typename Derived>
205 template<typename OtherDerived>
206 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
208 {
209  call_assignment(derived(), other.derived(), internal::mul_assign_op<Scalar,typename OtherDerived::Scalar>());
210  return derived();
211 }
212 
217 template<typename Derived>
218 template<typename OtherDerived>
219 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
221 {
222  call_assignment(derived(), other.derived(), internal::div_assign_op<Scalar,typename OtherDerived::Scalar>());
223  return derived();
224 }
225 
226 } // end namespace Eigen
227 
228 #endif // EIGEN_ARRAYBASE_H
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:43
Derived & operator/=(const ArrayBase< OtherDerived > &other)
Definition: ArrayBase.h:220
Derived & operator*=(const ArrayBase< OtherDerived > &other)
Definition: ArrayBase.h:207
Derived & operator=(const Scalar &value)
Definition: ArrayBase.h:118
Derived & operator=(const ArrayBase &other)
Definition: ArrayBase.h:109
Derived & operator+=(const ArrayBase< OtherDerived > &other)
Definition: ArrayBase.h:194
Derived & operator-=(const ArrayBase< OtherDerived > &other)
Definition: ArrayBase.h:181
MatrixWrapper< Derived > matrix()
Definition: ArrayBase.h:150
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:63
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
std::conditional_t< internal::is_same< typename internal::traits< Derived >::XprKind, MatrixXpr >::value, PlainMatrix, PlainArray > PlainObject
The plain matrix or array type corresponding to this expression.
Definition: DenseBase.h:204
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
CoeffReturnType value() const
Definition: DenseBase.h:515
Derived & derived()
Definition: EigenBase.h:48
Expression of an array as a mathematical vector or matrix.
Definition: ArrayWrapper.h:143
Namespace containing all symbols from the Eigen library.
Definition: Core:139
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231