This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: Two possible problems with gsl_complex behavior
- To: Charlie Zender <zender at uci dot edu>
- Subject: Re: Two possible problems with gsl_complex behavior
- From: Brian Gough <bjg at network-theory dot co dot uk>
- Date: Sat, 28 Jul 2001 12:58:44 +0100 (BST)
- Cc: GSL Discussion List <gsl-discuss at sources dot redhat dot com>
- References: <200107271646.f6RGkMV06065@cgd85.cgd.ucar.edu>
Charlie Zender writes:
> First, and least troublesome, is that the result of
> gsl_complex_cos(gsl_complex z) where z=(0.0,0.0) does not appear to
> be exactly (1.0,0.0), but rather (1.0,-0.0).
Thanks for the bug reports.
For cos(z) I've adjusted the code so that the sign of zero is positive
for Im(z) = 0.
The negative sign was a result of the identity used to calculate the
imaginary part,
cos(x+iy) = cosh(x) cos(y) - i sin(x) sinh(y)
> Second, and more troublesome, is the behavior of gsl_complex functions
> when used as arguments to other functions. Again, using g++-2.96, the
> following used to work in gsl-0.7 "as expected":
>
> float_complex cpx=(0.0,0.0);
> gsl_complex ngl_cos=gsl_complex_cos(gsl_complex_rect(cpx.real(),cpx.imag()));
I had a quick look and this function does not appear to have changed
between 0.7 and 0.9 apart from,
-- the name being changed from gsl_complex_xy() to gsl_complex_rect()
-- the addition of an inline version in the header file, wrapped with
#ifdef HAVE_INLINE (so this should not cause any change unless
compiling the test program with -DHAVE_INLINE)
I tried compiling with g++ 2.95 and it worked ok.
Before I investigate more did you try compiling with -Wall and other
warning options? Also, you know that the initializer should be
float_complex cpx(0.0,0.0); rather than =(0.0,0.0); right?
regards
Brian Gough