OSVR-Core
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 namespace Eigen {
14 
15 template<typename ExpressionType> class MatrixWrapper;
16 
39 template<typename Derived> class ArrayBase
40  : public DenseBase<Derived>
41 {
42  public:
43 #ifndef EIGEN_PARSED_BY_DOXYGEN
44 
46 
48 
49  typedef typename internal::traits<Derived>::StorageKind StorageKind;
51  typedef typename internal::traits<Derived>::Scalar Scalar;
52  typedef typename internal::packet_traits<Scalar>::type PacketScalar;
53  typedef typename NumTraits<Scalar>::Real RealScalar;
54 
55  typedef DenseBase<Derived> Base;
56  using Base::operator*;
64  using Base::Flags;
65  using Base::CoeffReadCost;
66 
67  using Base::derived;
68  using Base::const_cast_derived;
69  using Base::rows;
70  using Base::cols;
71  using Base::size;
72  using Base::coeff;
73  using Base::coeffRef;
74  using Base::lazyAssign;
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 
97  > PlainObject;
98 
99 
102 #endif // not EIGEN_PARSED_BY_DOXYGEN
103 
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
113 # endif
114 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
115 
119  Derived& operator=(const ArrayBase& other)
120  {
121  return internal::assign_selector<Derived,Derived>::run(derived(), other.derived());
122  }
123 
124  Derived& operator+=(const Scalar& scalar)
125  { return *this = derived() + scalar; }
126  Derived& operator-=(const Scalar& scalar)
127  { return *this = derived() - scalar; }
128 
129  template<typename OtherDerived>
130  Derived& operator+=(const ArrayBase<OtherDerived>& other);
131  template<typename OtherDerived>
132  Derived& operator-=(const ArrayBase<OtherDerived>& other);
133 
134  template<typename OtherDerived>
135  Derived& operator*=(const ArrayBase<OtherDerived>& other);
136 
137  template<typename OtherDerived>
138  Derived& operator/=(const ArrayBase<OtherDerived>& other);
139 
140  public:
141  ArrayBase<Derived>& array() { return *this; }
142  const ArrayBase<Derived>& array() const { return *this; }
143 
146  MatrixWrapper<Derived> matrix() { return derived(); }
147  const MatrixWrapper<const Derived> matrix() const { return derived(); }
148 
149 // template<typename Dest>
150 // inline void evalTo(Dest& dst) const { dst = matrix(); }
151 
152  protected:
153  ArrayBase() : Base() {}
154 
155  private:
156  explicit ArrayBase(Index);
157  ArrayBase(Index,Index);
158  template<typename OtherDerived> explicit ArrayBase(const ArrayBase<OtherDerived>&);
159  protected:
160  // mixing arrays and matrices is not legal
161  template<typename OtherDerived> Derived& operator+=(const MatrixBase<OtherDerived>& )
162  {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
163  // mixing arrays and matrices is not legal
164  template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& )
165  {EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
166 };
172 template<typename Derived>
173 template<typename OtherDerived>
174 EIGEN_STRONG_INLINE Derived &
176 {
177  SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, Derived, OtherDerived> tmp(derived());
178  tmp = other.derived();
179  return derived();
180 }
181 
186 template<typename Derived>
187 template<typename OtherDerived>
188 EIGEN_STRONG_INLINE Derived &
190 {
191  SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, Derived, OtherDerived> tmp(derived());
192  tmp = other.derived();
193  return derived();
194 }
195 
200 template<typename Derived>
201 template<typename OtherDerived>
202 EIGEN_STRONG_INLINE Derived &
204 {
205  SelfCwiseBinaryOp<internal::scalar_product_op<Scalar>, Derived, OtherDerived> tmp(derived());
206  tmp = other.derived();
207  return derived();
208 }
209 
214 template<typename Derived>
215 template<typename OtherDerived>
216 EIGEN_STRONG_INLINE Derived &
218 {
219  SelfCwiseBinaryOp<internal::scalar_quotient_op<Scalar>, Derived, OtherDerived> tmp(derived());
220  tmp = other.derived();
221  return derived();
222 }
223 
224 } // end namespace Eigen
225 
226 #endif // EIGEN_ARRAYBASE_H
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:49
ArrayBase StorageBaseType
The base class for a given storage type.
Definition: ArrayBase.h:45
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:60
This is a rough measure of how expensive it is to read one coefficient from this expression.
Definition: DenseBase.h:172
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
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:155
Holds information about the various numeric (i.e.
Definition: NumTraits.h:88
This is equal to the number of coefficients, i.e.
Definition: DenseBase.h:115
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:53
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
detail::size< coerce_list< Ts... >> size
Get the size of a list (number of elements.)
Definition: Size.h:56
Expression of an array as a mathematical vector or matrix.
Definition: ArrayBase.h:15
This stores expression Flags flags which may or may not be inherited by new expressions constructed f...
Definition: DenseBase.h:162
Definition: SelfCwiseBinaryOp.h:45
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:264
Definition: XprHelper.h:371
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:119
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:39
Definition: Assign.h:523
MatrixWrapper< Derived > matrix()
Definition: ArrayBase.h:146
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:266
The number of columns at compile-time.
Definition: DenseBase.h:108
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:42
This value is equal to the maximum possible number of coefficients that this expression might have...
Definition: DenseBase.h:143
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
This value is equal to the maximum possible number of rows that this expression might have...
Definition: DenseBase.h:121
Definition: ForwardDeclarations.h:17
Align the matrix itself if it is vectorizable fixed-size.
Definition: Constants.h:268
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48
The number of rows at compile-time.
Definition: DenseBase.h:102
This value is equal to the maximum possible number of columns that this expression might have...
Definition: DenseBase.h:132