| Contents | Index |
| On this page… |
|---|
Code in a function passed to arrayfun for execution on the GPU can use only these GPU native data types: single, double, int32, uint32, and logical.
The overloaded functions for GPUArrays support these types where appropriate. GPUArrays also support the storing of data types in addition to these. This allows a GPUArray to be used with kernels written for these alternative data types, such as int8, uint8, etc.
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) | x >= 1 |
| acsc(x) | x >= 1 |
| asec(x) | x >= 1 |
| asech(x) | 0 <= x <= 1 |
| asin(x) | abs(x) <= 1 |
| atanh | abs(x) <= 1 |
| log(x) | x >= 0 |
| log1p(x) | x >= -1 |
| log10(x) | x >= 0 |
| log2(x) | x >= 0 |
| power(x,y) | x >= 0 |
| reallog(x) | x >= 0 |
| realsqrt(x) | x >= 0 |
| sqrt(x) | x >= 0 |
![]() | Execute CUDA or PTX Code on the GPU | Object Reference | ![]() |

See how to solve large problems with minimal effort and reduce simulation time.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |