Sparse matrix operations cause extra non-zero values (very small)

2 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Aritra
Aritra il 31 Gen 2023
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:

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by