1#
2# Copyright (C) 2015 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17header:
18summary: Vector Math Functions
19description:
20 These functions interpret the input arguments as representation of vectors in
21 n-dimensional space.
22
23 The precision of the mathematical operations on 32 bit floats is affected by the pragmas
24# TODO Create an anchor for the section of http://developer.android.com/guide/topics/renderscript/compute.html that details rs_fp_* and link them here.
25 rs_fp_relaxed and rs_fp_full.  See <a href='rs_math.html'>Mathematical Constants and Functions</a> for details.
26
27 Different precision/speed tradeoffs can be achieved by using variants of the common math
28 functions.  Functions with a name starting with<ul>
29 <li>native_: May have custom hardware implementations with weaker precision.  Additionally,
30   subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and
31   infinity input may not be handled correctly.</li>
32 <li>fast_: May perform internal computations using 16 bit floats.  Additionally, subnormal
33   values may be flushed to zero, and rounding towards zero may be used.</li>
34 </ul>
35end:
36
37function: cross
38version: 9
39attrib: const
40w: 3, 4
41t: f32
42ret: #2#1
43arg: #2#1 left_vector
44arg: #2#1 right_vector
45summary: Cross product of two vectors
46description:
47 Computes the cross product of two vectors.
48test: vector
49end:
50
51function: cross
52version: 24
53attrib: const
54w: 3, 4
55t: f16
56ret: #2#1
57arg: #2#1 left_vector
58arg: #2#1 right_vector
59test: vector
60end:
61
62function: distance
63version: 9
64attrib: const
65w: 1, 2, 3, 4
66t: f32
67ret: #2
68arg: #2#1 left_vector
69arg: #2#1 right_vector
70summary: Distance between two points
71description:
72 Compute the distance between two points.
73
74 See also @fast_distance(), @native_distance().
75test: vector
76end:
77
78function: distance
79version: 24
80attrib: const
81w: 1, 2, 3, 4
82t: f16
83ret: #2
84arg: #2#1 left_vector
85arg: #2#1 right_vector
86test: vector
87end:
88
89function: dot
90version: 9
91attrib: const
92w: 1, 2, 3, 4
93t: f32
94ret: #2
95arg: #2#1 left_vector
96arg: #2#1 right_vector
97summary: Dot product of two vectors
98description:
99 Computes the dot product of two vectors.
100test: vector
101end:
102
103function: dot
104version: 24
105attrib: const
106w: 1, 2, 3, 4
107t: f16
108ret: #2
109arg: #2#1 left_vector
110arg: #2#1 right_vector
111test: vector
112end:
113
114function: fast_distance
115version: 17
116attrib: const
117w: 1, 2, 3, 4
118t: f32
119ret: #2
120arg: #2#1 left_vector
121arg: #2#1 right_vector
122summary: Approximate distance between two points
123description:
124 Computes the approximate distance between two points.
125
126 The precision is what would be expected from doing the computation using 16 bit floating
127 point values.
128
129 See also @distance(), @native_distance().
130test: vector
131end:
132
133function: fast_length
134version: 17
135attrib: const
136w: 1, 2, 3, 4
137t: f32
138ret: #2
139arg: #2#1 v
140summary: Approximate length of a vector
141description:
142 Computes the approximate length of a vector.
143
144 The precision is what would be expected from doing the computation using 16 bit floating
145 point values.
146
147 See also @length(), @native_length().
148test: vector
149end:
150
151function: fast_normalize
152version: 17
153attrib: const
154w: 1, 2, 3, 4
155t: f32
156ret: #2#1
157arg: #2#1 v
158summary: Approximate normalized vector
159description:
160 Approximately normalizes a vector.
161
162 For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for
163 positive values.
164
165 The precision is what would be expected from doing the computation using 16 bit floating
166 point values.
167
168 See also @normalize(), @native_normalize().
169test: vector
170end:
171
172function: length
173version: 9
174attrib: const
175w: 1, 2, 3, 4
176t: f32
177ret: #2
178arg: #2#1 v
179summary: Length of a vector
180description:
181 Computes the length of a vector.
182
183 See also @fast_length(), @native_length().
184test: vector
185end:
186
187function: length
188version: 24
189attrib: const
190w: 1, 2, 3, 4
191t: f16
192ret: #2
193arg: #2#1 v
194test: vector
195end:
196
197function: native_distance
198version: 21
199attrib: const
200w: 1, 2, 3, 4
201t: f32
202ret: #2
203arg: #2#1 left_vector
204arg: #2#1 right_vector
205summary: Approximate distance between two points
206description:
207 Computes the approximate distance between two points.
208
209 See also @distance(), @fast_distance().
210test: vector
211end:
212
213function: native_distance
214version: 24
215attrib: const
216w: 1, 2, 3, 4
217t: f16
218ret: #2
219arg: #2#1 left_vector
220arg: #2#1 right_vector
221test: vector
222end:
223
224function: native_length
225version: 21
226attrib: const
227w: 1, 2, 3, 4
228t: f32
229ret: #2
230arg: #2#1 v
231summary: Approximate length of a vector
232description:
233 Compute the approximate length of a vector.
234
235 See also @length(), @fast_length().
236test: vector
237end:
238
239function: native_length
240version: 24
241attrib: const
242w: 1, 2, 3, 4
243t: f16
244ret: #2
245arg: #2#1 v
246test: vector
247end:
248
249function: native_normalize
250version: 21
251attrib: const
252w: 1, 2, 3, 4
253t: f32
254ret: #2#1
255arg: #2#1 v
256summary:  Approximately normalize a vector
257description:
258 Approximately normalizes a vector.
259
260 See also @normalize(), @fast_normalize().
261test: vector
262end:
263
264function: native_normalize
265version: 24
266attrib: const
267w: 1, 2, 3, 4
268t: f16
269ret: #2#1
270arg: #2#1 v
271test: vector
272end:
273
274function: normalize
275version: 9
276attrib: const
277w: 1, 2, 3, 4
278t: f32
279ret: #2#1
280arg: #2#1 v
281summary: Normalize a vector
282description:
283 Normalize a vector.
284
285 For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for
286 positive values.
287
288 See also @fast_normalize(), @native_normalize().
289test: vector
290end:
291
292function: normalize
293version: 24
294attrib: const
295w: 1, 2, 3, 4
296t: f16
297ret: #2#1
298arg: #2#1 v
299test: vector
300end:
301