![]() |
Eigen
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> 00005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> 00006 // 00007 // This Source Code Form is subject to the terms of the Mozilla 00008 // Public License v. 2.0. If a copy of the MPL was not distributed 00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00010 00011 #ifndef EIGEN_NESTBYVALUE_H 00012 #define EIGEN_NESTBYVALUE_H 00013 00014 namespace Eigen { 00015 00016 namespace internal { 00017 template<typename ExpressionType> 00018 struct traits<NestByValue<ExpressionType> > : public traits<ExpressionType> 00019 {}; 00020 } 00021 00034 template<typename ExpressionType> class NestByValue 00035 : public internal::dense_xpr_base< NestByValue<ExpressionType> >::type 00036 { 00037 public: 00038 00039 typedef typename internal::dense_xpr_base<NestByValue>::type Base; 00040 EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) 00041 00042 EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} 00043 00044 EIGEN_DEVICE_FUNC inline Index rows() const { return m_expression.rows(); } 00045 EIGEN_DEVICE_FUNC inline Index cols() const { return m_expression.cols(); } 00046 EIGEN_DEVICE_FUNC inline Index outerStride() const { return m_expression.outerStride(); } 00047 EIGEN_DEVICE_FUNC inline Index innerStride() const { return m_expression.innerStride(); } 00048 00049 EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index row, Index col) const 00050 { 00051 return m_expression.coeff(row, col); 00052 } 00053 00054 EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col) 00055 { 00056 return m_expression.const_cast_derived().coeffRef(row, col); 00057 } 00058 00059 EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const 00060 { 00061 return m_expression.coeff(index); 00062 } 00063 00064 EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) 00065 { 00066 return m_expression.const_cast_derived().coeffRef(index); 00067 } 00068 00069 template<int LoadMode> 00070 inline const PacketScalar packet(Index row, Index col) const 00071 { 00072 return m_expression.template packet<LoadMode>(row, col); 00073 } 00074 00075 template<int LoadMode> 00076 inline void writePacket(Index row, Index col, const PacketScalar& x) 00077 { 00078 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x); 00079 } 00080 00081 template<int LoadMode> 00082 inline const PacketScalar packet(Index index) const 00083 { 00084 return m_expression.template packet<LoadMode>(index); 00085 } 00086 00087 template<int LoadMode> 00088 inline void writePacket(Index index, const PacketScalar& x) 00089 { 00090 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x); 00091 } 00092 00093 EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; } 00094 00095 protected: 00096 const ExpressionType m_expression; 00097 }; 00098 00101 template<typename Derived> 00102 inline const NestByValue<Derived> 00103 DenseBase<Derived>::nestByValue() const 00104 { 00105 return NestByValue<Derived>(derived()); 00106 } 00107 00108 } // end namespace Eigen 00109 00110 #endif // EIGEN_NESTBYVALUE_H