Description
The following table describes the list of built-in common functions. These all operate component-wise. The description is per-component.
The generic type name gentype indicates that the function can take any of
as the type for the arguments.
The generic type name gentypef indicates that the function can take any of
- 
float,float2,float3,float4,float8, orfloat16
as the type for the arguments.
The generic type name gentyped [3] indicates
that the function can take any of
- 
double,double2,double3,double4,double8ordouble16
as the type for the arguments.
The generic type name gentypeh [4] indicates
that the function can take any of
- 
half,half2,half3,half4,half8orhalf16
as the type for the arguments.
| All functions taking or returning halftypes are supported only when
thecl_khr_extension macro is supported. | 
| Function | Description | ||
|---|---|---|---|
| gentype clamp(gentype x, gentype minval, gentype maxval) gentypeh clamp(gentypeh x, half minval, half maxval) | Returns fmin(fmax(x, minval), maxval). Results are undefined if minval > maxval. | ||
| gentype degrees(gentype radians) | Converts radians to degrees, i.e. (180 / π) * radians. | ||
| gentype max(gentype x, gentype y) gentypeh max(gentypeh x, half y) | Returns y if x < y, otherwise it returns x. If x or y are infinite or NaN, the return values are undefined. | ||
| gentype min(gentype x, gentype y) gentypeh min(gentypeh x, half y) | Returns y if y < x, otherwise it returns x. If x or y are infinite or NaN, the return values are undefined. | ||
| gentype mix(gentype x, gentype y, gentype a) gentypeh mix(gentypeh x, gentypeh y, half a) | Returns the linear blend of x and y implemented as: x + (y - x) * a a must be a value in the range [0.0, 1.0]. If a is not in the range [0.0, 1.0], the return values are undefined. 
 | ||
| gentype radians(gentype degrees) | Converts degrees to radians, i.e. (π / 180) * degrees. | ||
| gentype step(gentype edge, gentype x) gentypeh step(half edge, gentypeh x) | Returns 0.0 if x < edge, otherwise it returns 1.0. | ||
| gentype smoothstep(gentype edge0, gentype edge1, gentype x) gentypeh smoothstep(half edge0, half edge1, gentypeh x) | Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold function with a smooth transition. This is equivalent to: Results are undefined if edge0 >= edge1 or if x, edge0 or edge1 is a NaN. 
 | ||
| gentype sign(gentype x) | Returns 1.0 if x > 0, -0.0 if x = -0.0, +0.0 if x = +0.0, or -1.0 if x < 0. Returns 0.0 if x is a NaN. | 
Document Notes
For more information, see the OpenCL C Specification
This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.