mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-07 03:39:04 +08:00
Fix usage of Dense versus DenseShape
This commit is contained in:
parent
d0261bd26c
commit
27ca9437a1
@ -526,6 +526,8 @@ public:
|
|||||||
Index size() const { return m_dstExpr.size(); }
|
Index size() const { return m_dstExpr.size(); }
|
||||||
Index innerSize() const { return m_dstExpr.innerSize(); }
|
Index innerSize() const { return m_dstExpr.innerSize(); }
|
||||||
Index outerSize() const { return m_dstExpr.outerSize(); }
|
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(); }
|
Index outerStride() const { return m_dstExpr.outerStride(); }
|
||||||
|
|
||||||
// TODO get rid of this one:
|
// TODO get rid of this one:
|
||||||
@ -534,16 +536,25 @@ public:
|
|||||||
DstEvaluatorType& dstEvaluator() { return m_dst; }
|
DstEvaluatorType& dstEvaluator() { return m_dst; }
|
||||||
const SrcEvaluatorType& srcEvaluator() const { return m_src; }
|
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)
|
void assignCoeff(Index row, Index col)
|
||||||
{
|
{
|
||||||
m_functor.assignCoeff(m_dst.coeffRef(row,col), m_src.coeff(row,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)
|
void assignCoeff(Index index)
|
||||||
{
|
{
|
||||||
m_functor.assignCoeff(m_dst.coeffRef(index), m_src.coeff(index));
|
m_functor.assignCoeff(m_dst.coeffRef(index), m_src.coeff(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \sa assignCoeff(Index,Index)
|
||||||
void assignCoeffByOuterInner(Index outer, Index inner)
|
void assignCoeffByOuterInner(Index outer, Index inner)
|
||||||
{
|
{
|
||||||
Index row = rowIndexByOuterInner(outer, 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
|
* 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,
|
// Based on the respective shapes of the destination and source,
|
||||||
// the class AssignmentKind determine the kind of assignment mechanism.
|
// the class AssignmentKind determine the kind of assignment mechanism.
|
||||||
// AssignmentKind must define a Kind typedef.
|
// AssignmentKind must define a Kind typedef.
|
||||||
template<typename DstShape, typename SrcShape> struct AssignmentKind;
|
template<typename DstShape, typename SrcShape> struct AssignmentKind;
|
||||||
|
|
||||||
// AssignmentKind<.,.>::Kind can be one of the following:
|
// Assignement kind defined in this file:
|
||||||
struct Dense2Dense {};
|
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
|
// This is the main assignment class
|
||||||
template< typename DstXprType, typename SrcXprType, typename Functor,
|
template< typename DstXprType, typename SrcXprType, typename Functor,
|
||||||
|
@ -42,14 +42,14 @@ template<typename StorageKind> struct storage_kind_to_shape;
|
|||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct storage_kind_to_shape<Dense> {
|
struct storage_kind_to_shape<Dense> {
|
||||||
typedef Dense Shape;
|
typedef DenseShape Shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO to be moved to SparseCore:
|
// TODO to be moved to SparseCore:
|
||||||
/*
|
/*
|
||||||
template<>
|
template<>
|
||||||
struct storage_kind_to_shape<Sparse> {
|
struct storage_kind_to_shape<Sparse> {
|
||||||
typedef Sparse Shape;
|
typedef SparseSpape Shape;
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ struct dense_product_impl;
|
|||||||
|
|
||||||
// The evaluator for default dense products creates a temporary and call dense_product_impl
|
// The evaluator for default dense products creates a temporary and call dense_product_impl
|
||||||
template<typename Lhs, typename Rhs, int ProductTag>
|
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
|
: public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>::type
|
||||||
{
|
{
|
||||||
typedef Product<Lhs, Rhs, DefaultProduct> XprType;
|
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;
|
struct etor_product_packet_impl;
|
||||||
|
|
||||||
template<typename Lhs, typename Rhs, int ProductTag>
|
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> >
|
: evaluator_base<Product<Lhs, Rhs, LazyProduct> >
|
||||||
{
|
{
|
||||||
typedef Product<Lhs, Rhs, LazyProduct> XprType;
|
typedef Product<Lhs, Rhs, LazyProduct> XprType;
|
||||||
|
@ -440,6 +440,18 @@ struct MatrixXpr {};
|
|||||||
/** The type used to identify an array expression */
|
/** The type used to identify an array expression */
|
||||||
struct ArrayXpr {};
|
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
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_CONSTANTS_H
|
#endif // EIGEN_CONSTANTS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user