Sparse matrix operations cause extra non-zero values (very small)
조회 수: 1 (최근 30일)
이전 댓글 표시
I have two big sparse matrix A, B and I want to get
C=A\B
However, many of the elements in C are actually very small (<1e-10), which I think is due to precision. This would lead to a significant increase of the memory to store C.
My question is, what should I do to eliminate those small numbers, before actually storing them? I don't want to make some selections to the elements of C after its creation, which already takes up memories.
댓글 수: 0
답변 (1개)
Aritra
2023년 1월 31일
Hi,
As per my understanding you are trying to convert values under a certain threshold (<1e-10) to 0.
You can make use of logical indexing for the task. Suppose you have a vector A with 5 elements, and you want to convert the values less than 3 to 0. Consider the following example illustrating the idea:
A = [1,2,3,4,5];
t = A(1:end)<3;
A(t) = 0;
For more details on logical indexing, you can refer to the below documentation on MATRIX Indexing in MATLAB:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!