MOAB  4.9.3pre
Inverse.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2014 Gael Guennebaud <[email protected]>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_INVERSE_H
00011 #define EIGEN_INVERSE_H
00012 
00013 namespace Eigen { 
00014 
00015 template<typename XprType,typename StorageKind> class InverseImpl;
00016 
00017 namespace internal {
00018 
00019 template<typename XprType>
00020 struct traits<Inverse<XprType> >
00021   : traits<typename XprType::PlainObject>
00022 {
00023   typedef typename XprType::PlainObject PlainObject;
00024   typedef traits<PlainObject> BaseTraits;
00025   enum {
00026     Flags = BaseTraits::Flags & RowMajorBit
00027   };
00028 };
00029 
00030 } // end namespace internal
00031 
00042 template<typename XprType>
00043 class Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind>
00044 {
00045 public:
00046   typedef typename XprType::StorageIndex StorageIndex;
00047   typedef typename XprType::PlainObject                       PlainObject;
00048   typedef typename internal::ref_selector<XprType>::type      XprTypeNested;
00049   typedef typename internal::remove_all<XprTypeNested>::type  XprTypeNestedCleaned;
00050   typedef typename internal::ref_selector<Inverse>::type Nested;
00051   typedef typename internal::remove_all<XprType>::type NestedExpression;
00052   
00053   explicit Inverse(const XprType &xpr)
00054     : m_xpr(xpr)
00055   {}
00056 
00057   EIGEN_DEVICE_FUNC Index rows() const { return m_xpr.rows(); }
00058   EIGEN_DEVICE_FUNC Index cols() const { return m_xpr.cols(); }
00059 
00060   EIGEN_DEVICE_FUNC const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; }
00061 
00062 protected:
00063   XprTypeNested m_xpr;
00064 };
00065 
00066 // Generic API dispatcher
00067 template<typename XprType, typename StorageKind>
00068 class InverseImpl
00069   : public internal::generic_xpr_base<Inverse<XprType> >::type
00070 {
00071 public:
00072   typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;
00073   typedef typename XprType::Scalar Scalar;
00074 private:
00075 
00076   Scalar coeff(Index row, Index col) const;
00077   Scalar coeff(Index i) const;
00078 };
00079 
00080 namespace internal {
00081 
00092 template<typename ArgType>
00093 struct unary_evaluator<Inverse<ArgType> >
00094   : public evaluator<typename Inverse<ArgType>::PlainObject>
00095 {
00096   typedef Inverse<ArgType> InverseType;
00097   typedef typename InverseType::PlainObject PlainObject;
00098   typedef evaluator<PlainObject> Base;
00099   
00100   enum { Flags = Base::Flags | EvalBeforeNestingBit };
00101 
00102   unary_evaluator(const InverseType& inv_xpr)
00103     : m_result(inv_xpr.rows(), inv_xpr.cols())
00104   {
00105     ::new (static_cast<Base*>(this)) Base(m_result);
00106     internal::call_assignment_no_alias(m_result, inv_xpr);
00107   }
00108   
00109 protected:
00110   PlainObject m_result;
00111 };
00112   
00113 } // end namespace internal
00114 
00115 } // end namespace Eigen
00116 
00117 #endif // EIGEN_INVERSE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines