diff options
author | 2010-10-27 15:13:03 +0200 | |
---|---|---|
committer | 2010-10-27 15:13:03 +0200 | |
commit | 02c8b6af821fddf1976141448977dfb12c71ec30 (patch) | |
tree | 03418a3aefc4146c815e54c408db5a82500f533f /Eigen/src/Sparse | |
parent | 241e5ee3e7a306feb7b70f7f57b94c7e045abb67 (diff) |
fix sparse rankUpdate and triangularView iterator
Diffstat (limited to 'Eigen/src/Sparse')
-rw-r--r-- | Eigen/src/Sparse/SparseSelfAdjointView.h | 10 | ||||
-rw-r--r-- | Eigen/src/Sparse/SparseTriangularView.h | 14 |
2 files changed, 13 insertions, 11 deletions
diff --git a/Eigen/src/Sparse/SparseSelfAdjointView.h b/Eigen/src/Sparse/SparseSelfAdjointView.h index 769a05cf7..2a7101082 100644 --- a/Eigen/src/Sparse/SparseSelfAdjointView.h +++ b/Eigen/src/Sparse/SparseSelfAdjointView.h @@ -92,7 +92,7 @@ template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView * call this function with u.adjoint(). */ template<typename DerivedU> - SparseSelfAdjointView& rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha = Scalar(1)); + SparseSelfAdjointView& rankUpdate(const SparseMatrixBase<DerivedU>& u, Scalar alpha = Scalar(1)); // const SparseLLT<PlainObject, UpLo> llt() const; // const SparseLDLT<PlainObject, UpLo> ldlt() const; @@ -127,15 +127,15 @@ SparseSelfAdjointView<Derived, UpLo> SparseMatrixBase<Derived>::selfadjointView( template<typename MatrixType, unsigned int UpLo> template<typename DerivedU> SparseSelfAdjointView<MatrixType,UpLo>& -SparseSelfAdjointView<MatrixType,UpLo>::rankUpdate(const MatrixBase<DerivedU>& u, Scalar alpha) +SparseSelfAdjointView<MatrixType,UpLo>::rankUpdate(const SparseMatrixBase<DerivedU>& u, Scalar alpha) { SparseMatrix<Scalar,MatrixType::Flags&RowMajorBit?RowMajor:ColMajor> tmp = u * u.adjoint(); if(alpha==Scalar(0)) - m_matrix = tmp.template triangularView<UpLo>(); + m_matrix.const_cast_derived() = tmp.template triangularView<UpLo>(); else - m_matrix += alpha * tmp.template triangularView<UpLo>(); + m_matrix.const_cast_derived() /*+*/= alpha * tmp.template triangularView<UpLo>(); - return this; + return *this; } /*************************************************************************** diff --git a/Eigen/src/Sparse/SparseTriangularView.h b/Eigen/src/Sparse/SparseTriangularView.h index 8d0256599..319eaf066 100644 --- a/Eigen/src/Sparse/SparseTriangularView.h +++ b/Eigen/src/Sparse/SparseTriangularView.h @@ -26,11 +26,13 @@ #define EIGEN_SPARSE_TRIANGULARVIEW_H namespace internal { + template<typename MatrixType, int Mode> struct traits<SparseTriangularView<MatrixType,Mode> > : public traits<MatrixType> {}; -} + +} // namespace internal template<typename MatrixType, int Mode> class SparseTriangularView : public SparseMatrixBase<SparseTriangularView<MatrixType,Mode> > @@ -38,13 +40,13 @@ template<typename MatrixType, int Mode> class SparseTriangularView enum { SkipFirst = (Mode==Lower && !(MatrixType::Flags&RowMajorBit)) || (Mode==Upper && (MatrixType::Flags&RowMajorBit)) }; public: + + EIGEN_SPARSE_PUBLIC_INTERFACE(SparseTriangularView) class InnerIterator; - typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; - inline Index rows() { return m_matrix.rows(); } - inline Index cols() { return m_matrix.cols(); } + inline Index rows() const { return m_matrix.rows(); } + inline Index cols() const { return m_matrix.cols(); } typedef typename internal::conditional<internal::must_nest_by_value<MatrixType>::ret, MatrixType, const MatrixType&>::type MatrixTypeNested; @@ -83,7 +85,7 @@ class SparseTriangularView<MatrixType,Mode>::InnerIterator : public MatrixType:: EIGEN_STRONG_INLINE operator bool() const { - return SkipFirst ? Base::operator bool() : (Base::operator bool() && this->index() < this->outer()); + return SkipFirst ? Base::operator bool() : (Base::operator bool() && this->index() <= this->outer()); } }; |