aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sparse_product.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2013-03-06 11:58:22 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2013-03-06 11:58:22 +0100
commit98ce4455ddad01ef028b65f96e232d4b750647f0 (patch)
tree248f3d88d1e65f8fe2cdbb18215f05982764560b /test/sparse_product.cpp
parent69bd334d2be5890cd7a8b5f4d7e62f5db1b02b18 (diff)
fix sparse vector assignment from a sparse matrix
Diffstat (limited to 'test/sparse_product.cpp')
-rw-r--r--test/sparse_product.cpp20
1 files changed, 19 insertions, 1 deletions
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<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);