Re: [eigen] fix double-promotion in 3.3 Core/SpecialFunctions.h |

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

On 2016-05-04 23:21, Christoph Hertzberg wrote:

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).

`It turned out to be a bit more changes than I expected, but I finished
``it just now. Some things I noticed:
`

`std::pow(float, int) actually gets promoted to std::pow(double, double).
``This is especially bad for std::pow(x, 2). Inside Eigen we can use
``numext::abs2(x) instead (and we already did most of the time, as far as
``I noticed).
`

`We have quite a lot of Scalar(EIGEN_PI) now. We could implement either
``scalar_traits<Scalar>::pi() or a numext::pi class with a templated
``conversion operator:
` struct pi {
template<class Scalar>
operator Scalar() const { return Scalar(EIGEN_PI); }
};

`The first would also have the advantage to allow higher-precision pi for
``custom scalar types (like mpreal).
``The second way would allow nicer code (and we could combine both, of
``course).
`
Christoph
--
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