[eigen] Fix for SparseMatrix/SparseVector::sum()

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

I fixed a small compiling problem when using
SparseMatrix/SparseVector::sum(). Patch is attached.
I wonder that nobody ever stumbled across this. Is nobody computing the
sum of sparse matrices? I hope I'm not being stupid here.

Jens
# HG changeset patch
# User Jens Mueller <jens.k.mueller@xxxxxx>
# Date 1274972544 -7200
# Node ID e4a8bdb76d11ac919e5784c36c70a11819831cd3
# Parent  6b0bce6fd35ade6390fc35c069eecd64786e2da4
Fix SparseMatrix/SparseVector::sum()

SparseMatrix/SparseVector::sum() uses Map to compute the sum. But Map expects a
pointer.

diff -r 6b0bce6fd35a -r e4a8bdb76d11 Eigen/src/Sparse/SparseRedux.h
--- a/Eigen/src/Sparse/SparseRedux.h	Wed May 26 13:00:55 2010 -0400
+++ b/Eigen/src/Sparse/SparseRedux.h	Thu May 27 17:02:24 2010 +0200
@@ -42,7 +42,7 @@
 SparseMatrix<_Scalar,_Options>::sum() const
 {
   ei_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
-  return Matrix<Scalar,1,Dynamic>::Map(m_data.value(0), m_data.size()).sum();
+  return Matrix<Scalar,1,Dynamic>::Map(&m_data.value(0), m_data.size()).sum();
 }
 
 template<typename _Scalar, int _Options>
@@ -50,7 +50,7 @@
 SparseVector<_Scalar,_Options>::sum() const
 {
   ei_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
-  return Matrix<Scalar,1,Dynamic>::Map(m_data.value(0), m_data.size()).sum();
+  return Matrix<Scalar,1,Dynamic>::Map(&m_data.value(0), m_data.size()).sum();
 }
 
 #endif // EIGEN_SPARSEREDUX_H


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/