10#ifndef EIGEN_ARRAYBASE_H
11#define EIGEN_ARRAYBASE_H
39template<
typename Derived>
class ArrayBase
43#ifndef EIGEN_PARSED_BY_DOXYGEN
45 typedef ArrayBase StorageBaseType;
47 typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl;
49 typedef typename internal::traits<Derived>::StorageKind StorageKind;
50 typedef typename internal::traits<Derived>::Index
Index;
51 typedef typename internal::traits<Derived>::Scalar Scalar;
52 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
53 typedef typename NumTraits<Scalar>::Real RealScalar;
56 using Base::operator*;
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;
65 using Base::CoeffReadCost;
68 using Base::const_cast_derived;
74 using Base::lazyAssign;
75 using Base::operator=;
76 using Base::operator+=;
77 using Base::operator-=;
78 using Base::operator*=;
79 using Base::operator/=;
81 typedef typename Base::CoeffReturnType CoeffReturnType;
85#ifndef EIGEN_PARSED_BY_DOXYGEN
92 internal::traits<Derived>::RowsAtCompileTime,
93 internal::traits<Derived>::ColsAtCompileTime,
95 internal::traits<Derived>::MaxRowsAtCompileTime,
96 internal::traits<Derived>::MaxColsAtCompileTime
104#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
105# include "../plugins/CommonCwiseUnaryOps.h"
106# include "../plugins/MatrixCwiseUnaryOps.h"
107# include "../plugins/ArrayCwiseUnaryOps.h"
108# include "../plugins/CommonCwiseBinaryOps.h"
109# include "../plugins/MatrixCwiseBinaryOps.h"
110# include "../plugins/ArrayCwiseBinaryOps.h"
111# ifdef EIGEN_ARRAYBASE_PLUGIN
112# include EIGEN_ARRAYBASE_PLUGIN
114#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
121 return internal::assign_selector<Derived,Derived>::run(derived(), other.derived());
124 Derived& operator+=(
const Scalar& scalar)
125 {
return *
this = derived() + scalar; }
126 Derived& operator-=(
const Scalar& scalar)
127 {
return *
this = derived() - scalar; }
129 template<
typename OtherDerived>
131 template<
typename OtherDerived>
134 template<
typename OtherDerived>
137 template<
typename OtherDerived>
141 ArrayBase<Derived>& array() {
return *
this; }
153 ArrayBase() : Base() {}
156 explicit ArrayBase(
Index);
158 template<
typename OtherDerived>
explicit ArrayBase(
const ArrayBase<OtherDerived>&);
162 {EIGEN_STATIC_ASSERT(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);
return *
this;}
165 {EIGEN_STATIC_ASSERT(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);
return *
this;}
172template<
typename Derived>
173template<
typename OtherDerived>
174EIGEN_STRONG_INLINE Derived &
175ArrayBase<Derived>::operator-=(
const ArrayBase<OtherDerived> &other)
177 SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived());
178 tmp = other.derived();
186template<
typename Derived>
187template<
typename OtherDerived>
188EIGEN_STRONG_INLINE Derived &
189ArrayBase<Derived>::operator+=(
const ArrayBase<OtherDerived>& other)
191 SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived());
192 tmp = other.derived();
200template<
typename Derived>
201template<
typename OtherDerived>
202EIGEN_STRONG_INLINE Derived &
205 SelfCwiseBinaryOp<internal::scalar_product_op<Scalar>, Derived, OtherDerived> tmp(derived());
206 tmp = other.derived();
214template<
typename Derived>
215template<
typename OtherDerived>
216EIGEN_STRONG_INLINE Derived &
219 SelfCwiseBinaryOp<internal::scalar_quotient_op<Scalar>, Derived, OtherDerived> tmp(derived());
220 tmp = other.derived();
Base class for all 1D and 2D array, and related expressions.
Definition ArrayBase.h:41
Derived & operator*=(const ArrayBase< OtherDerived > &other)
Definition ArrayBase.h:203
Derived & operator-=(const ArrayBase< OtherDerived > &other)
Definition ArrayBase.h:175
Derived & operator=(const ArrayBase &other)
Definition ArrayBase.h:119
MatrixWrapper< Derived > matrix()
Definition ArrayBase.h:146
Derived & operator+=(const ArrayBase< OtherDerived > &other)
Definition ArrayBase.h:189
Derived & operator/=(const ArrayBase< OtherDerived > &other)
Definition ArrayBase.h:217
General-purpose arrays with easy API for coefficient-wise operations.
Definition Array.h:44
Generic expression of a matrix where all coefficients are defined by a functor.
Definition CwiseNullaryOp.h:51
DenseBase()
Definition DenseBase.h:501
internal::traits< Array< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::Index Index
Definition DenseBase.h:60
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Expression of an array as a mathematical vector or matrix.
Definition ArrayWrapper.h:167
@ AutoAlign
Definition Constants.h:268
@ RowMajor
Definition Constants.h:266
@ ColMajor
Definition Constants.h:264
const unsigned int RowMajorBit
Definition Constants.h:53