sparse vs full

sparse vs full

Post by eric h » Wed, 10 Jul 2002 22:47:30



Is there any general rule of thumb that dictates when to use a full
matrix over a sparse matrix?   any specific matrix density ?

Does matlab run much slower if store and operate on relatively dense
matrices as a sparse matrix?

Basically, I'm working with a matrix that is about 1/4 full.   But all
the operators are one or a few times more dense than a diagonal
matrix. So I'm guessing that I should store the operators as sparse
matrices and have them operate on a full matrix.  The matrix
dimensions are on the order of around 1000's x 1000's.

 
 
 

sparse vs full

Post by mari » Thu, 11 Jul 2002 05:48:16


I learned in a numerical analysis class that usually a matrix is
considered sparse if approx 10% of the entries are non-zero.

I am not sure how dependable this percentage is, but it does say that
almost all the entries would be zero.

 
 
 

sparse vs full

Post by Cleve Mol » Thu, 11 Jul 2002 12:39:47



>Is there any general rule of thumb that dictates when to use a full
>matrix over a sparse matrix?   any specific matrix density ?

>Does matlab run much slower if store and operate on relatively dense
>matrices as a sparse matrix?

>Basically, I'm working with a matrix that is about 1/4 full.   But all
>the operators are one or a few times more dense than a diagonal
>matrix. So I'm guessing that I should store the operators as sparse
>matrices and have them operate on a full matrix.  The matrix
>dimensions are on the order of around 1000's x 1000's.

It depends a lot on what kind of operations you are doing.
Usually, matrices that have 1/4 of their elements nonzero are
best stored as full matrices.  Sparse matrices usually have a
tiny fraction of nonzero elements and are so large that it is
impossible to store them as full matrice3s.

  -- Cleve Moler

 
 
 

sparse vs full

Post by Sitansu B Pattnai » Fri, 12 Jul 2002 04:28:00


I tried using sparse matrices for image processing but the image processing
functions I tried to use did not work.
In terms of strorage spare matrices are really useful but were not useful in
image processing.
Cheers
Sitansu

Quote:> Is there any general rule of thumb that dictates when to use a full
> matrix over a sparse matrix?   any specific matrix density ?

> Does matlab run much slower if store and operate on relatively dense
> matrices as a sparse matrix?

> Basically, I'm working with a matrix that is about 1/4 full.   But all
> the operators are one or a few times more dense than a diagonal
> matrix. So I'm guessing that I should store the operators as sparse
> matrices and have them operate on a full matrix.  The matrix
> dimensions are on the order of around 1000's x 1000's.

 
 
 

1. Primitive operations on sparse Matrix done on full copy??

I have a number of sparse matrices, that I want to sum up. These are
composed in a for loop, and summing them up leeds to memory allocation
and reordering in every step of the loop. Very ugly and slow. So a
fellow came up with the idea of putting these matrices in columns of
large sparse matrix and do a

sum(M,2).

This leeds to a out of memory error. A

sum(M)

works fine. So I assume, Matlab does the summing along rows on
full(M),
wich is easier to implement, but not of that much use, as in the above
stated example, one dimension is some 10 million.
Yes, you read right, it is very sparse.

Transposing M seems to be done on full(M) as well.

I tried to do the sum on every row at a time, but even on row is too
large (otherwise the original matrices wouldn't have to be sparse ;-))

I ended up with doing the sum by hand, but a for loop over every
nonezero of the final matrix is REALLY slow.

Any good workaround?

(to Mathworks: if it isn't yet, would you copy these 'features' from my
wishlist to yours? Thanx)

Axel

2. Changing Printer Names

3. Inconsistent sparse/full behaviour (BUG?)

4. Accessing email Content-Type

5. student vs. full...errors...

6. yamaha crd200.DAE

7. sparse command and double vs single arrays

8. SETI@home for OS/2

9. Creating sparse matrices from sparse vectors

10. eigen value vs Newton's Method vs.... also Matlab Symbolic Toolkit

11. MR vs ARIMA (Multiple Regression vs Auto Regressive Integrated

12. Windows vs. Linux vs Unix

13. What to buy: P4s vs. PIIIs, Windows vs. Linux