Fix usage of Dense versus DenseShape

This commit is contained in:
Gael Guennebaud 2013-12-02 14:05:34 +01:00
parent d0261bd26c
commit 27ca9437a1
4 changed files with 30 additions and 21 deletions

View File

@ -526,6 +526,8 @@ public:
Index size() const { return m_dstExpr.size(); }
Index innerSize() const { return m_dstExpr.innerSize(); }
Index outerSize() const { return m_dstExpr.outerSize(); }
Index rows() const { return m_dstExpr.rows(); }
Index cols() const { return m_dstExpr.cols(); }
Index outerStride() const { return m_dstExpr.outerStride(); }
// TODO get rid of this one:
@ -534,16 +536,25 @@ public:
DstEvaluatorType& dstEvaluator() { return m_dst; }
const SrcEvaluatorType& srcEvaluator() const { return m_src; }
/// Assign src(row,col) to dst(row,col) through the assignment functor.
void assignCoeff(Index row, Index col)
{
m_functor.assignCoeff(m_dst.coeffRef(row,col), m_src.coeff(row,col));
}
/// This overload by-passes the source expression, i.e., dst(row,col) ?= value
void assignCoeff(Index row, Index col, const Scalar &value)
{
m_functor.assignCoeff(m_dst.coeffRef(row,col), value);
}
/// \sa assignCoeff(Index,Index)
void assignCoeff(Index index)
{
m_functor.assignCoeff(m_dst.coeffRef(index), m_src.coeff(index));
}
/// \sa assignCoeff(Index,Index)
void assignCoeffByOuterInner(Index outer, Index inner)
{
Index row = rowIndexByOuterInner(outer, inner);
@ -633,29 +644,15 @@ void call_dense_assignment_loop(const DstXprType& dst, const SrcXprType& src)
* Part 6 : Generic assignment
***************************************************************************/
// An evaluator must define its shape. It can be one of the following:
struct DenseShape {};
struct DiagonalShape {};
struct BandShape {};
struct TriangularShape {};
struct SelfAdjointShape {};
struct SparseShape {};
// Based on the respective shapes of the destination and source,
// the class AssignmentKind determine the kind of assignment mechanism.
// AssignmentKind must define a Kind typedef.
template<typename DstShape, typename SrcShape> struct AssignmentKind;
// AssignmentKind<.,.>::Kind can be one of the following:
// Assignement kind defined in this file:
struct Dense2Dense {};
struct Triangular2Triangular {};
// struct Diagonal2Diagonal {}; // <=> Dense2Dense
struct Sparse2Dense {};
struct Sparse2Sparse {};
template<> struct AssignmentKind<Dense,Dense> { typedef Dense2Dense Kind; };
template<> struct AssignmentKind<DenseShape,DenseShape> { typedef Dense2Dense Kind; };
// This is the main assignment class
template< typename DstXprType, typename SrcXprType, typename Functor,

View File

@ -42,14 +42,14 @@ template<typename StorageKind> struct storage_kind_to_shape;
template<>
struct storage_kind_to_shape<Dense> {
typedef Dense Shape;
typedef DenseShape Shape;
};
// TODO to be moved to SparseCore:
/*
template<>
struct storage_kind_to_shape<Sparse> {
typedef Sparse Shape;
typedef SparseSpape Shape;
};
*/

View File

@ -48,7 +48,7 @@ struct dense_product_impl;
// The evaluator for default dense products creates a temporary and call dense_product_impl
template<typename Lhs, typename Rhs, int ProductTag>
struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, Dense, Dense, typename Lhs::Scalar, typename Rhs::Scalar>
struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, DenseShape, DenseShape, typename Lhs::Scalar, typename Rhs::Scalar>
: public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>::type
{
typedef Product<Lhs, Rhs, DefaultProduct> XprType;
@ -217,7 +217,7 @@ template<int StorageOrder, int UnrollingIndex, typename Lhs, typename Rhs, typen
struct etor_product_packet_impl;
template<typename Lhs, typename Rhs, int ProductTag>
struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, Dense, Dense, typename Lhs::Scalar, typename Rhs::Scalar >
struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape, DenseShape, typename Lhs::Scalar, typename Rhs::Scalar >
: evaluator_base<Product<Lhs, Rhs, LazyProduct> >
{
typedef Product<Lhs, Rhs, LazyProduct> XprType;

View File

@ -440,6 +440,18 @@ struct MatrixXpr {};
/** The type used to identify an array expression */
struct ArrayXpr {};
#ifdef EIGEN_ENABLE_EVALUATORS
// An evaluator must define its shape. By default, it can be one of the following:
struct DenseShape { static std::string debugName() { return "DenseShape"; } };
struct DiagonalShape { static std::string debugName() { return "DiagonalShape"; } };
struct BandShape { static std::string debugName() { return "BandShape"; } };
struct TriangularShape { static std::string debugName() { return "TriangularShape"; } };
struct SelfAdjointShape { static std::string debugName() { return "SelfAdjointShape"; } };
struct SparseShape { static std::string debugName() { return "SparseShape"; } };
#endif
} // end namespace Eigen
#endif // EIGEN_CONSTANTS_H