cart-elc

Source code for CART-ELC
git clone git://git.laack.co/cart-elc.git
Log | Files | Refs | README | LICENSE

NestByValue.h (2520B)


      1 // This file is part of Eigen, a lightweight C++ template library
      2 // for linear algebra.
      3 //
      4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
      5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
      6 //
      7 // This Source Code Form is subject to the terms of the Mozilla
      8 // Public License v. 2.0. If a copy of the MPL was not distributed
      9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
     10 
     11 #ifndef EIGEN_NESTBYVALUE_H
     12 #define EIGEN_NESTBYVALUE_H
     13 
     14 namespace Eigen {
     15 
     16 namespace internal {
     17 template<typename ExpressionType>
     18 struct traits<NestByValue<ExpressionType> > : public traits<ExpressionType>
     19 {
     20   enum {
     21     Flags = traits<ExpressionType>::Flags & ~NestByRefBit
     22   };
     23 };
     24 }
     25 
     26 /** \class NestByValue
     27   * \ingroup Core_Module
     28   *
     29   * \brief Expression which must be nested by value
     30   *
     31   * \tparam ExpressionType the type of the object of which we are requiring nesting-by-value
     32   *
     33   * This class is the return type of MatrixBase::nestByValue()
     34   * and most of the time this is the only way it is used.
     35   *
     36   * \sa MatrixBase::nestByValue()
     37   */
     38 template<typename ExpressionType> class NestByValue
     39   : public internal::dense_xpr_base< NestByValue<ExpressionType> >::type
     40 {
     41   public:
     42 
     43     typedef typename internal::dense_xpr_base<NestByValue>::type Base;
     44     EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
     45 
     46     EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
     47 
     48     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
     49     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
     50 
     51     EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }
     52 
     53     EIGEN_DEVICE_FUNC const ExpressionType& nestedExpression() const { return m_expression; }
     54 
     55   protected:
     56     const ExpressionType m_expression;
     57 };
     58 
     59 /** \returns an expression of the temporary version of *this.
     60   */
     61 template<typename Derived>
     62 EIGEN_DEVICE_FUNC inline const NestByValue<Derived>
     63 DenseBase<Derived>::nestByValue() const
     64 {
     65   return NestByValue<Derived>(derived());
     66 }
     67 
     68 namespace internal {
     69 
     70 // Evaluator of Solve -> eval into a temporary
     71 template<typename ArgType>
     72 struct evaluator<NestByValue<ArgType> >
     73   : public evaluator<ArgType>
     74 {
     75   typedef evaluator<ArgType> Base;
     76 
     77   EIGEN_DEVICE_FUNC explicit evaluator(const NestByValue<ArgType>& xpr)
     78     : Base(xpr.nestedExpression())
     79   {}
     80 };
     81 }
     82 
     83 } // end namespace Eigen
     84 
     85 #endif // EIGEN_NESTBYVALUE_H