Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: create large sparse FEM matrix --> out of memory
Date: Mon, 10 Aug 2009 22:45:20 +0000 (UTC)
Organization: Cambridge Univ
Lines: 19
Message-ID: <h5q7u0$60t$1@fred.mathworks.com>
References: <h5pbe7$nc2$1@fred.mathworks.com> <h5pf1k$qit$1@fred.mathworks.com> <h5pm76$ou1$1@fred.mathworks.com> <h5pn7m$3po$1@fred.mathworks.com> <h5pomg$acs$1@fred.mathworks.com> <h5pp33$67h$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1249944320 6173 172.30.248.35 (10 Aug 2009 22:45:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 Aug 2009 22:45:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870214
Xref: news.mathworks.com comp.soft-sys.matlab:562246


A B

I have two hints.

The first is to search for an author on the file exchange named Tim Davis. He does a lot of work with sparse matrices, and has published mex functions in C (and I believe c++ in places?) which make MATLAB about as fast as any other system for handling sparse matrices. His Sparse2 command might be very useful is speed of assembly is your issue.

The second is to have a look at the way in which MATLAB stores sparse matrices (comb through the sparse documentation for 'ir', 'jc', 'pr' vectors). You don't need to store both row and column indices. For most sparsity patterns (i.e. anything where you have on average more than one element per column), it is more memory-efficient to store just the row index. Then, store a vector of length ncolumns+1, containing the cumulative number of elements in each column.

Storing like that could save you almost 1/3 of the memory space you're currently allocating.

Kind regards, and good luck!

Tom Clark




"A B" <gitsnedbutzi@hotmail.com> wrote in message <h5pp33$67h$1@fred.mathworks.com>...
> btw. i'm also thinking of switching to a c++ spare matrix library (preferably mtl4). have you got any idea on how fast matlab sparse is on operations as additions and multiplication compared to one of the common c++ libraries?