File indexing completed on 2025-01-18 09:56:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_INVERSE_H
0011 #define EIGEN_INVERSE_H
0012
0013 namespace Eigen {
0014
0015 template<typename XprType,typename StorageKind> class InverseImpl;
0016
0017 namespace internal {
0018
0019 template<typename XprType>
0020 struct traits<Inverse<XprType> >
0021 : traits<typename XprType::PlainObject>
0022 {
0023 typedef typename XprType::PlainObject PlainObject;
0024 typedef traits<PlainObject> BaseTraits;
0025 enum {
0026 Flags = BaseTraits::Flags & RowMajorBit
0027 };
0028 };
0029
0030 }
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 template<typename XprType>
0043 class Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind>
0044 {
0045 public:
0046 typedef typename XprType::StorageIndex StorageIndex;
0047 typedef typename XprType::Scalar Scalar;
0048 typedef typename internal::ref_selector<XprType>::type XprTypeNested;
0049 typedef typename internal::remove_all<XprTypeNested>::type XprTypeNestedCleaned;
0050 typedef typename internal::ref_selector<Inverse>::type Nested;
0051 typedef typename internal::remove_all<XprType>::type NestedExpression;
0052
0053 explicit EIGEN_DEVICE_FUNC Inverse(const XprType &xpr)
0054 : m_xpr(xpr)
0055 {}
0056
0057 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_xpr.cols(); }
0058 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_xpr.rows(); }
0059
0060 EIGEN_DEVICE_FUNC const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; }
0061
0062 protected:
0063 XprTypeNested m_xpr;
0064 };
0065
0066
0067 template<typename XprType, typename StorageKind>
0068 class InverseImpl
0069 : public internal::generic_xpr_base<Inverse<XprType> >::type
0070 {
0071 public:
0072 typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;
0073 typedef typename XprType::Scalar Scalar;
0074 private:
0075
0076 Scalar coeff(Index row, Index col) const;
0077 Scalar coeff(Index i) const;
0078 };
0079
0080 namespace internal {
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 template<typename ArgType>
0093 struct unary_evaluator<Inverse<ArgType> >
0094 : public evaluator<typename Inverse<ArgType>::PlainObject>
0095 {
0096 typedef Inverse<ArgType> InverseType;
0097 typedef typename InverseType::PlainObject PlainObject;
0098 typedef evaluator<PlainObject> Base;
0099
0100 enum { Flags = Base::Flags | EvalBeforeNestingBit };
0101
0102 unary_evaluator(const InverseType& inv_xpr)
0103 : m_result(inv_xpr.rows(), inv_xpr.cols())
0104 {
0105 ::new (static_cast<Base*>(this)) Base(m_result);
0106 internal::call_assignment_no_alias(m_result, inv_xpr);
0107 }
0108
0109 protected:
0110 PlainObject m_result;
0111 };
0112
0113 }
0114
0115 }
0116
0117 #endif