EigenBase.h
Go to the documentation of this file.
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 namespace Eigen {
15 
29 template<typename Derived> struct EigenBase
30 {
31 // typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
32 
40 
41  // FIXME is it needed?
43 
46  Derived& derived() { return *static_cast<Derived*>(this); }
49  const Derived& derived() const { return *static_cast<const Derived*>(this); }
50 
52  inline Derived& const_cast_derived() const
53  { return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
55  inline const Derived& const_derived() const
56  { return *static_cast<const Derived*>(this); }
57 
60  inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); }
63  inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); }
67  inline Index size() const EIGEN_NOEXCEPT { return rows() * cols(); }
68 
70  template<typename Dest>
72  inline void evalTo(Dest& dst) const
73  { derived().evalTo(dst); }
74 
76  template<typename Dest>
78  inline void addTo(Dest& dst) const
79  {
80  // This is the default implementation,
81  // derived class can reimplement it in a more optimized way.
82  typename Dest::PlainObject res(rows(),cols());
83  evalTo(res);
84  dst += res;
85  }
86 
88  template<typename Dest>
90  inline void subTo(Dest& dst) const
91  {
92  // This is the default implementation,
93  // derived class can reimplement it in a more optimized way.
94  typename Dest::PlainObject res(rows(),cols());
95  evalTo(res);
96  dst -= res;
97  }
98 
100  template<typename Dest>
101  EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const
102  {
103  // This is the default implementation,
104  // derived class can reimplement it in a more optimized way.
105  dst = dst * this->derived();
106  }
107 
109  template<typename Dest>
110  EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const
111  {
112  // This is the default implementation,
113  // derived class can reimplement it in a more optimized way.
114  dst = this->derived() * dst;
115  }
116 
117 };
118 
119 /***************************************************************************
120 * Implementation of matrix base methods
121 ***************************************************************************/
122 
131 template<typename Derived>
132 template<typename OtherDerived>
135 {
136  call_assignment(derived(), other.derived());
137  return derived();
138 }
139 
140 template<typename Derived>
141 template<typename OtherDerived>
144 {
146  return derived();
147 }
148 
149 template<typename Derived>
150 template<typename OtherDerived>
153 {
155  return derived();
156 }
157 
158 } // end namespace Eigen
159 
160 #endif // EIGEN_EIGENBASE_H
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition: EigenBase.h:72
EIGEN_DEVICE_FUNC Derived & operator+=(const EigenBase< OtherDerived > &other)
Definition: EigenBase.h:143
EIGEN_DEVICE_FUNC Derived & const_cast_derived() const
Definition: EigenBase.h:52
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:63
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:39
EIGEN_DEVICE_FUNC void applyThisOnTheLeft(Dest &dst) const
Definition: EigenBase.h:110
EIGEN_DEVICE_FUNC const Derived & derived() const
Definition: EigenBase.h:49
EIGEN_DEVICE_FUNC void applyThisOnTheRight(Dest &dst) const
Definition: EigenBase.h:101
EIGEN_DEVICE_FUNC Derived & operator-=(const EigenBase< OtherDerived > &other)
Definition: EigenBase.h:152
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
EIGEN_DEVICE_FUNC void subTo(Dest &dst) const
Definition: EigenBase.h:90
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:67
#define EIGEN_NOEXCEPT
Definition: Macros.h:1418
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator=(const DenseBase< OtherDerived > &other)
Definition: Assign.h:39
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
EIGEN_DEVICE_FUNC const Derived & const_derived() const
Definition: EigenBase.h:55
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:60
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
internal::traits< Derived >::StorageKind StorageKind
Definition: EigenBase.h:42
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment(Dst &dst, const Src &src)
EIGEN_DEVICE_FUNC void addTo(Dest &dst) const
Definition: EigenBase.h:78


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:11