This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: complex number
- From: Marco Atzeri <marco_atzeri at yahoo dot it>
- To: cygwin at cygwin dot com
- Date: Wed, 1 Apr 2009 16:58:38 +0000 (GMT)
- Subject: Re: complex number
--- Mer 1/4/09, Corinna Vinschen ha scritto:
> Da: Corinna Vinschen
> Oggetto: Re: complex number
> A: cygwin@cygwin.com
> Data: Mercoledì 1 Aprile 2009, 17:22
> On Apr? 1 14:48, Marco Atzeri
> wrote:
> >
> > Dear All,
> > I was trying to understand why this code
> >
> > #include <iostream>
> > #include <complex>
> >
> > int main()
> > {
> >???double a = 0;
> >???double b = 1. / a;
> >???a += 1;
> >???std::cout << std::abs
> (std::complex<double> (b, a)) << '\n';
> >? }
> >
> > produce Inf on most platform and NaN on cygwin.
>
> That's the result of the newlib function which is defined
> as
>
> ? double
> ? cabs(z)
> ? struct complex z;
> ? {
> ? ? return hypot(z.x, z.y);
> ? }
>
Hi Corinna,
that is not correct as hypot( 0, Inf)
return Inf and not NaN.
There is a cabs backup implementation in libgcc that is probably
the one used when system cabs is not available.
> > I found that newlib have the function cabs (complex
> absolute)
> > but in cygwin the prototypes is
> >
> >? ???extern double cabs();
>
> The math.h header is from newlib as well.? I don't
> know why the
> math.h header is missing a normal prototype.? I
> *assume* that nobody
> ever made the effort to convert these old functions (cabs
> is from 1994)
> to the ANSI C style.? You should ask this question on
> the newlib list.
>
> > so just a placeholder but not a useful function.
> > There is any reason why cygwin is missing functional
> > C99 complex functions ?
>
> Sorry, it's all about newlib.
>
>
> Corinna
Ok,
I will follow up on newlib,
I was not sure it is a newlib issue or cygwin specific,
as newlib have cabs function and for linux also
the expected header:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libc/sys/linux/include/cmathcalls.h?cvsroot=src
Regards
Marco
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/