rs_vector_math.spec revision 20b27d602a4778ed50a83df2147416a35b7c92be
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 n-dimensional space. 21 22 The precision of the mathematical operations is affected by the pragmas 23# 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. 24 rs_fp_relaxed and rs_fp_full. 25 26 Different precision/speed tradeoffs can be achieved by using three variants 27 of common math functions. Functions with a name starting with<ul> 28 <li>native_ may have custom hardware implementations with weaker precision,</li> 29 <li>half_ may perform internal computations using 16 bit floats, and</li> 30 <li>fast_ are n-dimensional space computations that may use 16 bit floats. 31 </ul> 32end: 33 34function: cross 35version: 9 36attrib: const 37w: 3, 4 38t: f32 39ret: #2#1 40arg: #2#1 left_vector 41arg: #2#1 right_vector 42summary: Cross product of two vectors 43description: 44 Computes the cross product of two vectors. 45test: vector 46end: 47 48function: distance 49version: 9 50attrib: const 51w: 1, 2, 3, 4 52t: f32 53ret: #2 54arg: #2#1 left_vector 55arg: #2#1 right_vector 56summary: Distance between two points 57description: 58 Compute the distance between two points. 59 60 See also @fast_distance(), @native_distance(). 61test: vector 62end: 63 64function: dot 65version: 9 66attrib: const 67w: 1, 2, 3, 4 68t: f32 69ret: #2 70arg: #2#1 left_vector 71arg: #2#1 right_vector 72summary: Dot product of two vectors 73description: 74 Computes the dot product of two vectors. 75test: vector 76end: 77 78function: fast_distance 79version: 17 80attrib: const 81w: 1, 2, 3, 4 82t: f32 83ret: #2 84arg: #2#1 left_vector 85arg: #2#1 right_vector 86summary: Approximate distance between two points 87description: 88 Computes the approximate distance between two points. 89 90 The precision is what would be expected from doing the computation using 16 bit floating point values. 91 92 See also @distance(), @native_distance(). 93test: vector 94end: 95 96function: fast_length 97version: 17 98attrib: const 99w: 1, 2, 3, 4 100t: f32 101ret: #2 102arg: #2#1 v 103summary: Approximate length of a vector 104description: 105 Computes the approximate length of a vector. 106 107 The precision is what would be expected from doing the computation using 16 bit floating point values. 108 109 See also @length(), @native_length(). 110test: vector 111end: 112 113function: fast_normalize 114version: 17 115attrib: const 116w: 1, 2, 3, 4 117t: f32 118ret: #2#1 119arg: #2#1 v 120summary: Approximate normalized vector 121description: 122 Approximately normalizes a vector. 123 124 For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values. 125 126 The precision is what would be expected from doing the computation using 16 bit floating point values. 127 128 See also @normalize(), @native_normalize(). 129test: vector 130end: 131 132function: length 133version: 9 134attrib: const 135w: 1, 2, 3, 4 136t: f32 137ret: #2 138arg: #2#1 v 139summary: Length of a vector 140description: 141 Computes the length of a vector. 142 143 See also @fast_length(), @native_length(). 144test: vector 145end: 146 147function: native_distance 148version: 21 149attrib: const 150w: 1, 2, 3, 4 151t: f32 152ret: #2 153arg: #2#1 left_vector 154arg: #2#1 right_vector 155summary: Approximate distance between two points 156description: 157 Computes the approximate distance between two points. 158 159 See also @distance(), @fast_distance(). 160test: vector 161end: 162 163function: native_length 164version: 21 165attrib: const 166w: 1, 2, 3, 4 167t: f32 168ret: #2 169arg: #2#1 v 170summary: Approximate length of a vector 171description: 172 Compute the approximate length of a vector. 173 174 See also @length(), @fast_length(). 175test: vector 176end: 177 178function: native_normalize 179version: 21 180attrib: const 181w: 1, 2, 3, 4 182t: f32 183ret: #2#1 184arg: #2#1 v 185summary: Approximately normalize a vector 186description: 187 Approximately normalizes a vector. 188 189 See also @normalize(), @fast_normalize(). 190test: vector 191end: 192 193function: normalize 194version: 9 195attrib: const 196w: 1, 2, 3, 4 197t: f32 198ret: #2#1 199arg: #2#1 v 200summary: Normalize a vector 201description: 202 Normalize a vector. 203 204 For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for positive values. 205 206 See also @fast_normalize(), @native_normalize(). 207test: vector 208end: 209