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

4 次查看(过去 30 天)
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

回答(0 个)

类别

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