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