필터 지우기
필터 지우기

Which is faster, the sparse or spdiag function?

조회 수: 8 (최근 30일)
d
d 2018년 4월 10일
댓글: d 2018년 4월 11일
In each iteration of a for loop I'm creating a big (approximatlly 10k*10k) five diagonal sparse matrix. Does anybody knows which function work faster? The sparse or spdiags. Is there a faster way to it if I only update the values of an existing sparse matrix in each iteration?
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 4월 10일
Be careful, updating an existing sparse matrix is slow if you are adding non-zero elements beyond what was allocated for the matrix with spalloc()
James Tursa
James Tursa 2018년 4월 10일
Even if you are not exceeding the currently allocated memory for the matrix, it can be slow if the operation causes a large number of existing elements to be moved around in this memory.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 4월 10일
spdiags() invokes sparse() after packaging together the appropriate content and indices.
  댓글 수: 1
d
d 2018년 4월 11일
So, it means that sparse() is better in terms of time consuming. Thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by