1
// This file is part of Eigen, a lightweight C++ template library
4
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
7
// Eigen is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 3 of the License, or (at your option) any later version.
12
// Alternatively, you can redistribute it and/or
13
// modify it under the terms of the GNU General Public License as
14
// published by the Free Software Foundation; either version 2 of
15
// the License, or (at your option) any later version.
17
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
20
// GNU General Public License for more details.
22
// You should have received a copy of the GNU Lesser General Public
23
// License and a copy of the GNU General Public License along with
24
// Eigen. If not, see <http://www.gnu.org/licenses/>.
26
#ifndef EIGEN_NESTBYVALUE_H
27
#define EIGEN_NESTBYVALUE_H
29
/** \class NestByValue
30
* \ingroup Core_Module
32
* \brief Expression which must be nested by value
34
* \param ExpressionType the type of the object of which we are requiring nesting-by-value
36
* This class is the return type of MatrixBase::nestByValue()
37
* and most of the time this is the only way it is used.
39
* \sa MatrixBase::nestByValue()
43
template<typename ExpressionType>
44
struct traits<NestByValue<ExpressionType> > : public traits<ExpressionType>
48
template<typename ExpressionType> class NestByValue
49
: public internal::dense_xpr_base< NestByValue<ExpressionType> >::type
53
typedef typename internal::dense_xpr_base<NestByValue>::type Base;
54
EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
56
inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
58
inline Index rows() const { return m_expression.rows(); }
59
inline Index cols() const { return m_expression.cols(); }
60
inline Index outerStride() const { return m_expression.outerStride(); }
61
inline Index innerStride() const { return m_expression.innerStride(); }
63
inline const CoeffReturnType coeff(Index row, Index col) const
65
return m_expression.coeff(row, col);
68
inline Scalar& coeffRef(Index row, Index col)
70
return m_expression.const_cast_derived().coeffRef(row, col);
73
inline const CoeffReturnType coeff(Index index) const
75
return m_expression.coeff(index);
78
inline Scalar& coeffRef(Index index)
80
return m_expression.const_cast_derived().coeffRef(index);
83
template<int LoadMode>
84
inline const PacketScalar packet(Index row, Index col) const
86
return m_expression.template packet<LoadMode>(row, col);
89
template<int LoadMode>
90
inline void writePacket(Index row, Index col, const PacketScalar& x)
92
m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
95
template<int LoadMode>
96
inline const PacketScalar packet(Index index) const
98
return m_expression.template packet<LoadMode>(index);
101
template<int LoadMode>
102
inline void writePacket(Index index, const PacketScalar& x)
104
m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
107
operator const ExpressionType&() const { return m_expression; }
110
const ExpressionType m_expression;
113
/** \returns an expression of the temporary version of *this.
115
template<typename Derived>
116
inline const NestByValue<Derived>
117
DenseBase<Derived>::nestByValue() const
119
return NestByValue<Derived>(derived());
122
#endif // EIGEN_NESTBYVALUE_H