Efficient sparse matrix operation

조회 수: 2 (최근 30일)
Esegboria Osarhemen
Esegboria Osarhemen 2019년 3월 5일
답변: Stephan 2019년 3월 5일
I have a 900 x 900 sparse matrix 'S' which contains alot of zeros, when i perform the following operation
S./sum(S,2)
It takes too long because it is operating on the zeros too and resulting in alot of NaN values. Is there a more efficient way to do this

답변 (1개)

Stephan
Stephan 2019년 3월 5일
Hi,
if you precalculate the sum and then calculate you can save some time:
N = sum(S,2);
S./N;
I tried using sparse matrices of 900x900 with about 10k non zero elements, which was more time consuming then this operation.
Best regards
Stephan

카테고리

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