This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 665 - Signed / unsigned comparison warning for triplet initialisation
Summary: Signed / unsigned comparison warning for triplet initialisation
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.2
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-27 17:38 UTC by Philippe Marti
Modified: 2019-12-04 12:38 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
Comment 3 Nobody 2019-12-04 12:38:59 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/665.

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