I would like to find the index of the smallest value resulting from some computation, like the nearest value, using Matlab gpuArrays.
However, in the arrayfun scenario the min function doesn't seem to offer the functionality.
With the following code:
function grid_gpu_test
gridSize = 8;
grid = gpuArray(rand(gridSize));
all_c=1:gridSize; % because : is not supported
function X = min_diff(row)
X = min(abs(grid(row,all_c)-grid(row,1)))
end
rows = gpuArray.colon(2, gridSize)';
arrayfun(@min_diff, rows)
end
I get the following error:
Too few input arguments supplied to: 'min'. Error in 'grid_gpu_test' (line: 9)
Is there a way to achieve this? I know that using min(gpuArray) works normally when it's not in arrayfun, but I want to achieve this with an operation that doesn't simplify into matrix operations.