Re: [eigen] matrix exponential with c++0x |

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

Hi
Quoting Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> First, M_LOG2_E suddenly was not defined anymore so I added
>
> #if defined(log2) && !defined(M_LOG2_E)
> #define M_LOG2_E 0.693147180559945309417
> #endif
As far as I know, M_LOG2_E was never standard? (not mentioned in C++98
or C99)
> The last error is really strange. I tried to play a little bit with
> it and
> it seems that std::pow(std::complex<double>(2), int) is returning a
> std::complex<float>. At least I get the error message "conversion
> from
> 'std::complex<double>' to non-scalar type 'const
> std::complex<float>'
> requested" when I try the following code
>
> const Scalar tmp = std::pow(Scalar(2), m_squarings);
> MatrixType A = *m_M / tmp;
This actually indicates the opposite, that std::pow returns a
complex<double> for arguments of type complex<float>.
The conversion constructors that might lose precision (e.g.
complex<double> to complex<float>) have always been explicit, so my
guess is that the rules for overload resolution have changed.
If m_squarings is a double, the call is pow(complex<float>, double).
Probably the compiler previously preferred the conversion double->float
(wow, although it loses precision), but now prefers complex<float> ->
complex<double> (which makes more sense actually). But maybe the type of
m_squarings changed for some reason or previous versions of GCC treated
complex<double> -> complex<float> less strictly than required?
Markus
Disclaimer: haven't actually tested this, just my two cents