diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-02-12 15:58:31 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-02-12 15:58:31 +0100 |
commit | 0a537cb2d87ada8206ec2271fb9f2904a18ccfce (patch) | |
tree | b6efed7b0954cfcde0867218157a48bfbc5e491c /Eigen | |
parent | b35d1a122ec2702cb5e6a262b6d34b3098f998b3 (diff) |
bug #901: fix triangular-view with unit diagonal of sparse rectangular matrices.
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/SparseCore/SparseTriangularView.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Eigen/src/SparseCore/SparseTriangularView.h b/Eigen/src/SparseCore/SparseTriangularView.h index 7c718e4e1..2c6aedaf9 100644 --- a/Eigen/src/SparseCore/SparseTriangularView.h +++ b/Eigen/src/SparseCore/SparseTriangularView.h @@ -70,20 +70,20 @@ class TriangularViewImpl<MatrixType,Mode,Sparse>::InnerIterator : public MatrixT public: EIGEN_STRONG_INLINE InnerIterator(const TriangularViewImpl& view, Index outer) - : Base(view.derived().nestedExpression(), outer), m_returnOne(false) + : Base(view.derived().nestedExpression(), outer), m_returnOne(false), m_containsDiag(Base::outer()<view.innerSize()) { if(SkipFirst) { while((*this) && ((HasUnitDiag||SkipDiag) ? this->index()<=outer : this->index()<outer)) Base::operator++(); if(HasUnitDiag) - m_returnOne = true; + m_returnOne = m_containsDiag; } else if(HasUnitDiag && ((!Base::operator bool()) || Base::index()>=Base::outer())) { if((!SkipFirst) && Base::operator bool()) Base::operator++(); - m_returnOne = true; + m_returnOne = m_containsDiag; } } @@ -98,7 +98,7 @@ class TriangularViewImpl<MatrixType,Mode,Sparse>::InnerIterator : public MatrixT { if((!SkipFirst) && Base::operator bool()) Base::operator++(); - m_returnOne = true; + m_returnOne = m_containsDiag; } } return *this; @@ -130,6 +130,7 @@ class TriangularViewImpl<MatrixType,Mode,Sparse>::InnerIterator : public MatrixT } protected: bool m_returnOne; + bool m_containsDiag; }; template<typename MatrixType, unsigned int Mode> @@ -193,7 +194,7 @@ public: Flags = XprType::Flags }; - explicit unary_evaluator(const XprType &xpr) : m_argImpl(xpr.nestedExpression()) {} + explicit unary_evaluator(const XprType &xpr) : m_argImpl(xpr.nestedExpression()), m_arg(xpr.nestedExpression()) {} inline Index nonZerosEstimate() const { return m_argImpl.nonZerosEstimate(); @@ -205,20 +206,20 @@ public: public: EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& xprEval, Index outer) - : Base(xprEval.m_argImpl,outer), m_returnOne(false) + : Base(xprEval.m_argImpl,outer), m_returnOne(false), m_containsDiag(Base::outer()<xprEval.m_arg.innerSize()) { if(SkipFirst) { while((*this) && ((HasUnitDiag||SkipDiag) ? this->index()<=outer : this->index()<outer)) Base::operator++(); if(HasUnitDiag) - m_returnOne = true; + m_returnOne = m_containsDiag; } else if(HasUnitDiag && ((!Base::operator bool()) || Base::index()>=Base::outer())) { if((!SkipFirst) && Base::operator bool()) Base::operator++(); - m_returnOne = true; // FIXME check innerSize()>outer(); + m_returnOne = m_containsDiag; } } @@ -233,7 +234,7 @@ public: { if((!SkipFirst) && Base::operator bool()) Base::operator++(); - m_returnOne = true; // FIXME check innerSize()>outer(); + m_returnOne = m_containsDiag; } } return *this; @@ -266,12 +267,14 @@ public: protected: bool m_returnOne; + bool m_containsDiag; private: Scalar& valueRef(); }; protected: evaluator<ArgType> m_argImpl; + const ArgType& m_arg; }; } // end namespace internal |