[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Saving memory in spones()
From: |
Rik |
Subject: |
Saving memory in spones() |
Date: |
Thu, 12 May 2011 11:58:03 -0700 |
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);
--Rik
- Saving memory in spones(),
Rik <=