aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-09-01 16:53:52 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-09-01 16:53:52 +0200
commitfbb53b6cbb7f1a7cce2166c9df981b76fdd37f87 (patch)
tree7f7b6caf3f8fe09d5806a47c784fc56e04b05a32
parent85c765957418cd2fd24b46ca3a14e6fcbad43f05 (diff)
Fix sparse matrix times sparse vector.
-rw-r--r--Eigen/src/SparseCore/ConservativeSparseSparseProduct.h6
-rw-r--r--test/sparse_vector.cpp1
2 files changed, 5 insertions, 2 deletions
diff --git a/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h b/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h
index 815fdb6d8..535713ec5 100644
--- a/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h
+++ b/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h
@@ -28,6 +28,8 @@ static void conservative_sparse_sparse_product_impl(const Lhs& lhs, const Rhs& r
ei_declare_aligned_stack_constructed_variable(bool, mask, rows, 0);
ei_declare_aligned_stack_constructed_variable(Scalar, values, rows, 0);
ei_declare_aligned_stack_constructed_variable(Index, indices, rows, 0);
+
+ std::memset(mask,0,sizeof(bool)*rows);
// estimate the number of non zero entries
// given a rhs column containing Y non zeros, we assume that the respective Y columns
@@ -155,14 +157,14 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,C
{
// perform sorted insertion
internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrix>(lhs, rhs, resCol, true);
- res.swap(resCol);
+ res = resCol.markAsRValue();
}
else
{
// ressort to transpose to sort the entries
internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrix>(lhs, rhs, resCol, false);
RowMajorMatrix resRow(resCol);
- res = resRow;
+ res = resRow.markAsRValue();
}
}
};
diff --git a/test/sparse_vector.cpp b/test/sparse_vector.cpp
index 0c9476803..5eea9edfd 100644
--- a/test/sparse_vector.cpp
+++ b/test/sparse_vector.cpp
@@ -71,6 +71,7 @@ template<typename Scalar,typename Index> void sparse_vector(int rows, int cols)
VERIFY_IS_APPROX(v1.dot(v2), refV1.dot(refV2));
VERIFY_IS_APPROX(v1.dot(refV2), refV1.dot(refV2));
+ VERIFY_IS_APPROX(m1*v2, refM1*refV2);
VERIFY_IS_APPROX(v1.dot(m1*v2), refV1.dot(refM1*refV2));
int i = internal::random<int>(0,rows-1);
VERIFY_IS_APPROX(v1.dot(m1.col(i)), refV1.dot(refM1.col(i)));