MATLAB: How to construct a complex gpuArray directly on the GPU

complexgpuarray

I am trying to initialize a complex gpuArray directly on the GPU (i.e. without first creating a complex array in host memory and then copying it over to the device).
So far the only thing I've found that works is:
foo = gpuArray(complex(0));
bar = zeros(4, 1, 'like',foo);
which seems kinda silly. Is there a way to allocate a complex gpuArray directly using something like gpuArray.zeros?

Best Answer

None of MATLAB's build methods (the zeros, ones family) build complex arrays, so the nearest you can get is to do something like:
complex(zeros(3, 'gpuArray'))
which never allocates any host memory, and results in a complex gpuArray.