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


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.
Sorry that I didn't think about including concrete numbers in my first
mail.

Wolfgang

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