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 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 + SparseSparseProduct::Flags&RowMajorBit) ? RowMajor : ColMajor,Index>, OtherDerived> + operator*(const SparseMatrixBase& rhs) const + { + return SparseSparseProduct::Flags&RowMajorBit) ? RowMajor : ColMajor, Index>, OtherDerived>(*this, rhs.derived()); + } + + /**sparse matrix times Sparse self-adjoint matrix product */ + template friend + SparseSparseProduct::Flags&RowMajorBit) ? RowMajor : ColMajor,Index> > + operator*(const SparseMatrixBase& lhs, const SparseSelfAdjointView& rhs) + { + return SparseSparseProduct< OtherDerived, SparseMatrix::Flags&RowMajorBit) ? RowMajor : ColMajor, Index> >(lhs.derived(), rhs.derived()); + } + /** Efficient sparse self-adjoint matrix times dense vector/matrix product */ template SparseSelfAdjointTimeDenseProduct 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 void sparse_product() VERIFY_IS_APPROX(x=mUp.template selfadjointView()*b, refX=refS*b); VERIFY_IS_APPROX(x=mLo.template selfadjointView()*b, refX=refS*b); VERIFY_IS_APPROX(x=mS.template selfadjointView()*b, refX=refS*b); + + // sparse selfadjointView * sparse + SparseMatrixType mSres(rows,rows); + VERIFY_IS_APPROX(mSres = mLo.template selfadjointView()*mS, + refX = refLo.template selfadjointView()*refS); + // sparse * sparse selfadjointview + VERIFY_IS_APPROX(mSres = mS * mLo.template selfadjointView(), + refX = refS * refLo.template selfadjointView()); } + } // New test for Bug in SparseTimeDenseProduct