help-octave
[Top][All Lists]
Advanced

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

Re: 0-1 sparse representations?


From: c.
Subject: Re: 0-1 sparse representations?
Date: Sun, 20 Nov 2011 08:57:07 +0100

On 19 Nov 2011, at 22:33, Jordi Gutiérrez Hermoso wrote:

> No. Sparse matrices must be of float types.

Do they?

---------------------------------------------------------------
>> b = sparse ([1 2 3]', [1 3 3]', true(3, 1))
b =

Compressed Column Sparse (rows = 3, cols = 3, nnz = 3 [33%])

  (1, 1) ->  1
  (2, 3) ->  1
  (3, 3) ->  1

>> whos b
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  ===== 
        b           3x3                         31  logical

Total is 3 elements using 31 bytes
---------------------------------------------------------------

isn't this a sparse matrix of logicals?
and it does seem to use less memory than a matrix of doubles:

---------------------------------------------------------------
>> b = sparse ([1 2 3]', [1 3 3]', ones(3, 1))
b =

Compressed Column Sparse (rows = 3, cols = 3, nnz = 3 [33%])

  (1, 1) ->  1
  (2, 3) ->  1
  (3, 3) ->  1

>> whos b
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  ===== 
        b           3x3                         52  double

Total is 3 elements using 52 bytes
---------------------------------------------------------------

c.



reply via email to

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