I have a sparse gpuArray (adj) and gpuArray A. Trying to execute
for i =1:length(A)
[~,c] = find(adj(A(i,1),:));
.
.
.
end
i get an error about matlab not allowing this way of indexing in sparse gpuArrays. After doing some search i understand that operator : inside adj(A(i,1),:) is causing the problem. Any suggestions of a solution or at least a way around this?

2 件のコメント

Matt J
Matt J 2017 年 4 月 7 日
編集済み: Matt J 2017 年 4 月 7 日
Hmmm...I'd like to see what the rest of the loop is doing.
Charis L
Charis L 2017 年 4 月 7 日
the loop is supposed to find every triangle the edges stored in A, participate in, and adj is the adjacency matrix, but it never moves beyond the fist line.

サインインしてコメントする。

 採用された回答

Joss Knight
Joss Knight 2017 年 4 月 13 日

0 投票

Generally if you are indexing scalar values in a sparse gpuArray then you're trying to do something very inefficient. Still, if you want the values in the j'th column of a sparse matrix you could go:
[I,J,V] = find(A);
j = 1;
ind = find(J==j);
Ij = I(ind);
Vj = V(ind);
Aj = zeros(size(A,1),1);
Aj(Ij) = Vj;
However, I get the impression that your A matrix is a column vector, in which case storing it as a sparse array is completely pointless since it saves you no space whatsoever. You may as well convert it to full.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSparse Matrices についてさらに検索

質問済み:

2017 年 4 月 7 日

回答済み:

2017 年 4 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by