How to use GPU to speed up the assignment process?

1 view (last 30 days)
For example, how to speed up the following program using GPU or removing the loop? (At fact, the actual number of variables x and z is more than 10^6. but to convenience, I just list 16 values ).
clear;
tic;
x=[1,2,3,4,5,6,7,8,10,12,13,14,15,16,17,18];
z=[1,125,612,365,489,612,365,855,1,126,610,365,489,610,365,859];
k=zeros(length(x),121*121);
for i=1:1:length(x)
k(i,z(i))=x(i);
end
k1=sum(k,1);
toc;

Answers (0)

Community Treasure Hunt

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

Start Hunting!