[Pkg-octave-devel] Re: Sparse + complex arithmetic inconsistency

David Bateman David.Bateman at motorola.com
Fri Mar 30 10:37:35 CET 2007


Rafael Laboissiere wrote:
> * David Bateman <David.Bateman at motorola.com> [2007-03-30 10:58]:
>
>   
>> Rafael Laboissiere wrote:
>>     
>>> I have here:
>>>
>>> $ g++ --version | fgrep g++
>>> g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
>>>   
>>>       
>> This might play a part in the issue.
>>     
>
> Could someone write a simple C++ test program that could put the bug in
> evidence?
>
>   
>> No I don't think this matters, as the "./" operator directly calls the
>> libc++ std::<complex>(double) division operator. However it should do this
>> for both "./" on full and sparse matrices, therefore "(1+1i)/0" and
>> "sparse(1+1i)/sparse(0)" should both give the same result. Can you confirm
>> what "sparse(1+1i)/sparse(0)" gives on your system? However, given the
>> "make check" failure you sent it appears that the full and sparse divisions
>> don't agree.
>>     
>
> Indeed:
>
> octave2.9:1> (1+1i)/0
> warning: division by zero
> ans = Inf + Infi
> octave2.9:2> sparse(1+1i)/sparse(0)
> warning: division by zero
> ans = NaN - NaNi
>
> However:
>
> octave2.9:3> 1/0
> warning: division by zero
> ans = Inf
> octave2.9:4> sparse(1)/sparse(0)
> warning: division by zero
> ans = Inf
>
> This is also weird:
>
> octave2.9:5> 0/0
> warning: division by zero
> ans = NaN
> octave2.9:6> sparse(0)/sparse(0)
> warning: division by zero
> ans = 0
>
>   
>> Looking at the code is Sparse-op-defs.h for quotient, I see no reason for
>> this.
>>     
>
> Which is the relevant part in this file?
>
>   

#include <math.h>
#include <complex.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
  complex double c = 1+I*1,z = 0.;
  // This should produce (inf,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));
  return 0;
}

Compiled with gcc. For me this returns (nan,nan)..

D.

-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary




More information about the Pkg-octave-devel mailing list