User`s guide
Run Built-In Functions on a GPU
9-11
(1,2) 1
(2,5) 1
g = gpuArray(s); % g is a sparse gpuArray
gt = transpose(g); % gt is a sparse gpuArray
f = full(gt) % f is a full gpuArray
0 0
1 0
0 0
0 0
0 1
Considerations for Complex Numbers
If the output of a function running on the GPU could potentially be complex, you must
explicitly specify its input arguments as complex. This applies to gpuArray or to
functions called in code run by arrayfun.
For example, if creating a gpuArray which might have negative elements, use G =
gpuArray(complex(p)), then you can successfully execute sqrt(G).
Or, within a function passed to arrayfun, if x is a vector of real numbers, and some
elements have negative values, sqrt(x) will generate an error; instead you should call
sqrt(complex(x)).
The following table lists the functions that might return complex data, along with the
input range over which the output remains real.
Function Input Range for Real Output
acos(x) abs(x) <= 1
acosh(x) x >= 1
acoth(x) abs(x) >= 1
acsc(x) abs(x) >= 1
asec(x) abs(x) >= 1
asech(x) 0 <= x <= 1
asin(x) abs(x) <= 1
atanh abs(x) <= 1