Home | History | Annotate | Download | only in script_api
      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 
     17 header:
     18 summary: Vector Math Functions
     19 description:
     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>
     35 end:
     36 
     37 function: cross
     38 version: 9
     39 attrib: const
     40 w: 3, 4
     41 t: f32
     42 ret: #2#1
     43 arg: #2#1 left_vector
     44 arg: #2#1 right_vector
     45 summary: Cross product of two vectors
     46 description:
     47  Computes the cross product of two vectors.
     48 test: vector
     49 end:
     50 
     51 function: cross
     52 version: 24
     53 attrib: const
     54 w: 3, 4
     55 t: f16
     56 ret: #2#1
     57 arg: #2#1 left_vector
     58 arg: #2#1 right_vector
     59 test: vector
     60 end:
     61 
     62 function: distance
     63 version: 9
     64 attrib: const
     65 w: 1, 2, 3, 4
     66 t: f32
     67 ret: #2
     68 arg: #2#1 left_vector
     69 arg: #2#1 right_vector
     70 summary: Distance between two points
     71 description:
     72  Compute the distance between two points.
     73 
     74  See also @fast_distance(), @native_distance().
     75 test: vector
     76 end:
     77 
     78 function: distance
     79 version: 24
     80 attrib: const
     81 w: 1, 2, 3, 4
     82 t: f16
     83 ret: #2
     84 arg: #2#1 left_vector
     85 arg: #2#1 right_vector
     86 test: vector
     87 end:
     88 
     89 function: dot
     90 version: 9
     91 attrib: const
     92 w: 1, 2, 3, 4
     93 t: f32
     94 ret: #2
     95 arg: #2#1 left_vector
     96 arg: #2#1 right_vector
     97 summary: Dot product of two vectors
     98 description:
     99  Computes the dot product of two vectors.
    100 test: vector
    101 end:
    102 
    103 function: dot
    104 version: 24
    105 attrib: const
    106 w: 1, 2, 3, 4
    107 t: f16
    108 ret: #2
    109 arg: #2#1 left_vector
    110 arg: #2#1 right_vector
    111 test: vector
    112 end:
    113 
    114 function: fast_distance
    115 version: 17
    116 attrib: const
    117 w: 1, 2, 3, 4
    118 t: f32
    119 ret: #2
    120 arg: #2#1 left_vector
    121 arg: #2#1 right_vector
    122 summary: Approximate distance between two points
    123 description:
    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().
    130 test: vector
    131 end:
    132 
    133 function: fast_length
    134 version: 17
    135 attrib: const
    136 w: 1, 2, 3, 4
    137 t: f32
    138 ret: #2
    139 arg: #2#1 v
    140 summary: Approximate length of a vector
    141 description:
    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().
    148 test: vector
    149 end:
    150 
    151 function: fast_normalize
    152 version: 17
    153 attrib: const
    154 w: 1, 2, 3, 4
    155 t: f32
    156 ret: #2#1
    157 arg: #2#1 v
    158 summary: Approximate normalized vector
    159 description:
    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().
    169 test: vector
    170 end:
    171 
    172 function: length
    173 version: 9
    174 attrib: const
    175 w: 1, 2, 3, 4
    176 t: f32
    177 ret: #2
    178 arg: #2#1 v
    179 summary: Length of a vector
    180 description:
    181  Computes the length of a vector.
    182 
    183  See also @fast_length(), @native_length().
    184 test: vector
    185 end:
    186 
    187 function: length
    188 version: 24
    189 attrib: const
    190 w: 1, 2, 3, 4
    191 t: f16
    192 ret: #2
    193 arg: #2#1 v
    194 test: vector
    195 end:
    196 
    197 function: native_distance
    198 version: 21
    199 attrib: const
    200 w: 1, 2, 3, 4
    201 t: f32
    202 ret: #2
    203 arg: #2#1 left_vector
    204 arg: #2#1 right_vector
    205 summary: Approximate distance between two points
    206 description:
    207  Computes the approximate distance between two points.
    208 
    209  See also @distance(), @fast_distance().
    210 test: vector
    211 end:
    212 
    213 function: native_distance
    214 version: 24
    215 attrib: const
    216 w: 1, 2, 3, 4
    217 t: f16
    218 ret: #2
    219 arg: #2#1 left_vector
    220 arg: #2#1 right_vector
    221 test: vector
    222 end:
    223 
    224 function: native_length
    225 version: 21
    226 attrib: const
    227 w: 1, 2, 3, 4
    228 t: f32
    229 ret: #2
    230 arg: #2#1 v
    231 summary: Approximate length of a vector
    232 description:
    233  Compute the approximate length of a vector.
    234 
    235  See also @length(), @fast_length().
    236 test: vector
    237 end:
    238 
    239 function: native_length
    240 version: 24
    241 attrib: const
    242 w: 1, 2, 3, 4
    243 t: f16
    244 ret: #2
    245 arg: #2#1 v
    246 test: vector
    247 end:
    248 
    249 function: native_normalize
    250 version: 21
    251 attrib: const
    252 w: 1, 2, 3, 4
    253 t: f32
    254 ret: #2#1
    255 arg: #2#1 v
    256 summary:  Approximately normalize a vector
    257 description:
    258  Approximately normalizes a vector.
    259 
    260  See also @normalize(), @fast_normalize().
    261 test: vector
    262 end:
    263 
    264 function: native_normalize
    265 version: 24
    266 attrib: const
    267 w: 1, 2, 3, 4
    268 t: f16
    269 ret: #2#1
    270 arg: #2#1 v
    271 test: vector
    272 end:
    273 
    274 function: normalize
    275 version: 9
    276 attrib: const
    277 w: 1, 2, 3, 4
    278 t: f32
    279 ret: #2#1
    280 arg: #2#1 v
    281 summary: Normalize a vector
    282 description:
    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().
    289 test: vector
    290 end:
    291 
    292 function: normalize
    293 version: 24
    294 attrib: const
    295 w: 1, 2, 3, 4
    296 t: f16
    297 ret: #2#1
    298 arg: #2#1 v
    299 test: vector
    300 end:
    301