Two possible problems with gsl_complex behavior
Brian Gough
bjg@network-theory.co.uk
Wed Dec 19 13:20:00 GMT 2001
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
More information about the Gsl-discuss
mailing list