What to do with sparse(sparse(2),1) ?

David Bateman David.Bateman at motorola.com
Tue Dec 11 07:58:21 CST 2007


Kim Hansen wrote:
> I am not really sure what the bug is here as the help in sparse seems
> to have a cut and paste error:
> =========================
> octave:4> help sparse
>  -- Loadable Function: S = sparse (A)
>      Create a sparse matrix from the full matrix A.  is forced back to
>      a full matrix is resulting matrix is sparse
>
>  -- Loadable Function: S = sparse (A, 1)
>      Create a sparse matrix and convert it back to a full matrix.  is
>      forced back to a full matrix is resulting matrix is sparse
> =========================
>
> The problem I saw was that these two results were different:
> =========================
> octave:1> sparse(2,1)
> ans =
>
> Compressed Column Sparse (rows = 2, cols = 1, nnz = 0)
>
>
> octave:2> sparse(sparse(2),1)
> ans = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1)
>
>   (1, 1) ->  2
>   
The second form is an undocumented way of calling sparse to force the
maybe_mutate function to be called on the returned value, so that if the
sparse to full mutation is allowed, it will occur, and is useful in the
test code of octave. As the default is to have this densification of the
matrix off, then perhaps this functionality should be removed. For
information the two are the same for Matlab.. John, should I make this
change?

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 Bug-octave mailing list