[Top][All Lists]

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

Re: Static storage of huge sparce matrices

From: c.
Subject: Re: Static storage of huge sparce matrices
Date: Fri, 2 Nov 2012 20:56:58 +0100

On 2 Nov 2012, at 20:41, Joza wrote:

> Interesting stuff! Thanks! I shall take a good look at that stuff further.
> Besides that, is there a good way to implement the static structure I
> mentioned? Or would I be best just making the full matrix using toeplitz?

the matrix produced by toeplitz will not be saprse, it is actually saved in 
exactly the same format you described.

> Actually, would Octave automatically recognize my matrix is sparse and store
> it that way!!??

no it does not recognize it automatically you have to define it as such, 
the function "toeplitz" does define its output as sparse. 

>> x = toeplitz(sparse([1 1], [1 2], [2, -1], 1, 1e3));
>> typeinfo (x)
ans = sparse matrix

another way to get the same sparse matrix is

>> x = spdiags (-ones(1000, 3), -1:1, 1000, 1000) + 3 * eye (1000);
>> typeinfo (x)
ans = sparse matrix

If you define the matrix using diag rather than spdiags you will get it as full

>> xfull = 2 * eye (1000) + diag (ones(999, 1), -1) + diag (ones(999, 1), 1);
>> typeinfo (xfull)
ans = matrix

the two matrices compute very different amount of memory:

>> whos x xfull
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  ===== 
        x        1000x1000                   39980  double
        xfull    1000x1000                 8000000  double

> Is such storage done automatically?

yes. Octave stores sparse matrices as Compressed Sparse Column as is explained 
in the links you got from previous replies.


reply via email to

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