[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Same .m file: different results with different versions of Octave
From: |
Jaroslav Hajek |
Subject: |
Re: Same .m file: different results with different versions of Octave |
Date: |
Mon, 19 Apr 2010 11:59:33 +0200 |
On Mon, Apr 19, 2010 at 9:04 AM, Søren Hauberg <address@hidden> wrote:
> man, 19 04 2010 kl. 08:43 +0200, skrev Jaroslav Hajek:
>> On Mon, Apr 19, 2010 at 8:24 AM, Judd Storrs <address@hidden> wrote:
>> > On Mon, Apr 19, 2010 at 2:17 AM, Søren Hauberg <address@hidden> wrote:
>> >> I am a bit lost in this thread. Has a bug report been filed against
>> >> glibc?
>> >
>> > I haven't filed one because Thomas and Jaroslav have confused me about
>> > if this is a problem or where the problem is. Jaroslav says it's
>> > probably an optimization problem.
>>
>> I already corrected myself. This is most likely a ctanh issue in libc.
>
> The following program:
>
> #include <math.h>
> #include <complex.h>
> #include <stdio.h>
> #define _GNU_SOURCE
> #include <gnu/libc-version.h>
>
> int main (void)
> {
> double complex arg = 711 + 711 * _Complex_I;
> double complex s, c, r, t;
> s = csinh (arg);
> c = ccosh (arg);
> r = s / c;
> t = ctanh (arg);
>
> printf ("libc version %s\n", gnu_get_libc_version ());
> printf ("libc release %s\n", gnu_get_libc_release ());
> printf ("arg = %f + %f * i\n", creal (arg), cimag
> (arg));
> printf ("tanh (arg) = %f + %f * i (should be 1 + 0 * i)\n",
> creal (t), cimag (t));
>
> return 0;
> }
>
> (A C version of a previously posted C++ program) gives me
>
> libc version 2.10.1
> libc release stable
> arg = 711.000000 + 711.000000 * i
> tanh (arg) = 0.000000 + 0.000000 * i (should be 1 + 0 * i)
>
> That pretty much confirms that the bug is in libc, right? Is anything
> besides this program needed to submit a bug report against glibc?
>
> Søren
>
You might want to add the attached patch that seems to fix the issue for me:
address@hidden:~/devel/scratch> ./a.out
libc version 2.11
libc release stable
arg = 711.000000 + 711.000000 * i
tanh (arg) = 1.000000 + 0.000000 * i (should be 1 + 0 * i)
This simply takes the limit if the denominator overflows, so it should
be safe to do.
And it's just an infrequent branch with a relatively cheap extra test,
so I would not expect a visible performance penalty.
I only tested this with the stable glibc 2.11, because I can't build
the Git sources due to a mysterious linker crash during build.
Comments?
--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
glibc-ctanh.diff
Description: Text Data
- Re: Same .m file: different results with different versions of Octave, (continued)
- Re: Same .m file: different results with different versions of Octave, Jaroslav Hajek, 2010/04/18
- Re: Same .m file: different results with different versions of Octave, Judd Storrs, 2010/04/18
- Re: Same .m file: different results with different versions of Octave, Juergen Rose, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Jaroslav Hajek, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Søren Hauberg, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Judd Storrs, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Jaroslav Hajek, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Søren Hauberg, 2010/04/19
- Re: Same .m file: different results with different versions of Octave,
Jaroslav Hajek <=
- Re: Same .m file: different results with different versions of Octave, Judd Storrs, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Judd Storrs, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Jaroslav Hajek, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Judd Storrs, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Judd Storrs, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Thomas D. Dean, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Søren Hauberg, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Thomas D. Dean, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Søren Hauberg, 2010/04/19
- Re: Same .m file: different results with different versions of Octave, Thomas D. Dean, 2010/04/19