Hello. I want to create a sparse upper triangular with size 10^5x10^5. Is it possible?
m = triu(ones(10^5);
and
m = sparse(triu(ones(10^5));
exceed maximum array size preference. Thanks.

 채택된 답변

James Tursa
James Tursa 2016년 6월 7일
편집: James Tursa 2016년 6월 7일

1 개 추천

A sparse version of the full triangular matrix will have slightly over 1/2 of the values, plus some extra overhead for the explicit index numbers that are saved. A comparison of memory usage is:
n = number of rows & columns
full memory = 8*n^2 bytes
sparse memory = (8 + (4 or 8))*n*(n+1)/2 + (4 or 8)*(n+1) bytes
The (4 or 8) will depend on whether the indexing is saved as 4 or 8 byte integers on your machine.
So, if we assume 8 byte integers on your machine and n = 10^5, the memory comparison is:
full memory = 8e10 bytes
sparse memory = 8.0001600008e+10 bytes
The sparse version of this triangular matrix will actually consume more data memory than the full version.
A logical version of this matrix will consume this amount of data memory:
sparse logical memory = (1 + (4 or 8))*n*(n+1)/2 + (4 or 8)*(n+1) bytes
So for 8 byte indexing and n = 10^5 as above, you would get:
sparse logical memory = 4.5001250008e+10 bytes
Still 56% the size of the full double version, so probably not what you need.
You need to find another way to solve your problem.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

제품

질문:

2016년 6월 7일

편집:

2016년 6월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by