mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fiw bug #553: add support for sparse matrix time sparse self-adjoint view products
This commit is contained in:
parent
fc27cbd914
commit
9f035c876a
@ -69,6 +69,22 @@ template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView
|
|||||||
const _MatrixTypeNested& matrix() const { return m_matrix; }
|
const _MatrixTypeNested& matrix() const { return m_matrix; }
|
||||||
_MatrixTypeNested& matrix() { return m_matrix.const_cast_derived(); }
|
_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 */
|
/** Efficient sparse self-adjoint matrix times dense vector/matrix product */
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
SparseSelfAdjointTimeDenseProduct<MatrixType,OtherDerived,UpLo>
|
SparseSelfAdjointTimeDenseProduct<MatrixType,OtherDerived,UpLo>
|
||||||
|
@ -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=mUp.template selfadjointView<Upper>()*b, refX=refS*b);
|
||||||
VERIFY_IS_APPROX(x=mLo.template selfadjointView<Lower>()*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);
|
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
|
// New test for Bug in SparseTimeDenseProduct
|
||||||
|
Loading…
x
Reference in New Issue
Block a user