Bug 665 - Signed / unsigned comparison warning for triplet initialisation
Signed / unsigned comparison warning for triplet initialisation
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Sparse
3.2
All All
: Normal Unknown
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-27 17:38 UTC by Philippe Marti
Modified: 2013-10-16 13:41 UTC (History)
2 users (show)



Attachments

Description Philippe Marti 2013-09-27 17:38:21 UTC
Hi,

The following code generates warnings about signed/unsigned comparisons:

   typedef Eigen::Triplet<double> T;
   std::vector<T> tripletList;
   tripletList.reserve(2);
   tripletList.push_back(T(0,0,7.0));
   tripletList.push_back(T(0,2,1.0));

   Eigen::SparseMatrix<double> matA(8,8);
   matA.setFromTriplets(tripletList.begin(), tripletList.end());

Warnings are at Eigen/src/SparseCore/SparseMatrix.h:951:7:

Regards,
Philippe
Comment 1 Kolja Brix 2013-10-16 09:01:22 UTC
Dear Philippe,

this is because Triplet by default uses unsigned int as index type.
Is this on purpose? I would propose to set the default index type to int
or SparseMatrix<>::index_type instead.

Until that is done you can set the index type using the second template parameter, i.e. in the above test code use

typedef Eigen::Triplet<double,int> T;

instead.

Best regards,

   Kolja
Comment 2 Christoph Hertzberg 2013-10-16 13:41:18 UTC
Fixed and back-ported to 3.2 here:
https://bitbucket.org/eigen/eigen/commits/0319f4dc86d60e3916617dc1bd4ce054c112814a

Note You need to log in before you can comment on or make changes to this bug.