Medial Code Documentation
Loading...
Searching...
No Matches
Inverse.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2014 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
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::PlainObject PlainObject;
52
53 explicit Inverse(const XprType &xpr)
54 : m_xpr(xpr)
55 {}
56
57 EIGEN_DEVICE_FUNC Index rows() const { return m_xpr.rows(); }
58 EIGEN_DEVICE_FUNC Index cols() const { return m_xpr.cols(); }
59
60 EIGEN_DEVICE_FUNC const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; }
61
62protected:
63 XprTypeNested m_xpr;
64};
65
66// Generic API dispatcher
67template<typename XprType, typename StorageKind>
69 : public internal::generic_xpr_base<Inverse<XprType> >::type
70{
71public:
72 typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;
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
92template<typename ArgType>
93struct unary_evaluator<Inverse<ArgType> >
94 : public evaluator<typename Inverse<ArgType>::PlainObject>
95{
96 typedef Inverse<ArgType> InverseType;
97 typedef typename InverseType::PlainObject PlainObject;
98 typedef evaluator<PlainObject> Base;
99
100 enum { Flags = Base::Flags | EvalBeforeNestingBit };
101
102 unary_evaluator(const InverseType& inv_xpr)
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:
110 PlainObject m_result;
111};
112
113} // end namespace internal
114
115} // end namespace Eigen
116
117#endif // EIGEN_INVERSE_H
Definition Inverse.h:70
Expression of the inverse of another expression.
Definition Inverse.h:44
Pseudo expression representing a solving operation.
Definition Solve.h:63
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition Constants.h:65
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition XprHelper.h:445
Definition ForwardDeclarations.h:17
Definition Meta.h:30