필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
kalana agampodi
kalana agampodi 2021년 10월 11일
편집: kalana agampodi 2021년 10월 11일
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