octave-maintainers
[Top][All Lists]
Advanced

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

Saving memory in spones()


From: John W. Eaton
Subject: Saving memory in spones()
Date: Fri, 13 May 2011 13:02:33 -0400

On 12-May-2011, Rik wrote:

| 5/12/11
| 
| The spones() function returns a sparse matrix with a 1 in each non-zero
| entry in the matrix.  It is useful for viewing the structure of a matrix,
| but obviously all of the actual values are lost.
| 
| The code is simple enough to quote in its entirety:
| 
| [i, j, v] = find (S);
| [m, n] = size (S);
| 
| r = sparse (i, j, 1, m, n);
| 
| Question: Why not return a sparse logical matrix rather than a sparse
| double matrix and save 7 bytes per entry?
| 
| r = sparse (i, j, logical (1), m, n);

The spones function also exists in Matlab and it apparently returns a
sparse matrix with class double.  I suppose it could cause some
compatibility problems if Octave behaved differently.

jwe


reply via email to

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