mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
fix sparse vector assignment from a sparse matrix
This commit is contained in:
@@ -46,6 +46,9 @@ template<typename SparseMatrixType> void sparse_product()
|
||||
double density = (std::max)(8./(rows*cols), 0.1);
|
||||
typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;
|
||||
typedef Matrix<Scalar,Dynamic,1> DenseVector;
|
||||
typedef Matrix<Scalar,1,Dynamic> RowDenseVector;
|
||||
typedef SparseVector<Scalar,0,Index> ColSpVector;
|
||||
typedef SparseVector<Scalar,RowMajor,Index> RowSpVector;
|
||||
|
||||
Scalar s1 = internal::random<Scalar>();
|
||||
Scalar s2 = internal::random<Scalar>();
|
||||
@@ -117,8 +120,23 @@ template<typename SparseMatrixType> void sparse_product()
|
||||
test_outer<SparseMatrixType,DenseMatrix>::run(m2,m4,refMat2,refMat4);
|
||||
|
||||
VERIFY_IS_APPROX(m6=m6*m6, refMat6=refMat6*refMat6);
|
||||
|
||||
// sparse matrix * sparse vector
|
||||
ColSpVector cv0(cols), cv1;
|
||||
DenseVector dcv0(cols), dcv1;
|
||||
initSparse(2*density,dcv0, cv0);
|
||||
|
||||
RowSpVector rv0(depth), rv1;
|
||||
RowDenseVector drv0(depth), drv1(rv1);
|
||||
initSparse(2*density,drv0, rv0);
|
||||
|
||||
VERIFY_IS_APPROX(cv1=rv0*m3, dcv1=drv0*refMat3);
|
||||
VERIFY_IS_APPROX(rv1=rv0*m3, drv1=drv0*refMat3);
|
||||
VERIFY_IS_APPROX(cv1=m3*cv0, dcv1=refMat3*dcv0);
|
||||
VERIFY_IS_APPROX(cv1=m3t.adjoint()*cv0, dcv1=refMat3t.adjoint()*dcv0);
|
||||
VERIFY_IS_APPROX(rv1=m3*cv0, drv1=refMat3*dcv0);
|
||||
}
|
||||
|
||||
|
||||
// test matrix - diagonal product
|
||||
{
|
||||
DenseMatrix refM2 = DenseMatrix::Zero(rows, cols);
|
||||
|
||||
Reference in New Issue
Block a user