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: Wed, 03 Jan 2007 18:19:01 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

address@hidden wrote:
> > Ok, this was a lot more work than I though it would be, but here is the
> > patch. Basically it allows scalars to be stored in a sparse matrix
> > container and to be treated as if they were scalars. This is necessary
> > as Mathworks chose the path of letting the user store scalars as sparse
> > matrices rather than automatically reconverting these to scalars. In any
> > case the attached patch makes octave matlab compatible for scalars
> > stored as sparse matrices for all operators...
>  
> But it does not solve the fact that (note element-wise division):
>  
> [1+i 2-i] ./ [0 0-i]
>  
> gives under Octave
>  
> [NaN + NaNi     1 +   2i]
>  
> and under Matlab
>  
> [Inf +    Infi   1.0000 + 2.0000i]
>  
> Does it?
>  
> 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

I have no idea if this is fixed in later versions of g++, but I hope
so.. As for MSVC, tell microsoft about their bug :-)

D.

-- 
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

#include <complex>
#include <iostream>

typedef std::complex<double> Complex;

int main (void)
{
  std::cout << "(1+i) / (0 + 0i) : " << Complex(1.,1.) / Complex(0.,0.) << "\n";
  std::cout << "(1+i) / 0 : " << Complex(1.,1.) / 0. << "\n";
  std::cout << "1 / 0 : " << 1. / 0. << "\n";
  return 0;
}

reply via email to

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