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