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 // IWYU pragma: private
15 #include "./InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
32 template <typename Derived>
33 struct EigenBase {
34  // typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
35 
44 
45  // FIXME is it needed?
47 
49  EIGEN_DEVICE_FUNC constexpr Derived& derived() { return *static_cast<Derived*>(this); }
51  EIGEN_DEVICE_FUNC constexpr const Derived& derived() const { return *static_cast<const Derived*>(this); }
52 
53  EIGEN_DEVICE_FUNC inline Derived& const_cast_derived() const {
54  return *static_cast<Derived*>(const_cast<EigenBase*>(this));
55  }
56  EIGEN_DEVICE_FUNC inline const Derived& const_derived() const { return *static_cast<const Derived*>(this); }
57 
59  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); }
61  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); }
65 
67  template <typename Dest>
68  EIGEN_DEVICE_FUNC inline void evalTo(Dest& dst) const {
69  derived().evalTo(dst);
70  }
71 
73  template <typename Dest>
74  EIGEN_DEVICE_FUNC inline void addTo(Dest& dst) const {
75  // This is the default implementation,
76  // derived class can reimplement it in a more optimized way.
77  typename Dest::PlainObject res(rows(), cols());
79  dst += res;
80  }
81 
83  template <typename Dest>
84  EIGEN_DEVICE_FUNC inline void subTo(Dest& dst) const {
85  // This is the default implementation,
86  // derived class can reimplement it in a more optimized way.
87  typename Dest::PlainObject res(rows(), cols());
88  evalTo(res);
89  dst -= res;
90  }
91 
93  template <typename Dest>
94  EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const {
95  // This is the default implementation,
96  // derived class can reimplement it in a more optimized way.
97  dst = dst * this->derived();
98  }
99 
101  template <typename Dest>
102  EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const {
103  // This is the default implementation,
104  // derived class can reimplement it in a more optimized way.
105  dst = this->derived() * dst;
106  }
107 
108  template <typename Device>
110  template <typename Device>
112 };
113 
114 /***************************************************************************
115  * Implementation of matrix base methods
116  ***************************************************************************/
117 
126 template <typename Derived>
127 template <typename OtherDerived>
129  call_assignment(derived(), other.derived());
130  return derived();
131 }
132 
133 template <typename Derived>
134 template <typename OtherDerived>
137  return derived();
138 }
139 
140 template <typename Derived>
141 template <typename OtherDerived>
144  return derived();
145 }
146 
147 } // end namespace Eigen
148 
149 #endif // EIGEN_EIGENBASE_H
#define EIGEN_NOEXCEPT
Definition: Macros.h:1267
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator=(const DenseBase< OtherDerived > &other)
Definition: Assign.h:39
EIGEN_DEVICE_FUNC Derived & operator-=(const EigenBase< OtherDerived > &other)
Definition: EigenBase.h:142
EIGEN_DEVICE_FUNC Derived & operator+=(const EigenBase< OtherDerived > &other)
Definition: EigenBase.h:135
constexpr EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:49
void evalTo(MatrixBase< DenseDerived > &other) const
Definition: PermutationMatrix.h:100
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment(Dst &dst, const Src &src)
Definition: AssignEvaluator.h:781
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: DeviceWrapper.h:15
Definition: EigenBase.h:33
EIGEN_DEVICE_FUNC const Derived & const_derived() const
Definition: EigenBase.h:56
constexpr EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:49
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:61
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
EIGEN_DEVICE_FUNC Derived & const_cast_derived() const
Definition: EigenBase.h:53
EIGEN_DEVICE_FUNC void subTo(Dest &dst) const
Definition: EigenBase.h:84
internal::traits< Derived >::StorageKind StorageKind
Definition: EigenBase.h:46
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition: EigenBase.h:68
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:64
EIGEN_DEVICE_FUNC void applyThisOnTheRight(Dest &dst) const
Definition: EigenBase.h:94
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper< Derived, Device > device(Device &device)
Definition: DeviceWrapper.h:144
constexpr EIGEN_DEVICE_FUNC const Derived & derived() const
Definition: EigenBase.h:51
EIGEN_DEVICE_FUNC void applyThisOnTheLeft(Dest &dst) const
Definition: EigenBase.h:102
EIGEN_DEVICE_FUNC void addTo(Dest &dst) const
Definition: EigenBase.h:74
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:59
Template functor for scalar/packet assignment with addition.
Definition: AssignmentFunctors.h:52
Template functor for scalar/packet assignment with subtraction.
Definition: AssignmentFunctors.h:73
Definition: ForwardDeclarations.h:21