Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 1 | # |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 2 | # Copyright (C) 2014 The Android Open Source Project |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 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: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 18 | summary: Mathematical Constants and Functions |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 19 | description: |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 20 | The mathematical functions below can be applied to scalars and vectors. When applied |
| 21 | to vectors, the returned value is a vector of the function applied to each entry of the input. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 22 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 23 | For example:<code><br/> |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 24 | float3 a, b;<br/> |
| 25 | // The following call sets<br/> |
| 26 | // a.x to sin(b.x),<br/> |
| 27 | // a.y to sin(b.y), and<br/> |
| 28 | // a.z to sin(b.z).<br/> |
| 29 | a = sin(b);<br/> |
| 30 | </code> |
| 31 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 32 | See <a href='rs_vector_math.html'>Vector Math Functions</a> for functions like @distance() and @length() that interpret |
| 33 | instead the input as a single vector in n-dimensional space. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 34 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 35 | The precision of the mathematical operations on 32 bit floats is affected by the pragmas |
| 36 | rs_fp_relaxed and rs_fp_full. Under rs_fp_relaxed, subnormal values may be flushed to zero and |
| 37 | rounding may be done towards zero. In comparison, rs_fp_full requires correct handling of |
| 38 | subnormal values, i.e. smaller than 1.17549435e-38f. rs_fp_rull also requires round to nearest |
| 39 | with ties to even. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 40 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 41 | Different precision/speed tradeoffs can be achieved by using variants of the common math |
| 42 | functions. Functions with a name starting with<ul> |
| 43 | <li>native_: May have custom hardware implementations with weaker precision. Additionally, |
| 44 | subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and |
| 45 | infinity input may not be handled correctly.</li> |
| 46 | <li>half_: May perform internal computations using 16 bit floats. Additionally, subnormal |
| 47 | values may be flushed to zero, and rounding towards zero may be used.</li> |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 48 | </ul> |
| 49 | end: |
| 50 | |
| 51 | constant: M_1_PI |
| 52 | value: 0.318309886183790671537767526745028724f |
| 53 | summary: 1 / pi, as a 32 bit float |
| 54 | description: |
| 55 | The inverse of pi, as a 32 bit float. |
| 56 | end: |
| 57 | |
| 58 | constant: M_2_PI |
| 59 | value: 0.636619772367581343075535053490057448f |
| 60 | summary: 2 / pi, as a 32 bit float |
| 61 | description: |
| 62 | 2 divided by pi, as a 32 bit float. |
| 63 | end: |
| 64 | |
| 65 | constant: M_2_PIl |
| 66 | value: 0.636619772367581343075535053490057448f |
| 67 | hidden: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 68 | deprecated: Use M_2_PI instead. |
| 69 | summary: 2 / pi, as a 32 bit float |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 70 | description: |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 71 | 2 divided by pi, as a 32 bit float. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 72 | end: |
| 73 | |
| 74 | constant: M_2_SQRTPI |
| 75 | value: 1.128379167095512573896158903121545172f |
| 76 | summary: 2 / sqrt(pi), as a 32 bit float |
| 77 | description: |
| 78 | 2 divided by the square root of pi, as a 32 bit float. |
| 79 | end: |
| 80 | |
| 81 | constant: M_E |
| 82 | value: 2.718281828459045235360287471352662498f |
| 83 | summary: e, as a 32 bit float |
| 84 | description: |
| 85 | The number e, the base of the natural logarithm, as a 32 bit float. |
| 86 | end: |
| 87 | |
| 88 | constant: M_LN10 |
| 89 | value: 2.302585092994045684017991454684364208f |
| 90 | summary: log_e(10), as a 32 bit float |
| 91 | description: |
| 92 | The natural logarithm of 10, as a 32 bit float. |
| 93 | end: |
| 94 | |
| 95 | constant: M_LN2 |
| 96 | value: 0.693147180559945309417232121458176568f |
| 97 | summary: log_e(2), as a 32 bit float |
| 98 | description: |
| 99 | The natural logarithm of 2, as a 32 bit float. |
| 100 | end: |
| 101 | |
| 102 | constant: M_LOG10E |
| 103 | value: 0.434294481903251827651128918916605082f |
| 104 | summary: log_10(e), as a 32 bit float |
| 105 | description: |
| 106 | The logarithm base 10 of e, as a 32 bit float. |
| 107 | end: |
| 108 | |
| 109 | constant: M_LOG2E |
| 110 | value: 1.442695040888963407359924681001892137f |
| 111 | summary: log_2(e), as a 32 bit float |
| 112 | description: |
| 113 | The logarithm base 2 of e, as a 32 bit float. |
| 114 | end: |
| 115 | |
| 116 | constant: M_PI |
| 117 | value: 3.141592653589793238462643383279502884f |
| 118 | summary: pi, as a 32 bit float |
| 119 | description: |
| 120 | The constant pi, as a 32 bit float. |
| 121 | end: |
| 122 | |
| 123 | constant: M_PI_2 |
| 124 | value: 1.570796326794896619231321691639751442f |
| 125 | summary: pi / 2, as a 32 bit float |
| 126 | description: |
| 127 | Pi divided by 2, as a 32 bit float. |
| 128 | end: |
| 129 | |
| 130 | constant: M_PI_4 |
| 131 | value: 0.785398163397448309615660845819875721f |
| 132 | summary: pi / 4, as a 32 bit float |
| 133 | description: |
| 134 | Pi divided by 4, as a 32 bit float. |
| 135 | end: |
| 136 | |
| 137 | constant: M_SQRT1_2 |
| 138 | value: 0.707106781186547524400844362104849039f |
| 139 | summary: 1 / sqrt(2), as a 32 bit float |
| 140 | description: |
| 141 | The inverse of the square root of 2, as a 32 bit float. |
| 142 | end: |
| 143 | |
| 144 | constant: M_SQRT2 |
| 145 | value: 1.414213562373095048801688724209698079f |
| 146 | summary: sqrt(2), as a 32 bit float |
| 147 | description: |
| 148 | The square root of 2, as a 32 bit float. |
| 149 | end: |
| 150 | |
| 151 | function: abs |
| 152 | version: 9 |
| 153 | attrib: const |
| 154 | w: 1, 2, 3, 4 |
| 155 | t: i8, i16, i32 |
| 156 | ret: u#2#1 |
| 157 | arg: #2#1 v |
| 158 | summary: Absolute value of an integer |
| 159 | description: |
| 160 | Returns the absolute value of an integer. |
| 161 | |
| 162 | For floats, use @fabs(). |
| 163 | end: |
| 164 | |
| 165 | function: acos |
| 166 | version: 9 |
| 167 | attrib: const |
| 168 | w: 1, 2, 3, 4 |
| 169 | t: f32 |
| 170 | ret: #2#1 |
| 171 | arg: #2#1 v, range(-1,1) |
| 172 | summary: Inverse cosine |
| 173 | description: |
| 174 | Returns the inverse cosine, in radians. |
| 175 | |
| 176 | See also @native_acos(). |
| 177 | end: |
| 178 | |
| 179 | function: acosh |
| 180 | version: 9 |
| 181 | attrib: const |
| 182 | w: 1, 2, 3, 4 |
| 183 | t: f32 |
| 184 | ret: #2#1 |
| 185 | arg: #2#1 v |
| 186 | summary: Inverse hyperbolic cosine |
| 187 | description: |
| 188 | Returns the inverse hyperbolic cosine, in radians. |
| 189 | |
| 190 | See also @native_acosh(). |
| 191 | end: |
| 192 | |
| 193 | function: acospi |
| 194 | version: 9 |
| 195 | attrib: const |
| 196 | w: 1, 2, 3, 4 |
| 197 | t: f32 |
| 198 | ret: #2#1 |
| 199 | arg: #2#1 v, range(-1,1) |
| 200 | summary: Inverse cosine divided by pi |
| 201 | description: |
| 202 | Returns the inverse cosine in radians, divided by pi. |
| 203 | |
| 204 | To get an inverse cosine measured in degrees, use <code>acospi(a) * 180.f</code>. |
| 205 | |
| 206 | See also @native_acospi(). |
| 207 | end: |
| 208 | |
| 209 | function: asin |
| 210 | version: 9 |
| 211 | attrib: const |
| 212 | w: 1, 2, 3, 4 |
| 213 | t: f32 |
| 214 | ret: #2#1 |
| 215 | arg: #2#1 v, range(-1,1) |
| 216 | summary: Inverse sine |
| 217 | description: |
| 218 | Returns the inverse sine, in radians. |
| 219 | |
| 220 | See also @native_asin(). |
| 221 | end: |
| 222 | |
| 223 | function: asinh |
| 224 | version: 9 |
| 225 | attrib: const |
| 226 | w: 1, 2, 3, 4 |
| 227 | t: f32 |
| 228 | ret: #2#1 |
| 229 | arg: #2#1 v |
| 230 | summary: Inverse hyperbolic sine |
| 231 | description: |
| 232 | Returns the inverse hyperbolic sine, in radians. |
| 233 | |
| 234 | See also @native_asinh(). |
| 235 | end: |
| 236 | |
| 237 | function: asinpi |
| 238 | version: 9 |
| 239 | attrib: const |
| 240 | w: 1, 2, 3, 4 |
| 241 | t: f32 |
| 242 | ret: #2#1 |
| 243 | arg: #2#1 v, range(-1,1) |
| 244 | summary: Inverse sine divided by pi |
| 245 | description: |
| 246 | Returns the inverse sine in radians, divided by pi. |
| 247 | |
| 248 | To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>. |
| 249 | |
| 250 | See also @native_asinpi(). |
| 251 | end: |
| 252 | |
| 253 | function: atan |
| 254 | version: 9 |
| 255 | attrib: const |
| 256 | w: 1, 2, 3, 4 |
| 257 | t: f32 |
| 258 | ret: #2#1 |
| 259 | arg: #2#1 v, range(-1,1) |
| 260 | summary: Inverse tangent |
| 261 | description: |
| 262 | Returns the inverse tangent, in radians. |
| 263 | |
| 264 | See also @native_atan(). |
| 265 | end: |
| 266 | |
| 267 | function: atan2 |
| 268 | version: 9 |
| 269 | attrib: const |
| 270 | w: 1, 2, 3, 4 |
| 271 | t: f32 |
| 272 | ret: #2#1 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 273 | arg: #2#1 numerator, "Numerator." |
| 274 | arg: #2#1 denominator, "Denominator. Can be 0." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 275 | summary: Inverse tangent of a ratio |
| 276 | description: |
| 277 | Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians. |
| 278 | |
| 279 | See also @native_atan2(). |
| 280 | end: |
| 281 | |
| 282 | function: atan2pi |
| 283 | version: 9 |
| 284 | attrib: const |
| 285 | w: 1, 2, 3, 4 |
| 286 | t: f32 |
| 287 | ret: #2#1 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 288 | arg: #2#1 numerator, "Numerator." |
| 289 | arg: #2#1 denominator, "Denominator. Can be 0." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 290 | summary: Inverse tangent of a ratio, divided by pi |
| 291 | description: |
| 292 | Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians, divided by pi. |
| 293 | |
| 294 | To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>. |
| 295 | |
| 296 | See also @native_atan2pi(). |
| 297 | end: |
| 298 | |
| 299 | function: atanh |
| 300 | version: 9 |
| 301 | attrib: const |
| 302 | w: 1, 2, 3, 4 |
| 303 | t: f32 |
| 304 | ret: #2#1 |
| 305 | arg: #2#1 v, range(-1,1) |
| 306 | summary: Inverse hyperbolic tangent |
| 307 | description: |
| 308 | Returns the inverse hyperbolic tangent, in radians. |
| 309 | |
| 310 | See also @native_atanh(). |
| 311 | end: |
| 312 | |
| 313 | function: atanpi |
| 314 | version: 9 |
| 315 | attrib: const |
| 316 | w: 1, 2, 3, 4 |
| 317 | t: f32 |
| 318 | ret: #2#1 |
| 319 | arg: #2#1 v, range(-1,1) |
| 320 | summary: Inverse tangent divided by pi |
| 321 | description: |
| 322 | Returns the inverse tangent in radians, divided by pi. |
| 323 | |
| 324 | To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>. |
| 325 | |
| 326 | See also @native_atanpi(). |
| 327 | end: |
| 328 | |
| 329 | function: cbrt |
| 330 | version: 9 |
| 331 | attrib: const |
| 332 | w: 1, 2, 3, 4 |
| 333 | t: f32 |
| 334 | ret: #2#1 |
| 335 | arg: #2#1 v |
| 336 | summary: Cube root |
| 337 | description: |
| 338 | Returns the cube root. |
| 339 | |
| 340 | See also @native_cbrt(). |
| 341 | end: |
| 342 | |
| 343 | function: ceil |
| 344 | version: 9 |
| 345 | attrib: const |
| 346 | w: 1, 2, 3, 4 |
| 347 | t: f32 |
| 348 | ret: #2#1 |
| 349 | arg: #2#1 v |
| 350 | summary: Smallest integer not less than a value |
| 351 | description: |
| 352 | Returns the smallest integer not less than a value. |
| 353 | |
| 354 | For example, <code>ceil(1.2f)</code> returns 2.f, and <code>ceil(-1.2f)</code> returns -1.f. |
| 355 | |
| 356 | See also @floor(). |
| 357 | end: |
| 358 | |
| 359 | function: clamp |
| 360 | version: 9 |
| 361 | attrib: const |
| 362 | w: 1, 2, 3, 4 |
| 363 | t: f32 |
| 364 | ret: #2#1 |
| 365 | arg: #2#1 value, "Value to be clamped." |
| 366 | arg: #2#1 min_value, "Lower bound, a scalar or matching vector." |
| 367 | arg: #2#1 max_value, above(min_value), "High bound, must match the type of low." |
| 368 | summary: Restrain a value to a range |
| 369 | description: |
| 370 | Clamps a value to a specified high and low bound. clamp() returns min_value |
| 371 | if value < min_value, max_value if value > max_value, otherwise value. |
| 372 | |
| 373 | There are two variants of clamp: one where the min and max are scalars applied |
| 374 | to all entries of the value, the other where the min and max are also vectors. |
| 375 | |
| 376 | If min_value is greater than max_value, the results are undefined. |
| 377 | end: |
| 378 | |
| 379 | function: clamp |
| 380 | version: 9 |
| 381 | attrib: const |
| 382 | w: 2, 3, 4 |
| 383 | t: f32 |
| 384 | ret: #2#1 |
| 385 | arg: #2#1 value |
| 386 | arg: #2 min_value |
| 387 | arg: #2 max_value, above(min_value) |
| 388 | end: |
| 389 | |
| 390 | function: clamp |
| 391 | version: 19 |
| 392 | attrib: const |
| 393 | w: 1, 2, 3, 4 |
| 394 | t: u8, u16, u32, u64, i8, i16, i32, i64 |
| 395 | ret: #2#1 |
| 396 | arg: #2#1 value |
| 397 | arg: #2#1 min_value |
| 398 | arg: #2#1 max_value, above(min_value) |
| 399 | end: |
| 400 | |
| 401 | function: clamp |
| 402 | version: 19 |
| 403 | attrib: const |
| 404 | w: 2, 3, 4 |
| 405 | t: u8, u16, u32, u64, i8, i16, i32, i64 |
| 406 | ret: #2#1 |
| 407 | arg: #2#1 value |
| 408 | arg: #2 min_value |
| 409 | arg: #2 max_value, above(min_value) |
| 410 | end: |
| 411 | |
| 412 | function: clz |
| 413 | version: 9 |
| 414 | attrib: const |
| 415 | w: 1, 2, 3, 4 |
| 416 | t: u8, u16, u32, i8, i16, i32 |
| 417 | ret: #2#1 |
| 418 | arg: #2#1 value |
| 419 | summary: Number of leading 0 bits |
| 420 | description: |
| 421 | Returns the number of leading 0-bits in a value. |
| 422 | |
| 423 | For example, <code>clz((char)0x03)</code> returns 6. |
| 424 | end: |
| 425 | |
| 426 | function: copysign |
| 427 | version: 9 |
| 428 | attrib: const |
| 429 | w: 1, 2, 3, 4 |
| 430 | t: f32 |
| 431 | ret: #2#1 |
| 432 | arg: #2#1 magnitude_value |
| 433 | arg: #2#1 sign_value |
| 434 | summary: Copies the sign of a number to another |
| 435 | description: |
| 436 | Copies the sign from sign_value to magnitude_value. |
| 437 | |
| 438 | The value returned is either magnitude_value or -magnitude_value. |
| 439 | |
| 440 | For example, <code>copysign(4.0f, -2.7f)</code> returns -4.0f and <code>copysign(-4.0f, 2.7f)</code> returns 4.0f. |
| 441 | end: |
| 442 | |
| 443 | function: cos |
| 444 | version: 9 |
| 445 | attrib: const |
| 446 | w: 1, 2, 3, 4 |
| 447 | t: f32 |
| 448 | ret: #2#1 |
| 449 | arg: #2#1 v |
| 450 | summary: Cosine |
| 451 | description: |
| 452 | Returns the cosine of an angle measured in radians. |
| 453 | |
| 454 | See also @native_cos(). |
| 455 | end: |
| 456 | |
| 457 | function: cosh |
| 458 | version: 9 |
| 459 | attrib: const |
| 460 | w: 1, 2, 3, 4 |
| 461 | t: f32 |
| 462 | ret: #2#1 |
| 463 | arg: #2#1 v |
| 464 | summary: Hypebolic cosine |
| 465 | description: |
| 466 | Returns the hypebolic cosine of v, where v is measured in radians. |
| 467 | |
| 468 | See also @native_cosh(). |
| 469 | end: |
| 470 | |
| 471 | function: cospi |
| 472 | version: 9 |
| 473 | attrib: const |
| 474 | w: 1, 2, 3, 4 |
| 475 | t: f32 |
| 476 | ret: #2#1 |
| 477 | arg: #2#1 v |
| 478 | summary: Cosine of a number multiplied by pi |
| 479 | description: |
| 480 | Returns the cosine of <code>(v * pi)</code>, where <code>(v * pi)</code> is measured in radians. |
| 481 | |
| 482 | To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>. |
| 483 | |
| 484 | See also @native_cospi(). |
| 485 | end: |
| 486 | |
| 487 | function: degrees |
| 488 | version: 9 |
| 489 | attrib: const |
| 490 | w: 1, 2, 3, 4 |
| 491 | t: f32 |
| 492 | ret: #2#1 |
| 493 | arg: #2#1 v |
| 494 | summary: Converts radians into degrees |
| 495 | description: |
| 496 | Converts from radians to degrees. |
| 497 | end: |
| 498 | |
| 499 | function: erf |
| 500 | version: 9 |
| 501 | attrib: const |
| 502 | w: 1, 2, 3, 4 |
| 503 | t: f32 |
| 504 | ret: #2#1 |
| 505 | arg: #2#1 v |
| 506 | summary: Mathematical error function |
| 507 | description: |
| 508 | Returns the error function. |
| 509 | end: |
| 510 | |
| 511 | function: erfc |
| 512 | version: 9 |
| 513 | attrib: const |
| 514 | w: 1, 2, 3, 4 |
| 515 | t: f32 |
| 516 | ret: #2#1 |
| 517 | arg: #2#1 v |
| 518 | summary: Mathematical complementary error function |
| 519 | description: |
| 520 | Returns the complementary error function. |
| 521 | end: |
| 522 | |
| 523 | function: exp |
| 524 | version: 9 |
| 525 | attrib: const |
| 526 | w: 1, 2, 3, 4 |
| 527 | t: f32 |
| 528 | ret: #2#1 |
| 529 | arg: #2#1 v |
| 530 | summary: e raised to a number |
| 531 | description: |
| 532 | Returns e raised to v, i.e. e ^ v. |
| 533 | |
| 534 | See also @native_exp(). |
| 535 | end: |
| 536 | |
| 537 | function: exp10 |
| 538 | version: 9 |
| 539 | attrib: const |
| 540 | w: 1, 2, 3, 4 |
| 541 | t: f32 |
| 542 | ret: #2#1 |
| 543 | arg: #2#1 v |
| 544 | summary: 10 raised to a number |
| 545 | description: |
| 546 | Returns 10 raised to v, i.e. 10.f ^ v. |
| 547 | |
| 548 | See also @native_exp10(). |
| 549 | end: |
| 550 | |
| 551 | function: exp2 |
| 552 | version: 9 |
| 553 | attrib: const |
| 554 | w: 1, 2, 3, 4 |
| 555 | t: f32 |
| 556 | ret: #2#1 |
| 557 | arg: #2#1 v |
| 558 | summary: 2 raised to a number |
| 559 | description: |
| 560 | Returns 2 raised to v, i.e. 2.f ^ v. |
| 561 | |
| 562 | See also @native_exp2(). |
| 563 | end: |
| 564 | |
| 565 | function: expm1 |
| 566 | version: 9 |
| 567 | attrib: const |
| 568 | w: 1, 2, 3, 4 |
| 569 | t: f32 |
| 570 | ret: #2#1 |
| 571 | arg: #2#1 v |
| 572 | summary: e raised to a number minus one |
| 573 | description: |
| 574 | Returns e raised to v minus 1, i.e. (e ^ v) - 1. |
| 575 | |
| 576 | See also @native_expm1(). |
| 577 | end: |
| 578 | |
| 579 | function: fabs |
| 580 | version: 9 |
| 581 | attrib: const |
| 582 | w: 1, 2, 3, 4 |
| 583 | t: f32 |
| 584 | ret: #2#1 |
| 585 | arg: #2#1 v |
| 586 | summary: Absolute value of a float |
| 587 | description: |
| 588 | Returns the absolute value of the float v. |
| 589 | |
| 590 | For integers, use @abs(). |
| 591 | end: |
| 592 | |
| 593 | function: fdim |
| 594 | version: 9 |
| 595 | attrib: const |
| 596 | w: 1, 2, 3, 4 |
| 597 | t: f32 |
| 598 | ret: #2#1 |
| 599 | arg: #2#1 a |
| 600 | arg: #2#1 b |
| 601 | summary: Positive difference between two values |
| 602 | description: |
| 603 | Returns the positive difference between two values. |
| 604 | |
| 605 | If a > b, returns (a - b) otherwise returns 0f. |
| 606 | end: |
| 607 | |
| 608 | function: floor |
| 609 | version: 9 |
| 610 | attrib: const |
| 611 | w: 1, 2, 3, 4 |
| 612 | t: f32 |
| 613 | ret: #2#1 |
| 614 | arg: #2#1 v |
| 615 | summary: Smallest integer not greater than a value |
| 616 | description: |
| 617 | Returns the smallest integer not greater than a value. |
| 618 | |
| 619 | For example, <code>floor(1.2f)</code> returns 1.f, and <code>floor(-1.2f)</code> returns -2.f. |
| 620 | |
| 621 | See also @ceil(). |
| 622 | end: |
| 623 | |
| 624 | function: fma |
| 625 | version: 9 |
| 626 | attrib: const |
| 627 | w: 1, 2, 3, 4 |
| 628 | t: f32 |
| 629 | ret: #2#1 |
| 630 | arg: #2#1 multiplicand1 |
| 631 | arg: #2#1 multiplicand2 |
| 632 | arg: #2#1 offset |
| 633 | summary: Multiply and add |
| 634 | description: |
| 635 | Multiply and add. Returns <code>(multiplicand1 * multiplicand2) + offset</code>. |
| 636 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 637 | This function is similar to @mad(). fma() retains full precision of the multiplied result |
| 638 | and rounds only after the addition. @mad() rounds after the multiplication and the addition. |
| 639 | This extra precision is not guaranteed in rs_fp_relaxed mode. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 640 | end: |
| 641 | |
| 642 | function: fmax |
| 643 | version: 9 |
| 644 | attrib: const |
| 645 | w: 1, 2, 3, 4 |
| 646 | t: f32 |
| 647 | ret: #2#1 |
| 648 | arg: #2#1 a |
| 649 | arg: #2#1 b |
| 650 | summary: Maximum of two floats |
| 651 | description: |
| 652 | Returns the maximum of a and b, i.e. <code>(a < b ? b : a)</code>. |
| 653 | |
| 654 | The @max() function returns identical results but can be applied to more data types. |
| 655 | end: |
| 656 | |
| 657 | function: fmax |
| 658 | version: 9 |
| 659 | attrib: const |
| 660 | w: 2, 3, 4 |
| 661 | t: f32 |
| 662 | ret: #2#1 |
| 663 | arg: #2#1 a |
| 664 | arg: #2 b |
| 665 | end: |
| 666 | |
| 667 | function: fmin |
| 668 | version: 9 |
| 669 | attrib: const |
| 670 | w: 1, 2, 3, 4 |
| 671 | t: f32 |
| 672 | ret: #2#1 |
| 673 | arg: #2#1 a |
| 674 | arg: #2#1 b |
| 675 | summary: Minimum of two floats |
| 676 | description: |
| 677 | Returns the minimum of a and b, i.e. <code>(a > b ? b : a)</code>. |
| 678 | |
| 679 | The @min() function returns identical results but can be applied to more data types. |
| 680 | end: |
| 681 | |
| 682 | function: fmin |
| 683 | version: 9 |
| 684 | attrib: const |
| 685 | w: 2, 3, 4 |
| 686 | t: f32 |
| 687 | ret: #2#1 |
| 688 | arg: #2#1 a |
| 689 | arg: #2 b |
| 690 | end: |
| 691 | |
| 692 | function: fmod |
| 693 | version: 9 |
| 694 | attrib: const |
| 695 | w: 1, 2, 3, 4 |
| 696 | t: f32 |
| 697 | ret: #2#1 |
| 698 | arg: #2#1 numerator |
| 699 | arg: #2#1 denominator |
| 700 | summary: Modulo |
| 701 | description: |
| 702 | Returns the remainder of (numerator / denominator), where the quotient is rounded towards zero. |
| 703 | |
| 704 | The function @remainder() is similar but rounds toward the closest interger. |
| 705 | For example, <code>fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f) |
| 706 | while <code>@remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f). |
| 707 | end: |
| 708 | |
| 709 | function: fract |
| 710 | version: 9 |
| 711 | w: 1, 2, 3, 4 |
| 712 | t: f32 |
| 713 | ret: #2#1 |
| 714 | arg: #2#1 v, "Input value." |
| 715 | arg: #2#1* floor, "If floor is not null, *floor will be set to the floor of v." |
| 716 | summary: Positive fractional part |
| 717 | description: |
| 718 | Returns the positive fractional part of v, i.e. <code>v - floor(v)</code>. |
| 719 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 720 | For example, <code>fract(1.3f, &val)</code> returns 0.3f and sets val to 1.f. |
| 721 | <code>fract(-1.3f, &val)</code> returns 0.7f and sets val to -2.f. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 722 | end: |
| 723 | |
| 724 | function: fract |
| 725 | version: 9 |
| 726 | attrib: const |
| 727 | w: 1, 2, 3, 4 |
| 728 | t: f32 |
| 729 | ret: #2#1 |
| 730 | arg: #2#1 v |
| 731 | inline: |
| 732 | #2#1 unused; |
| 733 | return fract(v, &unused); |
| 734 | end: |
| 735 | |
| 736 | function: frexp |
| 737 | version: 9 |
| 738 | w: 1, 2, 3, 4 |
| 739 | t: f32 |
| 740 | ret: #2#1 |
| 741 | arg: #2#1 v, "Input value." |
| 742 | arg: int#1* exponent, "If exponent is not null, *exponent will be set to the exponent of v." |
| 743 | summary: Binary mantissa and exponent |
| 744 | description: |
| 745 | Returns the binary mantissa and exponent of v, i.e. <code>v == mantissa * 2 ^ exponent</code>. |
| 746 | |
| 747 | The mantissa is always between 0.5 (inclusive) and 1.0 (exclusive). |
| 748 | |
| 749 | See @ldexp() for the reverse operation. See also @logb() and @ilogb(). |
| 750 | end: |
| 751 | |
| 752 | function: half_recip |
| 753 | version: 17 |
| 754 | attrib: const |
| 755 | w: 1, 2, 3, 4 |
| 756 | t: f32 |
| 757 | ret: #2#1 |
| 758 | arg: #2#1 v |
| 759 | summary: Reciprocal computed to 16 bit precision |
| 760 | description: |
| 761 | Returns the approximate reciprocal of a value. |
| 762 | |
| 763 | The precision is that of a 16 bit floating point value. |
| 764 | |
| 765 | See also @native_recip(). |
| 766 | end: |
| 767 | |
| 768 | function: half_rsqrt |
| 769 | version: 17 |
| 770 | attrib: const |
| 771 | w: 1, 2, 3, 4 |
| 772 | t: f32 |
| 773 | ret: #2#1 |
| 774 | arg: #2#1 v |
| 775 | summary: Reciprocal of a square root computed to 16 bit precision |
| 776 | description: |
| 777 | Returns the approximate value of <code>(1.f / sqrt(value))</code>. |
| 778 | |
| 779 | The precision is that of a 16 bit floating point value. |
| 780 | |
| 781 | See also @rsqrt(), @native_rsqrt(). |
| 782 | end: |
| 783 | |
| 784 | function: half_sqrt |
| 785 | version: 17 |
| 786 | attrib: const |
| 787 | w: 1, 2, 3, 4 |
| 788 | t: f32 |
| 789 | ret: #2#1 |
| 790 | arg: #2#1 v |
| 791 | summary: Square root computed to 16 bit precision |
| 792 | description: |
| 793 | Returns the approximate square root of a value. |
| 794 | |
| 795 | The precision is that of a 16 bit floating point value. |
| 796 | |
| 797 | See also @sqrt(), @native_sqrt(). |
| 798 | end: |
| 799 | |
| 800 | function: hypot |
| 801 | version: 9 |
| 802 | attrib: const |
| 803 | w: 1, 2, 3, 4 |
| 804 | t: f32 |
| 805 | ret: #2#1 |
| 806 | arg: #2#1 a |
| 807 | arg: #2#1 b |
| 808 | summary: Hypotenuse |
| 809 | description: |
| 810 | Returns the hypotenuse, i.e. <code>sqrt(a * a + b * b)</code>. |
| 811 | |
| 812 | See also @native_hypot(). |
| 813 | end: |
| 814 | |
| 815 | function: ilogb |
| 816 | version: 9 |
| 817 | attrib: const |
| 818 | w: 1, 2, 3, 4 |
| 819 | t: f32 |
| 820 | ret: int#1 |
| 821 | arg: float#1 v |
| 822 | summary: Base two exponent |
| 823 | description: |
| 824 | Returns the base two exponent of a value, where the mantissa is between |
| 825 | 1.f (inclusive) and 2.f (exclusive). |
| 826 | |
| 827 | For example, <code>ilogb(8.5f)</code> returns 3. |
| 828 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 829 | Because of the difference in mantissa, this number is one less than is returned by @frexp(). |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 830 | |
| 831 | @logb() is similar but returns a float. |
| 832 | test: custom |
| 833 | end: |
| 834 | |
| 835 | function: ldexp |
| 836 | version: 9 |
| 837 | attrib: const |
| 838 | w: 1, 2, 3, 4 |
| 839 | ret: float#1 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 840 | arg: float#1 mantissa, "Mantissa." |
| 841 | arg: int#1 exponent, "Exponent, a single component or matching vector." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 842 | summary: Creates a floating point from mantissa and exponent |
| 843 | description: |
| 844 | Returns the floating point created from the mantissa and exponent, |
| 845 | i.e. (mantissa * 2 ^ exponent). |
| 846 | |
| 847 | See @frexp() for the reverse operation. |
| 848 | end: |
| 849 | |
| 850 | function: ldexp |
| 851 | version: 9 |
| 852 | attrib: const |
| 853 | w: 2, 3, 4 |
| 854 | ret: float#1 |
| 855 | arg: float#1 mantissa |
| 856 | arg: int exponent |
| 857 | end: |
| 858 | |
| 859 | function: lgamma |
| 860 | version: 9 |
| 861 | attrib: const |
| 862 | w: 1, 2, 3, 4 |
| 863 | t: f32 |
| 864 | ret: #2#1 |
| 865 | arg: #2#1 v |
| 866 | summary: Natural logarithm of the gamma function |
| 867 | description: |
| 868 | Returns the natural logarithm of the absolute value of the gamma function, |
| 869 | i.e. <code>@log(@fabs(@tgamma(v)))</code>. |
| 870 | |
| 871 | See also @tgamma(). |
| 872 | end: |
| 873 | |
| 874 | function: lgamma |
| 875 | version: 9 |
| 876 | w: 1, 2, 3, 4 |
| 877 | t: f32 |
| 878 | ret: #2#1 |
| 879 | arg: #2#1 v |
| 880 | arg: int#1* sign_of_gamma, "If sign_of_gamma is not null, *sign_of_gamma will be set to -1.f if the gamma of v is negative, otherwise to 1.f." |
| 881 | test: custom |
| 882 | #TODO Temporary until bionic & associated drivers are fixed |
| 883 | end: |
| 884 | |
| 885 | function: log |
| 886 | version: 9 |
| 887 | attrib: const |
| 888 | w: 1, 2, 3, 4 |
| 889 | t: f32 |
| 890 | ret: #2#1 |
| 891 | arg: #2#1 v |
| 892 | summary: Natural logarithm |
| 893 | description: |
| 894 | Returns the natural logarithm. |
| 895 | |
| 896 | See also @native_log(). |
| 897 | end: |
| 898 | |
| 899 | function: log10 |
| 900 | version: 9 |
| 901 | attrib: const |
| 902 | w: 1, 2, 3, 4 |
| 903 | t: f32 |
| 904 | ret: #2#1 |
| 905 | arg: #2#1 v |
| 906 | summary: Base 10 logarithm |
| 907 | description: |
| 908 | Returns the base 10 logarithm. |
| 909 | |
| 910 | See also @native_log10(). |
| 911 | end: |
| 912 | |
| 913 | function: log1p |
| 914 | version: 9 |
| 915 | attrib: const |
| 916 | w: 1, 2, 3, 4 |
| 917 | t: f32 |
| 918 | ret: #2#1 |
| 919 | arg: #2#1 v |
| 920 | summary: Natural logarithm of a value plus 1 |
| 921 | description: |
| 922 | Returns the natural logarithm of <code>(v + 1.f)</code>. |
| 923 | |
| 924 | See also @native_log1p(). |
| 925 | end: |
| 926 | |
| 927 | function: log2 |
| 928 | version: 9 |
| 929 | attrib: const |
| 930 | w: 1, 2, 3, 4 |
| 931 | t: f32 |
| 932 | ret: #2#1 |
| 933 | arg: #2#1 v |
| 934 | summary: Base 2 logarithm |
| 935 | description: |
| 936 | Returns the base 2 logarithm. |
| 937 | |
| 938 | See also @native_log2(). |
| 939 | end: |
| 940 | |
| 941 | function: logb |
| 942 | version: 9 |
| 943 | attrib: const |
| 944 | w: 1, 2, 3, 4 |
| 945 | t: f32 |
| 946 | ret: #2#1 |
| 947 | arg: #2#1 v |
| 948 | summary: Base two exponent |
| 949 | description: |
| 950 | Returns the base two exponent of a value, where the mantissa is between |
| 951 | 1.f (inclusive) and 2.f (exclusive). |
| 952 | |
| 953 | For example, <code>logb(8.5f)</code> returns 3.f. |
| 954 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 955 | Because of the difference in mantissa, this number is one less than is returned by frexp(). |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 956 | |
| 957 | @ilogb() is similar but returns an integer. |
| 958 | end: |
| 959 | |
| 960 | function: mad |
| 961 | version: 9 |
| 962 | attrib: const |
| 963 | w: 1, 2, 3, 4 |
| 964 | t: f32 |
| 965 | ret: #2#1 |
| 966 | arg: #2#1 multiplicand1 |
| 967 | arg: #2#1 multiplicand2 |
| 968 | arg: #2#1 offset |
| 969 | summary: Multiply and add |
| 970 | description: |
| 971 | Multiply and add. Returns <code>(multiplicand1 * multiplicand2) + offset</code>. |
| 972 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 973 | This function is similar to @fma(). @fma() retains full precision of the multiplied result |
| 974 | and rounds only after the addition. mad() rounds after the multiplication and the addition. |
| 975 | In rs_fp_relaxed mode, mad() may not do the rounding after multiplicaiton. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 976 | end: |
| 977 | |
| 978 | function: max |
| 979 | version: 9 |
| 980 | attrib: const |
| 981 | w: 1, 2, 3, 4 |
| 982 | t: f32 |
| 983 | ret: #2#1 |
| 984 | arg: #2#1 a |
| 985 | arg: #2#1 b |
| 986 | summary: Maximum |
| 987 | description: |
| 988 | Returns the maximum value of two arguments. |
| 989 | end: |
| 990 | |
| 991 | function: max |
| 992 | version: 9 20 |
| 993 | attrib: const |
| 994 | w: 1 |
| 995 | t: i8, i16, i32, u8, u16, u32 |
| 996 | ret: #2#1 |
| 997 | arg: #2#1 a |
| 998 | arg: #2#1 b |
| 999 | inline: |
| 1000 | return (a > b ? a : b); |
| 1001 | end: |
| 1002 | |
| 1003 | function: max |
| 1004 | version: 9 20 |
| 1005 | attrib: const |
| 1006 | w: 2 |
| 1007 | t: i8, i16, i32, u8, u16, u32 |
| 1008 | ret: #2#1 |
| 1009 | arg: #2#1 a |
| 1010 | arg: #2#1 b |
| 1011 | inline: |
| 1012 | #2#1 tmp; |
| 1013 | tmp.x = (a.x > b.x ? a.x : b.x); |
| 1014 | tmp.y = (a.y > b.y ? a.y : b.y); |
| 1015 | return tmp; |
| 1016 | end: |
| 1017 | |
| 1018 | function: max |
| 1019 | version: 9 20 |
| 1020 | attrib: const |
| 1021 | w: 3 |
| 1022 | t: i8, i16, i32, u8, u16, u32 |
| 1023 | ret: #2#1 |
| 1024 | arg: #2#1 a |
| 1025 | arg: #2#1 b |
| 1026 | inline: |
| 1027 | #2#1 tmp; |
| 1028 | tmp.x = (a.x > b.x ? a.x : b.x); |
| 1029 | tmp.y = (a.y > b.y ? a.y : b.y); |
| 1030 | tmp.z = (a.z > b.z ? a.z : b.z); |
| 1031 | return tmp; |
| 1032 | end: |
| 1033 | |
| 1034 | function: max |
| 1035 | version: 9 20 |
| 1036 | attrib: const |
| 1037 | w: 4 |
| 1038 | t: i8, i16, i32, u8, u16, u32 |
| 1039 | ret: #2#1 |
| 1040 | arg: #2#1 a |
| 1041 | arg: #2#1 b |
| 1042 | inline: |
| 1043 | #2#1 tmp; |
| 1044 | tmp.x = (a.x > b.x ? a.x : b.x); |
| 1045 | tmp.y = (a.y > b.y ? a.y : b.y); |
| 1046 | tmp.z = (a.z > b.z ? a.z : b.z); |
| 1047 | tmp.w = (a.w > b.w ? a.w : b.w); |
| 1048 | return tmp; |
| 1049 | end: |
| 1050 | |
| 1051 | function: max |
| 1052 | version: 21 |
| 1053 | attrib: const |
| 1054 | w: 1, 2, 3, 4 |
| 1055 | t: i8, i16, i32, i64, u8, u16, u32, u64 |
| 1056 | ret: #2#1 |
| 1057 | arg: #2#1 a |
| 1058 | arg: #2#1 b |
| 1059 | end: |
| 1060 | |
| 1061 | function: min |
| 1062 | version: 9 |
| 1063 | attrib: const |
| 1064 | w: 1, 2, 3, 4 |
| 1065 | t: f32 |
| 1066 | ret: #2#1 |
| 1067 | arg: #2#1 a |
| 1068 | arg: #2#1 b |
| 1069 | summary: Minimum |
| 1070 | description: |
| 1071 | Returns the minimum value of two arguments. |
| 1072 | end: |
| 1073 | |
| 1074 | function: min |
| 1075 | version: 9 20 |
| 1076 | attrib: const |
| 1077 | w: 1 |
| 1078 | t: i8, i16, i32, u8, u16, u32 |
| 1079 | ret: #2#1 |
| 1080 | arg: #2#1 a |
| 1081 | arg: #2#1 b |
| 1082 | inline: |
| 1083 | return (a < b ? a : b); |
| 1084 | end: |
| 1085 | |
| 1086 | function: min |
| 1087 | version: 9 20 |
| 1088 | attrib: const |
| 1089 | w: 2 |
| 1090 | t: i8, i16, i32, u8, u16, u32 |
| 1091 | ret: #2#1 |
| 1092 | arg: #2#1 a |
| 1093 | arg: #2#1 b |
| 1094 | inline: |
| 1095 | #2#1 tmp; |
| 1096 | tmp.x = (a.x < b.x ? a.x : b.x); |
| 1097 | tmp.y = (a.y < b.y ? a.y : b.y); |
| 1098 | return tmp; |
| 1099 | end: |
| 1100 | |
| 1101 | function: min |
| 1102 | version: 9 20 |
| 1103 | attrib: const |
| 1104 | w: 3 |
| 1105 | t: i8, i16, i32, u8, u16, u32 |
| 1106 | ret: #2#1 |
| 1107 | arg: #2#1 a |
| 1108 | arg: #2#1 b |
| 1109 | inline: |
| 1110 | #2#1 tmp; |
| 1111 | tmp.x = (a.x < b.x ? a.x : b.x); |
| 1112 | tmp.y = (a.y < b.y ? a.y : b.y); |
| 1113 | tmp.z = (a.z < b.z ? a.z : b.z); |
| 1114 | return tmp; |
| 1115 | end: |
| 1116 | |
| 1117 | function: min |
| 1118 | version: 9 20 |
| 1119 | attrib: const |
| 1120 | w: 4 |
| 1121 | t: i8, i16, i32, u8, u16, u32 |
| 1122 | ret: #2#1 |
| 1123 | arg: #2#1 a |
| 1124 | arg: #2#1 b |
| 1125 | inline: |
| 1126 | #2#1 tmp; |
| 1127 | tmp.x = (a.x < b.x ? a.x : b.x); |
| 1128 | tmp.y = (a.y < b.y ? a.y : b.y); |
| 1129 | tmp.z = (a.z < b.z ? a.z : b.z); |
| 1130 | tmp.w = (a.w < b.w ? a.w : b.w); |
| 1131 | return tmp; |
| 1132 | end: |
| 1133 | |
| 1134 | function: min |
| 1135 | version: 21 |
| 1136 | attrib: const |
| 1137 | w: 1, 2, 3, 4 |
| 1138 | t: i8, i16, i32, i64, u8, u16, u32, u64 |
| 1139 | ret: #2#1 |
| 1140 | arg: #2#1 a |
| 1141 | arg: #2#1 b |
| 1142 | end: |
| 1143 | |
| 1144 | function: mix |
| 1145 | version: 9 |
| 1146 | attrib: const |
| 1147 | w: 1, 2, 3, 4 |
| 1148 | t: f32 |
| 1149 | ret: #2#1 |
| 1150 | arg: #2#1 start |
| 1151 | arg: #2#1 stop |
| 1152 | arg: #2#1 fraction |
| 1153 | summary: Mixes two values |
| 1154 | description: |
| 1155 | Returns start + ((stop - start) * fraction). |
| 1156 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1157 | This can be useful for mixing two values. For example, to create a new color that is |
| 1158 | 40% color1 and 60% color2, use <code>mix(color1, color2, 0.6f)</code>. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1159 | end: |
| 1160 | |
| 1161 | function: mix |
| 1162 | version: 9 |
| 1163 | attrib: const |
| 1164 | w: 2, 3, 4 |
| 1165 | t: f32 |
| 1166 | ret: #2#1 |
| 1167 | arg: #2#1 start |
| 1168 | arg: #2#1 stop |
| 1169 | arg: #2 fraction |
| 1170 | end: |
| 1171 | |
| 1172 | function: modf |
| 1173 | version: 9 |
| 1174 | w: 1, 2, 3, 4 |
| 1175 | t: f32 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1176 | ret: #2#1, "Floating point portion of the value." |
| 1177 | arg: #2#1 v, "Source value." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1178 | arg: #2#1* integral_part, "*integral_part will be set to the integral portion of the number." |
| 1179 | summary: Integral and fractional components |
| 1180 | description: |
| 1181 | Returns the integral and fractional components of a number. |
| 1182 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1183 | Both components will have the same sign as x. For example, for an input of -3.72f, |
| 1184 | iret will be set to -3.f and .72f will be returned. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1185 | end: |
| 1186 | |
| 1187 | function: nan |
| 1188 | version: 9 |
| 1189 | attrib: const |
| 1190 | w: 1 |
| 1191 | t: f32 |
| 1192 | ret: #2#1 |
| 1193 | arg: uint#1 v, "Not used." |
| 1194 | #TODO We're not using the argument. Once we do, add this documentation line: |
| 1195 | # The argument is embedded into the return value and can be used to distinguish various NaNs. |
| 1196 | summary: Not a Number |
| 1197 | description: |
| 1198 | Returns a NaN value (Not a Number). |
| 1199 | end: |
| 1200 | |
| 1201 | function: native_acos |
| 1202 | version: 21 |
| 1203 | attrib: const |
| 1204 | w: 1, 2, 3, 4 |
| 1205 | t: f32 |
| 1206 | ret: #2#1 |
| 1207 | arg: #2#1 v, range(-1,1) |
| 1208 | summary: Approximate inverse cosine |
| 1209 | description: |
| 1210 | Returns the approximate inverse cosine, in radians. |
| 1211 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1212 | This function yields undefined results from input values less than -1 or greater than 1. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1213 | |
| 1214 | See also @acos(). |
| 1215 | # TODO Temporary |
| 1216 | test: limited(0.0005) |
| 1217 | end: |
| 1218 | |
| 1219 | function: native_acosh |
| 1220 | version: 21 |
| 1221 | attrib: const |
| 1222 | w: 1, 2, 3, 4 |
| 1223 | t: f32 |
| 1224 | ret: #2#1 |
| 1225 | arg: #2#1 v |
| 1226 | summary: Approximate inverse hyperbolic cosine |
| 1227 | description: |
| 1228 | Returns the approximate inverse hyperbolic cosine, in radians. |
| 1229 | |
| 1230 | See also @acosh(). |
| 1231 | # TODO Temporary |
| 1232 | test: limited(0.0005) |
| 1233 | end: |
| 1234 | |
| 1235 | function: native_acospi |
| 1236 | version: 21 |
| 1237 | attrib: const |
| 1238 | w: 1, 2, 3, 4 |
| 1239 | t: f32 |
| 1240 | ret: #2#1 |
| 1241 | arg: #2#1 v, range(-1,1) |
| 1242 | summary: Approximate inverse cosine divided by pi |
| 1243 | description: |
| 1244 | Returns the approximate inverse cosine in radians, divided by pi. |
| 1245 | |
| 1246 | To get an inverse cosine measured in degrees, use <code>acospi(a) * 180.f</code>. |
| 1247 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1248 | This function yields undefined results from input values less than -1 or greater than 1. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1249 | |
| 1250 | See also @acospi(). |
| 1251 | # TODO Temporary |
| 1252 | test: limited(0.0005) |
| 1253 | end: |
| 1254 | |
| 1255 | function: native_asin |
| 1256 | version: 21 |
| 1257 | attrib: const |
| 1258 | w: 1, 2, 3, 4 |
| 1259 | t: f32 |
| 1260 | ret: #2#1 |
| 1261 | arg: #2#1 v, range(-1,1) |
| 1262 | summary: Approximate inverse sine |
| 1263 | description: |
| 1264 | Returns the approximate inverse sine, in radians. |
| 1265 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1266 | This function yields undefined results from input values less than -1 or greater than 1. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1267 | |
| 1268 | See also @asin(). |
| 1269 | # TODO Temporary |
| 1270 | test: limited(0.0005) |
| 1271 | end: |
| 1272 | |
| 1273 | function: native_asinh |
| 1274 | version: 21 |
| 1275 | attrib: const |
| 1276 | w: 1, 2, 3, 4 |
| 1277 | t: f32 |
| 1278 | ret: #2#1 |
| 1279 | arg: #2#1 v |
| 1280 | summary: Approximate inverse hyperbolic sine |
| 1281 | description: |
| 1282 | Returns the approximate inverse hyperbolic sine, in radians. |
| 1283 | |
| 1284 | See also @asinh(). |
| 1285 | # TODO Temporary |
| 1286 | test: limited(0.0005) |
| 1287 | end: |
| 1288 | |
| 1289 | function: native_asinpi |
| 1290 | version: 21 |
| 1291 | attrib: const |
| 1292 | w: 1, 2, 3, 4 |
| 1293 | t: f32 |
| 1294 | ret: #2#1 |
| 1295 | arg: #2#1 v, range(-1,1) |
| 1296 | summary: Approximate inverse sine divided by pi |
| 1297 | description: |
| 1298 | Returns the approximate inverse sine in radians, divided by pi. |
| 1299 | |
| 1300 | To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>. |
| 1301 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1302 | This function yields undefined results from input values less than -1 or greater than 1. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1303 | |
| 1304 | See also @asinpi(). |
| 1305 | # TODO Temporary |
| 1306 | test: limited(0.0005) |
| 1307 | end: |
| 1308 | |
| 1309 | function: native_atan |
| 1310 | version: 21 |
| 1311 | attrib: const |
| 1312 | w: 1, 2, 3, 4 |
| 1313 | t: f32 |
| 1314 | ret: #2#1 |
| 1315 | arg: #2#1 v, range(-1,1) |
| 1316 | summary: Approximate inverse tangent |
| 1317 | description: |
| 1318 | Returns the approximate inverse tangent, in radians. |
| 1319 | |
| 1320 | See also @atan(). |
| 1321 | # TODO Temporary |
| 1322 | test: limited(0.0005) |
| 1323 | end: |
| 1324 | |
| 1325 | function: native_atan2 |
| 1326 | version: 21 |
| 1327 | attrib: const |
| 1328 | w: 1, 2, 3, 4 |
| 1329 | t: f32 |
| 1330 | ret: #2#1 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1331 | arg: #2#1 numerator, "Numerator." |
| 1332 | arg: #2#1 denominator, "Denominator. Can be 0." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1333 | summary: Approximate inverse tangent of a ratio |
| 1334 | description: |
| 1335 | Returns the approximate inverse tangent of <code>(numerator / denominator)</code>, in radians. |
| 1336 | |
| 1337 | See also @atan2(). |
| 1338 | # TODO Temporary |
| 1339 | test: limited(0.0005) |
| 1340 | end: |
| 1341 | |
| 1342 | function: native_atan2pi |
| 1343 | version: 21 |
| 1344 | attrib: const |
| 1345 | w: 1, 2, 3, 4 |
| 1346 | t: f32 |
| 1347 | ret: #2#1 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1348 | arg: #2#1 numerator, "Numerator." |
| 1349 | arg: #2#1 denominator, "Denominator. Can be 0." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1350 | summary: Approximate inverse tangent of a ratio, divided by pi |
| 1351 | description: |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1352 | Returns the approximate inverse tangent of <code>(numerator / denominator)</code>, |
| 1353 | in radians, divided by pi. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1354 | |
| 1355 | To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>. |
| 1356 | |
| 1357 | See also @atan2pi(). |
| 1358 | # TODO Temporary |
| 1359 | test: limited(0.0005) |
| 1360 | end: |
| 1361 | |
| 1362 | function: native_atanh |
| 1363 | version: 21 |
| 1364 | attrib: const |
| 1365 | w: 1, 2, 3, 4 |
| 1366 | t: f32 |
| 1367 | ret: #2#1 |
| 1368 | arg: #2#1 v, range(-1,1) |
| 1369 | summary: Approximate inverse hyperbolic tangent |
| 1370 | description: |
| 1371 | Returns the approximate inverse hyperbolic tangent, in radians. |
| 1372 | |
| 1373 | See also @atanh(). |
| 1374 | # TODO Temporary |
| 1375 | test: limited(0.0005) |
| 1376 | end: |
| 1377 | |
| 1378 | function: native_atanpi |
| 1379 | version: 21 |
| 1380 | attrib: const |
| 1381 | w: 1, 2, 3, 4 |
| 1382 | t: f32 |
| 1383 | ret: #2#1 |
| 1384 | arg: #2#1 v, range(-1,1) |
| 1385 | summary: Approximate inverse tangent divided by pi |
| 1386 | description: |
| 1387 | Returns the approximate inverse tangent in radians, divided by pi. |
| 1388 | |
| 1389 | To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>. |
| 1390 | |
| 1391 | See also @atanpi(). |
| 1392 | # TODO Temporary |
| 1393 | test: limited(0.0005) |
| 1394 | end: |
| 1395 | |
| 1396 | function: native_cbrt |
| 1397 | version: 21 |
| 1398 | attrib: const |
| 1399 | w: 1, 2, 3, 4 |
| 1400 | t: f32 |
| 1401 | ret: #2#1 |
| 1402 | arg: #2#1 v |
| 1403 | summary: Approximate cube root |
| 1404 | description: |
| 1405 | Returns the approximate cubic root. |
| 1406 | |
| 1407 | See also @cbrt(). |
| 1408 | end: |
| 1409 | |
| 1410 | function: native_cos |
| 1411 | version: 21 |
| 1412 | attrib: const |
| 1413 | w: 1, 2, 3, 4 |
| 1414 | t: f32 |
| 1415 | ret: #2#1 |
| 1416 | arg: #2#1 v |
| 1417 | summary: Approximate cosine |
| 1418 | description: |
| 1419 | Returns the approximate cosine of an angle measured in radians. |
| 1420 | |
| 1421 | See also @cos(). |
| 1422 | end: |
| 1423 | |
| 1424 | function: native_cosh |
| 1425 | version: 21 |
| 1426 | attrib: const |
| 1427 | w: 1, 2, 3, 4 |
| 1428 | t: f32 |
| 1429 | ret: #2#1 |
| 1430 | arg: #2#1 v |
| 1431 | summary: Approximate hypebolic cosine |
| 1432 | description: |
| 1433 | Returns the approximate hypebolic cosine. |
| 1434 | |
| 1435 | See also @cosh(). |
| 1436 | end: |
| 1437 | |
| 1438 | function: native_cospi |
| 1439 | version: 21 |
| 1440 | attrib: const |
| 1441 | w: 1, 2, 3, 4 |
| 1442 | t: f32 |
| 1443 | ret: #2#1 |
| 1444 | arg: #2#1 v |
| 1445 | summary: Approximate cosine of a number multiplied by pi |
| 1446 | description: |
| 1447 | Returns the approximate cosine of (v * pi), where (v * pi) is measured in radians. |
| 1448 | |
| 1449 | To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>. |
| 1450 | |
| 1451 | See also @cospi(). |
| 1452 | end: |
| 1453 | |
| 1454 | function: native_divide |
| 1455 | version: 21 |
| 1456 | attrib: const |
| 1457 | w: 1, 2, 3, 4 |
| 1458 | t: f32 |
| 1459 | ret: #2#1 |
| 1460 | arg: #2#1 left_vector |
| 1461 | arg: #2#1 right_vector |
| 1462 | summary: Approximate division |
| 1463 | description: |
| 1464 | Computes the approximate division of two values. |
| 1465 | end: |
| 1466 | |
| 1467 | function: native_exp |
| 1468 | version: 18 |
| 1469 | attrib: const |
| 1470 | w: 1, 2, 3, 4 |
| 1471 | t: f32 |
| 1472 | ret: #2#1 |
| 1473 | arg: #2#1 v, range(-86,86) |
| 1474 | summary: Approximate e raised to a number |
| 1475 | description: |
| 1476 | Fast approximate exp. |
| 1477 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1478 | It is valid for inputs from -86.f to 86.f. The precision is no worse than what would be |
| 1479 | expected from using 16 bit floating point values. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1480 | |
| 1481 | See also @exp(). |
| 1482 | test: limited |
| 1483 | end: |
| 1484 | |
| 1485 | function: native_exp10 |
| 1486 | version: 18 |
| 1487 | attrib: const |
| 1488 | w: 1, 2, 3, 4 |
| 1489 | t: f32 |
| 1490 | ret: #2#1 |
| 1491 | arg: #2#1 v, range(-37,37) |
| 1492 | summary: Approximate 10 raised to a number |
| 1493 | description: |
| 1494 | Fast approximate exp10. |
| 1495 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1496 | It is valid for inputs from -37.f to 37.f. The precision is no worse than what would be |
| 1497 | expected from using 16 bit floating point values. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1498 | |
| 1499 | See also @exp10(). |
| 1500 | test: limited |
| 1501 | end: |
| 1502 | |
| 1503 | function: native_exp2 |
| 1504 | version: 18 |
| 1505 | attrib: const |
| 1506 | w: 1, 2, 3, 4 |
| 1507 | t: f32 |
| 1508 | ret: #2#1 |
| 1509 | arg: #2#1 v, range(-125,125) |
| 1510 | summary: Approximate 2 raised to a number |
| 1511 | description: |
| 1512 | Fast approximate exp2. |
| 1513 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1514 | It is valid for inputs from -125.f to 125.f. The precision is no worse than what would be |
| 1515 | expected from using 16 bit floating point values. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1516 | |
| 1517 | See also @exp2(). |
| 1518 | test: limited |
| 1519 | end: |
| 1520 | |
| 1521 | function: native_expm1 |
| 1522 | version: 21 |
| 1523 | attrib: const |
| 1524 | w: 1, 2, 3, 4 |
| 1525 | t: f32 |
| 1526 | ret: #2#1 |
| 1527 | arg: #2#1 v |
| 1528 | summary: Approximate e raised to a number minus one |
| 1529 | description: |
| 1530 | Returns the approximate (e ^ v) - 1. |
| 1531 | |
| 1532 | See also @expm1(). |
| 1533 | end: |
| 1534 | |
| 1535 | function: native_hypot |
| 1536 | version: 21 |
| 1537 | attrib: const |
| 1538 | w: 1, 2, 3, 4 |
| 1539 | t: f32 |
| 1540 | ret: #2#1 |
| 1541 | arg: #2#1 a |
| 1542 | arg: #2#1 b |
| 1543 | summary: Approximate hypotenuse |
| 1544 | description: |
| 1545 | Returns the approximate native_sqrt(a * a + b * b) |
| 1546 | |
| 1547 | See also @hypot(). |
| 1548 | end: |
| 1549 | |
| 1550 | function: native_log |
| 1551 | version: 18 |
| 1552 | attrib: const |
| 1553 | w: 1, 2, 3, 4 |
| 1554 | t: f32 |
| 1555 | ret: #2#1 |
| 1556 | arg: #2#1 v, range(10e-10,10e10) |
| 1557 | summary: Approximate natural logarithm |
| 1558 | description: |
| 1559 | Fast approximate log. |
| 1560 | |
| 1561 | It is not accurate for values very close to zero. |
| 1562 | |
| 1563 | See also @log(). |
| 1564 | test: limited |
| 1565 | end: |
| 1566 | |
| 1567 | function: native_log10 |
| 1568 | version: 18 |
| 1569 | attrib: const |
| 1570 | w: 1, 2, 3, 4 |
| 1571 | t: f32 |
| 1572 | ret: #2#1 |
| 1573 | arg: #2#1 v, range(10e-10,10e10) |
| 1574 | summary: Approximate base 10 logarithm |
| 1575 | description: |
| 1576 | Fast approximate log10. |
| 1577 | |
| 1578 | It is not accurate for values very close to zero. |
| 1579 | |
| 1580 | See also @log10(). |
| 1581 | test: limited |
| 1582 | end: |
| 1583 | |
| 1584 | function: native_log1p |
| 1585 | version: 21 |
| 1586 | attrib: const |
| 1587 | w: 1, 2, 3, 4 |
| 1588 | t: f32 |
| 1589 | ret: #2#1 |
| 1590 | arg: #2#1 v |
| 1591 | summary: Approximate natural logarithm of a value plus 1 |
| 1592 | description: |
| 1593 | Returns the approximate natural logarithm of (v + 1.0f) |
| 1594 | |
| 1595 | See also @log1p(). |
| 1596 | end: |
| 1597 | |
| 1598 | function: native_log2 |
| 1599 | version: 18 |
| 1600 | attrib: const |
| 1601 | w: 1, 2, 3, 4 |
| 1602 | t: f32 |
| 1603 | ret: #2#1 |
| 1604 | arg: #2#1 v, range(10e-10,10e10) |
| 1605 | summary: Approximate base 2 logarithm |
| 1606 | description: |
| 1607 | Fast approximate log2. |
| 1608 | |
| 1609 | It is not accurate for values very close to zero. |
| 1610 | |
| 1611 | See also @log2(). |
| 1612 | test: limited |
| 1613 | end: |
| 1614 | |
| 1615 | function: native_powr |
| 1616 | version: 18 |
| 1617 | attrib: const |
| 1618 | w: 1, 2, 3, 4 |
| 1619 | t: f32 |
| 1620 | ret: #2#1 |
| 1621 | arg: #2#1 base, range(0,256), "Must be between 0.f and 256.f. The function is not accurate for values very close to zero." |
| 1622 | arg: #2#1 exponent, range(-15,15), "Must be between -15.f and 15.f." |
| 1623 | summary: Approximate positive base raised to an exponent |
| 1624 | description: |
| 1625 | Fast approximate (base ^ exponent). |
| 1626 | |
| 1627 | See also @powr(). |
| 1628 | test: limited |
| 1629 | end: |
| 1630 | |
| 1631 | function: native_recip |
| 1632 | version: 21 |
| 1633 | attrib: const |
| 1634 | w: 1, 2, 3, 4 |
| 1635 | t: f32 |
| 1636 | ret: #2#1 |
| 1637 | arg: #2#1 v |
| 1638 | summary: Approximate reciprocal |
| 1639 | description: |
| 1640 | Returns the approximate approximate reciprocal of a value. |
| 1641 | |
| 1642 | See also @half_recip(). |
| 1643 | end: |
| 1644 | |
| 1645 | function: native_rootn |
| 1646 | version: 21 |
| 1647 | attrib: const |
| 1648 | w: 1, 2, 3, 4 |
| 1649 | t: f32 |
| 1650 | ret: #2#1 |
| 1651 | arg: #2#1 v |
| 1652 | arg: int#1 n |
| 1653 | summary: Approximate nth root |
| 1654 | description: |
| 1655 | Compute the approximate Nth root of a value. |
| 1656 | |
| 1657 | See also @rootn(). |
| 1658 | end: |
| 1659 | |
| 1660 | function: native_rsqrt |
| 1661 | version: 21 |
| 1662 | attrib: const |
| 1663 | w: 1, 2, 3, 4 |
| 1664 | t: f32 |
| 1665 | ret: #2#1 |
| 1666 | arg: #2#1 v |
| 1667 | summary: Approximate reciprocal of a square root |
| 1668 | description: |
| 1669 | Returns approximate (1 / sqrt(v)). |
| 1670 | |
| 1671 | See also @rsqrt(), @half_rsqrt(). |
| 1672 | end: |
| 1673 | |
| 1674 | function: native_sin |
| 1675 | version: 21 |
| 1676 | attrib: const |
| 1677 | w: 1, 2, 3, 4 |
| 1678 | t: f32 |
| 1679 | ret: #2#1 |
| 1680 | arg: #2#1 v |
| 1681 | summary: Approximate sine |
| 1682 | description: |
| 1683 | Returns the approximate sine of an angle measured in radians. |
| 1684 | |
| 1685 | See also @sin(). |
| 1686 | end: |
| 1687 | |
| 1688 | function: native_sincos |
| 1689 | version: 21 |
| 1690 | w: 1, 2, 3, 4 |
| 1691 | t: f32 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1692 | ret: #2#1, "Sine." |
| 1693 | arg: #2#1 v, "Incoming value in radians." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1694 | arg: #2#1* cos, "*cos will be set to the cosine value." |
| 1695 | summary: Approximate sine and cosine |
| 1696 | description: |
| 1697 | Returns the approximate sine and cosine of a value. |
| 1698 | |
| 1699 | See also @sincos(). |
| 1700 | # TODO Temporary |
| 1701 | test: limited(0.0005) |
| 1702 | end: |
| 1703 | |
| 1704 | function: native_sinh |
| 1705 | version: 21 |
| 1706 | attrib: const |
| 1707 | w: 1, 2, 3, 4 |
| 1708 | t: f32 |
| 1709 | ret: #2#1 |
| 1710 | arg: #2#1 v |
| 1711 | summary: Approximate hyperbolic sine |
| 1712 | description: |
| 1713 | Returns the approximate hyperbolic sine of a value specified in radians. |
| 1714 | |
| 1715 | See also @sinh(). |
| 1716 | end: |
| 1717 | |
| 1718 | function: native_sinpi |
| 1719 | version: 21 |
| 1720 | attrib: const |
| 1721 | w: 1, 2, 3, 4 |
| 1722 | t: f32 |
| 1723 | ret: #2#1 |
| 1724 | arg: #2#1 v |
| 1725 | summary: Approximate sine of a number multiplied by pi |
| 1726 | description: |
| 1727 | Returns the approximate sine of (v * pi), where (v * pi) is measured in radians. |
| 1728 | |
| 1729 | To get the sine of a value measured in degrees, call <code>sinpi(v / 180.f)</code>. |
| 1730 | |
| 1731 | See also @sinpi(). |
| 1732 | end: |
| 1733 | |
| 1734 | function: native_sqrt |
| 1735 | version: 21 |
| 1736 | attrib: const |
| 1737 | w: 1, 2, 3, 4 |
| 1738 | t: f32 |
| 1739 | ret: #2#1 |
| 1740 | arg: #2#1 v |
| 1741 | summary: Approximate square root |
| 1742 | description: |
| 1743 | Returns the approximate sqrt(v). |
| 1744 | |
| 1745 | See also @sqrt(), @half_sqrt(). |
| 1746 | end: |
| 1747 | |
| 1748 | function: native_tan |
| 1749 | version: 21 |
| 1750 | attrib: const |
| 1751 | w: 1, 2, 3, 4 |
| 1752 | t: f32 |
| 1753 | ret: #2#1 |
| 1754 | arg: #2#1 v |
| 1755 | summary: Approximate tangent |
| 1756 | description: |
| 1757 | Returns the approximate tangent of an angle measured in radians. |
| 1758 | end: |
| 1759 | |
| 1760 | function: native_tanh |
| 1761 | version: 21 |
| 1762 | attrib: const |
| 1763 | w: 1, 2, 3, 4 |
| 1764 | t: f32 |
| 1765 | ret: #2#1 |
| 1766 | arg: #2#1 v |
| 1767 | summary: Approximate hyperbolic tangent |
| 1768 | description: |
| 1769 | Returns the approximate hyperbolic tangent of a value. |
| 1770 | |
| 1771 | See also @tanh(). |
| 1772 | end: |
| 1773 | |
| 1774 | function: native_tanpi |
| 1775 | version: 21 |
| 1776 | attrib: const |
| 1777 | w: 1, 2, 3, 4 |
| 1778 | t: f32 |
| 1779 | ret: #2#1 |
| 1780 | arg: #2#1 v |
| 1781 | summary: Approximate tangent of a number multiplied by pi |
| 1782 | description: |
| 1783 | Returns the approximate tangent of (v * pi), where (v * pi) is measured in radians. |
| 1784 | |
| 1785 | To get the tangent of a value measured in degrees, call <code>tanpi(v / 180.f)</code>. |
| 1786 | |
| 1787 | See also @tanpi(). |
| 1788 | end: |
| 1789 | |
| 1790 | function: nextafter |
| 1791 | version: 9 |
| 1792 | attrib: const |
| 1793 | w: 1, 2, 3, 4 |
| 1794 | t: f32 |
| 1795 | ret: #2#1 |
| 1796 | arg: #2#1 v |
| 1797 | arg: #2#1 target |
| 1798 | summary: Next floating point number |
| 1799 | description: |
| 1800 | Returns the next representable floating point number from v towards target. |
| 1801 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1802 | In rs_fp_relaxed mode, a denormalized input value may not yield the next denormalized |
| 1803 | value, as support of denormalized values is optional in relaxed mode. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1804 | end: |
| 1805 | |
| 1806 | function: pow |
| 1807 | version: 9 |
| 1808 | attrib: const |
| 1809 | w: 1, 2, 3, 4 |
| 1810 | t: f32 |
| 1811 | ret: #2#1 |
| 1812 | arg: #2#1 base |
| 1813 | arg: #2#1 exponent |
| 1814 | summary: Base raised to an exponent |
| 1815 | description: |
| 1816 | Returns base raised to the power exponent, i.e. base ^ exponent. |
| 1817 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1818 | @pown() and @powr() are similar. @pown() takes an integer exponent. @powr() assumes the |
| 1819 | base to be non-negative. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1820 | end: |
| 1821 | |
| 1822 | function: pown |
| 1823 | version: 9 |
| 1824 | attrib: const |
| 1825 | w: 1, 2, 3, 4 |
| 1826 | t: f32 |
| 1827 | ret: #2#1 |
| 1828 | arg: #2#1 base |
| 1829 | arg: int#1 exponent |
| 1830 | summary: Base raised to an integer exponent |
| 1831 | description: |
| 1832 | Returns base raised to the power exponent, i.e. base ^ exponent. |
| 1833 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1834 | @pow() and @powr() are similar. The both take a float exponent. @powr() also assumes the |
| 1835 | base to be non-negative. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1836 | end: |
| 1837 | |
| 1838 | function: powr |
| 1839 | version: 9 |
| 1840 | attrib: const |
| 1841 | w: 1, 2, 3, 4 |
| 1842 | t: f32 |
| 1843 | ret: #2#1 |
| 1844 | arg: #2#1 base, range(0,3000) |
| 1845 | arg: #2#1 exponent |
| 1846 | summary: Positive base raised to an exponent |
| 1847 | description: |
| 1848 | Returns base raised to the power exponent, i.e. base ^ exponent. base must be >= 0. |
| 1849 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1850 | @pow() and @pown() are similar. They both make no assumptions about the base. |
| 1851 | @pow() takes a float exponent while @pown() take an integer. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1852 | |
| 1853 | See also @native_powr(). |
| 1854 | end: |
| 1855 | |
| 1856 | function: radians |
| 1857 | version: 9 |
| 1858 | attrib: const |
| 1859 | w: 1, 2, 3, 4 |
| 1860 | t: f32 |
| 1861 | ret: #2#1 |
| 1862 | arg: #2#1 v |
| 1863 | summary: Converts degrees into radians |
| 1864 | description: |
| 1865 | Converts from degrees to radians. |
| 1866 | end: |
| 1867 | |
| 1868 | function: remainder |
| 1869 | version: 9 |
| 1870 | attrib: const |
| 1871 | w: 1, 2, 3, 4 |
| 1872 | t: f32 |
| 1873 | ret: #2#1 |
| 1874 | arg: #2#1 numerator |
| 1875 | arg: #2#1 denominator |
| 1876 | summary: Remainder of a division |
| 1877 | description: |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1878 | Returns the remainder of (numerator / denominator), where the quotient is rounded towards |
| 1879 | the nearest integer. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1880 | |
| 1881 | The function @fmod() is similar but rounds toward the closest interger. |
| 1882 | For example, <code>@fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f) |
| 1883 | while <code>remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f). |
| 1884 | end: |
| 1885 | |
| 1886 | function: remquo |
| 1887 | version: 9 |
| 1888 | w: 1, 2, 3, 4 |
| 1889 | t: f32 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1890 | ret: #2#1, "Remainder, precise only for the low three bits." |
| 1891 | arg: #2#1 numerator, "Numerator." |
| 1892 | arg: #2#1 denominator, "Denominator." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1893 | arg: int#1* quotient, "*quotient will be set to the integer quotient." |
| 1894 | summary: Remainder and quotient of a division |
| 1895 | description: |
| 1896 | Returns the quotient and the remainder of (numerator / denominator). |
| 1897 | |
| 1898 | Only the sign and lowest three bits of the quotient are guaranteed to be accurate. |
| 1899 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1900 | This function is useful for implementing periodic functions. The low three bits of the |
| 1901 | quotient gives the quadrant and the remainder the distance within the quadrant. |
| 1902 | For example, an implementation of @sin(x) could call <code>remquo(x, PI / 2.f, &quadrant)</code> |
| 1903 | to reduce very large value of x to something within a limited range. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1904 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1905 | Example: <code>remquo(-23.5f, 8.f, &quot)</code> sets the lowest three bits of quot to 3 |
| 1906 | and the sign negative. It returns 0.5f. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1907 | test: custom |
| 1908 | end: |
| 1909 | |
| 1910 | function: rint |
| 1911 | version: 9 |
| 1912 | attrib: const |
| 1913 | w: 1, 2, 3, 4 |
| 1914 | t: f32 |
| 1915 | ret: #2#1 |
| 1916 | arg: #2#1 v |
| 1917 | summary: Round to even |
| 1918 | description: |
| 1919 | Rounds to the nearest integral value. |
| 1920 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1921 | rint() rounds half values to even. For example, <code>rint(0.5f)</code> returns 0.f and |
| 1922 | <code>rint(1.5f)</code> returns 2.f. Similarly, <code>rint(-0.5f)</code> returns -0.f and |
| 1923 | <code>rint(-1.5f)</code> returns -2.f. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1924 | |
| 1925 | @round() is similar but rounds away from zero. @trunc() truncates the decimal fraction. |
| 1926 | end: |
| 1927 | |
| 1928 | function: rootn |
| 1929 | version: 9 |
| 1930 | attrib: const |
| 1931 | w: 1, 2, 3, 4 |
| 1932 | t: f32 |
| 1933 | ret: #2#1 |
| 1934 | arg: #2#1 v |
| 1935 | arg: int#1 n |
| 1936 | summary: Nth root |
| 1937 | description: |
| 1938 | Compute the Nth root of a value. |
| 1939 | |
| 1940 | See also @native_rootn(). |
| 1941 | end: |
| 1942 | |
| 1943 | function: round |
| 1944 | version: 9 |
| 1945 | attrib: const |
| 1946 | w: 1, 2, 3, 4 |
| 1947 | t: f32 |
| 1948 | ret: #2#1 |
| 1949 | arg: #2#1 v |
| 1950 | summary: Round away from zero |
| 1951 | description: |
| 1952 | Round to the nearest integral value. |
| 1953 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 1954 | round() rounds half values away from zero. For example, <code>round(0.5f)</code> returns 1.f |
| 1955 | and <code>round(1.5f)</code> returns 2.f. Similarly, <code>round(-0.5f)</code> returns -1.f |
| 1956 | and <code>round(-1.5f)</code> returns -2.f. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 1957 | |
| 1958 | @rint() is similar but rounds half values toward even. @trunc() truncates the decimal fraction. |
| 1959 | end: |
| 1960 | |
| 1961 | function: rsqrt |
| 1962 | version: 9 |
| 1963 | attrib: const |
| 1964 | w: 1, 2, 3, 4 |
| 1965 | t: f32 |
| 1966 | ret: #2#1 |
| 1967 | arg: #2#1 v |
| 1968 | summary: Reciprocal of a square root |
| 1969 | description: |
| 1970 | Returns (1 / sqrt(v)). |
| 1971 | |
| 1972 | See also @half_rsqrt(), @native_rsqrt(). |
| 1973 | end: |
| 1974 | |
| 1975 | function: sign |
| 1976 | version: 9 |
| 1977 | attrib: const |
| 1978 | w: 1, 2, 3, 4 |
| 1979 | t: f32 |
| 1980 | ret: #2#1 |
| 1981 | arg: #2#1 v |
| 1982 | summary: Sign of a value |
| 1983 | description: |
| 1984 | Returns the sign of a value. |
| 1985 | |
| 1986 | if (v < 0) return -1.f; |
| 1987 | else if (v > 0) return 1.f; |
| 1988 | else return 0.f; |
| 1989 | end: |
| 1990 | |
| 1991 | function: sin |
| 1992 | version: 9 |
| 1993 | attrib: const |
| 1994 | w: 1, 2, 3, 4 |
| 1995 | t: f32 |
| 1996 | ret: #2#1 |
| 1997 | arg: #2#1 v |
| 1998 | summary: Sine |
| 1999 | description: |
| 2000 | Returns the sine of an angle measured in radians. |
| 2001 | |
| 2002 | See also @native_sin(). |
| 2003 | end: |
| 2004 | |
| 2005 | function: sincos |
| 2006 | version: 9 |
| 2007 | w: 1, 2, 3, 4 |
| 2008 | t: f32 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 2009 | ret: #2#1, "Sine of v." |
| 2010 | arg: #2#1 v, "Incoming value in radians." |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 2011 | arg: #2#1* cos, "*cos will be set to the cosine value." |
| 2012 | summary: Sine and cosine |
| 2013 | description: |
| 2014 | Returns the sine and cosine of a value. |
| 2015 | |
| 2016 | See also @native_sincos(). |
| 2017 | end: |
| 2018 | |
| 2019 | function: sinh |
| 2020 | version: 9 |
| 2021 | attrib: const |
| 2022 | w: 1, 2, 3, 4 |
| 2023 | t: f32 |
| 2024 | ret: #2#1 |
| 2025 | arg: #2#1 v |
| 2026 | summary: Hyperbolic sine |
| 2027 | description: |
| 2028 | Returns the hyperbolic sine of v, where v is measured in radians. |
| 2029 | |
| 2030 | See also @native_sinh(). |
| 2031 | end: |
| 2032 | |
| 2033 | function: sinpi |
| 2034 | version: 9 |
| 2035 | attrib: const |
| 2036 | w: 1, 2, 3, 4 |
| 2037 | t: f32 |
| 2038 | ret: #2#1 |
| 2039 | arg: #2#1 v |
| 2040 | summary: Sine of a number multiplied by pi |
| 2041 | description: |
| 2042 | Returns the sine of (v * pi), where (v * pi) is measured in radians. |
| 2043 | |
| 2044 | To get the sine of a value measured in degrees, call <code>sinpi(v / 180.f)</code>. |
| 2045 | |
| 2046 | See also @native_sinpi(). |
| 2047 | end: |
| 2048 | |
| 2049 | function: sqrt |
| 2050 | version: 9 |
| 2051 | attrib: const |
| 2052 | w: 1, 2, 3, 4 |
| 2053 | t: f32 |
| 2054 | ret: #2#1 |
| 2055 | arg: #2#1 v |
| 2056 | summary: Square root |
| 2057 | description: |
| 2058 | Returns the square root of a value. |
| 2059 | |
| 2060 | See also @half_sqrt(), @native_sqrt(). |
| 2061 | end: |
| 2062 | |
| 2063 | function: step |
| 2064 | version: 9 |
| 2065 | attrib: const |
| 2066 | w: 1, 2, 3, 4 |
| 2067 | t: f32 |
| 2068 | ret: #2#1 |
| 2069 | arg: #2#1 edge |
| 2070 | arg: #2#1 v |
| 2071 | summary: 0 if less than a value, 0 otherwise |
| 2072 | description: |
| 2073 | Returns 0.f if v < edge, 1.f otherwise. |
| 2074 | |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 2075 | This can be useful to create conditional computations without using loops and branching |
| 2076 | instructions. For example, instead of computing <code>(a[i] < b[i]) ? 0.f : @atan2(a[i], b[i])</code> |
| 2077 | for the corresponding elements of a vector, you could instead use <code>step(a, b) * @atan2(a, b)</code>. |
Jean-Luc Brouillet | be21638 | 2015-03-22 12:44:27 -0700 | [diff] [blame] | 2078 | end: |
| 2079 | |
| 2080 | function: step |
| 2081 | version: 9 |
| 2082 | attrib: const |
| 2083 | w: 2, 3, 4 |
| 2084 | t: f32 |
| 2085 | ret: #2#1 |
| 2086 | arg: #2#1 edge |
| 2087 | arg: #2 v |
| 2088 | end: |
| 2089 | |
| 2090 | function: step |
| 2091 | version: 21 |
| 2092 | attrib: const |
| 2093 | w: 2, 3, 4 |
| 2094 | t: f32 |
| 2095 | ret: #2#1 |
| 2096 | arg: #2 edge |
| 2097 | arg: #2#1 v |
| 2098 | end: |
| 2099 | |
| 2100 | function: tan |
| 2101 | version: 9 |
| 2102 | attrib: const |
| 2103 | w: 1, 2, 3, 4 |
| 2104 | t: f32 |
| 2105 | ret: #2#1 |
| 2106 | arg: #2#1 v |
| 2107 | summary: Tangent |
| 2108 | description: |
| 2109 | Returns the tangent of an angle measured in radians. |
| 2110 | |
| 2111 | See also @native_tan(). |
| 2112 | end: |
| 2113 | |
| 2114 | function: tanh |
| 2115 | version: 9 |
| 2116 | attrib: const |
| 2117 | w: 1, 2, 3, 4 |
| 2118 | t: f32 |
| 2119 | ret: #2#1 |
| 2120 | arg: #2#1 v |
| 2121 | summary: Hyperbolic tangent |
| 2122 | description: |
| 2123 | Returns the hyperbolic tangent of a value. |
| 2124 | |
| 2125 | See also @native_tanh(). |
| 2126 | end: |
| 2127 | |
| 2128 | function: tanpi |
| 2129 | version: 9 |
| 2130 | attrib: const |
| 2131 | w: 1, 2, 3, 4 |
| 2132 | t: f32 |
| 2133 | ret: #2#1 |
| 2134 | arg: #2#1 v |
| 2135 | summary: Tangent of a number multiplied by pi |
| 2136 | description: |
| 2137 | Returns the tangent of (v * pi), where (v * pi) is measured in radians. |
| 2138 | |
| 2139 | To get the tangent of a value measured in degrees, call <code>tanpi(v / 180.f)</code>. |
| 2140 | |
| 2141 | See also @native_tanpi(). |
| 2142 | end: |
| 2143 | |
| 2144 | function: tgamma |
| 2145 | version: 9 |
| 2146 | attrib: const |
| 2147 | w: 1, 2, 3, 4 |
| 2148 | t: f32 |
| 2149 | ret: #2#1 |
| 2150 | arg: #2#1 v |
| 2151 | summary: Gamma function |
| 2152 | description: |
| 2153 | Returns the gamma function of a value. |
| 2154 | |
| 2155 | See also @lgamma(). |
| 2156 | end: |
| 2157 | |
| 2158 | function: trunc |
| 2159 | version: 9 |
| 2160 | attrib: const |
| 2161 | w: 1, 2, 3, 4 |
| 2162 | t: f32 |
| 2163 | ret: #2#1 |
| 2164 | arg: #2#1 v |
| 2165 | summary: Truncates a floating point |
| 2166 | description: |
| 2167 | Rounds to integral using truncation. |
| 2168 | |
| 2169 | For example, <code>trunc(1.7f)</code> returns 1.f and <code>trunc(-1.7f)</code> returns -1.f. |
| 2170 | |
| 2171 | See @rint() and @round() for other rounding options. |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 2172 | end: |
| 2173 | |
| 2174 | function: rsClamp |
| 2175 | # TODO Why always_inline? |
| 2176 | attrib: const, always_inline |
| 2177 | t: i8, i16, i32, u8, u16, u32 |
| 2178 | ret: #1 |
Jean-Luc Brouillet | 6386ceb | 2015-04-28 15:06:30 -0700 | [diff] [blame^] | 2179 | arg: #1 amount, "Value to clamp." |
| 2180 | arg: #1 low, "Lower bound." |
| 2181 | arg: #1 high, "Upper bound." |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 2182 | deprecated: Use @clamp() instead. |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 2183 | summary: Restrain a value to a range |
| 2184 | description: |
| 2185 | Clamp a value between low and high. |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 2186 | test: none |
| 2187 | end: |
| 2188 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 2189 | function: rsFrac |
| 2190 | attrib: const |
| 2191 | ret: float |
| 2192 | arg: float v |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 2193 | deprecated: Use @fract() instead. |
| 2194 | summary: Returns the fractional part of a float |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 2195 | description: |
| 2196 | Returns the fractional part of a float |
| 2197 | test: none |
| 2198 | end: |
| 2199 | |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 2200 | function: rsRand |
| 2201 | ret: int |
| 2202 | arg: int max_value |
Jean-Luc Brouillet | 20b27d6 | 2015-04-03 14:39:53 -0700 | [diff] [blame] | 2203 | summary: Pseudo-random number |
Jean-Luc Brouillet | c5184e2 | 2015-03-13 13:51:24 -0700 | [diff] [blame] | 2204 | description: |
| 2205 | Return a random value between 0 (or min_value) and max_malue. |
| 2206 | test: none |
| 2207 | end: |
| 2208 | |
| 2209 | function: rsRand |
| 2210 | ret: int |
| 2211 | arg: int min_value |
| 2212 | arg: int max_value |
| 2213 | test: none |
| 2214 | end: |
| 2215 | |
| 2216 | function: rsRand |
| 2217 | ret: float |
| 2218 | arg: float max_value |
| 2219 | test: none |
| 2220 | end: |
| 2221 | |
| 2222 | function: rsRand |
| 2223 | ret: float |
| 2224 | arg: float min_value |
| 2225 | arg: float max_value |
| 2226 | test: none |
| 2227 | end: |