This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1424 - Eigen::Matrix< unsigned int >::setLinSpaced
Summary: Eigen::Matrix< unsigned int >::setLinSpaced
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All Windows
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-02 12:23 UTC by simon.floery
Modified: 2019-12-04 16:58 UTC (History)
4 users (show)



Attachments

Description simon.floery 2017-05-02 12:23:48 UTC
Dear all,

In both VS2015 and VS2017, the following code snippet fails to compile with eigen-3.3.3.:

	Eigen::Matrix< unsigned int, 1, 5 > m;
	m.setLinSpaced(0u, 7u);

VS2015 complains:
Severity	Code	Description	Project	File	Line
Error	C2668	'abs': ambiguous call to overloaded function	eigen_vs2015	c:\eigen-3.3.3\eigen\src\core\mathfunctions.h	1066

With eigen-3.2.8, we do not get any errors.

thanks, Simon
Comment 1 Flavio Gagliardi 2017-05-05 12:14:34 UTC
(In reply to simon.floery from comment #0)
> Dear all,
> 
> In both VS2015 and VS2017, the following code snippet fails to compile with
> eigen-3.3.3.:
> 
> 	Eigen::Matrix< unsigned int, 1, 5 > m;
> 	m.setLinSpaced(0u, 7u);
> 
> VS2015 complains:
> Severity	Code	Description	Project	File	Line
> Error	C2668	'abs': ambiguous call to overloaded function	eigen_vs2015
> c:\eigen-3.3.3\eigen\src\core\mathfunctions.h	1066
> 
> With eigen-3.2.8, we do not get any errors.
> 
> thanks, Simon

I am not an expert and I don't know if a better solution exists. Personally, I solved this problem in GCC 7.1 by adding a template specialization for unsigned int and long unsigned int in MathFunctions.h

after the function

template<typename T>
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
typename NumTraits<T>::Real abs(const T &x) {
  EIGEN_USING_STD_MATH(abs);
  return abs(x);
}


I added 

template<>
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
typename NumTraits<long unsigned int>::Real abs(const long unsigned int& x) {
  return x;
}

template<>
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
typename NumTraits<unsigned int>::Real abs(const unsigned int& x) {
  return x;
}
Comment 2 Gael Guennebaud 2017-06-09 10:02:01 UTC
Thank you for the report, fixed:

https://bitbucket.org/eigen/eigen/commits/cfb064a552e8/ (devel)
https://bitbucket.org/eigen/eigen/commits/15f6a8f430ab/ (3.3)
Comment 3 Nobody 2019-12-04 16:58:43 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/1424.

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