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