Eigen  3.4.90 (git rev a4098ac676528a83cfb73d4d26ce1b42ec05f47c)
Inverse.h
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
13#include "./InternalHeaderCheck.h"
14
15namespace Eigen {
16
17template<typename XprType,typename StorageKind> class InverseImpl;
18
19namespace internal {
20
21template<typename XprType>
22struct traits<Inverse<XprType> >
23 : traits<typename XprType::PlainObject>
24{
25 typedef typename XprType::PlainObject PlainObject;
26 typedef traits<PlainObject> BaseTraits;
27 enum {
28 Flags = BaseTraits::Flags & RowMajorBit
29 };
30};
31
32} // end namespace internal
33
44template<typename XprType>
45class Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind>
46{
47public:
48 typedef typename XprType::StorageIndex StorageIndex;
49 typedef typename XprType::Scalar Scalar;
50 typedef typename internal::ref_selector<XprType>::type XprTypeNested;
51 typedef typename internal::remove_all<XprTypeNested>::type XprTypeNestedCleaned;
52 typedef typename internal::ref_selector<Inverse>::type Nested;
53 typedef typename internal::remove_all<XprType>::type NestedExpression;
54
55 explicit EIGEN_DEVICE_FUNC Inverse(const XprType &xpr)
56 : m_xpr(xpr)
57 {}
58
59 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_xpr.cols(); }
60 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_xpr.rows(); }
61
62 EIGEN_DEVICE_FUNC const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; }
63
64protected:
65 XprTypeNested m_xpr;
66};
67
68// Generic API dispatcher
69template<typename XprType, typename StorageKind>
70class InverseImpl
71 : public internal::generic_xpr_base<Inverse<XprType> >::type
72{
73public:
74 typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;
75 typedef typename XprType::Scalar Scalar;
76private:
77
78 Scalar coeff(Index row, Index col) const;
79 Scalar coeff(Index i) const;
80};
81
82namespace internal {
83
94template<typename ArgType>
95struct unary_evaluator<Inverse<ArgType> >
96 : public evaluator<typename Inverse<ArgType>::PlainObject>
97{
98 typedef Inverse<ArgType> InverseType;
99 typedef typename InverseType::PlainObject PlainObject;
100 typedef evaluator<PlainObject> Base;
101
102 enum { Flags = Base::Flags | EvalBeforeNestingBit };
103
104 unary_evaluator(const InverseType& inv_xpr)
105 : m_result(inv_xpr.rows(), inv_xpr.cols())
106 {
107 ::new (static_cast<Base*>(this)) Base(m_result);
108 internal::call_assignment_no_alias(m_result, inv_xpr);
109 }
110
111protected:
112 PlainObject m_result;
113};
114
115} // end namespace internal
116
117} // end namespace Eigen
118
119#endif // EIGEN_INVERSE_H
Expression of the inverse of another expression.
Definition: Inverse.h:46
const unsigned int EvalBeforeNestingBit
Definition: Constants.h:72
const unsigned int RowMajorBit
Definition: Constants.h:68
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:59