[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gsl] Complex: gsl_complex_div_real bug
From: |
Chris |
Subject: |
Re: [Bug-gsl] Complex: gsl_complex_div_real bug |
Date: |
Wed, 7 May 2008 19:16:58 -0700 |
Hi brian,
Actually after having tried to implement such a bug i've realised that
it was impossible. The fn — Function: gsl_complex gsl_complex_div_real
(gsl_complex a,float b)
gives you this: answer = z / b
However i was imagining a situation where you want to do b / z which
would if Im(Z) = 0 give you a spurious divide by zero error. However
since there is no function for doing this it's not an issue.
I must confess that i came across this bug in my own cuda
re-implementation of the gsl complex class, i just assumed it'd be
present if you actually used the gsl code as it should be.
Finally however, if you do use the gsl_complex_inverse on a complex
number z which has a zero imaginary part then the imaginary part
becomes negative zero instead of still being zero.
Viz the following program, it's not the original bug but it's another.
Thanks
#include "stdio.h"
#include "stdlib.h"
#include "gsl/gsl_complex.h"
#include "gsl/gsl_complex_math.h"
int main (void){
gsl_complex complex_number;
gsl_complex answer;
GSL_SET_COMPLEX(&complex_number, 4, 0);
complex_number = gsl_complex_inverse(complex_number);
printf("%g,%g\n", GSL_REAL(complex_number), GSL_IMAG(complex_number));
}
On Tue, May 6, 2008 at 1:30 PM, Brian Gough <address@hidden> wrote:
> At Mon, 5 May 2008 13:37:08 -0700,
> chris coleman-smith wrote:
>> There is a bug in the implementation of gsl_complex_div_real
>> (gsl_complex a, double x), from the 1.9 package in the complex/math.c
>> file.
>
> Can you send a small program which demonstrates the problem. Thank
> you.
>
> --
> Brian Gough
>
>