Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
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 
15 namespace Eigen {
16 
17 template<typename XprType,typename StorageKind> class InverseImpl;
18 
19 namespace internal {
20 
21 template<typename XprType>
22 struct 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 
44 template<typename XprType>
45 class Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind>
46 {
47 public:
48  typedef typename XprType::StorageIndex StorageIndex;
49  typedef typename XprType::Scalar Scalar;
50  typedef typename internal::ref_selector<XprType>::type XprTypeNested;
51  typedef internal::remove_all_t<XprTypeNested> XprTypeNestedCleaned;
52  typedef typename internal::ref_selector<Inverse>::type Nested;
53  typedef internal::remove_all_t<XprType> 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 
64 protected:
65  XprTypeNested m_xpr;
66 };
67 
68 // Generic API dispatcher
69 template<typename XprType, typename StorageKind>
70 class InverseImpl
71  : public internal::generic_xpr_base<Inverse<XprType> >::type
72 {
73 public:
74  typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;
75  typedef typename XprType::Scalar Scalar;
76 private:
77 
78  Scalar coeff(Index row, Index col) const;
79  Scalar coeff(Index i) const;
80 };
81 
82 namespace internal {
83 
94 template<typename ArgType>
95 struct 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  internal::construct_at<Base>(this, m_result);
108  internal::call_assignment_no_alias(m_result, inv_xpr);
109  }
110 
111 protected:
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: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59