필터 지우기
필터 지우기

Speed up for loops for arrays

조회 수: 1 (최근 30일)
Mantas Vaitonis
Mantas Vaitonis 2018년 11월 9일
편집: madhan ravi 2018년 11월 9일
Hello, Maybe someone could help me to speedup this type of for loop? I did try parfor, I did try to think of way using GPU, but it does not work with indexing.
clear;
a=7811200001;
d=1083355908;
c=zeros(1083355908,1)
parfor i = 1:d
c(i,1)=a+i;
end

채택된 답변

madhan ravi
madhan ravi 2018년 11월 9일
편집: madhan ravi 2018년 11월 9일
a=7811200001;
d=1083355908;
c=a+(1:d);
c=(a+1):(a+d); %edited after jan's comment
  댓글 수: 10
Jan
Jan 2018년 11월 9일
Another hint: In a+(1:d) you create the double vector 1:d at first and then add a to each element. It is more efficient to omit the addition and create vector directly:
(a+1):(a+d)
madhan ravi
madhan ravi 2018년 11월 9일
편집: madhan ravi 2018년 11월 9일
Selbverständlich , danke schön @Jan

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by