2008-05-28 05:14:16 +00:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-22 20:25:33 +02:00
|
|
|
// for linear algebra.
|
2008-05-28 05:14:16 +00:00
|
|
|
//
|
2010-06-24 23:21:58 +02:00
|
|
|
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2008-11-24 13:40:43 +00:00
|
|
|
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
2008-05-28 05:14:16 +00:00
|
|
|
//
|
|
|
|
|
// Eigen is free software; you can redistribute it and/or
|
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
|
// version 3 of the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Alternatively, you can redistribute it and/or
|
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2 of
|
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License and a copy of the GNU General Public License along with
|
|
|
|
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
#ifndef EIGEN_NESTBYVALUE_H
|
|
|
|
|
#define EIGEN_NESTBYVALUE_H
|
|
|
|
|
|
|
|
|
|
/** \class NestByValue
|
2010-07-06 13:10:08 +01:00
|
|
|
* \ingroup Core_Module
|
2008-05-28 05:14:16 +00:00
|
|
|
*
|
|
|
|
|
* \brief Expression which must be nested by value
|
|
|
|
|
*
|
|
|
|
|
* \param ExpressionType the type of the object of which we are requiring nesting-by-value
|
|
|
|
|
*
|
|
|
|
|
* This class is the return type of MatrixBase::nestByValue()
|
|
|
|
|
* and most of the time this is the only way it is used.
|
|
|
|
|
*
|
|
|
|
|
* \sa MatrixBase::nestByValue()
|
|
|
|
|
*/
|
|
|
|
|
template<typename ExpressionType>
|
2009-01-11 22:03:40 +00:00
|
|
|
struct ei_traits<NestByValue<ExpressionType> > : public ei_traits<ExpressionType>
|
|
|
|
|
{};
|
2008-05-28 05:14:16 +00:00
|
|
|
|
|
|
|
|
template<typename ExpressionType> class NestByValue
|
2010-04-23 12:16:30 -04:00
|
|
|
: public ei_dense_xpr_base< NestByValue<ExpressionType> >::type
|
2008-05-28 05:14:16 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2010-04-23 12:16:30 -04:00
|
|
|
typedef typename ei_dense_xpr_base<NestByValue>::type Base;
|
2010-01-22 10:15:41 +01:00
|
|
|
EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
|
2008-05-28 05:14:16 +00:00
|
|
|
|
|
|
|
|
inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
|
|
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index rows() const { return m_expression.rows(); }
|
|
|
|
|
inline Index cols() const { return m_expression.cols(); }
|
|
|
|
|
inline Index outerStride() const { return m_expression.outerStride(); }
|
|
|
|
|
inline Index innerStride() const { return m_expression.innerStride(); }
|
2008-05-28 05:14:16 +00:00
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline const CoeffReturnType coeff(Index row, Index col) const
|
2008-05-28 05:14:16 +00:00
|
|
|
{
|
|
|
|
|
return m_expression.coeff(row, col);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Scalar& coeffRef(Index row, Index col)
|
2008-05-28 09:09:18 +00:00
|
|
|
{
|
|
|
|
|
return m_expression.const_cast_derived().coeffRef(row, col);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline const CoeffReturnType coeff(Index index) const
|
2008-06-26 16:06:41 +00:00
|
|
|
{
|
|
|
|
|
return m_expression.coeff(index);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Scalar& coeffRef(Index index)
|
2008-06-26 16:06:41 +00:00
|
|
|
{
|
|
|
|
|
return m_expression.const_cast_derived().coeffRef(index);
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-28 05:14:16 +00:00
|
|
|
template<int LoadMode>
|
2010-05-30 16:00:58 -04:00
|
|
|
inline const PacketScalar packet(Index row, Index col) const
|
2008-05-28 05:14:16 +00:00
|
|
|
{
|
2008-06-16 14:54:31 +00:00
|
|
|
return m_expression.template packet<LoadMode>(row, col);
|
2008-05-28 05:14:16 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-28 09:09:18 +00:00
|
|
|
template<int LoadMode>
|
2010-05-30 16:00:58 -04:00
|
|
|
inline void writePacket(Index row, Index col, const PacketScalar& x)
|
2008-05-28 09:09:18 +00:00
|
|
|
{
|
2008-06-16 14:54:31 +00:00
|
|
|
m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
|
2008-05-28 09:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-26 16:06:41 +00:00
|
|
|
template<int LoadMode>
|
2010-05-30 16:00:58 -04:00
|
|
|
inline const PacketScalar packet(Index index) const
|
2008-06-26 16:06:41 +00:00
|
|
|
{
|
|
|
|
|
return m_expression.template packet<LoadMode>(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<int LoadMode>
|
2010-05-30 16:00:58 -04:00
|
|
|
inline void writePacket(Index index, const PacketScalar& x)
|
2008-06-26 16:06:41 +00:00
|
|
|
{
|
|
|
|
|
m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
|
|
|
|
|
}
|
2010-01-22 10:15:41 +01:00
|
|
|
|
2009-01-28 16:26:06 +00:00
|
|
|
operator const ExpressionType&() const { return m_expression; }
|
2008-06-26 16:06:41 +00:00
|
|
|
|
2008-05-28 05:14:16 +00:00
|
|
|
protected:
|
|
|
|
|
const ExpressionType m_expression;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** \returns an expression of the temporary version of *this.
|
|
|
|
|
*/
|
|
|
|
|
template<typename Derived>
|
|
|
|
|
inline const NestByValue<Derived>
|
2010-02-01 11:44:44 +01:00
|
|
|
DenseBase<Derived>::nestByValue() const
|
2008-05-28 05:14:16 +00:00
|
|
|
{
|
|
|
|
|
return NestByValue<Derived>(derived());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // EIGEN_NESTBYVALUE_H
|