Eigen  3.4.90 (git rev 9589cc4e7fd8e4538bedef80dd36c7738977a8be)
 
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
32template <typename Derived>
33struct EigenBase {
34 // typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
35
44
45 // FIXME is it needed?
46 typedef typename internal::traits<Derived>::StorageKind StorageKind;
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(); }
64 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index size() const EIGEN_NOEXCEPT { return rows() * 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());
78 evalTo(res);
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>
109 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper<Derived, Device> device(Device& device);
110 template <typename Device>
111 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper<const Derived, Device> device(Device& device) const;
112};
113
114/***************************************************************************
115 * Implementation of matrix base methods
116 ***************************************************************************/
117
126template <typename Derived>
127template <typename OtherDerived>
128EIGEN_DEVICE_FUNC Derived& DenseBase<Derived>::operator=(const EigenBase<OtherDerived>& other) {
129 call_assignment(derived(), other.derived());
130 return derived();
131}
132
133template <typename Derived>
134template <typename OtherDerived>
135EIGEN_DEVICE_FUNC Derived& DenseBase<Derived>::operator+=(const EigenBase<OtherDerived>& other) {
136 call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar, typename OtherDerived::Scalar>());
137 return derived();
138}
139
140template <typename Derived>
141template <typename OtherDerived>
142EIGEN_DEVICE_FUNC Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived>& other) {
143 call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>());
144 return derived();
145}
146
147} // end namespace Eigen
148
149#endif // EIGEN_EIGENBASE_H
Derived & operator=(const DenseBase< OtherDerived > &other)
Definition Assign.h:39
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
Definition ForwardDeclarations.h:57
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition EigenBase.h:61
constexpr Derived & derived()
Definition EigenBase.h:49
Eigen::Index Index
Definition EigenBase.h:43
constexpr const Derived & derived() const
Definition EigenBase.h:51
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition EigenBase.h:59
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition EigenBase.h:64