[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: |
Tue, 19 Dec 2006 11:31:04 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (Windows/20060909) |
address@hidden wrote:
I notice that:
sparse(1+i) ./ sparse(0) => NaN + NaNi
(instead of infinity).
This leads to several failures in the test regression suites. I tried on
2.1.73 under cygwin, with the same result. I also noticed the "FIXME"
in the sparse operators definitions, I guess it's related...
Michael.
With octave 2.9.9+ I get
octave:1> sparse(1+i)/sparse(0)
warning: matrix singular to machine precision, rcond = 0
warning: attempting to find minimum norm solution
ans = 0
octave:2> (1+i)/0
warning: division by zero
ans = NaN - NaNi
octave:3> (1+i)/0
warning: division by zero
ans = NaN - NaNi
octave:4> 1/0
warning: division by zero
ans = Inf
with matlab R2006b I get
>> 1/0
Warning: Divide by zero.
ans =
Inf
>> (1+1i)/0
Warning: Divide by zero.
ans =
Inf + Infi
>> sparse(1+1i)/sparse(0)
Warning: Divide by zero.
ans =
(1,1) Inf + Infi
I believe the (1+1i)/0 issue is the fault of my c++ complex class
implementation and not in octave at all. However, the sparse issue is
different. The problem here is there is no sparse scalar class (it
doesn't make sense), and so the standard matrix "/" operator is used. So
I'm get the answer back from CXSparse's QR solver. To get this right
will need care to be taken in the "\" and "/" operator that the size of
the sparse matrix passed isn't in fact a scalar, and if it is to convert
to scalar before the operators. However if we do that, then something
like "speye(5)*sparse(2)" should also be valid and in fact is in matlab.
This is a bit of a mess and easier would be to have "sparse(2)" return a
scalar rather than a sparse matrix, though that will break other things.
I'll make a possible patch for consideration, but there are lots of
files to touch to get this right..
D.