Description
The following table describes the list of builtin
geometric functions.
These all operate componentwise.
The description is percomponent.
floatn
is float
, float2
, float3
, or float4
and doublen
is
double
^{[1]}, double2
, double3
, or
double4
.
Function 
Description 
float4 cross(float4 p0, float4 p1) 
Returns the cross product of p0.xyz and p1.xyz.
The w component of 
float dot(floatn p0, floatn p1) 
Compute dot product. 
float distance(floatn p0, floatn p1) 
Returns the distance between p0 and p1. This is calculated as length(p0  p1). 
float length(floatn p) 
Return the length of vector p, i.e., √ p.x^{2} + p.y ^{2} + … 
floatn normalize(floatn p) 
Returns a vector in the same direction as p but with a length of 1. 
float fast_distance(floatn p0, floatn p1) 
Returns fast_length(p0  p1). 
float fast_length(floatn p) 
Returns the length of vector p computed as: half_sqrt(p.x^{2} + p.y^{2} + …) 
floatn fast_normalize(floatn p) 
Returns a vector in the same direction as p but with a length of 1. fast_normalize is computed as: p * half_rsqrt(p.x^{2} + p.y^{2} + …) The result shall be within 8192 ulps error from the infinitely precise result of
with the following exceptions:

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.