From 98ce4455ddad01ef028b65f96e232d4b750647f0 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 6 Mar 2013 11:58:22 +0100 Subject: fix sparse vector assignment from a sparse matrix --- test/sparse_product.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'test/sparse_product.cpp') diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index 4eae263fa..67a59ecd8 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -46,6 +46,9 @@ template void sparse_product() double density = (std::max)(8./(rows*cols), 0.1); typedef Matrix DenseMatrix; typedef Matrix DenseVector; + typedef Matrix RowDenseVector; + typedef SparseVector ColSpVector; + typedef SparseVector RowSpVector; Scalar s1 = internal::random(); Scalar s2 = internal::random(); @@ -117,8 +120,23 @@ template void sparse_product() test_outer::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); -- cgit v1.2.3