problem adding complex to newlib/cygwin

Marco Atzeri marco_atzeri@yahoo.it
Mon Oct 4 21:17:00 GMT 2010


--- Lun 4/10/10, Corinna Vinschen  ha scritto:

> On Oct  4 14:37, Marco Atzeri
> wrote:
> > --- Lun 4/10/10, Corinna Vinschen  ha scritto:
> > 
> > > 
> > > Btw., you'll note that cabs and cabsf are
> already
> > > available
> > > (from newlib/libm/math/w[f]_cabs.c files):
> > > 
> > >   cabs NOSIGFE
> > >   _cabs = cabs NOSIGFE
> > >   cabsf NOSIGFE
> > >   _cabsf = cabsf NOSIGFE
> > > 
> > 
> > I know, the potential problem is that they are slight
> different
> > I need to test if the implementation is the same or
> not.
> > The cleanest way should be to use the new version:
> > 
> > ---------------------------------------------
> > double
> > cabs(double complex z)
> > {
> > 
> >         return
> hypot(__real__ z, __imag__ z);
> > }
> > ----------------------------------------------
> > versus the previous one
> > 
> > -------------------------------------------
> > struct complex {
> >         double x;
> >         double y;
> > };
> > 
> > double
> > cabs(z)
> >         struct complex
> z;
> > {
> >         return
> hypot(z.x, z.y);
> > }
> > -------------------------------------------
> 
> Ouch.  Yes, that should be replaced.
> 
> 
> Corinna
> 

Hi Corinna,
I re-uploaded the patch to add the complex to newlib
and cygwin on

http://matzeri.altervista.org/works/complex/

As suggested the code is taken from netbsd.
No changelog yet, and eventually some code cleaning
is needed, however it seems to work.

After building the DLL I was able to compile a 
small test programs using all the complex functions

a = 1.000000+1.000000I
b = 3.141590+1.200000I
a+b = 4.141590+2.200000I
a*b = 1.941590+4.341590I
1/c = 0.500000-0.500000I
-a = -1.000000-1.000000I
abs(a) = 1.414214+0.000000I
cacos(a) = 0.904557-1.061275I
casin(a) = 0.666239+1.061275I
catan(a) = 1.017222+0.402359I
ccos(a) = 0.833730-0.988898I
csin(a) = 1.298458+0.634964I
ctan(a) = 0.271753+1.083923I
cacosh(a) = 1.061275+0.904557I
casinh(a) = 1.061275+0.666239I
catanh(a) = 0.402359+1.017222I
ccosh(a) = 0.833730+0.988898I
csinh(a) = 0.634964+1.298458I
ctanh(a) = 1.083923+0.271753I
cexp(a) = 1.468694+2.287355I
clog(a) = 0.346574+0.785398I
cpow(a) = -1.119157+0.295690I
csqrt(a) = 1.098684+0.455090I
carg(a) = 0.785398+0.000000I
cimag(a) = 1.000000+0.000000I
conj(a) = 1.000000-1.000000I
cproj(a) = 1.000000+1.000000I
creal(a) = 1.000000+0.000000I

Could you review and let me know ho to proceed for the
implementation ?

Regards
Marco







More information about the Cygwin-developers mailing list