Borrar filtros
Borrar filtros

How to get the compressed row sparse CRS in a matrix ?

6 visualizaciones (últimos 30 días)
kalana agampodi
kalana agampodi el 11 de Oct. de 2021
Editada: kalana agampodi el 11 de Oct. de 2021
I want to get the compressed row sparse (CRS) of the following matrix.
A=[ 1 0 -2 0 0;...
2 8 0 1 0;...
0 0 3 0 -2;...
0 -3 2 0 0;...
1 2 0 0 -4]
So far I have the folliwing code but how ever I do not know to get the row pointer. Hoow do I get the row pointer for the above matrix ?
So far i have...
n=length(A);
c=1;
for i=1:n
for j=1:n
if A(i,j) ~= 0;
row(c,1)=i;
col(c,1)=j;
val(c,1)=A(i,j);
index(c,1)= c;
data = {index, val};
c=c+1;
end
end
end

Respuestas (0)

Categorías

Más información sobre Sparse Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by