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