Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
EigenBase.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
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_EIGENBASE_H
12 #define EIGEN_EIGENBASE_H
13 
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
31 template<typename Derived> struct EigenBase
32 {
33 // typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
34 
42 
43  // FIXME is it needed?
44  typedef typename internal::traits<Derived>::StorageKind StorageKind;
45 
47  EIGEN_DEVICE_FUNC
48  Derived& derived() { return *static_cast<Derived*>(this); }
50  EIGEN_DEVICE_FUNC
51  const Derived& derived() const { return *static_cast<const Derived*>(this); }
52 
53  EIGEN_DEVICE_FUNC
54  inline Derived& const_cast_derived() const
55  { return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
56  EIGEN_DEVICE_FUNC
57  inline const Derived& const_derived() const
58  { return *static_cast<const Derived*>(this); }
59 
61  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
62  inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); }
64  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
65  inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); }
68  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
69  inline Index size() const EIGEN_NOEXCEPT { return rows() * cols(); }
70 
72  template<typename Dest>
73  EIGEN_DEVICE_FUNC
74  inline void evalTo(Dest& dst) const
75  { derived().evalTo(dst); }
76 
78  template<typename Dest>
79  EIGEN_DEVICE_FUNC
80  inline void addTo(Dest& dst) const
81  {
82  // This is the default implementation,
83  // derived class can reimplement it in a more optimized way.
84  typename Dest::PlainObject res(rows(),cols());
85  evalTo(res);
86  dst += res;
87  }
88 
90  template<typename Dest>
91  EIGEN_DEVICE_FUNC
92  inline void subTo(Dest& dst) const
93  {
94  // This is the default implementation,
95  // derived class can reimplement it in a more optimized way.
96  typename Dest::PlainObject res(rows(),cols());
97  evalTo(res);
98  dst -= res;
99  }
100 
102  template<typename Dest>
103  EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const
104  {
105  // This is the default implementation,
106  // derived class can reimplement it in a more optimized way.
107  dst = dst * this->derived();
108  }
109 
111  template<typename Dest>
112  EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const
113  {
114  // This is the default implementation,
115  // derived class can reimplement it in a more optimized way.
116  dst = this->derived() * dst;
117  }
118 
119 };
120 
121 /***************************************************************************
122 * Implementation of matrix base methods
123 ***************************************************************************/
124 
133 template<typename Derived>
134 template<typename OtherDerived>
135 EIGEN_DEVICE_FUNC
137 {
138  call_assignment(derived(), other.derived());
139  return derived();
140 }
141 
142 template<typename Derived>
143 template<typename OtherDerived>
144 EIGEN_DEVICE_FUNC
146 {
147  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
148  return derived();
149 }
150 
151 template<typename Derived>
152 template<typename OtherDerived>
153 EIGEN_DEVICE_FUNC
154 Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)
155 {
156  call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
157  return derived();
158 }
159 
160 } // end namespace Eigen
161 
162 #endif // EIGEN_EIGENBASE_H
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
Derived & operator=(const DenseBase< OtherDerived > &other)
Definition: Assign.h:41
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
Definition: EigenBase.h:32
Derived & derived()
Definition: EigenBase.h:48
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:69
const Derived & derived() const
Definition: EigenBase.h:51