Using Arrays inside arrayfun()
이전 댓글 표시
I'm using gpuArrays with arrayfun to speed up calculations, and I would need to pass an array inside the call, as such
[Zn] = arrayfun( @iterFuncDelta,Xo,Yo,orbit)
function [Zn] = iterFuncDelta(xdelta0,ydelta0,refOrbit)
maxIterations=2^15;
delta=complex(xdelta0,ydelta0);
delta0=delta;
n=2;
Zn=refOrbit(1,1)+delta;
while ( n <= maxIterations )
Zn=refOrbit(n,1)+delta;
delta=2*refOrbit(n,1)*delta+delta^2+delta0;
n=n+1;
end
end
How could I pass the array 'orbit' so that it is not treated as a single point (like Xo and Yo) ?
Thanks.
채택된 답변
추가 답변 (2개)
Walter Roberson
2017년 12월 23일
0 개 추천
댓글 수: 3
Walter Roberson
2017년 12월 23일
[Zn] = arrayfun( @(x,y) iterFuncDelta(x,y,orbit), Xo, Yo )
Matt J
2017년 12월 24일
I don't think this will work on the GPU.
Joss Knight
2017년 12월 26일
0 개 추천
You can't do any array or matrix operations in a GPU arrayfun kernel. You can access the contents of an array that is present as an up-level variable such as has been demonstrated in the comments. You can then loop over the contents of the array one element at a time, to emulate array operations such as a dot product. This blog article gives an example of doing this for a simple 3-vector.
카테고리
도움말 센터 및 File Exchange에서 GPU Computing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!