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 
28 template<typename Derived> struct EigenBase
29 {
30 // typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
31 
38 
39  // FIXME is it needed?
41 
43  EIGEN_DEVICE_FUNC
44  Derived& derived() { return *static_cast<Derived*>(this); }
46  EIGEN_DEVICE_FUNC
47  const Derived& derived() const { return *static_cast<const Derived*>(this); }
48 
49  EIGEN_DEVICE_FUNC
50  inline Derived& const_cast_derived() const
51  { return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
52  EIGEN_DEVICE_FUNC
53  inline const Derived& const_derived() const
54  { return *static_cast<const Derived*>(this); }
55 
57  EIGEN_DEVICE_FUNC
58  inline Index rows() const { return derived().rows(); }
60  EIGEN_DEVICE_FUNC
61  inline Index cols() const { return derived().cols(); }
64  EIGEN_DEVICE_FUNC
65  inline Index size() const { return rows() * cols(); }
66 
68  template<typename Dest>
69  EIGEN_DEVICE_FUNC
70  inline void evalTo(Dest& dst) const
71  { derived().evalTo(dst); }
72 
74  template<typename Dest>
75  EIGEN_DEVICE_FUNC
76  inline void addTo(Dest& dst) const
77  {
78  // This is the default implementation,
79  // derived class can reimplement it in a more optimized way.
80  typename Dest::PlainObject res(rows(),cols());
81  evalTo(res);
82  dst += res;
83  }
84 
86  template<typename Dest>
87  EIGEN_DEVICE_FUNC
88  inline void subTo(Dest& dst) const
89  {
90  // This is the default implementation,
91  // derived class can reimplement it in a more optimized way.
92  typename Dest::PlainObject res(rows(),cols());
93  evalTo(res);
94  dst -= res;
95  }
96 
98  template<typename Dest>
99  EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const
100  {
101  // This is the default implementation,
102  // derived class can reimplement it in a more optimized way.
103  dst = dst * this->derived();
104  }
105 
107  template<typename Dest>
108  EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const
109  {
110  // This is the default implementation,
111  // derived class can reimplement it in a more optimized way.
112  dst = this->derived() * dst;
113  }
114 
115 };
116 
117 /***************************************************************************
118 * Implementation of matrix base methods
119 ***************************************************************************/
120 
129 template<typename Derived>
130 template<typename OtherDerived>
132 {
133  call_assignment(derived(), other.derived());
134  return derived();
135 }
136 
137 template<typename Derived>
138 template<typename OtherDerived>
140 {
142  return derived();
143 }
144 
145 template<typename Derived>
146 template<typename OtherDerived>
148 {
150  return derived();
151 }
152 
153 } // end namespace Eigen
154 
155 #endif // EIGEN_EIGENBASE_H
EIGEN_DEVICE_FUNC Derived & operator-=(const EigenBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC Index rows() const
Definition: EigenBase.h:58
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition: EigenBase.h:70
EIGEN_DEVICE_FUNC Derived & const_cast_derived() const
Definition: EigenBase.h:50
Definition: LDLT.h:16
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:37
EIGEN_DEVICE_FUNC void applyThisOnTheLeft(Dest &dst) const
Definition: EigenBase.h:108
EIGEN_DEVICE_FUNC const Derived & derived() const
Definition: EigenBase.h:47
EIGEN_DEVICE_FUNC Derived & operator+=(const EigenBase< OtherDerived > &other)
EIGEN_DEVICE_FUNC void applyThisOnTheRight(Dest &dst) const
Definition: EigenBase.h:99
EIGEN_DEVICE_FUNC void subTo(Dest &dst) const
Definition: EigenBase.h:88
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator=(const DenseBase< OtherDerived > &other)
Definition: Assign.h:39
EIGEN_DEVICE_FUNC const Derived & const_derived() const
Definition: EigenBase.h:53
internal::traits< Derived >::StorageKind StorageKind
Definition: EigenBase.h:40
EIGEN_DEVICE_FUNC Index cols() const
Definition: EigenBase.h:61
EIGEN_DEVICE_FUNC Index size() const
Definition: EigenBase.h:65
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:44
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:76


co_scan
Author(s):
autogenerated on Mon Feb 28 2022 23:00:41