WPILibC++ 2023.4.3-108-ge5452e3
Inverse.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) 2014-2019 Gael Guennebaud <gael.guennebaud@inria.fr>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_INVERSE_H
11#define EIGEN_INVERSE_H
12
13namespace Eigen {
14
15template<typename XprType,typename StorageKind> class InverseImpl;
16
17namespace internal {
18
19template<typename XprType>
20struct traits<Inverse<XprType> >
21 : traits<typename XprType::PlainObject>
22{
23 typedef typename XprType::PlainObject PlainObject;
25 enum {
26 Flags = BaseTraits::Flags & RowMajorBit
27 };
28};
29
30} // end namespace internal
31
32/** \class Inverse
33 *
34 * \brief Expression of the inverse of another expression
35 *
36 * \tparam XprType the type of the expression we are taking the inverse
37 *
38 * This class represents an abstract expression of A.inverse()
39 * and most of the time this is the only way it is used.
40 *
41 */
42template<typename XprType>
43class Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind>
44{
45public:
46 typedef typename XprType::StorageIndex StorageIndex;
47 typedef typename XprType::Scalar Scalar;
52
53 explicit EIGEN_DEVICE_FUNC Inverse(const XprType &xpr)
54 : m_xpr(xpr)
55 {}
56
59
61
62protected:
64};
65
66// Generic API dispatcher
67template<typename XprType, typename StorageKind>
69 : public internal::generic_xpr_base<Inverse<XprType> >::type
70{
71public:
73 typedef typename XprType::Scalar Scalar;
74private:
75
76 Scalar coeff(Index row, Index col) const;
77 Scalar coeff(Index i) const;
78};
79
80namespace internal {
81
82/** \internal
83 * \brief Default evaluator for Inverse expression.
84 *
85 * This default evaluator for Inverse expression simply evaluate the inverse into a temporary
86 * by a call to internal::call_assignment_no_alias.
87 * Therefore, inverse implementers only have to specialize Assignment<Dst,Inverse<...>, ...> for
88 * there own nested expression.
89 *
90 * \sa class Inverse
91 */
92template<typename ArgType>
93struct unary_evaluator<Inverse<ArgType> >
94 : public evaluator<typename Inverse<ArgType>::PlainObject>
95{
97 typedef typename InverseType::PlainObject PlainObject;
99
100 enum { Flags = Base::Flags | EvalBeforeNestingBit };
101
103 : m_result(inv_xpr.rows(), inv_xpr.cols())
104 {
105 ::new (static_cast<Base*>(this)) Base(m_result);
106 internal::call_assignment_no_alias(m_result, inv_xpr);
107 }
108
109protected:
111};
112
113} // end namespace internal
114
115} // end namespace Eigen
116
117#endif // EIGEN_INVERSE_H
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ColXpr col(Index i)
This is the const version of col().
Definition: BlockMethods.h:1097
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE RowXpr row(Index i)
This is the const version of row(). *‍/.
Definition: BlockMethods.h:1118
#define EIGEN_NOEXCEPT
Definition: Macros.h:1428
#define EIGEN_CONSTEXPR
Definition: Macros.h:797
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
Expression of the inverse of another expression.
Definition: Inverse.h:44
internal::ref_selector< XprType >::type XprTypeNested
Definition: Inverse.h:48
EIGEN_DEVICE_FUNC const XprTypeNestedCleaned & nestedExpression() const
Definition: Inverse.h:60
XprType::StorageIndex StorageIndex
Definition: Inverse.h:46
internal::remove_all< XprType >::type NestedExpression
Definition: Inverse.h:51
internal::ref_selector< Inverse >::type Nested
Definition: Inverse.h:50
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Inverse.h:58
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: Inverse.h:57
XprTypeNested m_xpr
Definition: Inverse.h:63
internal::remove_all< XprTypeNested >::type XprTypeNestedCleaned
Definition: Inverse.h:49
EIGEN_DEVICE_FUNC Inverse(const XprType &xpr)
Definition: Inverse.h:53
XprType::Scalar Scalar
Definition: Inverse.h:47
Definition: Inverse.h:70
internal::generic_xpr_base< Inverse< XprType > >::type Base
Definition: Inverse.h:72
XprType::Scalar Scalar
Definition: Inverse.h:73
type
Definition: core.h:575
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition: Constants.h:70
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:66
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:873
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: Eigen_Colamd.h:50
Definition: CoreEvaluators.h:91
Definition: XprHelper.h:501
T type
Definition: Meta.h:126
XprType::PlainObject PlainObject
Definition: Inverse.h:23
traits< PlainObject > BaseTraits
Definition: Inverse.h:24
Definition: ForwardDeclarations.h:17
Definition: Meta.h:96
unary_evaluator(const InverseType &inv_xpr)
Definition: Inverse.h:102
InverseType::PlainObject PlainObject
Definition: Inverse.h:97
PlainObject m_result
Definition: Inverse.h:110
evaluator< PlainObject > Base
Definition: Inverse.h:98
Inverse< ArgType > InverseType
Definition: Inverse.h:96
Definition: CoreEvaluators.h:65