diff options
-rw-r--r-- | Eigen/src/SparseCore/SparseSelfAdjointView.h | 16 | ||||
-rw-r--r-- | test/sparse_product.cpp | 9 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Eigen/src/SparseCore/SparseSelfAdjointView.h b/Eigen/src/SparseCore/SparseSelfAdjointView.h index d2e170410..1770f21e6 100644 --- a/Eigen/src/SparseCore/SparseSelfAdjointView.h +++ b/Eigen/src/SparseCore/SparseSelfAdjointView.h @@ -69,6 +69,22 @@ template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView const _MatrixTypeNested& matrix() const { return m_matrix; } _MatrixTypeNested& matrix() { return m_matrix.const_cast_derived(); } + /** Sparse self-adjoint matrix times sparse matrix product */ + template<typename OtherDerived> + SparseSparseProduct<SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor,Index>, OtherDerived> + operator*(const SparseMatrixBase<OtherDerived>& rhs) const + { + return SparseSparseProduct<SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor, Index>, OtherDerived>(*this, rhs.derived()); + } + + /**sparse matrix times Sparse self-adjoint matrix product */ + template<typename OtherDerived> friend + SparseSparseProduct<OtherDerived, SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor,Index> > + operator*(const SparseMatrixBase<OtherDerived>& lhs, const SparseSelfAdjointView& rhs) + { + return SparseSparseProduct< OtherDerived, SparseMatrix<Scalar, (internal::traits<OtherDerived>::Flags&RowMajorBit) ? RowMajor : ColMajor, Index> >(lhs.derived(), rhs.derived()); + } + /** Efficient sparse self-adjoint matrix times dense vector/matrix product */ template<typename OtherDerived> SparseSelfAdjointTimeDenseProduct<MatrixType,OtherDerived,UpLo> diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index 338c3d378..51eed428b 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -201,7 +201,16 @@ template<typename SparseMatrixType> void sparse_product() VERIFY_IS_APPROX(x=mUp.template selfadjointView<Upper>()*b, refX=refS*b); VERIFY_IS_APPROX(x=mLo.template selfadjointView<Lower>()*b, refX=refS*b); VERIFY_IS_APPROX(x=mS.template selfadjointView<Upper|Lower>()*b, refX=refS*b); + + // sparse selfadjointView * sparse + SparseMatrixType mSres(rows,rows); + VERIFY_IS_APPROX(mSres = mLo.template selfadjointView<Lower>()*mS, + refX = refLo.template selfadjointView<Lower>()*refS); + // sparse * sparse selfadjointview + VERIFY_IS_APPROX(mSres = mS * mLo.template selfadjointView<Lower>(), + refX = refS * refLo.template selfadjointView<Lower>()); } + } // New test for Bug in SparseTimeDenseProduct |