User`s guide

Establish Arrays on a GPU
9-5
For example, to see the help on the colon constructor, type
help gpuArray/colon
Example: Construct an Identity Matrix on the GPU
To create a 1024-by-1024 identity matrix of type int32 on the GPU, type
II = eye(1024,'int32','gpuArray');
size(II)
1024 1024
With one numerical argument, you create a 2-dimensional matrix.
Example: Construct a Multidimensional Array on the GPU
To create a 3-dimensional array of ones with data class double on the GPU, type
G = ones(100,100,50,'gpuArray');
size(G)
100 100 50
classUnderlying(G)
double
The default class of the data is double, so you do not have to specify it.
Example: Construct a Vector on the GPU
To create a 8192-element column vector of zeros on the GPU, type
Z = zeros(8192,1,'gpuArray');
size(Z)
8192 1
For a column vector, the size of the second dimension is 1.
Control the Random Stream for gpuArray
The following functions control the random number stream on the GPU:
parallel.gpu.rng