2008-04-05 11:10:54 +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-04-05 11:10:54 +00:00
|
|
|
//
|
2008-11-24 13:40:43 +00:00
|
|
|
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
|
2008-04-05 11:10:54 +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/>.
|
|
|
|
|
|
2008-05-14 08:20:15 +00:00
|
|
|
#ifndef EIGEN_FLAGGED_H
|
|
|
|
|
#define EIGEN_FLAGGED_H
|
2008-04-05 11:10:54 +00:00
|
|
|
|
2010-02-04 18:28:09 +01:00
|
|
|
/** \class Flagged
|
2010-07-06 13:10:08 +01:00
|
|
|
* \ingroup Core_Module
|
2008-04-05 11:10:54 +00:00
|
|
|
*
|
2008-05-14 08:20:15 +00:00
|
|
|
* \brief Expression with modified flags
|
2008-04-05 11:10:54 +00:00
|
|
|
*
|
2008-05-14 08:20:15 +00:00
|
|
|
* \param ExpressionType the type of the object of which we are modifying the flags
|
|
|
|
|
* \param Added the flags added to the expression
|
|
|
|
|
* \param Removed the flags removed from the expression (has priority over Added).
|
2008-04-05 11:10:54 +00:00
|
|
|
*
|
2008-05-28 04:38:16 +00:00
|
|
|
* This class represents an expression whose flags have been modified.
|
2008-05-14 08:20:15 +00:00
|
|
|
* It is the return type of MatrixBase::flagged()
|
2008-04-05 11:10:54 +00:00
|
|
|
* and most of the time this is the only way it is used.
|
|
|
|
|
*
|
2008-05-14 08:20:15 +00:00
|
|
|
* \sa MatrixBase::flagged()
|
2008-04-05 11:10:54 +00:00
|
|
|
*/
|
2010-10-25 10:15:22 -04:00
|
|
|
|
|
|
|
|
namespace internal {
|
2008-05-14 08:20:15 +00:00
|
|
|
template<typename ExpressionType, unsigned int Added, unsigned int Removed>
|
2010-10-25 10:15:22 -04:00
|
|
|
struct traits<Flagged<ExpressionType, Added, Removed> > : traits<ExpressionType>
|
2008-04-05 11:10:54 +00:00
|
|
|
{
|
2009-01-11 22:03:40 +00:00
|
|
|
enum { Flags = (ExpressionType::Flags | Added) & ~Removed };
|
2008-04-05 11:10:54 +00:00
|
|
|
};
|
2010-10-25 10:15:22 -04:00
|
|
|
}
|
2008-04-05 11:10:54 +00:00
|
|
|
|
2008-05-14 08:20:15 +00:00
|
|
|
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged
|
|
|
|
|
: public MatrixBase<Flagged<ExpressionType, Added, Removed> >
|
2008-04-05 11:10:54 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2010-01-22 10:15:41 +01:00
|
|
|
typedef MatrixBase<Flagged> Base;
|
|
|
|
|
EIGEN_DENSE_PUBLIC_INTERFACE(Flagged)
|
2010-10-25 22:13:49 +02:00
|
|
|
typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
|
|
|
|
|
ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
|
2008-09-02 19:55:26 +00:00
|
|
|
typedef typename ExpressionType::InnerIterator InnerIterator;
|
2008-04-05 11:10:54 +00:00
|
|
|
|
2008-05-27 05:47:30 +00:00
|
|
|
inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {}
|
2008-04-05 11:10:54 +00:00
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Index rows() const { return m_matrix.rows(); }
|
|
|
|
|
inline Index cols() const { return m_matrix.cols(); }
|
|
|
|
|
inline Index outerStride() const { return m_matrix.outerStride(); }
|
|
|
|
|
inline Index innerStride() const { return m_matrix.innerStride(); }
|
2008-04-05 11:10:54 +00:00
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline const Scalar coeff(Index row, Index col) const
|
2008-04-05 11:10:54 +00:00
|
|
|
{
|
2008-05-27 05:47:30 +00:00
|
|
|
return m_matrix.coeff(row, col);
|
2008-04-05 11:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline Scalar& coeffRef(Index row, Index col)
|
2008-05-14 08:20:15 +00:00
|
|
|
{
|
2008-05-27 05:47:30 +00:00
|
|
|
return m_matrix.const_cast_derived().coeffRef(row, col);
|
2008-05-14 08:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-30 16:00:58 -04:00
|
|
|
inline const Scalar coeff(Index index) const
|
2008-06-26 16:06:41 +00:00
|
|
|
{
|
|
|
|
|
return m_matrix.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_matrix.const_cast_derived().coeffRef(index);
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-05 10:23:29 +00:00
|
|
|
template<int LoadMode>
|
2010-05-30 16:00:58 -04:00
|
|
|
inline const PacketScalar packet(Index row, Index col) const
|
2008-04-25 15:46:18 +00:00
|
|
|
{
|
2008-06-16 14:54:31 +00:00
|
|
|
return m_matrix.template packet<LoadMode>(row, col);
|
2008-04-25 15:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-14 08:20:15 +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-14 08:20:15 +00:00
|
|
|
{
|
2008-06-16 14:54:31 +00:00
|
|
|
m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x);
|
2008-05-14 08:20:15 +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_matrix.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_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-01 16:20:06 +00:00
|
|
|
const ExpressionType& _expression() const { return m_matrix; }
|
|
|
|
|
|
2010-01-07 21:15:32 +01:00
|
|
|
template<typename OtherDerived>
|
2010-02-20 15:53:57 +01:00
|
|
|
typename ExpressionType::PlainObject solveTriangular(const MatrixBase<OtherDerived>& other) const;
|
2010-01-07 21:15:32 +01:00
|
|
|
|
|
|
|
|
template<typename OtherDerived>
|
|
|
|
|
void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
|
|
|
|
|
|
2008-04-05 11:10:54 +00:00
|
|
|
protected:
|
2008-05-28 22:11:47 +00:00
|
|
|
ExpressionTypeNested m_matrix;
|
2008-04-05 11:10:54 +00:00
|
|
|
};
|
|
|
|
|
|
2010-02-05 23:44:24 +01:00
|
|
|
/** \returns an expression of *this with added and removed flags
|
|
|
|
|
*
|
|
|
|
|
* This is mostly for internal use.
|
|
|
|
|
*
|
|
|
|
|
* \sa class Flagged
|
|
|
|
|
*/
|
|
|
|
|
template<typename Derived>
|
|
|
|
|
template<unsigned int Added,unsigned int Removed>
|
|
|
|
|
inline const Flagged<Derived, Added, Removed>
|
|
|
|
|
DenseBase<Derived>::flagged() const
|
|
|
|
|
{
|
|
|
|
|
return derived();
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 08:20:15 +00:00
|
|
|
#endif // EIGEN_FLAGGED_H
|