[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About diagonal matrices
From: |
John W. Eaton |
Subject: |
Re: About diagonal matrices |
Date: |
Fri, 20 Feb 2009 12:04:44 -0500 |
On 20-Feb-2009, Jaroslav Hajek wrote:
| On Fri, Feb 20, 2009 at 5:45 PM, John W. Eaton <address@hidden> wrote:
|
| > But I think there are also some bugs. Shouldn't the following return
| > full matrices with the zero elements replaced by NaN (or -0, in the
| > case of dividing by -Inf)?
| >
| > diag ([1,2,3]) / 0
| > diag ([1,2,3]) / NaN
| > diag ([1,2,3]) / -Inf
| > diag ([1,2,3]) * NaN
| > diag ([1,2,3]) * Inf
| >
|
| I think it's better in the current manner. I don't like the idea that
| the memory can suddenly explode just because the multiplier happened
| to be Inf. Right now, scalar * diag gives invariantly diag. This is
| somewhat analogous to how sparse matrices behave.
I see
octave:3> speye (3)*Inf
ans =
Compressed Column Sparse (rows = 3, cols = 3, nnz = 3 [33%])
)
(1, 1) -> Inf
(2, 2) -> Inf
(3, 3) -> Inf
octave:4> speye (3)/0
warning: division by zero
ans =
Inf NaN NaN
NaN Inf NaN
NaN NaN Inf
So there seems to be some disagreement here, even within Octave.
I'm not sure what is best here, but I don't like it that we produce
numerically incorrect or incompatible answers just because of a
storage scheme.
BTW, for the two examples above, Matlab appears to keep the sparse
storage scheme, but does now fill with NaN values. If I recall
correctly, some previous versions did not do the operations on the
zero values at all.
For sparse matrices, I don't mind switching the storage scheme, though
I can imagine some cases where that would not be desirable either.
For diagonal matrices, we can't fill in the zero values and keep the
diagonal matrix storage scheme. But we could convert back to diagonal
if the off diagonal elements become zero. Should we be doing that?
It doesn't appear to be implemented now.
jwe
- Re: About diagonal matrices,
John W. Eaton <=
- Re: About diagonal matrices, Jaroslav Hajek, 2009/02/20
- Re: About diagonal matrices, John W. Eaton, 2009/02/20
- Re: About diagonal matrices, Jaroslav Hajek, 2009/02/20
- Re: About diagonal matrices, Jaroslav Hajek, 2009/02/20
- Re: About diagonal matrices, dbateman, 2009/02/20
- Re: About diagonal matrices, Daniel J Sebald, 2009/02/21
- Re: About diagonal matrices, Jaroslav Hajek, 2009/02/21
- Re: About diagonal matrices, John W. Eaton, 2009/02/21
- Re: About diagonal matrices, Søren Hauberg, 2009/02/21
- Re: About diagonal matrices, Daniel J Sebald, 2009/02/21