Fix double constructions of the nested CwiseBinaryOp evaluator in sparse*diagonal product iterator.

This commit is contained in:
Gael Guennebaud 2014-06-27 16:41:45 +02:00
parent 73e686c6a4
commit c401167712
2 changed files with 15 additions and 11 deletions

View File

@ -607,7 +607,6 @@ struct unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBa
protected: protected:
typedef typename evaluator<ArgType>::InnerIterator EvalIterator; typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
typename evaluator<ArgType>::nestedType m_argImpl; typename evaluator<ArgType>::nestedType m_argImpl;
const XprType &m_block; const XprType &m_block;
@ -620,7 +619,7 @@ class unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBas
const XprType& m_block; const XprType& m_block;
Index m_end; Index m_end;
public: public:
EIGEN_STRONG_INLINE InnerVectorInnerIterator(const unary_evaluator& aEval, Index outer) EIGEN_STRONG_INLINE InnerVectorInnerIterator(const unary_evaluator& aEval, Index outer)
: EvalIterator(aEval.m_argImpl, outer + (IsRowMajor ? aEval.m_block.startRow() : aEval.m_block.startCol())), : EvalIterator(aEval.m_argImpl, outer + (IsRowMajor ? aEval.m_block.startRow() : aEval.m_block.startCol())),
m_block(aEval.m_block), m_block(aEval.m_block),

View File

@ -266,24 +266,29 @@ struct sparse_diagonal_product_evaluator<SparseXprType, DiagCoeffType, SDP_AsCwi
typedef typename evaluator<CwiseProductType>::type CwiseProductEval; typedef typename evaluator<CwiseProductType>::type CwiseProductEval;
typedef typename evaluator<CwiseProductType>::InnerIterator CwiseProductIterator; typedef typename evaluator<CwiseProductType>::InnerIterator CwiseProductIterator;
class InnerIterator : public CwiseProductIterator class InnerIterator
{ {
public: public:
InnerIterator(const sparse_diagonal_product_evaluator &xprEval, Index outer) InnerIterator(const sparse_diagonal_product_evaluator &xprEval, Index outer)
: CwiseProductIterator(CwiseProductEval(xprEval.m_sparseXprNested.innerVector(outer).cwiseProduct(xprEval.m_diagCoeffNested)),0), : m_cwiseEval(xprEval.m_sparseXprNested.innerVector(outer).cwiseProduct(xprEval.m_diagCoeffNested)),
m_cwiseEval(xprEval.m_sparseXprNested.innerVector(outer).cwiseProduct(xprEval.m_diagCoeffNested)), m_cwiseIter(m_cwiseEval, 0),
m_outer(outer) m_outer(outer)
{ {}
::new (static_cast<CwiseProductIterator*>(this)) CwiseProductIterator(m_cwiseEval,0);
}
inline Scalar value() const { return m_cwiseIter.value(); }
inline Index index() const { return m_cwiseIter.index(); }
inline Index outer() const { return m_outer; } inline Index outer() const { return m_outer; }
inline Index col() const { return SparseXprType::IsRowMajor ? CwiseProductIterator::index() : m_outer; } inline Index col() const { return SparseXprType::IsRowMajor ? m_cwiseIter.index() : m_outer; }
inline Index row() const { return SparseXprType::IsRowMajor ? m_outer : CwiseProductIterator::index(); } inline Index row() const { return SparseXprType::IsRowMajor ? m_outer : m_cwiseIter.index(); }
EIGEN_STRONG_INLINE InnerIterator& operator++()
{ ++m_cwiseIter; return *this; }
inline operator bool() const { return m_cwiseIter; }
protected: protected:
Index m_outer;
CwiseProductEval m_cwiseEval; CwiseProductEval m_cwiseEval;
CwiseProductIterator m_cwiseIter;
Index m_outer;
}; };
sparse_diagonal_product_evaluator(const SparseXprType &sparseXpr, const DiagCoeffType &diagCoeff) sparse_diagonal_product_evaluator(const SparseXprType &sparseXpr, const DiagCoeffType &diagCoeff)