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
|
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
|
|
|
*/
|
2008-05-14 08:20:15 +00:00
|
|
|
template<typename ExpressionType, unsigned int Added, unsigned int Removed>
|
2009-01-11 22:03:40 +00:00
|
|
|
struct ei_traits<Flagged<ExpressionType, Added, Removed> > : ei_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
|
|
|
};
|
|
|
|
|
|
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)
|
2008-05-28 22:11:47 +00:00
|
|
|
typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
|
|
|
|
|
ExpressionType, const ExpressionType&>::ret 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
|
|
|
|
2008-06-26 20:08:16 +00:00
|
|
|
inline int rows() const { return m_matrix.rows(); }
|
|
|
|
|
inline int cols() const { return m_matrix.cols(); }
|
2010-02-25 21:01:52 -05:00
|
|
|
inline int outerStride() const { return m_matrix.outerStride(); }
|
|
|
|
|
inline int innerStride() const { return m_matrix.innerStride(); }
|
2008-04-05 11:10:54 +00:00
|
|
|
|
2008-06-26 20:08:16 +00:00
|
|
|
inline const Scalar coeff(int row, int 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
|
|
|
}
|
|
|
|
|
|
2008-06-26 20:08:16 +00:00
|
|
|
inline Scalar& coeffRef(int row, int 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
|
|
|
}
|
|
|
|
|
|
2008-06-26 20:08:16 +00:00
|
|
|
inline const Scalar coeff(int index) const
|
2008-06-26 16:06:41 +00:00
|
|
|
{
|
|
|
|
|
return m_matrix.coeff(index);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-26 20:08:16 +00:00
|
|
|
inline Scalar& coeffRef(int 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>
|
2008-06-26 20:08:16 +00:00
|
|
|
inline const PacketScalar packet(int row, int 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>
|
2008-06-26 20:08:16 +00:00
|
|
|
inline void writePacket(int row, int 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>
|
2008-06-26 20:08:16 +00:00
|
|
|
inline const PacketScalar packet(int index) const
|
2008-06-26 16:06:41 +00:00
|
|
|
{
|
|
|
|
|
return m_matrix.template packet<LoadMode>(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<int LoadMode>
|
2008-06-26 20:08:16 +00:00
|
|
|
inline void writePacket(int 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
|