Medial Code Documentation
Loading...
Searching...
No Matches
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
13namespace Eigen {
14
15template<typename ExpressionType> class MatrixWrapper;
16
39template<typename Derived> class ArrayBase
40 : public DenseBase<Derived>
41{
42 public:
43#ifndef EIGEN_PARSED_BY_DOXYGEN
46
48
49 typedef typename internal::traits<Derived>::StorageKind StorageKind;
50 typedef typename internal::traits<Derived>::Scalar Scalar;
51 typedef typename internal::packet_traits<Scalar>::type PacketScalar;
52 typedef typename NumTraits<Scalar>::Real RealScalar;
53
55 using Base::operator*;
56 using Base::operator/;
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
80 typedef typename Base::CoeffReturnType CoeffReturnType;
81
82#endif // not EIGEN_PARSED_BY_DOXYGEN
83
84#ifndef EIGEN_PARSED_BY_DOXYGEN
85 typedef typename Base::PlainObject PlainObject;
86
89#endif // not EIGEN_PARSED_BY_DOXYGEN
90
91#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
92# include "../plugins/CommonCwiseUnaryOps.h"
93# include "../plugins/MatrixCwiseUnaryOps.h"
94# include "../plugins/ArrayCwiseUnaryOps.h"
95# include "../plugins/CommonCwiseBinaryOps.h"
96# include "../plugins/MatrixCwiseBinaryOps.h"
97# include "../plugins/ArrayCwiseBinaryOps.h"
98# ifdef EIGEN_ARRAYBASE_PLUGIN
99# include EIGEN_ARRAYBASE_PLUGIN
100# endif
101#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
102
107 Derived& operator=(const ArrayBase& other)
108 {
109 internal::call_assignment(derived(), other.derived());
110 return derived();
111 }
112
116 Derived& operator=(const Scalar &value)
117 { Base::setConstant(value); return derived(); }
118
120 Derived& operator+=(const Scalar& scalar);
122 Derived& operator-=(const Scalar& scalar);
123
124 template<typename OtherDerived>
126 Derived& operator+=(const ArrayBase<OtherDerived>& other);
127 template<typename OtherDerived>
129 Derived& operator-=(const ArrayBase<OtherDerived>& other);
130
131 template<typename OtherDerived>
133 Derived& operator*=(const ArrayBase<OtherDerived>& other);
134
135 template<typename OtherDerived>
137 Derived& operator/=(const ArrayBase<OtherDerived>& other);
138
139 public:
141 ArrayBase<Derived>& array() { return *this; }
142 EIGEN_DEVICE_FUNC
143 const ArrayBase<Derived>& array() const { return *this; }
144
147 EIGEN_DEVICE_FUNC
150 const MatrixWrapper<const Derived> matrix() const { return MatrixWrapper<const Derived>(derived()); }
151
152// template<typename Dest>
153// inline void evalTo(Dest& dst) const { dst = matrix(); }
154
155 protected:
156 EIGEN_DEVICE_FUNC
157 ArrayBase() : Base() {}
158
159 private:
160 explicit ArrayBase(Index);
161 ArrayBase(Index,Index);
162 template<typename OtherDerived> explicit ArrayBase(const ArrayBase<OtherDerived>&);
163 protected:
164 // mixing arrays and matrices is not legal
165 template<typename OtherDerived> Derived& operator+=(const MatrixBase<OtherDerived>& )
166 {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
167 // mixing arrays and matrices is not legal
168 template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& )
169 {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
170};
171
176template<typename Derived>
177template<typename OtherDerived>
178EIGEN_STRONG_INLINE Derived &
180{
181 call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar>());
182 return derived();
183}
184
189template<typename Derived>
190template<typename OtherDerived>
191EIGEN_STRONG_INLINE Derived &
193{
194 call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar>());
195 return derived();
196}
197
202template<typename Derived>
203template<typename OtherDerived>
204EIGEN_STRONG_INLINE Derived &
206{
207 call_assignment(derived(), other.derived(), internal::mul_assign_op<Scalar,typename OtherDerived::Scalar>());
208 return derived();
209}
210
215template<typename Derived>
216template<typename OtherDerived>
217EIGEN_STRONG_INLINE Derived &
219{
220 call_assignment(derived(), other.derived(), internal::div_assign_op<Scalar>());
221 return derived();
222}
223
224} // end namespace Eigen
225
226#endif // EIGEN_ARRAYBASE_H
Base class for all 1D and 2D array, and related expressions.
Definition ArrayBase.h:41
EIGEN_DEVICE_FUNC MatrixWrapper< Derived > matrix()
Definition ArrayBase.h:148
ArrayBase StorageBaseType
The base class for a given storage type.
Definition ArrayBase.h:45
EIGEN_DEVICE_FUNC Derived & operator=(const Scalar &value)
Set all the entries to value.
Definition ArrayBase.h:116
EIGEN_DEVICE_FUNC Derived & operator=(const ArrayBase &other)
Special case of the template operator=, in order to prevent the compiler from generating a default op...
Definition ArrayBase.h:107
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:49
EIGEN_DEVICE_FUNC Derived & setConstant(const Scalar &value)
Sets all coefficients in this expression to value.
Definition CwiseNullaryOp.h:336
EIGEN_DEVICE_FUNC CoeffReturnType value() const
Definition DenseBase.h:474
@ IsVectorAtCompileTime
This is set to true if either the number of rows or the number of columns is known at compile-time to...
Definition DenseBase.h:157
@ SizeAtCompileTime
This is equal to the number of coefficients, i.e.
Definition DenseBase.h:117
@ MaxSizeAtCompileTime
This value is equal to the maximum possible number of coefficients that this expression might have.
Definition DenseBase.h:145
@ Flags
This stores expression Flags flags which may or may not be inherited by new expressions constructed f...
Definition DenseBase.h:164
@ ColsAtCompileTime
The number of columns at compile-time.
Definition DenseBase.h:110
@ MaxColsAtCompileTime
This value is equal to the maximum possible number of columns that this expression might have.
Definition DenseBase.h:134
@ MaxRowsAtCompileTime
This value is equal to the maximum possible number of rows that this expression might have.
Definition DenseBase.h:123
@ RowsAtCompileTime
The number of rows at compile-time.
Definition DenseBase.h:104
EIGEN_DEVICE_FUNC Derived & lazyAssign(const DenseBase< OtherDerived > &other)
\ínternal Copies other into *this without evaluating other.
Pseudo expression representing a solving operation.
Definition Solve.h:63
Definition AssignmentFunctors.h:42
Definition AssignmentFunctors.h:107
Definition AssignmentFunctors.h:85
Definition AssignmentFunctors.h:63
Definition ForwardDeclarations.h:17
Definition Meta.h:30