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>
|
||||
struct evaluator<SparseView<Product<Lhs, Rhs, Options> > >
|
||||
struct unary_evaluator<SparseView<Product<Lhs, Rhs, Options> >, IteratorBased>
|
||||
: public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>
|
||||
{
|
||||
typedef SparseView<Product<Lhs, Rhs, Options> > XprType;
|
||||
typedef typename XprType::PlainObject PlainObject;
|
||||
typedef evaluator<PlainObject> Base;
|
||||
|
||||
explicit evaluator(const XprType& xpr)
|
||||
explicit unary_evaluator(const XprType& xpr)
|
||||
: m_result(xpr.rows(), xpr.cols())
|
||||
{
|
||||
using std::abs;
|
||||
|
@ -372,6 +372,12 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
SparseMatrixType m2(rows, rows);
|
||||
initSparse<Scalar>(density, refMat2, m2);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user