Prev: How do I set uitable focus?
Next: Web Services & Matlab
From: Cris Luengo on 9 Apr 2010 10:23 The documentation for SPARSE says: "The sparse attribute allows MATLAB to: [...] Store only the nonzero elements of the matrix, together with their indices." This is not true. It turns out, MATLAB stores sparse matrices as sparse columns, but there is some data for every column, even if the column is completely empty. I noticed this when converting a very long vector with only a few non-zero elements to a sparse matrix. There was no reduction in size until I transposed it. For a very simple example, try this: a = sparse(1:5,ones(1,5),1:5,10000,1); b = a'; whos The matrix A is 96 bytes, B is 80088 bytes. A better implementation would compress along columns or vectors, depending on which are longer. A better documentation would warn users about this.
From: Matt J on 9 Apr 2010 10:32 "Cris Luengo" <cris.luengo(a)google.for.my.name.to.contact.me> wrote in message <hpnd89$dua$1(a)fred.mathworks.com>... > The documentation for SPARSE says: > "The sparse attribute allows MATLAB to: [...] Store only the nonzero elements of the matrix, together with their indices." ===== Sparse matrix objects maintain a count of the number of non-zero elements in each column. It is that which accounts for what you are seeing and it is in the documentation. The implication of the passage that you quoted is that no zero elements of the matrix are stored, and that is true.
|
Pages: 1 Prev: How do I set uitable focus? Next: Web Services & Matlab |