| Re: [eigen] fix double-promotion in 3.3 Core/SpecialFunctions.h | 
[ Thread Index | 
Date Index
| More lists.tuxfamily.org/eigen Archives
] 
Hi!
Thanks, the patch looks good, I pushed it. The first cast was not really 
necessary, I guess, but it does not hurt either.
I will also add the -Wdouble-promotion to our standard compile-flags. It 
looks like our code was mostly clean with regard to that (except some 
test-code which I will fix now).
I guess -Wconversion would also make sense (we already enable 
-Wshorten-64-to-32 on clang), but at the moment it generates too much 
noise. I'll probably add a bugzilla entry for that.
Cheers,
Christoph
On 2016-05-04 10:57, Ola Røer Thorsen wrote:
Hi,
I'm trying out the current Eigen default branch ("almost-3.3"), compiling
code that has been using Eigen 3.2 until now.
I'm using the GCC warnings -Wdouble-promotion and -Wfloat-conversion as
these are really helpful to uncover performance bugs on some of the ARM
CPUs I am using (only single-precision FPU, use of double is very slow).
This uncovered some slight bugs in Core/SpecialFunctions.h where some
expressions were using double-precision when they should use floats, such as
extern/eigen3/Eigen/src/Core/SpecialFunctions.h:762:13: error: implicit
conversion from 'float' to 'double' to match other operand of binary
expression [-Werror=double-promotion]
        c *= x/r;
extern/eigen3/Eigen/src/Core/SpecialFunctions.h:767:25: error: conversion
to 'float' from 'double' may alter its value [-Werror=float-conversion]
      return (ans * ax / a);
Attached here is a small patch that fixes the issues I found. It was
created against the default branch as of this morning. I'm not experienced
with Mercurial so I hope i made the file correctly - please let me know if
it should be done differently.
Best regards,
Ola
--
 Dipl. Inf., Dipl. Math. Christoph Hertzberg
 Universität Bremen
 FB 3 - Mathematik und Informatik
 AG Robotik
 Robert-Hooke-Straße 1
 28359 Bremen, Germany
 Zentrale: +49 421 178 45-6611
 Besuchsadresse der Nebengeschäftsstelle:
 Robert-Hooke-Straße 5
 28359 Bremen, Germany
 Tel.:    +49 421 178 45-4021
 Empfang: +49 421 178 45-6600
 Fax:     +49 421 178 45-4150
 E-Mail:  chtz@xxxxxxxxxxxxxxxxxxxxxxxx
 Weitere Informationen: http://www.informatik.uni-bremen.de/robotik