A few questions on memory management of sparse matrices...

2 ビュー (過去 30 日間)
Martin
Martin 2013 年 7 月 19 日
Hi,
I have a bit of trouble with the space used by sparse matrices.
I use two ways of creating the same matrix, say P:
(1) allocating some space and filling the matrix like P(4,2) = 89; the space allocated at the beginning is exactly the space used.
(2) or creating 3 arrays of rows and columns indices and matrix values, and making P in just one command line.
What I observed: - when I create twice the same matrix with both methods, the space used in bigger for the first one (until half much more space).
- the second method was faster when I created one big matrix. but the first is faster when I create a relatively large cell array filled with many smaller sparse matrices. Actually, when using the first method, I receive this matlab warning (that advises me to use the second method) when I want to create the big sparse matrix but not when I create the cell arrays of matrices.
- with the second method, I obtain 3 arrays of 8MB but my matrix is 500MB!
I can't explain all these things. Could you?
Thank!
  3 件のコメント
James Tursa
James Tursa 2013 年 7 月 19 日
I agree with Jan ... we need to see the code. A simple expression like P(4,2) = 89 may cause the entire existing sparse matrix memory to be copied to new memory. So understanding exactly how you are doing the sparse matrix build is critical to the memory usage and timing issues.
Jan
Jan 2013 年 7 月 19 日
編集済み: Jan 2013 年 7 月 19 日
@James: I had a discussion about why Matlab required more than 8GB free RAM to create q [1x1e9] UINT32 vector, although 4GB should be enough. The description as a text did not reveal the cause, but the seeing the code did:
uint32(1:1e9) % 8GB used for the temporary double array! Better:
uint32(1):uint32(1e9) % 4GB

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by