1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3
"http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd" [
4
<!ENTITY geometricFunctionsInc SYSTEM "geometricFunctionsInc.xml">
10
<keyword>fast_normalize</keyword>
15
<refentrytitle>fast_normalize</refentrytitle>
19
<year>2007-2011</year>
20
<holder>The Khronos Group Inc.
21
Permission is hereby granted, free of charge, to any person obtaining a
22
copy of this software and/or associated documentation files (the
23
"Materials"), to deal in the Materials without restriction, including
24
without limitation the rights to use, copy, modify, merge, publish,
25
distribute, sublicense, and/or sell copies of the Materials, and to
26
permit persons to whom the Materials are furnished to do so, subject to
27
the condition that this copyright notice and permission notice shall be included
28
in all copies or substantial portions of the Materials.</holder>
31
<manvolnum>3</manvolnum>
34
<!-- ================================ SYNOPSIS -->
36
<refnamediv id="fast_normalize">
37
<refname>fast_normalize</refname>
40
Normal vector length 1.
44
<refsynopsisdiv xmlns:xlink="http://www.w3.org/1999/xlink"><title></title>
48
<link xlink:href="vectorDataTypes.html">float<replaceable>n</replaceable></link>
53
<paramdef><link xlink:href="vectorDataTypes.html">float<replaceable>n</replaceable></link><parameter>p</parameter></paramdef>
59
<!-- ================================ DESCRIPTION -->
61
<refsect1 id="description"><title>Description</title>
63
Returns a vector in the same direction as <varname>p</varname> but with a length of 1.
64
<function>fast_normalize</function> is computed as:
65
<literallayout> <varname>p</varname> * <citerefentry href="sqrt"><refentrytitle>half_sqrt</refentrytitle></citerefentry>(<varname>p.x</varname><superscript>2</superscript> + <varname>p.y</varname><superscript>2</superscript> +...)</literallayout>
69
The result shall be within 8192 ulps error from the infinitely precise result of:
70
<literallayout> if ( <citerefentry href="any"><refentrytitle>all</refentrytitle></citerefentry>(<varname>p</varname> == 0.0f))
71
<varname>result = p</varname>;
73
<varname>result = p</varname> / <citerefentry><refentrytitle>sqrt</refentrytitle></citerefentry>(<varname>p.x</varname><superscript>2</superscript> + <varname>p.y</varname><superscript>2</superscript> +...);</literallayout>
77
with the following exceptions:
83
If the sum of squares is greater than <constant>FLT_MAX</constant> then the
84
value of the floating-point values in the result vector are undefined.
90
If the sum of squares is less than <constant>FLT_MIN</constant> then the
91
implementation may return back <varname>p</varname>.
97
If the device is in 'denorms are flushed to zero'
98
mode, individual operand elements with magnitude less than
99
<citerefentry><refentrytitle>sqrt</refentrytitle></citerefentry>(<constant>FLT_MIN</constant>)
100
may be flushed to zero before proceeding with the calculation.
106
<!-- ================================ NOTES -->
108
<refsect1 id="notes"><title>Notes</title>
110
&geometricFunctionsInc;
114
<!-- ================================ EXAMPLE -->
115
<!-- DO NOT DELETE IN CASE AN EXAMPLE IS ADDED IN THE FUTURE -->
117
<refsect2 id="example1">
122
<informaltable frame="none">
123
<tgroup cols="1" align="left" colsep="0" rowsep="0">
124
<colspec colname="col1" colnum="1" />
128
Example goes here - it will be set in "code" type with white space preserved.
137
<!-- ================================ SPECIFICATION -->
138
<!-- Set the "uri" attribute in the <olink /> element to the "named destination" for the PDF page
140
<refsect1 id="specification"><title>Specification</title>
143
<imagedata fileref="pdficon_small1.gif" format="gif" />
146
<olink uri="geometricFunctions">OpenCL Specification</olink>
150
<!-- ================================ ALSO SEE -->
152
<refsect1 id="seealso"><title>Also see</title>
154
<citerefentry href="geometricFunctions"><refentrytitle>Geometric Functions</refentrytitle></citerefentry>
158
<!-- ============================== COPYRIGHT -->
159
<!-- Content included from copyright.inc.xsl -->
161
<refsect3 id="Copyright"><title></title>
163
<imagedata fileref="KhronosLogo.jpg" format="jpg" />