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

5 ビュー (過去 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 Center および File ExchangeSparse Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by