blob: cdd712303fd55155f4c499cd30d637ad86e80fef [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 Brouillet6386ceb2015-04-28 15:06:30 -070020 The mathematical functions below can be applied to scalars and vectors. When applied
21 to vectors, the returned value is a vector of the function applied to each entry of the input.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070022
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070023 For example:<code><br/>
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070024 float3 a, b;<br/>
25 // The following call sets<br/>
26 // a.x to sin(b.x),<br/>
27 // a.y to sin(b.y), and<br/>
28 // a.z to sin(b.z).<br/>
29 a = sin(b);<br/>
30 </code>
31
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070032 See <a href='rs_vector_math.html'>Vector Math Functions</a> for functions like @distance() and @length() that interpret
33 instead the input as a single vector in n-dimensional space.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070034
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070035 The precision of the mathematical operations on 32 bit floats is affected by the pragmas
36 rs_fp_relaxed and rs_fp_full. Under rs_fp_relaxed, subnormal values may be flushed to zero and
37 rounding may be done towards zero. In comparison, rs_fp_full requires correct handling of
38 subnormal values, i.e. smaller than 1.17549435e-38f. rs_fp_rull also requires round to nearest
39 with ties to even.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070040
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -070041 Different precision/speed tradeoffs can be achieved by using variants of the common math
42 functions. Functions with a name starting with<ul>
43 <li>native_: May have custom hardware implementations with weaker precision. Additionally,
44 subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and
45 infinity input may not be handled correctly.</li>
46 <li>half_: May perform internal computations using 16 bit floats. Additionally, subnormal
47 values may be flushed to zero, and rounding towards zero may be used.</li>
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070048 </ul>
49end:
50
51constant: M_1_PI
52value: 0.318309886183790671537767526745028724f
53summary: 1 / pi, as a 32 bit float
54description:
55 The inverse of pi, as a 32 bit float.
56end:
57
58constant: M_2_PI
59value: 0.636619772367581343075535053490057448f
60summary: 2 / pi, as a 32 bit float
61description:
62 2 divided by pi, as a 32 bit float.
63end:
64
65constant: M_2_PIl
66value: 0.636619772367581343075535053490057448f
67hidden:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070068deprecated: Use M_2_PI instead.
69summary: 2 / pi, as a 32 bit float
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070070description:
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -070071 2 divided by pi, as a 32 bit float.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -070072end:
73
74constant: M_2_SQRTPI
75value: 1.128379167095512573896158903121545172f
76summary: 2 / sqrt(pi), as a 32 bit float
77description:
78 2 divided by the square root of pi, as a 32 bit float.
79end:
80
81constant: M_E
82value: 2.718281828459045235360287471352662498f
83summary: e, as a 32 bit float
84description:
85 The number e, the base of the natural logarithm, as a 32 bit float.
86end:
87
88constant: M_LN10
89value: 2.302585092994045684017991454684364208f
90summary: log_e(10), as a 32 bit float
91description:
92 The natural logarithm of 10, as a 32 bit float.
93end:
94
95constant: M_LN2
96value: 0.693147180559945309417232121458176568f
97summary: log_e(2), as a 32 bit float
98description:
99 The natural logarithm of 2, as a 32 bit float.
100end:
101
102constant: M_LOG10E
103value: 0.434294481903251827651128918916605082f
104summary: log_10(e), as a 32 bit float
105description:
106 The logarithm base 10 of e, as a 32 bit float.
107end:
108
109constant: M_LOG2E
110value: 1.442695040888963407359924681001892137f
111summary: log_2(e), as a 32 bit float
112description:
113 The logarithm base 2 of e, as a 32 bit float.
114end:
115
116constant: M_PI
117value: 3.141592653589793238462643383279502884f
118summary: pi, as a 32 bit float
119description:
120 The constant pi, as a 32 bit float.
121end:
122
123constant: M_PI_2
124value: 1.570796326794896619231321691639751442f
125summary: pi / 2, as a 32 bit float
126description:
127 Pi divided by 2, as a 32 bit float.
128end:
129
130constant: M_PI_4
131value: 0.785398163397448309615660845819875721f
132summary: pi / 4, as a 32 bit float
133description:
134 Pi divided by 4, as a 32 bit float.
135end:
136
137constant: M_SQRT1_2
138value: 0.707106781186547524400844362104849039f
139summary: 1 / sqrt(2), as a 32 bit float
140description:
141 The inverse of the square root of 2, as a 32 bit float.
142end:
143
144constant: M_SQRT2
145value: 1.414213562373095048801688724209698079f
146summary: sqrt(2), as a 32 bit float
147description:
148 The square root of 2, as a 32 bit float.
149end:
150
151function: abs
152version: 9
153attrib: const
154w: 1, 2, 3, 4
155t: i8, i16, i32
156ret: u#2#1
157arg: #2#1 v
158summary: Absolute value of an integer
159description:
160 Returns the absolute value of an integer.
161
162 For floats, use @fabs().
163end:
164
165function: acos
166version: 9
167attrib: const
168w: 1, 2, 3, 4
169t: f32
170ret: #2#1
171arg: #2#1 v, range(-1,1)
172summary: Inverse cosine
173description:
174 Returns the inverse cosine, in radians.
175
176 See also @native_acos().
177end:
178
179function: acosh
180version: 9
181attrib: const
182w: 1, 2, 3, 4
183t: f32
184ret: #2#1
185arg: #2#1 v
186summary: Inverse hyperbolic cosine
187description:
188 Returns the inverse hyperbolic cosine, in radians.
189
190 See also @native_acosh().
191end:
192
193function: acospi
194version: 9
195attrib: const
196w: 1, 2, 3, 4
197t: f32
198ret: #2#1
199arg: #2#1 v, range(-1,1)
200summary: Inverse cosine divided by pi
201description:
202 Returns the inverse cosine in radians, divided by pi.
203
204 To get an inverse cosine measured in degrees, use <code>acospi(a) * 180.f</code>.
205
206 See also @native_acospi().
207end:
208
209function: asin
210version: 9
211attrib: const
212w: 1, 2, 3, 4
213t: f32
214ret: #2#1
215arg: #2#1 v, range(-1,1)
216summary: Inverse sine
217description:
218 Returns the inverse sine, in radians.
219
220 See also @native_asin().
221end:
222
223function: asinh
224version: 9
225attrib: const
226w: 1, 2, 3, 4
227t: f32
228ret: #2#1
229arg: #2#1 v
230summary: Inverse hyperbolic sine
231description:
232 Returns the inverse hyperbolic sine, in radians.
233
234 See also @native_asinh().
235end:
236
237function: asinpi
238version: 9
239attrib: const
240w: 1, 2, 3, 4
241t: f32
242ret: #2#1
243arg: #2#1 v, range(-1,1)
244summary: Inverse sine divided by pi
245description:
246 Returns the inverse sine in radians, divided by pi.
247
248 To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>.
249
250 See also @native_asinpi().
251end:
252
253function: atan
254version: 9
255attrib: const
256w: 1, 2, 3, 4
257t: f32
258ret: #2#1
259arg: #2#1 v, range(-1,1)
260summary: Inverse tangent
261description:
262 Returns the inverse tangent, in radians.
263
264 See also @native_atan().
265end:
266
267function: atan2
268version: 9
269attrib: const
270w: 1, 2, 3, 4
271t: f32
272ret: #2#1
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700273arg: #2#1 numerator, "Numerator."
274arg: #2#1 denominator, "Denominator. Can be 0."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700275summary: Inverse tangent of a ratio
276description:
277 Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians.
278
279 See also @native_atan2().
280end:
281
282function: atan2pi
283version: 9
284attrib: const
285w: 1, 2, 3, 4
286t: f32
287ret: #2#1
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700288arg: #2#1 numerator, "Numerator."
289arg: #2#1 denominator, "Denominator. Can be 0."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700290summary: Inverse tangent of a ratio, divided by pi
291description:
292 Returns the inverse tangent of <code>(numerator / denominator)</code>, in radians, divided by pi.
293
294 To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>.
295
296 See also @native_atan2pi().
297end:
298
299function: atanh
300version: 9
301attrib: const
302w: 1, 2, 3, 4
303t: f32
304ret: #2#1
305arg: #2#1 v, range(-1,1)
306summary: Inverse hyperbolic tangent
307description:
308 Returns the inverse hyperbolic tangent, in radians.
309
310 See also @native_atanh().
311end:
312
313function: atanpi
314version: 9
315attrib: const
316w: 1, 2, 3, 4
317t: f32
318ret: #2#1
319arg: #2#1 v, range(-1,1)
320summary: Inverse tangent divided by pi
321description:
322 Returns the inverse tangent in radians, divided by pi.
323
324 To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>.
325
326 See also @native_atanpi().
327end:
328
329function: cbrt
330version: 9
331attrib: const
332w: 1, 2, 3, 4
333t: f32
334ret: #2#1
335arg: #2#1 v
336summary: Cube root
337description:
338 Returns the cube root.
339
340 See also @native_cbrt().
341end:
342
343function: ceil
344version: 9
345attrib: const
346w: 1, 2, 3, 4
347t: f32
348ret: #2#1
349arg: #2#1 v
350summary: Smallest integer not less than a value
351description:
352 Returns the smallest integer not less than a value.
353
354 For example, <code>ceil(1.2f)</code> returns 2.f, and <code>ceil(-1.2f)</code> returns -1.f.
355
356 See also @floor().
357end:
358
359function: clamp
360version: 9
361attrib: const
362w: 1, 2, 3, 4
363t: f32
364ret: #2#1
365arg: #2#1 value, "Value to be clamped."
366arg: #2#1 min_value, "Lower bound, a scalar or matching vector."
367arg: #2#1 max_value, above(min_value), "High bound, must match the type of low."
368summary: Restrain a value to a range
369description:
370 Clamps a value to a specified high and low bound. clamp() returns min_value
371 if value &lt; min_value, max_value if value &gt; max_value, otherwise value.
372
373 There are two variants of clamp: one where the min and max are scalars applied
374 to all entries of the value, the other where the min and max are also vectors.
375
376 If min_value is greater than max_value, the results are undefined.
377end:
378
379function: clamp
380version: 9
381attrib: const
382w: 2, 3, 4
383t: f32
384ret: #2#1
385arg: #2#1 value
386arg: #2 min_value
387arg: #2 max_value, above(min_value)
388end:
389
390function: clamp
391version: 19
392attrib: const
393w: 1, 2, 3, 4
394t: u8, u16, u32, u64, i8, i16, i32, i64
395ret: #2#1
396arg: #2#1 value
397arg: #2#1 min_value
398arg: #2#1 max_value, above(min_value)
399end:
400
401function: clamp
402version: 19
403attrib: const
404w: 2, 3, 4
405t: u8, u16, u32, u64, i8, i16, i32, i64
406ret: #2#1
407arg: #2#1 value
408arg: #2 min_value
409arg: #2 max_value, above(min_value)
410end:
411
412function: clz
413version: 9
414attrib: const
415w: 1, 2, 3, 4
416t: u8, u16, u32, i8, i16, i32
417ret: #2#1
418arg: #2#1 value
419summary: Number of leading 0 bits
420description:
421 Returns the number of leading 0-bits in a value.
422
423 For example, <code>clz((char)0x03)</code> returns 6.
424end:
425
426function: copysign
427version: 9
428attrib: const
429w: 1, 2, 3, 4
430t: f32
431ret: #2#1
432arg: #2#1 magnitude_value
433arg: #2#1 sign_value
434summary: Copies the sign of a number to another
435description:
436 Copies the sign from sign_value to magnitude_value.
437
438 The value returned is either magnitude_value or -magnitude_value.
439
440 For example, <code>copysign(4.0f, -2.7f)</code> returns -4.0f and <code>copysign(-4.0f, 2.7f)</code> returns 4.0f.
441end:
442
443function: cos
444version: 9
445attrib: const
446w: 1, 2, 3, 4
447t: f32
448ret: #2#1
449arg: #2#1 v
450summary: Cosine
451description:
452 Returns the cosine of an angle measured in radians.
453
454 See also @native_cos().
455end:
456
457function: cosh
458version: 9
459attrib: const
460w: 1, 2, 3, 4
461t: f32
462ret: #2#1
463arg: #2#1 v
464summary: Hypebolic cosine
465description:
466 Returns the hypebolic cosine of v, where v is measured in radians.
467
468 See also @native_cosh().
469end:
470
471function: cospi
472version: 9
473attrib: const
474w: 1, 2, 3, 4
475t: f32
476ret: #2#1
477arg: #2#1 v
478summary: Cosine of a number multiplied by pi
479description:
480 Returns the cosine of <code>(v * pi)</code>, where <code>(v * pi)</code> is measured in radians.
481
482 To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>.
483
484 See also @native_cospi().
485end:
486
487function: degrees
488version: 9
489attrib: const
490w: 1, 2, 3, 4
491t: f32
492ret: #2#1
493arg: #2#1 v
494summary: Converts radians into degrees
495description:
496 Converts from radians to degrees.
497end:
498
499function: erf
500version: 9
501attrib: const
502w: 1, 2, 3, 4
503t: f32
504ret: #2#1
505arg: #2#1 v
506summary: Mathematical error function
507description:
508 Returns the error function.
509end:
510
511function: erfc
512version: 9
513attrib: const
514w: 1, 2, 3, 4
515t: f32
516ret: #2#1
517arg: #2#1 v
518summary: Mathematical complementary error function
519description:
520 Returns the complementary error function.
521end:
522
523function: exp
524version: 9
525attrib: const
526w: 1, 2, 3, 4
527t: f32
528ret: #2#1
529arg: #2#1 v
530summary: e raised to a number
531description:
532 Returns e raised to v, i.e. e ^ v.
533
534 See also @native_exp().
535end:
536
537function: exp10
538version: 9
539attrib: const
540w: 1, 2, 3, 4
541t: f32
542ret: #2#1
543arg: #2#1 v
544summary: 10 raised to a number
545description:
546 Returns 10 raised to v, i.e. 10.f ^ v.
547
548 See also @native_exp10().
549end:
550
551function: exp2
552version: 9
553attrib: const
554w: 1, 2, 3, 4
555t: f32
556ret: #2#1
557arg: #2#1 v
558summary: 2 raised to a number
559description:
560 Returns 2 raised to v, i.e. 2.f ^ v.
561
562 See also @native_exp2().
563end:
564
565function: expm1
566version: 9
567attrib: const
568w: 1, 2, 3, 4
569t: f32
570ret: #2#1
571arg: #2#1 v
572summary: e raised to a number minus one
573description:
574 Returns e raised to v minus 1, i.e. (e ^ v) - 1.
575
576 See also @native_expm1().
577end:
578
579function: fabs
580version: 9
581attrib: const
582w: 1, 2, 3, 4
583t: f32
584ret: #2#1
585arg: #2#1 v
586summary: Absolute value of a float
587description:
588 Returns the absolute value of the float v.
589
590 For integers, use @abs().
591end:
592
593function: fdim
594version: 9
595attrib: const
596w: 1, 2, 3, 4
597t: f32
598ret: #2#1
599arg: #2#1 a
600arg: #2#1 b
601summary: Positive difference between two values
602description:
603 Returns the positive difference between two values.
604
605 If a &gt; b, returns (a - b) otherwise returns 0f.
606end:
607
608function: floor
609version: 9
610attrib: const
611w: 1, 2, 3, 4
612t: f32
613ret: #2#1
614arg: #2#1 v
615summary: Smallest integer not greater than a value
616description:
617 Returns the smallest integer not greater than a value.
618
619 For example, <code>floor(1.2f)</code> returns 1.f, and <code>floor(-1.2f)</code> returns -2.f.
620
621 See also @ceil().
622end:
623
624function: fma
625version: 9
626attrib: const
627w: 1, 2, 3, 4
628t: f32
629ret: #2#1
630arg: #2#1 multiplicand1
631arg: #2#1 multiplicand2
632arg: #2#1 offset
633summary: Multiply and add
634description:
635 Multiply and add. Returns <code>(multiplicand1 * multiplicand2) + offset</code>.
636
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700637 This function is similar to @mad(). fma() retains full precision of the multiplied result
638 and rounds only after the addition. @mad() rounds after the multiplication and the addition.
639 This extra precision is not guaranteed in rs_fp_relaxed mode.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700640end:
641
642function: fmax
643version: 9
644attrib: const
645w: 1, 2, 3, 4
646t: f32
647ret: #2#1
648arg: #2#1 a
649arg: #2#1 b
650summary: Maximum of two floats
651description:
652 Returns the maximum of a and b, i.e. <code>(a &lt; b ? b : a)</code>.
653
654 The @max() function returns identical results but can be applied to more data types.
655end:
656
657function: fmax
658version: 9
659attrib: const
660w: 2, 3, 4
661t: f32
662ret: #2#1
663arg: #2#1 a
664arg: #2 b
665end:
666
667function: fmin
668version: 9
669attrib: const
670w: 1, 2, 3, 4
671t: f32
672ret: #2#1
673arg: #2#1 a
674arg: #2#1 b
675summary: Minimum of two floats
676description:
677 Returns the minimum of a and b, i.e. <code>(a &gt; b ? b : a)</code>.
678
679 The @min() function returns identical results but can be applied to more data types.
680end:
681
682function: fmin
683version: 9
684attrib: const
685w: 2, 3, 4
686t: f32
687ret: #2#1
688arg: #2#1 a
689arg: #2 b
690end:
691
692function: fmod
693version: 9
694attrib: const
695w: 1, 2, 3, 4
696t: f32
697ret: #2#1
698arg: #2#1 numerator
699arg: #2#1 denominator
700summary: Modulo
701description:
702 Returns the remainder of (numerator / denominator), where the quotient is rounded towards zero.
703
704 The function @remainder() is similar but rounds toward the closest interger.
705 For example, <code>fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f)
706 while <code>@remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f).
707end:
708
709function: fract
710version: 9
711w: 1, 2, 3, 4
712t: f32
713ret: #2#1
714arg: #2#1 v, "Input value."
715arg: #2#1* floor, "If floor is not null, *floor will be set to the floor of v."
716summary: Positive fractional part
717description:
718 Returns the positive fractional part of v, i.e. <code>v - floor(v)</code>.
719
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700720 For example, <code>fract(1.3f, &amp;val)</code> returns 0.3f and sets val to 1.f.
721 <code>fract(-1.3f, &amp;val)</code> returns 0.7f and sets val to -2.f.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700722end:
723
724function: fract
725version: 9
726attrib: const
727w: 1, 2, 3, 4
728t: f32
729ret: #2#1
730arg: #2#1 v
731inline:
732 #2#1 unused;
733 return fract(v, &unused);
734end:
735
736function: frexp
737version: 9
738w: 1, 2, 3, 4
739t: f32
740ret: #2#1
741arg: #2#1 v, "Input value."
742arg: int#1* exponent, "If exponent is not null, *exponent will be set to the exponent of v."
743summary: Binary mantissa and exponent
744description:
745 Returns the binary mantissa and exponent of v, i.e. <code>v == mantissa * 2 ^ exponent</code>.
746
747 The mantissa is always between 0.5 (inclusive) and 1.0 (exclusive).
748
749 See @ldexp() for the reverse operation. See also @logb() and @ilogb().
750end:
751
752function: half_recip
753version: 17
754attrib: const
755w: 1, 2, 3, 4
756t: f32
757ret: #2#1
758arg: #2#1 v
759summary: Reciprocal computed to 16 bit precision
760description:
761 Returns the approximate reciprocal of a value.
762
763 The precision is that of a 16 bit floating point value.
764
765 See also @native_recip().
766end:
767
768function: half_rsqrt
769version: 17
770attrib: const
771w: 1, 2, 3, 4
772t: f32
773ret: #2#1
774arg: #2#1 v
775summary: Reciprocal of a square root computed to 16 bit precision
776description:
777 Returns the approximate value of <code>(1.f / sqrt(value))</code>.
778
779 The precision is that of a 16 bit floating point value.
780
781 See also @rsqrt(), @native_rsqrt().
782end:
783
784function: half_sqrt
785version: 17
786attrib: const
787w: 1, 2, 3, 4
788t: f32
789ret: #2#1
790arg: #2#1 v
791summary: Square root computed to 16 bit precision
792description:
793 Returns the approximate square root of a value.
794
795 The precision is that of a 16 bit floating point value.
796
797 See also @sqrt(), @native_sqrt().
798end:
799
800function: hypot
801version: 9
802attrib: const
803w: 1, 2, 3, 4
804t: f32
805ret: #2#1
806arg: #2#1 a
807arg: #2#1 b
808summary: Hypotenuse
809description:
810 Returns the hypotenuse, i.e. <code>sqrt(a * a + b * b)</code>.
811
812 See also @native_hypot().
813end:
814
815function: ilogb
816version: 9
817attrib: const
818w: 1, 2, 3, 4
819t: f32
820ret: int#1
821arg: float#1 v
822summary: Base two exponent
823description:
824 Returns the base two exponent of a value, where the mantissa is between
825 1.f (inclusive) and 2.f (exclusive).
826
827 For example, <code>ilogb(8.5f)</code> returns 3.
828
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700829 Because of the difference in mantissa, this number is one less than is returned by @frexp().
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700830
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700840arg: float#1 mantissa, "Mantissa."
841arg: int#1 exponent, "Exponent, a single component or matching vector."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700842summary: 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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700955 Because of the difference in mantissa, this number is one less than is returned by frexp().
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700956
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -0700973 This function is similar to @fma(). @fma() retains full precision of the multiplied result
974 and rounds only after the addition. mad() rounds after the multiplication and the addition.
975 In rs_fp_relaxed mode, mad() may not do the rounding after multiplicaiton.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -0700976end:
977
978function: max
979version: 9
980attrib: const
981w: 1, 2, 3, 4
982t: f32
983ret: #2#1
984arg: #2#1 a
985arg: #2#1 b
986summary: Maximum
987description:
988 Returns the maximum value of two arguments.
989end:
990
991function: max
992version: 9 20
993attrib: const
994w: 1
995t: i8, i16, i32, u8, u16, u32
996ret: #2#1
997arg: #2#1 a
998arg: #2#1 b
999inline:
1000 return (a > b ? a : b);
1001end:
1002
1003function: max
1004version: 9 20
1005attrib: const
1006w: 2
1007t: i8, i16, i32, u8, u16, u32
1008ret: #2#1
1009arg: #2#1 a
1010arg: #2#1 b
1011inline:
1012 #2#1 tmp;
1013 tmp.x = (a.x > b.x ? a.x : b.x);
1014 tmp.y = (a.y > b.y ? a.y : b.y);
1015 return tmp;
1016end:
1017
1018function: max
1019version: 9 20
1020attrib: const
1021w: 3
1022t: i8, i16, i32, u8, u16, u32
1023ret: #2#1
1024arg: #2#1 a
1025arg: #2#1 b
1026inline:
1027 #2#1 tmp;
1028 tmp.x = (a.x > b.x ? a.x : b.x);
1029 tmp.y = (a.y > b.y ? a.y : b.y);
1030 tmp.z = (a.z > b.z ? a.z : b.z);
1031 return tmp;
1032end:
1033
1034function: max
1035version: 9 20
1036attrib: const
1037w: 4
1038t: i8, i16, i32, u8, u16, u32
1039ret: #2#1
1040arg: #2#1 a
1041arg: #2#1 b
1042inline:
1043 #2#1 tmp;
1044 tmp.x = (a.x > b.x ? a.x : b.x);
1045 tmp.y = (a.y > b.y ? a.y : b.y);
1046 tmp.z = (a.z > b.z ? a.z : b.z);
1047 tmp.w = (a.w > b.w ? a.w : b.w);
1048 return tmp;
1049end:
1050
1051function: max
1052version: 21
1053attrib: const
1054w: 1, 2, 3, 4
1055t: i8, i16, i32, i64, u8, u16, u32, u64
1056ret: #2#1
1057arg: #2#1 a
1058arg: #2#1 b
1059end:
1060
1061function: min
1062version: 9
1063attrib: const
1064w: 1, 2, 3, 4
1065t: f32
1066ret: #2#1
1067arg: #2#1 a
1068arg: #2#1 b
1069summary: Minimum
1070description:
1071 Returns the minimum value of two arguments.
1072end:
1073
1074function: min
1075version: 9 20
1076attrib: const
1077w: 1
1078t: i8, i16, i32, u8, u16, u32
1079ret: #2#1
1080arg: #2#1 a
1081arg: #2#1 b
1082inline:
1083 return (a < b ? a : b);
1084end:
1085
1086function: min
1087version: 9 20
1088attrib: const
1089w: 2
1090t: i8, i16, i32, u8, u16, u32
1091ret: #2#1
1092arg: #2#1 a
1093arg: #2#1 b
1094inline:
1095 #2#1 tmp;
1096 tmp.x = (a.x < b.x ? a.x : b.x);
1097 tmp.y = (a.y < b.y ? a.y : b.y);
1098 return tmp;
1099end:
1100
1101function: min
1102version: 9 20
1103attrib: const
1104w: 3
1105t: i8, i16, i32, u8, u16, u32
1106ret: #2#1
1107arg: #2#1 a
1108arg: #2#1 b
1109inline:
1110 #2#1 tmp;
1111 tmp.x = (a.x < b.x ? a.x : b.x);
1112 tmp.y = (a.y < b.y ? a.y : b.y);
1113 tmp.z = (a.z < b.z ? a.z : b.z);
1114 return tmp;
1115end:
1116
1117function: min
1118version: 9 20
1119attrib: const
1120w: 4
1121t: i8, i16, i32, u8, u16, u32
1122ret: #2#1
1123arg: #2#1 a
1124arg: #2#1 b
1125inline:
1126 #2#1 tmp;
1127 tmp.x = (a.x < b.x ? a.x : b.x);
1128 tmp.y = (a.y < b.y ? a.y : b.y);
1129 tmp.z = (a.z < b.z ? a.z : b.z);
1130 tmp.w = (a.w < b.w ? a.w : b.w);
1131 return tmp;
1132end:
1133
1134function: min
1135version: 21
1136attrib: const
1137w: 1, 2, 3, 4
1138t: i8, i16, i32, i64, u8, u16, u32, u64
1139ret: #2#1
1140arg: #2#1 a
1141arg: #2#1 b
1142end:
1143
1144function: mix
1145version: 9
1146attrib: const
1147w: 1, 2, 3, 4
1148t: f32
1149ret: #2#1
1150arg: #2#1 start
1151arg: #2#1 stop
1152arg: #2#1 fraction
1153summary: Mixes two values
1154description:
1155 Returns start + ((stop - start) * fraction).
1156
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001157 This can be useful for mixing two values. For example, to create a new color that is
1158 40% color1 and 60% color2, use <code>mix(color1, color2, 0.6f)</code>.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001159end:
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001176ret: #2#1, "Floating point portion of the value."
1177arg: #2#1 v, "Source value."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001178arg: #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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001183 Both components will have the same sign as x. For example, for an input of -3.72f,
1184 iret will be set to -3.f and .72f will be returned.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001185end:
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001212 This function yields undefined results from input values less than -1 or greater than 1.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001213
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001248 This function yields undefined results from input values less than -1 or greater than 1.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001249
1250 See also @acospi().
1251# TODO Temporary
1252test: limited(0.0005)
1253end:
1254
1255function: native_asin
1256version: 21
1257attrib: const
1258w: 1, 2, 3, 4
1259t: f32
1260ret: #2#1
1261arg: #2#1 v, range(-1,1)
1262summary: Approximate inverse sine
1263description:
1264 Returns the approximate inverse sine, in radians.
1265
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001266 This function yields undefined results from input values less than -1 or greater than 1.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001267
1268 See also @asin().
1269# TODO Temporary
1270test: limited(0.0005)
1271end:
1272
1273function: native_asinh
1274version: 21
1275attrib: const
1276w: 1, 2, 3, 4
1277t: f32
1278ret: #2#1
1279arg: #2#1 v
1280summary: Approximate inverse hyperbolic sine
1281description:
1282 Returns the approximate inverse hyperbolic sine, in radians.
1283
1284 See also @asinh().
1285# TODO Temporary
1286test: limited(0.0005)
1287end:
1288
1289function: native_asinpi
1290version: 21
1291attrib: const
1292w: 1, 2, 3, 4
1293t: f32
1294ret: #2#1
1295arg: #2#1 v, range(-1,1)
1296summary: Approximate inverse sine divided by pi
1297description:
1298 Returns the approximate inverse sine in radians, divided by pi.
1299
1300 To get an inverse sine measured in degrees, use <code>asinpi(a) * 180.f</code>.
1301
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001302 This function yields undefined results from input values less than -1 or greater than 1.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001303
1304 See also @asinpi().
1305# TODO Temporary
1306test: limited(0.0005)
1307end:
1308
1309function: native_atan
1310version: 21
1311attrib: const
1312w: 1, 2, 3, 4
1313t: f32
1314ret: #2#1
1315arg: #2#1 v, range(-1,1)
1316summary: Approximate inverse tangent
1317description:
1318 Returns the approximate inverse tangent, in radians.
1319
1320 See also @atan().
1321# TODO Temporary
1322test: limited(0.0005)
1323end:
1324
1325function: native_atan2
1326version: 21
1327attrib: const
1328w: 1, 2, 3, 4
1329t: f32
1330ret: #2#1
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001331arg: #2#1 numerator, "Numerator."
1332arg: #2#1 denominator, "Denominator. Can be 0."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001333summary: Approximate inverse tangent of a ratio
1334description:
1335 Returns the approximate inverse tangent of <code>(numerator / denominator)</code>, in radians.
1336
1337 See also @atan2().
1338# TODO Temporary
1339test: limited(0.0005)
1340end:
1341
1342function: native_atan2pi
1343version: 21
1344attrib: const
1345w: 1, 2, 3, 4
1346t: f32
1347ret: #2#1
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001348arg: #2#1 numerator, "Numerator."
1349arg: #2#1 denominator, "Denominator. Can be 0."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001350summary: Approximate inverse tangent of a ratio, divided by pi
1351description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001352 Returns the approximate inverse tangent of <code>(numerator / denominator)</code>,
1353 in radians, divided by pi.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001354
1355 To get an inverse tangent measured in degrees, use <code>atan2pi(n, d) * 180.f</code>.
1356
1357 See also @atan2pi().
1358# TODO Temporary
1359test: limited(0.0005)
1360end:
1361
1362function: native_atanh
1363version: 21
1364attrib: const
1365w: 1, 2, 3, 4
1366t: f32
1367ret: #2#1
1368arg: #2#1 v, range(-1,1)
1369summary: Approximate inverse hyperbolic tangent
1370description:
1371 Returns the approximate inverse hyperbolic tangent, in radians.
1372
1373 See also @atanh().
1374# TODO Temporary
1375test: limited(0.0005)
1376end:
1377
1378function: native_atanpi
1379version: 21
1380attrib: const
1381w: 1, 2, 3, 4
1382t: f32
1383ret: #2#1
1384arg: #2#1 v, range(-1,1)
1385summary: Approximate inverse tangent divided by pi
1386description:
1387 Returns the approximate inverse tangent in radians, divided by pi.
1388
1389 To get an inverse tangent measured in degrees, use <code>atanpi(a) * 180.f</code>.
1390
1391 See also @atanpi().
1392# TODO Temporary
1393test: limited(0.0005)
1394end:
1395
1396function: native_cbrt
1397version: 21
1398attrib: const
1399w: 1, 2, 3, 4
1400t: f32
1401ret: #2#1
1402arg: #2#1 v
1403summary: Approximate cube root
1404description:
1405 Returns the approximate cubic root.
1406
1407 See also @cbrt().
1408end:
1409
1410function: native_cos
1411version: 21
1412attrib: const
1413w: 1, 2, 3, 4
1414t: f32
1415ret: #2#1
1416arg: #2#1 v
1417summary: Approximate cosine
1418description:
1419 Returns the approximate cosine of an angle measured in radians.
1420
1421 See also @cos().
1422end:
1423
1424function: native_cosh
1425version: 21
1426attrib: const
1427w: 1, 2, 3, 4
1428t: f32
1429ret: #2#1
1430arg: #2#1 v
1431summary: Approximate hypebolic cosine
1432description:
1433 Returns the approximate hypebolic cosine.
1434
1435 See also @cosh().
1436end:
1437
1438function: native_cospi
1439version: 21
1440attrib: const
1441w: 1, 2, 3, 4
1442t: f32
1443ret: #2#1
1444arg: #2#1 v
1445summary: Approximate cosine of a number multiplied by pi
1446description:
1447 Returns the approximate cosine of (v * pi), where (v * pi) is measured in radians.
1448
1449 To get the cosine of a value measured in degrees, call <code>cospi(v / 180.f)</code>.
1450
1451 See also @cospi().
1452end:
1453
1454function: native_divide
1455version: 21
1456attrib: const
1457w: 1, 2, 3, 4
1458t: f32
1459ret: #2#1
1460arg: #2#1 left_vector
1461arg: #2#1 right_vector
1462summary: Approximate division
1463description:
1464 Computes the approximate division of two values.
1465end:
1466
1467function: native_exp
1468version: 18
1469attrib: const
1470w: 1, 2, 3, 4
1471t: f32
1472ret: #2#1
1473arg: #2#1 v, range(-86,86)
1474summary: Approximate e raised to a number
1475description:
1476 Fast approximate exp.
1477
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001478 It is valid for inputs from -86.f to 86.f. The precision is no worse than what would be
1479 expected from using 16 bit floating point values.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001480
1481 See also @exp().
1482test: limited
1483end:
1484
1485function: native_exp10
1486version: 18
1487attrib: const
1488w: 1, 2, 3, 4
1489t: f32
1490ret: #2#1
1491arg: #2#1 v, range(-37,37)
1492summary: Approximate 10 raised to a number
1493description:
1494 Fast approximate exp10.
1495
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001496 It is valid for inputs from -37.f to 37.f. The precision is no worse than what would be
1497 expected from using 16 bit floating point values.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001498
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001514 It is valid for inputs from -125.f to 125.f. The precision is no worse than what would be
1515 expected from using 16 bit floating point values.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001516
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001692ret: #2#1, "Sine."
1693arg: #2#1 v, "Incoming value in radians."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001694arg: #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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001802 In rs_fp_relaxed mode, a denormalized input value may not yield the next denormalized
1803 value, as support of denormalized values is optional in relaxed mode.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001804end:
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001818 @pown() and @powr() are similar. @pown() takes an integer exponent. @powr() assumes the
1819 base to be non-negative.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001820end:
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
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001834 @pow() and @powr() are similar. The both take a float exponent. @powr() also assumes the
1835 base to be non-negative.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001836end:
1837
1838function: powr
1839version: 9
1840attrib: const
1841w: 1, 2, 3, 4
1842t: f32
1843ret: #2#1
1844arg: #2#1 base, range(0,3000)
1845arg: #2#1 exponent
1846summary: Positive base raised to an exponent
1847description:
1848 Returns base raised to the power exponent, i.e. base ^ exponent. base must be &gt;= 0.
1849
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001850 @pow() and @pown() are similar. They both make no assumptions about the base.
1851 @pow() takes a float exponent while @pown() take an integer.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001852
1853 See also @native_powr().
1854end:
1855
1856function: radians
1857version: 9
1858attrib: const
1859w: 1, 2, 3, 4
1860t: f32
1861ret: #2#1
1862arg: #2#1 v
1863summary: Converts degrees into radians
1864description:
1865 Converts from degrees to radians.
1866end:
1867
1868function: remainder
1869version: 9
1870attrib: const
1871w: 1, 2, 3, 4
1872t: f32
1873ret: #2#1
1874arg: #2#1 numerator
1875arg: #2#1 denominator
1876summary: Remainder of a division
1877description:
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001878 Returns the remainder of (numerator / denominator), where the quotient is rounded towards
1879 the nearest integer.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001880
1881 The function @fmod() is similar but rounds toward the closest interger.
1882 For example, <code>@fmod(-3.8f, 2.f)</code> returns -1.8f (-3.8f - -1.f * 2.f)
1883 while <code>remainder(-3.8f, 2.f)</code> returns 0.2f (-3.8f - -2.f * 2.f).
1884end:
1885
1886function: remquo
1887version: 9
1888w: 1, 2, 3, 4
1889t: f32
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001890ret: #2#1, "Remainder, precise only for the low three bits."
1891arg: #2#1 numerator, "Numerator."
1892arg: #2#1 denominator, "Denominator."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001893arg: int#1* quotient, "*quotient will be set to the integer quotient."
1894summary: Remainder and quotient of a division
1895description:
1896 Returns the quotient and the remainder of (numerator / denominator).
1897
1898 Only the sign and lowest three bits of the quotient are guaranteed to be accurate.
1899
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001900 This function is useful for implementing periodic functions. The low three bits of the
1901 quotient gives the quadrant and the remainder the distance within the quadrant.
1902 For example, an implementation of @sin(x) could call <code>remquo(x, PI / 2.f, &amp;quadrant)</code>
1903 to reduce very large value of x to something within a limited range.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001904
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001905 Example: <code>remquo(-23.5f, 8.f, &amp;quot)</code> sets the lowest three bits of quot to 3
1906 and the sign negative. It returns 0.5f.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001907test: custom
1908end:
1909
1910function: rint
1911version: 9
1912attrib: const
1913w: 1, 2, 3, 4
1914t: f32
1915ret: #2#1
1916arg: #2#1 v
1917summary: Round to even
1918description:
1919 Rounds to the nearest integral value.
1920
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001921 rint() rounds half values to even. For example, <code>rint(0.5f)</code> returns 0.f and
1922 <code>rint(1.5f)</code> returns 2.f. Similarly, <code>rint(-0.5f)</code> returns -0.f and
1923 <code>rint(-1.5f)</code> returns -2.f.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001924
1925 @round() is similar but rounds away from zero. @trunc() truncates the decimal fraction.
1926end:
1927
1928function: rootn
1929version: 9
1930attrib: const
1931w: 1, 2, 3, 4
1932t: f32
1933ret: #2#1
1934arg: #2#1 v
1935arg: int#1 n
1936summary: Nth root
1937description:
1938 Compute the Nth root of a value.
1939
1940 See also @native_rootn().
1941end:
1942
1943function: round
1944version: 9
1945attrib: const
1946w: 1, 2, 3, 4
1947t: f32
1948ret: #2#1
1949arg: #2#1 v
1950summary: Round away from zero
1951description:
1952 Round to the nearest integral value.
1953
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07001954 round() rounds half values away from zero. For example, <code>round(0.5f)</code> returns 1.f
1955 and <code>round(1.5f)</code> returns 2.f. Similarly, <code>round(-0.5f)</code> returns -1.f
1956 and <code>round(-1.5f)</code> returns -2.f.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07001957
1958 @rint() is similar but rounds half values toward even. @trunc() truncates the decimal fraction.
1959end:
1960
1961function: rsqrt
1962version: 9
1963attrib: const
1964w: 1, 2, 3, 4
1965t: f32
1966ret: #2#1
1967arg: #2#1 v
1968summary: Reciprocal of a square root
1969description:
1970 Returns (1 / sqrt(v)).
1971
1972 See also @half_rsqrt(), @native_rsqrt().
1973end:
1974
1975function: sign
1976version: 9
1977attrib: const
1978w: 1, 2, 3, 4
1979t: f32
1980ret: #2#1
1981arg: #2#1 v
1982summary: Sign of a value
1983description:
1984 Returns the sign of a value.
1985
1986 if (v &lt; 0) return -1.f;
1987 else if (v &gt; 0) return 1.f;
1988 else return 0.f;
1989end:
1990
1991function: sin
1992version: 9
1993attrib: const
1994w: 1, 2, 3, 4
1995t: f32
1996ret: #2#1
1997arg: #2#1 v
1998summary: Sine
1999description:
2000 Returns the sine of an angle measured in radians.
2001
2002 See also @native_sin().
2003end:
2004
2005function: sincos
2006version: 9
2007w: 1, 2, 3, 4
2008t: f32
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07002009ret: #2#1, "Sine of v."
2010arg: #2#1 v, "Incoming value in radians."
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07002011arg: #2#1* cos, "*cos will be set to the cosine value."
2012summary: Sine and cosine
2013description:
2014 Returns the sine and cosine of a value.
2015
2016 See also @native_sincos().
2017end:
2018
2019function: sinh
2020version: 9
2021attrib: const
2022w: 1, 2, 3, 4
2023t: f32
2024ret: #2#1
2025arg: #2#1 v
2026summary: Hyperbolic sine
2027description:
2028 Returns the hyperbolic sine of v, where v is measured in radians.
2029
2030 See also @native_sinh().
2031end:
2032
2033function: sinpi
2034version: 9
2035attrib: const
2036w: 1, 2, 3, 4
2037t: f32
2038ret: #2#1
2039arg: #2#1 v
2040summary: Sine of a number multiplied by pi
2041description:
2042 Returns the sine of (v * pi), where (v * pi) is measured in radians.
2043
2044 To get the sine of a value measured in degrees, call <code>sinpi(v / 180.f)</code>.
2045
2046 See also @native_sinpi().
2047end:
2048
2049function: sqrt
2050version: 9
2051attrib: const
2052w: 1, 2, 3, 4
2053t: f32
2054ret: #2#1
2055arg: #2#1 v
2056summary: Square root
2057description:
2058 Returns the square root of a value.
2059
2060 See also @half_sqrt(), @native_sqrt().
2061end:
2062
2063function: step
2064version: 9
2065attrib: const
2066w: 1, 2, 3, 4
2067t: f32
2068ret: #2#1
2069arg: #2#1 edge
2070arg: #2#1 v
2071summary: 0 if less than a value, 0 otherwise
2072description:
2073 Returns 0.f if v &lt; edge, 1.f otherwise.
2074
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07002075 This can be useful to create conditional computations without using loops and branching
2076 instructions. For example, instead of computing <code>(a[i] &lt; b[i]) ? 0.f : @atan2(a[i], b[i])</code>
2077 for the corresponding elements of a vector, you could instead use <code>step(a, b) * @atan2(a, b)</code>.
Jean-Luc Brouilletbe216382015-03-22 12:44:27 -07002078end:
2079
2080function: step
2081version: 9
2082attrib: const
2083w: 2, 3, 4
2084t: f32
2085ret: #2#1
2086arg: #2#1 edge
2087arg: #2 v
2088end:
2089
2090function: step
2091version: 21
2092attrib: const
2093w: 2, 3, 4
2094t: f32
2095ret: #2#1
2096arg: #2 edge
2097arg: #2#1 v
2098end:
2099
2100function: tan
2101version: 9
2102attrib: const
2103w: 1, 2, 3, 4
2104t: f32
2105ret: #2#1
2106arg: #2#1 v
2107summary: Tangent
2108description:
2109 Returns the tangent of an angle measured in radians.
2110
2111 See also @native_tan().
2112end:
2113
2114function: tanh
2115version: 9
2116attrib: const
2117w: 1, 2, 3, 4
2118t: f32
2119ret: #2#1
2120arg: #2#1 v
2121summary: Hyperbolic tangent
2122description:
2123 Returns the hyperbolic tangent of a value.
2124
2125 See also @native_tanh().
2126end:
2127
2128function: tanpi
2129version: 9
2130attrib: const
2131w: 1, 2, 3, 4
2132t: f32
2133ret: #2#1
2134arg: #2#1 v
2135summary: Tangent of a number multiplied by pi
2136description:
2137 Returns the tangent of (v * pi), where (v * pi) is measured in radians.
2138
2139 To get the tangent of a value measured in degrees, call <code>tanpi(v / 180.f)</code>.
2140
2141 See also @native_tanpi().
2142end:
2143
2144function: tgamma
2145version: 9
2146attrib: const
2147w: 1, 2, 3, 4
2148t: f32
2149ret: #2#1
2150arg: #2#1 v
2151summary: Gamma function
2152description:
2153 Returns the gamma function of a value.
2154
2155 See also @lgamma().
2156end:
2157
2158function: trunc
2159version: 9
2160attrib: const
2161w: 1, 2, 3, 4
2162t: f32
2163ret: #2#1
2164arg: #2#1 v
2165summary: Truncates a floating point
2166description:
2167 Rounds to integral using truncation.
2168
2169 For example, <code>trunc(1.7f)</code> returns 1.f and <code>trunc(-1.7f)</code> returns -1.f.
2170
2171 See @rint() and @round() for other rounding options.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07002172end:
2173
2174function: rsClamp
2175# TODO Why always_inline?
2176attrib: const, always_inline
2177t: i8, i16, i32, u8, u16, u32
2178ret: #1
Jean-Luc Brouillet6386ceb2015-04-28 15:06:30 -07002179arg: #1 amount, "Value to clamp."
2180arg: #1 low, "Lower bound."
2181arg: #1 high, "Upper bound."
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -07002182deprecated: Use @clamp() instead.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07002183summary: Restrain a value to a range
2184description:
2185 Clamp a value between low and high.
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07002186test: none
2187end:
2188
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07002189function: rsFrac
2190attrib: const
2191ret: float
2192arg: float v
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -07002193deprecated: Use @fract() instead.
2194summary: Returns the fractional part of a float
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07002195description:
2196 Returns the fractional part of a float
2197test: none
2198end:
2199
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07002200function: rsRand
2201ret: int
2202arg: int max_value
Jean-Luc Brouillet20b27d62015-04-03 14:39:53 -07002203summary: Pseudo-random number
Jean-Luc Brouilletc5184e22015-03-13 13:51:24 -07002204description:
2205 Return a random value between 0 (or min_value) and max_malue.
2206test: none
2207end:
2208
2209function: rsRand
2210ret: int
2211arg: int min_value
2212arg: int max_value
2213test: none
2214end:
2215
2216function: rsRand
2217ret: float
2218arg: float max_value
2219test: none
2220end:
2221
2222function: rsRand
2223ret: float
2224arg: float min_value
2225arg: float max_value
2226test: none
2227end: