Re: out of memory
- From: "Tim Davis" <davis@xxxxxxxxxxxx>
- Date: Mon, 28 Aug 2006 20:50:43 -0400
spasmous wrote:
answer
Bin Jiang wrote:
Thanks, run your suggested commend nnz for my matrix, the
is
as follows:
ans =
36292
Any further comments?
Let me get this straight. You have a 20000x20000 matrix with 36000
elements - or approximately 2 per row. Hm that's like a 6000x6000
dense
matrix (+overhead). Quite big - if only MATLAB allowed single
precision
sparse matrices...
One solution might be to create your own sparse format (eg. see
numerical recipes) and use singles and ints for storage. Look at
CSPARSE -
<http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11740&objectType=file>.
The source code cs.h defines the matrix like this:
typedef struct cs_sparse /* matrix in compressed-column or
triplet
form */
{
int nzmax ; /* maximum number of entries */
int m ; /* number of rows */
int n ; /* number of columns */
int *p ; /* column pointers (size n+1) or col indices (size
nzmax) */
int *i ; /* row indices, size nzmax */
double *x ; /* numerical values, size nzmax */
int nz ; /* # of entries in triplet matrix, -1 for
compressed-col */
} cs ;
I guess if you want it badly enough you can change the doubles to
floats (and elsewhere in the code).
This is actually a very small problem ... you just need to store it
as a sparse matrix, not as a dense one. You don't need much memory.
With only 36000 entries, you can trivially work in double precision.
You don't need sparse single precision.
A 20,000 by 20,0000 matrix with 36,000 nonzeros would take memory
equal to
4*20000 + 12*36000 bytes = 512K bytes.
This entire matrix will fit in the cache of most processors ... you
do work on it with hardly any memory at all.
Don't attempt to create the matrix as a dense one. Create a list of
nonzero entries: three arrays i,j,x of length 36000. Then the kth
entry in the matrix is in row i(k), column j(k), and has value x(k).
The order of entries in this list doesn't matter; they can appear in
any order. Then do
A = sparse (i,j,x) ;
then type "whos", and you'll see this problem is quite small.
You don't need to modify CSparse to solve this problem.
So what is it you want to do with this matrix?
Tim Davis (...author of CSparse, x=A\b when A is sparse, etc).
.
- References:
- out of memory
- From: Bin Jiang
- Re: out of memory
- From: Bin Jiang
- Re: out of memory
- From: spasmous
- Re: out of memory
- From: Bin Jiang
- Re: out of memory
- From: spasmous
- out of memory
- Prev by Date: Purchase Broccoli Extract----Choose lily!
- Next by Date: Purchase Bilberry Extract------Choose lily!
- Previous by thread: Re: out of memory
- Next by thread: Re: out of memory
- Index(es):
Relevant Pages
|
Loading