Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
 
Loading...
Searching...
No Matches
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
14namespace Eigen {
15
29template<typename Derived> struct EigenBase
30{
31// typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
32
40
41 // FIXME is it needed?
42 typedef typename internal::traits<Derived>::StorageKind StorageKind;
43
45 EIGEN_DEVICE_FUNC
46 Derived& derived() { return *static_cast<Derived*>(this); }
48 EIGEN_DEVICE_FUNC
49 const Derived& derived() const { return *static_cast<const Derived*>(this); }
50
51 EIGEN_DEVICE_FUNC
52 inline Derived& const_cast_derived() const
53 { return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
54 EIGEN_DEVICE_FUNC
55 inline const Derived& const_derived() const
56 { return *static_cast<const Derived*>(this); }
57
59 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
60 inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); }
62 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
63 inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); }
66 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
67 inline Index size() const EIGEN_NOEXCEPT { return rows() * cols(); }
68
70 template<typename Dest>
71 EIGEN_DEVICE_FUNC
72 inline void evalTo(Dest& dst) const
73 { derived().evalTo(dst); }
74
76 template<typename Dest>
77 EIGEN_DEVICE_FUNC
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>
89 EIGEN_DEVICE_FUNC
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
131template<typename Derived>
132template<typename OtherDerived>
133EIGEN_DEVICE_FUNC
135{
136 call_assignment(derived(), other.derived());
137 return derived();
138}
139
140template<typename Derived>
141template<typename OtherDerived>
142EIGEN_DEVICE_FUNC
144{
145 call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
146 return derived();
147}
148
149template<typename Derived>
150template<typename OtherDerived>
151EIGEN_DEVICE_FUNC
152Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)
153{
154 call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
155 return derived();
156}
157
158} // end namespace Eigen
159
160#endif // EIGEN_EIGENBASE_H
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:47
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: EigenBase.h:30
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:63
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:39
Derived & derived()
Definition: EigenBase.h:46
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:60
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:67
const Derived & derived() const
Definition: EigenBase.h:49