sparse cell array?
7 views (last 30 days)
Show older comments
i have a cell array where the cells contain matrices. i need to preallocate it for efficiency.
it has to be a cell array because i need to assign matrices in blocks.
but the cell array is huge... upwards of 30,000x30,000 with 10x10 matrices in diagonal and off diagonal cells (and at the corners).
once the matrices are assigned, i use a simple indexing routine to assign to assign all the elements to a sparse matrix of complex numbers.
while the final matrix is < 1 gb, the problem is that it requires ~10 gb of memory to assign the cell array in the first place...
is there a way to preallocate a sparse cell array?
thanks guys :D
0 Comments
Answers (1)
James Tursa
on 9 Jul 2018
If you mean can the cell array itself be sparse, the answer is no to that as MATLAB only supports sparse double and logical. What you could do is maintain the cell array as a simple linear array, and then keep track of the indexing yourself off to the side. E.g., with row & column number indexing arrays, or perhaps employing a sparse logical matrix to implicitly keep the indexing.
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!