'\" t .\" Title: fast_normalize .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 02/03/2019 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "FAST_NORMALIZE" "3clc" "02/03/2019" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" fast_normalize \- Normal vector length 1\&. .SH "" .HP \w'floatn\ fast_normalize('u .BI "floatn fast_normalize(floatn\ " "p" ");" .SH "DESCRIPTION" .PP Returns a vector in the same direction as \fIp\fR but with a length of 1\&. \fBfast_normalize\fR is computed as: .sp .if n \{\ .RS 4 .\} .nf \fIp\fR * \fBsqrt\fR(3clc)(\fIp\&.x\fR2 + \fIp\&.y\fR2 +\&.\&.\&.) .fi .if n \{\ .RE .\} .PP The result shall be within 8192 ulps error from the infinitely precise result of: .sp .if n \{\ .RS 4 .\} .nf if ( \fBany\fR(3clc)(\fIp\fR == 0\&.0f)) \fIresult = p\fR; else \fIresult = p\fR / \fBsqrt\fR(3clc)(\fIp\&.x\fR2 + \fIp\&.y\fR2 +\&.\&.\&.); .fi .if n \{\ .RE .\} .PP with the following exceptions: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} If the sum of squares is greater than \fBFLT_MAX\fR then the value of the floating\-point values in the result vector are undefined\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} If the sum of squares is less than \fBFLT_MIN\fR then the implementation may return back \fIp\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} If the device is in \*(Aqdenorms are flushed to zero\*(Aq mode, individual operand elements with magnitude less than \fBsqrt\fR(3clc)(\fBFLT_MIN\fR) may be flushed to zero before proceeding with the calculation\&. .RE .SH "NOTES" .PP Built\-in geometric functions operate component\-wise\&. The description is per\-component\&. \fBfloat\fR\fB\fIn\fR\fR is \fBfloat\fR, \fBfloat2\fR, \fBfloat3\fR, or \fBfloat4\fR and \fBdouble\fR\fB\fIn\fR\fR is \fBdouble\fR, \fBdouble2\fR, \fBdouble3\fR, or \fBdouble4\fR\&. The built\-in geometric functions are implemented using the round to nearest even rounding mode\&. .PP The geometric functions can be implemented using contractions such as \fBmad\fR(3clc) or \fBfma\fR(3clc)\&. .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBgeometricFunctions\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 262, section 6.12.5 - Geometric Functions .RE