/src/eigen/Eigen/src/Core/EigenBase.h
Line | Count | Source |
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 | | |
19 | | /** \class EigenBase |
20 | | * \ingroup Core_Module |
21 | | * |
22 | | * Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T). |
23 | | * |
24 | | * In other words, an EigenBase object is an object that can be copied into a MatrixBase. |
25 | | * |
26 | | * Besides MatrixBase-derived classes, this also includes special matrix classes such as diagonal matrices, etc. |
27 | | * |
28 | | * Notice that this class is trivial, it is only used to disambiguate overloaded functions. |
29 | | * |
30 | | * \sa \blank \ref TopicClassHierarchy |
31 | | */ |
32 | | template <typename Derived> |
33 | | struct EigenBase { |
34 | | // typedef typename internal::plain_matrix_type<Derived>::type PlainObject; |
35 | | |
36 | | /** \brief The interface type of indices |
37 | | * \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE. |
38 | | * \sa StorageIndex, \ref TopicPreprocessorDirectives. |
39 | | * DEPRECATED: Since Eigen 3.3, its usage is deprecated. Use Eigen::Index instead. |
40 | | * Deprecation is not marked with a doxygen comment because there are too many existing usages to add the deprecation |
41 | | * attribute. |
42 | | */ |
43 | | typedef Eigen::Index Index; |
44 | | |
45 | | // FIXME is it needed? |
46 | | typedef typename internal::traits<Derived>::StorageKind StorageKind; |
47 | | |
48 | | /** \returns a reference to the derived object */ |
49 | 18.7M | EIGEN_DEVICE_FUNC Derived& derived() { return *static_cast<Derived*>(this); } Eigen::EigenBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >::derived() Line | Count | Source | 49 | 41.0k | EIGEN_DEVICE_FUNC Derived& derived() { return *static_cast<Derived*>(this); } |
Eigen::EigenBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >::derived() Line | Count | Source | 49 | 18.6M | EIGEN_DEVICE_FUNC Derived& derived() { return *static_cast<Derived*>(this); } |
Eigen::EigenBase<Eigen::Transpose<Eigen::Matrix<int, -1, -1, 0, -1, -1> > >::derived() Line | Count | Source | 49 | 292 | EIGEN_DEVICE_FUNC Derived& derived() { return *static_cast<Derived*>(this); } |
|
50 | | /** \returns a const reference to the derived object */ |
51 | 74.7M | EIGEN_DEVICE_FUNC const Derived& derived() const { return *static_cast<const Derived*>(this); } Eigen::EigenBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >::derived() const Line | Count | Source | 51 | 82.9k | EIGEN_DEVICE_FUNC const Derived& derived() const { return *static_cast<const Derived*>(this); } |
Eigen::EigenBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >::derived() const Line | Count | Source | 51 | 74.6M | EIGEN_DEVICE_FUNC 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 | | |
58 | | /** \returns the number of rows. \sa cols(), RowsAtCompileTime */ |
59 | 37.3M | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); } Eigen::EigenBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >::rows() const Line | Count | Source | 59 | 41.0k | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); } |
Eigen::EigenBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >::rows() const Line | Count | Source | 59 | 37.3M | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); } |
|
60 | | /** \returns the number of columns. \sa rows(), ColsAtCompileTime*/ |
61 | 18.7M | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); } Eigen::EigenBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >::cols() const Line | Count | Source | 61 | 41.0k | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); } |
Eigen::EigenBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >::cols() const Line | Count | Source | 61 | 18.6M | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); } |
|
62 | | /** \returns the number of coefficients, which is rows()*cols(). |
63 | | * \sa rows(), cols(), SizeAtCompileTime. */ |
64 | 41.0k | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index size() const EIGEN_NOEXCEPT { return rows() * cols(); } Eigen::EigenBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >::size() const Line | Count | Source | 64 | 41.0k | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index size() const EIGEN_NOEXCEPT { return rows() * cols(); } |
Unexecuted instantiation: Eigen::EigenBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >::size() const |
65 | | |
66 | | /** \internal Don't use it, but do the equivalent: \code dst = *this; \endcode */ |
67 | | template <typename Dest> |
68 | | EIGEN_DEVICE_FUNC inline void evalTo(Dest& dst) const { |
69 | | derived().evalTo(dst); |
70 | | } |
71 | | |
72 | | /** \internal Don't use it, but do the equivalent: \code dst += *this; \endcode */ |
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 | | |
82 | | /** \internal Don't use it, but do the equivalent: \code dst -= *this; \endcode */ |
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 | | |
92 | | /** \internal Don't use it, but do the equivalent: \code dst.applyOnTheRight(*this); \endcode */ |
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 | | |
100 | | /** \internal Don't use it, but do the equivalent: \code dst.applyOnTheLeft(*this); \endcode */ |
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 | | |
109 | | /*************************************************************************** |
110 | | * Implementation of matrix base methods |
111 | | ***************************************************************************/ |
112 | | |
113 | | /** \brief Copies the generic expression \a other into *this. |
114 | | * |
115 | | * \details The expression must provide a (templated) evalTo(Derived& dst) const |
116 | | * function which does the actual job. In practice, this allows any user to write |
117 | | * its own special matrix without having to modify MatrixBase |
118 | | * |
119 | | * \returns a reference to *this. |
120 | | */ |
121 | | template <typename Derived> |
122 | | template <typename OtherDerived> |
123 | | EIGEN_DEVICE_FUNC Derived& DenseBase<Derived>::operator=(const EigenBase<OtherDerived>& other) { |
124 | | call_assignment(derived(), other.derived()); |
125 | | return derived(); |
126 | | } |
127 | | |
128 | | template <typename Derived> |
129 | | template <typename OtherDerived> |
130 | | EIGEN_DEVICE_FUNC Derived& DenseBase<Derived>::operator+=(const EigenBase<OtherDerived>& other) { |
131 | | call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar, typename OtherDerived::Scalar>()); |
132 | | return derived(); |
133 | | } |
134 | | |
135 | | template <typename Derived> |
136 | | template <typename OtherDerived> |
137 | | EIGEN_DEVICE_FUNC Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived>& other) { |
138 | | call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>()); |
139 | | return derived(); |
140 | | } |
141 | | |
142 | | } // end namespace Eigen |
143 | | |
144 | | #endif // EIGEN_EIGENBASE_H |