This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Problems exp'ing complex numbers


Wolfgang Mauerer <wolfgang@mynetix.de> writes:

| Hi,
| Gabriel Dos Reis wrote:
| > 
| > Do you have a test case?
| The following program:
| 
| #include <iostream>
| #include <complex>
| 
| int main()
| {
|   long_double_complex test (1000,0);
| 
|   cout << "test      : " << test << endl;
|   cout << "exp(test) : " << exp(test) << endl;
|   return 0;
| }
| 
| results in
| 
| test      : (1000,0)
| exp(test) : (inf,nan)
| 
| If the definition
| 
| complex<long double> exp(const complex<long double> x) {
|   return polar(expl(real(x)), imag(x));
| }
| 
| is included into the file, the following result is gained then:
| 
| test      : (1000,0)
| exp(test) : (1.97007e+434,0)
| 
| Obviously, one has to use expl instead of exp for calculating
| the exponentiation of the real part. That isn't done
| in the standard library, here the normal exp is used
| for all data types.

Well, from the definition

  template<typename _Tp>
    inline complex<_Tp>
    exp(const complex<_Tp>& __z)
    { return polar(exp(__z.real()), __z.imag()); }

I suspect that to call to exp() in exp(__z.real()) is not resolved to
the long double version.  So the question is to know whether or not
exp(long double) is defined.  Maybe it one of the place we're just
using the stub exp(double).  Need to take a closer look at this.

Thanks,

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]