rs_vector_math.spec revision 21a9fe9b488b85a9eb0f4819af612bf95ea16c16
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_length
214version: 21
215attrib: const
216w: 1, 2, 3, 4
217t: f32
218ret: #2
219arg: #2#1 v
220summary: Approximate length of a vector
221description:
222 Compute the approximate length of a vector.
223
224 See also @length(), @fast_length().
225test: vector
226end:
227
228function: native_length
229version: 24
230attrib: const
231w: 1, 2, 3, 4
232t: f16
233ret: #2
234arg: #2#1 v
235test: vector
236end:
237
238function: native_normalize
239version: 21
240attrib: const
241w: 1, 2, 3, 4
242t: f32
243ret: #2#1
244arg: #2#1 v
245summary:  Approximately normalize a vector
246description:
247 Approximately normalizes a vector.
248
249 See also @normalize(), @fast_normalize().
250test: vector
251end:
252
253function: native_normalize
254version: 24
255attrib: const
256w: 1, 2, 3, 4
257t: f16
258ret: #2#1
259arg: #2#1 v
260test: vector
261end:
262
263function: normalize
264version: 9
265attrib: const
266w: 1, 2, 3, 4
267t: f32
268ret: #2#1
269arg: #2#1 v
270summary: Normalize a vector
271description:
272 Normalize a vector.
273
274 For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for
275 positive values.
276
277 See also @fast_normalize(), @native_normalize().
278test: vector
279end:
280
281function: normalize
282version: 24
283attrib: const
284w: 1, 2, 3, 4
285t: f16
286ret: #2#1
287arg: #2#1 v
288test: vector
289end:
290