[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sparse + complex arithmetic inconsistency
From: |
John W. Eaton |
Subject: |
Re: Sparse + complex arithmetic inconsistency |
Date: |
Sat, 31 Mar 2007 14:54:18 -0400 |
On 30-Mar-2007, David Bateman wrote:
| Or a slightly modification
|
| #include <math.h>
| #include <complex.h>
| #include <stdio.h>
| int main(int argc, char *argv[])
| {
| complex double b=1,c=I*1,d = 1+I*1,z = 0.;
| // This should produce (inf,0), not (nan,nan).
| printf("(%f,%f) / (%f,%f) -> (%f,%f)\n",
| creal(b),cimag(b),creal(z),cimag(z),creal(b/z),cimag(b/z));
| // This should produce (0,inf), not (nan,nan).
| printf("(%f,%f) / (%f,%f) -> (%f,%f)\n",
| creal(c),cimag(c),creal(z),cimag(z),creal(c/z),cimag(c/z));
| // This should produce (inf,inf), not (nan,nan).
| printf("(%f,%f) / (%f,%f) -> (%f,%f)\n",
| creal(d),cimag(d),creal(z),cimag(z),creal(d/z),cimag(d/z));
| return 0;
| }
|
| that all return (nan,nan) for me.
Here is what I see:
$ gcc foo.c
$ ./a.out
(1.000000,0.000000) / (0.000000,0.000000) -> (nan,nan)
(0.000000,1.000000) / (0.000000,0.000000) -> (nan,nan)
(1.000000,1.000000) / (0.000000,0.000000) -> (nan,nan)
$ gcc -O2 foo.c
$ ./a.out
(1.000000,0.000000) / (0.000000,0.000000) -> (inf,0.000000)
(0.000000,1.000000) / (0.000000,0.000000) -> (0.000000,inf)
(1.000000,1.000000) / (0.000000,0.000000) -> (inf,inf)
$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Is that acceptable behavior or a bug?
I seem to recall this problem coming up before, and we may have even
discussed it on the bug or maintainers list (the topic just seems
familiar; I haven't tried to find the thread in the archives).
jwe
- Re: [Pkg-octave-devel] Re: Debian packages for Octave 2.9.10 available in experimental, (continued)
- Re: [Pkg-octave-devel] Re: Debian packages for Octave 2.9.10 available in experimental, Rafael Laboissiere, 2007/03/30
- Re: [Pkg-octave-devel] Re: Debian packages for Octave 2.9.10 available in experimental, David Bateman, 2007/03/30
- Sparse + complex arithmetic inconsistency, Rafael Laboissiere, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency, David Bateman, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency, David Bateman, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency, Michael Goffioul, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency, David Bateman, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency, Rafael Laboissiere, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency, Michael Goffioul, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency, Rafael Laboissiere, 2007/03/30
- Re: Sparse + complex arithmetic inconsistency,
John W. Eaton <=
- Re: Sparse + complex arithmetic inconsistency, David Bateman, 2007/03/31
- Re: Sparse + complex arithmetic inconsistency, Rafael Laboissiere, 2007/03/31
- Re: Sparse + complex arithmetic inconsistency, Paul Kienzle, 2007/03/31
- Re: Sparse + complex arithmetic inconsistency, David Bateman, 2007/03/31