Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:56:15

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
0005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
0006 //
0007 // This Source Code Form is subject to the terms of the Mozilla
0008 // Public License v. 2.0. If a copy of the MPL was not distributed
0009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0010 
0011 #ifndef EIGEN_NESTBYVALUE_H
0012 #define EIGEN_NESTBYVALUE_H
0013 
0014 namespace Eigen {
0015 
0016 namespace internal {
0017 template<typename ExpressionType>
0018 struct traits<NestByValue<ExpressionType> > : public traits<ExpressionType>
0019 {
0020   enum {
0021     Flags = traits<ExpressionType>::Flags & ~NestByRefBit
0022   };
0023 };
0024 }
0025 
0026 /** \class NestByValue
0027   * \ingroup Core_Module
0028   *
0029   * \brief Expression which must be nested by value
0030   *
0031   * \tparam ExpressionType the type of the object of which we are requiring nesting-by-value
0032   *
0033   * This class is the return type of MatrixBase::nestByValue()
0034   * and most of the time this is the only way it is used.
0035   *
0036   * \sa MatrixBase::nestByValue()
0037   */
0038 template<typename ExpressionType> class NestByValue
0039   : public internal::dense_xpr_base< NestByValue<ExpressionType> >::type
0040 {
0041   public:
0042 
0043     typedef typename internal::dense_xpr_base<NestByValue>::type Base;
0044     EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
0045 
0046     EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
0047 
0048     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
0049     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
0050 
0051     EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }
0052 
0053     EIGEN_DEVICE_FUNC const ExpressionType& nestedExpression() const { return m_expression; }
0054 
0055   protected:
0056     const ExpressionType m_expression;
0057 };
0058 
0059 /** \returns an expression of the temporary version of *this.
0060   */
0061 template<typename Derived>
0062 EIGEN_DEVICE_FUNC inline const NestByValue<Derived>
0063 DenseBase<Derived>::nestByValue() const
0064 {
0065   return NestByValue<Derived>(derived());
0066 }
0067 
0068 namespace internal {
0069 
0070 // Evaluator of Solve -> eval into a temporary
0071 template<typename ArgType>
0072 struct evaluator<NestByValue<ArgType> >
0073   : public evaluator<ArgType>
0074 {
0075   typedef evaluator<ArgType> Base;
0076 
0077   EIGEN_DEVICE_FUNC explicit evaluator(const NestByValue<ArgType>& xpr)
0078     : Base(xpr.nestedExpression())
0079   {}
0080 };
0081 }
0082 
0083 } // end namespace Eigen
0084 
0085 #endif // EIGEN_NESTBYVALUE_H