mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-27 07:29:52 +08:00
bug #1224: fix regression in (dense*dense).sparseView() by specializing evaluator<SparseView<Product>> for sparse products only.
This commit is contained in:
parent
b507b82326
commit
8456bbbadb
@ -131,14 +131,14 @@ struct Assignment<DstXprType, Product<Lhs,Rhs,AliasFreeProduct>, internal::sub_a
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename Lhs, typename Rhs, int Options>
|
template<typename Lhs, typename Rhs, int Options>
|
||||||
struct evaluator<SparseView<Product<Lhs, Rhs, Options> > >
|
struct unary_evaluator<SparseView<Product<Lhs, Rhs, Options> >, IteratorBased>
|
||||||
: public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>
|
: public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>
|
||||||
{
|
{
|
||||||
typedef SparseView<Product<Lhs, Rhs, Options> > XprType;
|
typedef SparseView<Product<Lhs, Rhs, Options> > XprType;
|
||||||
typedef typename XprType::PlainObject PlainObject;
|
typedef typename XprType::PlainObject PlainObject;
|
||||||
typedef evaluator<PlainObject> Base;
|
typedef evaluator<PlainObject> Base;
|
||||||
|
|
||||||
explicit evaluator(const XprType& xpr)
|
explicit unary_evaluator(const XprType& xpr)
|
||||||
: m_result(xpr.rows(), xpr.cols())
|
: m_result(xpr.rows(), xpr.cols())
|
||||||
{
|
{
|
||||||
using std::abs;
|
using std::abs;
|
||||||
@ -147,13 +147,13 @@ struct evaluator<SparseView<Product<Lhs, Rhs, Options> > >
|
|||||||
typedef typename nested_eval<Rhs,Dynamic>::type RhsNested;
|
typedef typename nested_eval<Rhs,Dynamic>::type RhsNested;
|
||||||
LhsNested lhsNested(xpr.nestedExpression().lhs());
|
LhsNested lhsNested(xpr.nestedExpression().lhs());
|
||||||
RhsNested rhsNested(xpr.nestedExpression().rhs());
|
RhsNested rhsNested(xpr.nestedExpression().rhs());
|
||||||
|
|
||||||
internal::sparse_sparse_product_with_pruning_selector<typename remove_all<LhsNested>::type,
|
internal::sparse_sparse_product_with_pruning_selector<typename remove_all<LhsNested>::type,
|
||||||
typename remove_all<RhsNested>::type, PlainObject>::run(lhsNested,rhsNested,m_result,
|
typename remove_all<RhsNested>::type, PlainObject>::run(lhsNested,rhsNested,m_result,
|
||||||
abs(xpr.reference())*xpr.epsilon());
|
abs(xpr.reference())*xpr.epsilon());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PlainObject m_result;
|
PlainObject m_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -372,6 +372,12 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
|||||||
SparseMatrixType m2(rows, rows);
|
SparseMatrixType m2(rows, rows);
|
||||||
initSparse<Scalar>(density, refMat2, m2);
|
initSparse<Scalar>(density, refMat2, m2);
|
||||||
VERIFY_IS_APPROX(m2.eval(), refMat2.sparseView().eval());
|
VERIFY_IS_APPROX(m2.eval(), refMat2.sparseView().eval());
|
||||||
|
|
||||||
|
// sparse view on expressions:
|
||||||
|
VERIFY_IS_APPROX((s1*m2).eval(), (s1*refMat2).sparseView().eval());
|
||||||
|
VERIFY_IS_APPROX((m2+m2).eval(), (refMat2+refMat2).sparseView().eval());
|
||||||
|
VERIFY_IS_APPROX((m2*m2).eval(), (refMat2.lazyProduct(refMat2)).sparseView().eval());
|
||||||
|
VERIFY_IS_APPROX((m2*m2).eval(), (refMat2*refMat2).sparseView().eval());
|
||||||
}
|
}
|
||||||
|
|
||||||
// test diagonal
|
// test diagonal
|
||||||
|
Loading…
Reference in New Issue
Block a user