octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sparse matrix problem


From: David Bateman
Subject: Re: Sparse matrix problem
Date: Thu, 04 Jan 2007 18:14:45 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Dmitri A. Sergatskov wrote:
> On 1/3/07, David Bateman <address@hidden> wrote:
>> address@hidden wrote:
>>
>> > [1+i 2-i] ./ [0 0-i]
>> >
>> > gives under Octave
>> >
>> > [NaN + NaNi     1 +   2i]
>> >
>
>> >
>> > Michael.
>> >
>> No as that is a problem with the underlying C++ complex class and not
>> octave at all.. Try the attached test program, which for me using g++
>> 4.0.1 returns
>>
>> (1+i) / (0 + 0i) : (nan,nan)
>> (1+i) / 0 : (nan,nan)
>> 1 / 0 : inf
>>
>
> Try to compile the test program with optimization on. On my computer
> (gcc version 4.1.1 20061011 (Red Hat 4.1.1-30))
> address@hidden test1]$ g++ -O0 test.cc -o test
> test.cc: In function 'int main()':
> test.cc:10: warning: division by zero in '1.0e+0 / 0.'
> address@hidden test1]$ ./test
> (1+i) / (0 + 0i) : (nan,nan)
> (1+i) / 0 : (nan,nan)
> 1 / 0 : inf
> address@hidden test1]$ g++ -O2 test.cc -o test
> test.cc: In function 'int main()':
> test.cc:10: warning: division by zero in '1.0e+0 / 0.'
> address@hidden test1]$ ./test
> (1+i) / (0 + 0i) : (inf,inf)
> (1+i) / 0 : (inf,inf)
> 1 / 0 : inf
> (The same result with -O1)
Then this is something that changed between 4.0.x and 4.1.x as
optimization makes no difference for me..

> In octave I get:
>
> octave:1> [1+i 2-i] ./ 0
> warning: division by zero
> ans =
>
>   Inf + Infi   Inf - Infi
>
> octave:2> [1+i 2-i] ./ [0, i]
> ans =
>
>   NaN - NaNi    -1 -   2i
>
> Since Octave is compiled with -O2 this test program does not seems to
> be a representative example ...
As far as I can see the code is representative of what is happening in
octave.. I used the typedef for Complex itself from Octave so as to make
as few mistakes as possible... I must admit I have no idea given the
behavior you should with optimization, why this is happening, though I
still think the fault is with gcc/g++...

Cheers

D.




>
> Sincerely,
>
> Dmitri.
> -- 
>


-- 
David Bateman                                address@hidden
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]