www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/04/01/11:59:02

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Message-ID: <8704.38224.qm@web25004.mail.ukl.yahoo.com>
Date: Wed, 1 Apr 2009 16:58:38 +0000 (GMT)
From: Marco Atzeri <marco_atzeri AT yahoo DOT it>
Subject: Re: complex number
To: cygwin AT cygwin DOT com
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--- Mer 1/4/09, Corinna Vinschen  ha scritto:

> Da: Corinna Vinschen=20
> Oggetto: Re: complex number
> A: cygwin AT cygwin DOT com
> Data: Mercoled=EC 1 Aprile 2009, 17:22
> On Apr=A0 1 14:48, Marco Atzeri
> wrote:
> >=20
> > Dear All,
> > I was trying to understand why this code
> >=20
> > #include <iostream>
> > #include <complex>
> >=20
> > int main()
> > {
> >=A0=A0=A0double a =3D 0;
> >=A0=A0=A0double b =3D 1. / a;
> >=A0=A0=A0a +=3D 1;
> >=A0=A0=A0std::cout << std::abs
> (std::complex<double> (b, a)) << '\n';
> >=A0 }
> >=20
> > produce Inf on most platform and NaN on cygwin.
>=20
> That's the result of the newlib function which is defined
> as
>=20
> =A0 double
> =A0 cabs(z)
> =A0 struct complex z;
> =A0 {
> =A0 =A0 return hypot(z.x, z.y);
> =A0 }
>=20

Hi Corinna,
that is not correct as hypot( 0, Inf)=20
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
> >=20
> >=A0 =A0=A0=A0extern double cabs();
>=20
> The math.h header is from newlib as well.=A0 I don't
> know why the
> math.h header is missing a normal prototype.=A0 I
> *assume* that nobody
> ever made the effort to convert these old functions (cabs
> is from 1994)
> to the ANSI C style.=A0 You should ask this question on
> the newlib list.
>=20
> > so just a placeholder but not a useful function.
> > There is any reason why cygwin is missing functional
> > C99 complex functions ?
>=20
> Sorry, it's all about newlib.
>=20
>=20
> 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=3Dsrc

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019