rs_math.rsh revision 386e87ecf4114084c10dd385edc1c2baebe80a04
1/*
2 * Copyright (C) 2015 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
17// Don't edit this file!  It is auto-generated by frameworks/rs/api/gen_runtime.
18
19/*
20 * rs_math.rsh: Mathematical functions
21 *
22 * Most mathematical functions can be applied to scalars and vectors.
23 * When applied to vectors, a vector of the function applied to each entry
24 * of the input is returned.
25 *
26 * For example:
27 *
28 * float3 a, b;
29 * // The following call sets
30 * //   a.x to sin(b.x),
31 * //   a.y to sin(b.y), and
32 * //   a.z to sin(b.z).
33 * a = sin(b);
34 *
35 *
36 * A few functions like distance() and length() interpret instead the input
37 * as a single vector in n-dimensional space.
38 *
39 * The precision of the mathematical operations is affected by the pragmas
40 * rs_fp_relaxed and rs_fp_full.
41 *
42 * Different precision/speed tradeoffs can be achieved by using three variants
43 * of common math functions.  Functions with a name starting with
44 * native_ may have custom hardware implementations with weaker precision,
45 * half_ may perform internal computations using 16 bit floats, and
46 * fast_ are n-dimensional space computations that may use 16 bit floats.
47 *
48 */
49#ifndef RENDERSCRIPT_RS_MATH_RSH
50#define RENDERSCRIPT_RS_MATH_RSH
51
52/*
53 * M_1_PI: 1 / pi, as a 32 bit float
54 *
55 * The inverse of pi, as a 32 bit float.
56 */
57#define M_1_PI 0.318309886183790671537767526745028724f
58
59/*
60 * M_2_PI: 2 / pi, as a 32 bit float
61 *
62 * 2 divided by pi, as a 32 bit float.
63 */
64#define M_2_PI 0.636619772367581343075535053490057448f
65
66/*
67 * M_2_PIl: Deprecated.  Use M_2_PI instead.
68 *
69 */
70#define M_2_PIl 0.636619772367581343075535053490057448f
71
72/*
73 * M_2_SQRTPI: 2 / sqrt(pi), as a 32 bit float
74 *
75 * 2 divided by the square root of pi, as a 32 bit float.
76 */
77#define M_2_SQRTPI 1.128379167095512573896158903121545172f
78
79/*
80 * M_E: e, as a 32 bit float
81 *
82 * The number e, the base of the natural logarithm, as a 32 bit float.
83 */
84#define M_E 2.718281828459045235360287471352662498f
85
86/*
87 * M_LN10: log_e(10), as a 32 bit float
88 *
89 * The natural logarithm of 10, as a 32 bit float.
90 */
91#define M_LN10 2.302585092994045684017991454684364208f
92
93/*
94 * M_LN2: log_e(2), as a 32 bit float
95 *
96 * The natural logarithm of 2, as a 32 bit float.
97 */
98#define M_LN2 0.693147180559945309417232121458176568f
99
100/*
101 * M_LOG10E: log_10(e), as a 32 bit float
102 *
103 * The logarithm base 10 of e, as a 32 bit float.
104 */
105#define M_LOG10E 0.434294481903251827651128918916605082f
106
107/*
108 * M_LOG2E: log_2(e), as a 32 bit float
109 *
110 * The logarithm base 2 of e, as a 32 bit float.
111 */
112#define M_LOG2E 1.442695040888963407359924681001892137f
113
114/*
115 * M_PI: pi, as a 32 bit float
116 *
117 * The constant pi, as a 32 bit float.
118 */
119#define M_PI 3.141592653589793238462643383279502884f
120
121/*
122 * M_PI_2: pi / 2, as a 32 bit float
123 *
124 * Pi divided by 2, as a 32 bit float.
125 */
126#define M_PI_2 1.570796326794896619231321691639751442f
127
128/*
129 * M_PI_4: pi / 4, as a 32 bit float
130 *
131 * Pi divided by 4, as a 32 bit float.
132 */
133#define M_PI_4 0.785398163397448309615660845819875721f
134
135/*
136 * M_SQRT1_2: 1 / sqrt(2), as a 32 bit float
137 *
138 * The inverse of the square root of 2, as a 32 bit float.
139 */
140#define M_SQRT1_2 0.707106781186547524400844362104849039f
141
142/*
143 * M_SQRT2: sqrt(2), as a 32 bit float
144 *
145 * The square root of 2, as a 32 bit float.
146 */
147#define M_SQRT2 1.414213562373095048801688724209698079f
148
149/*
150 * abs: Absolute value of an integer
151 *
152 * Returns the absolute value of an integer.
153 *
154 * For floats, use fabs().
155 */
156extern uchar __attribute__((const, overloadable))
157    abs(char v);
158
159extern uchar2 __attribute__((const, overloadable))
160    abs(char2 v);
161
162extern uchar3 __attribute__((const, overloadable))
163    abs(char3 v);
164
165extern uchar4 __attribute__((const, overloadable))
166    abs(char4 v);
167
168extern ushort __attribute__((const, overloadable))
169    abs(short v);
170
171extern ushort2 __attribute__((const, overloadable))
172    abs(short2 v);
173
174extern ushort3 __attribute__((const, overloadable))
175    abs(short3 v);
176
177extern ushort4 __attribute__((const, overloadable))
178    abs(short4 v);
179
180extern uint __attribute__((const, overloadable))
181    abs(int v);
182
183extern uint2 __attribute__((const, overloadable))
184    abs(int2 v);
185
186extern uint3 __attribute__((const, overloadable))
187    abs(int3 v);
188
189extern uint4 __attribute__((const, overloadable))
190    abs(int4 v);
191
192/*
193 * acos: Inverse cosine
194 *
195 * Returns the inverse cosine, in radians.
196 *
197 * See also native_acos().
198 */
199extern float __attribute__((const, overloadable))
200    acos(float v);
201
202extern float2 __attribute__((const, overloadable))
203    acos(float2 v);
204
205extern float3 __attribute__((const, overloadable))
206    acos(float3 v);
207
208extern float4 __attribute__((const, overloadable))
209    acos(float4 v);
210
211/*
212 * acosh: Inverse hyperbolic cosine
213 *
214 * Returns the inverse hyperbolic cosine, in radians.
215 *
216 * See also native_acosh().
217 */
218extern float __attribute__((const, overloadable))
219    acosh(float v);
220
221extern float2 __attribute__((const, overloadable))
222    acosh(float2 v);
223
224extern float3 __attribute__((const, overloadable))
225    acosh(float3 v);
226
227extern float4 __attribute__((const, overloadable))
228    acosh(float4 v);
229
230/*
231 * acospi: Inverse cosine divided by pi
232 *
233 * Returns the inverse cosine in radians, divided by pi.
234 *
235 * To get an inverse cosine measured in degrees, use acospi(a) * 180.f.
236 *
237 * See also native_acospi().
238 */
239extern float __attribute__((const, overloadable))
240    acospi(float v);
241
242extern float2 __attribute__((const, overloadable))
243    acospi(float2 v);
244
245extern float3 __attribute__((const, overloadable))
246    acospi(float3 v);
247
248extern float4 __attribute__((const, overloadable))
249    acospi(float4 v);
250
251/*
252 * asin: Inverse sine
253 *
254 * Returns the inverse sine, in radians.
255 *
256 * See also native_asin().
257 */
258extern float __attribute__((const, overloadable))
259    asin(float v);
260
261extern float2 __attribute__((const, overloadable))
262    asin(float2 v);
263
264extern float3 __attribute__((const, overloadable))
265    asin(float3 v);
266
267extern float4 __attribute__((const, overloadable))
268    asin(float4 v);
269
270/*
271 * asinh: Inverse hyperbolic sine
272 *
273 * Returns the inverse hyperbolic sine, in radians.
274 *
275 * See also native_asinh().
276 */
277extern float __attribute__((const, overloadable))
278    asinh(float v);
279
280extern float2 __attribute__((const, overloadable))
281    asinh(float2 v);
282
283extern float3 __attribute__((const, overloadable))
284    asinh(float3 v);
285
286extern float4 __attribute__((const, overloadable))
287    asinh(float4 v);
288
289/*
290 * asinpi: Inverse sine divided by pi
291 *
292 * Returns the inverse sine in radians, divided by pi.
293 *
294 * To get an inverse sine measured in degrees, use asinpi(a) * 180.f.
295 *
296 * See also native_asinpi().
297 */
298extern float __attribute__((const, overloadable))
299    asinpi(float v);
300
301extern float2 __attribute__((const, overloadable))
302    asinpi(float2 v);
303
304extern float3 __attribute__((const, overloadable))
305    asinpi(float3 v);
306
307extern float4 __attribute__((const, overloadable))
308    asinpi(float4 v);
309
310/*
311 * atan: Inverse tangent
312 *
313 * Returns the inverse tangent, in radians.
314 *
315 * See also native_atan().
316 */
317extern float __attribute__((const, overloadable))
318    atan(float v);
319
320extern float2 __attribute__((const, overloadable))
321    atan(float2 v);
322
323extern float3 __attribute__((const, overloadable))
324    atan(float3 v);
325
326extern float4 __attribute__((const, overloadable))
327    atan(float4 v);
328
329/*
330 * atan2: Inverse tangent of a ratio
331 *
332 * Returns the inverse tangent of (numerator / denominator), in radians.
333 *
334 * See also native_atan2().
335 *
336 * Parameters:
337 *   numerator The numerator
338 *   denominator The denominator.  Can be 0.
339 */
340extern float __attribute__((const, overloadable))
341    atan2(float numerator, float denominator);
342
343extern float2 __attribute__((const, overloadable))
344    atan2(float2 numerator, float2 denominator);
345
346extern float3 __attribute__((const, overloadable))
347    atan2(float3 numerator, float3 denominator);
348
349extern float4 __attribute__((const, overloadable))
350    atan2(float4 numerator, float4 denominator);
351
352/*
353 * atan2pi: Inverse tangent of a ratio, divided by pi
354 *
355 * Returns the inverse tangent of (numerator / denominator), in radians, divided by pi.
356 *
357 * To get an inverse tangent measured in degrees, use atan2pi(n, d) * 180.f.
358 *
359 * See also native_atan2pi().
360 *
361 * Parameters:
362 *   numerator The numerator
363 *   denominator The denominator.  Can be 0.
364 */
365extern float __attribute__((const, overloadable))
366    atan2pi(float numerator, float denominator);
367
368extern float2 __attribute__((const, overloadable))
369    atan2pi(float2 numerator, float2 denominator);
370
371extern float3 __attribute__((const, overloadable))
372    atan2pi(float3 numerator, float3 denominator);
373
374extern float4 __attribute__((const, overloadable))
375    atan2pi(float4 numerator, float4 denominator);
376
377/*
378 * atanh: Inverse hyperbolic tangent
379 *
380 * Returns the inverse hyperbolic tangent, in radians.
381 *
382 * See also native_atanh().
383 */
384extern float __attribute__((const, overloadable))
385    atanh(float v);
386
387extern float2 __attribute__((const, overloadable))
388    atanh(float2 v);
389
390extern float3 __attribute__((const, overloadable))
391    atanh(float3 v);
392
393extern float4 __attribute__((const, overloadable))
394    atanh(float4 v);
395
396/*
397 * atanpi: Inverse tangent divided by pi
398 *
399 * Returns the inverse tangent in radians, divided by pi.
400 *
401 * To get an inverse tangent measured in degrees, use atanpi(a) * 180.f.
402 *
403 * See also native_atanpi().
404 */
405extern float __attribute__((const, overloadable))
406    atanpi(float v);
407
408extern float2 __attribute__((const, overloadable))
409    atanpi(float2 v);
410
411extern float3 __attribute__((const, overloadable))
412    atanpi(float3 v);
413
414extern float4 __attribute__((const, overloadable))
415    atanpi(float4 v);
416
417/*
418 * cbrt: Cube root
419 *
420 * Returns the cube root.
421 *
422 * See also native_cbrt().
423 */
424extern float __attribute__((const, overloadable))
425    cbrt(float v);
426
427extern float2 __attribute__((const, overloadable))
428    cbrt(float2 v);
429
430extern float3 __attribute__((const, overloadable))
431    cbrt(float3 v);
432
433extern float4 __attribute__((const, overloadable))
434    cbrt(float4 v);
435
436/*
437 * ceil: Smallest integer not less than a value
438 *
439 * Returns the smallest integer not less than a value.
440 *
441 * For example, ceil(1.2f) returns 2.f, and ceil(-1.2f) returns -1.f.
442 *
443 * See also floor().
444 */
445extern float __attribute__((const, overloadable))
446    ceil(float v);
447
448extern float2 __attribute__((const, overloadable))
449    ceil(float2 v);
450
451extern float3 __attribute__((const, overloadable))
452    ceil(float3 v);
453
454extern float4 __attribute__((const, overloadable))
455    ceil(float4 v);
456
457/*
458 * clamp: Restrain a value to a range
459 *
460 * Clamps a value to a specified high and low bound.  clamp() returns min_value
461 * if value < min_value, max_value if value > max_value, otherwise value.
462 *
463 * There are two variants of clamp: one where the min and max are scalars applied
464 * to all entries of the value, the other where the min and max are also vectors.
465 *
466 * If min_value is greater than max_value, the results are undefined.
467 *
468 * Parameters:
469 *   value Value to be clamped.
470 *   min_value Lower bound, a scalar or matching vector.
471 *   max_value High bound, must match the type of low.
472 */
473extern float __attribute__((const, overloadable))
474    clamp(float value, float min_value, float max_value);
475
476extern float2 __attribute__((const, overloadable))
477    clamp(float2 value, float2 min_value, float2 max_value);
478
479extern float3 __attribute__((const, overloadable))
480    clamp(float3 value, float3 min_value, float3 max_value);
481
482extern float4 __attribute__((const, overloadable))
483    clamp(float4 value, float4 min_value, float4 max_value);
484
485extern float2 __attribute__((const, overloadable))
486    clamp(float2 value, float min_value, float max_value);
487
488extern float3 __attribute__((const, overloadable))
489    clamp(float3 value, float min_value, float max_value);
490
491extern float4 __attribute__((const, overloadable))
492    clamp(float4 value, float min_value, float max_value);
493
494#if (defined(RS_VERSION) && (RS_VERSION >= 19))
495extern char __attribute__((const, overloadable))
496    clamp(char value, char min_value, char max_value);
497#endif
498
499#if (defined(RS_VERSION) && (RS_VERSION >= 19))
500extern char2 __attribute__((const, overloadable))
501    clamp(char2 value, char2 min_value, char2 max_value);
502#endif
503
504#if (defined(RS_VERSION) && (RS_VERSION >= 19))
505extern char3 __attribute__((const, overloadable))
506    clamp(char3 value, char3 min_value, char3 max_value);
507#endif
508
509#if (defined(RS_VERSION) && (RS_VERSION >= 19))
510extern char4 __attribute__((const, overloadable))
511    clamp(char4 value, char4 min_value, char4 max_value);
512#endif
513
514#if (defined(RS_VERSION) && (RS_VERSION >= 19))
515extern uchar __attribute__((const, overloadable))
516    clamp(uchar value, uchar min_value, uchar max_value);
517#endif
518
519#if (defined(RS_VERSION) && (RS_VERSION >= 19))
520extern uchar2 __attribute__((const, overloadable))
521    clamp(uchar2 value, uchar2 min_value, uchar2 max_value);
522#endif
523
524#if (defined(RS_VERSION) && (RS_VERSION >= 19))
525extern uchar3 __attribute__((const, overloadable))
526    clamp(uchar3 value, uchar3 min_value, uchar3 max_value);
527#endif
528
529#if (defined(RS_VERSION) && (RS_VERSION >= 19))
530extern uchar4 __attribute__((const, overloadable))
531    clamp(uchar4 value, uchar4 min_value, uchar4 max_value);
532#endif
533
534#if (defined(RS_VERSION) && (RS_VERSION >= 19))
535extern short __attribute__((const, overloadable))
536    clamp(short value, short min_value, short max_value);
537#endif
538
539#if (defined(RS_VERSION) && (RS_VERSION >= 19))
540extern short2 __attribute__((const, overloadable))
541    clamp(short2 value, short2 min_value, short2 max_value);
542#endif
543
544#if (defined(RS_VERSION) && (RS_VERSION >= 19))
545extern short3 __attribute__((const, overloadable))
546    clamp(short3 value, short3 min_value, short3 max_value);
547#endif
548
549#if (defined(RS_VERSION) && (RS_VERSION >= 19))
550extern short4 __attribute__((const, overloadable))
551    clamp(short4 value, short4 min_value, short4 max_value);
552#endif
553
554#if (defined(RS_VERSION) && (RS_VERSION >= 19))
555extern ushort __attribute__((const, overloadable))
556    clamp(ushort value, ushort min_value, ushort max_value);
557#endif
558
559#if (defined(RS_VERSION) && (RS_VERSION >= 19))
560extern ushort2 __attribute__((const, overloadable))
561    clamp(ushort2 value, ushort2 min_value, ushort2 max_value);
562#endif
563
564#if (defined(RS_VERSION) && (RS_VERSION >= 19))
565extern ushort3 __attribute__((const, overloadable))
566    clamp(ushort3 value, ushort3 min_value, ushort3 max_value);
567#endif
568
569#if (defined(RS_VERSION) && (RS_VERSION >= 19))
570extern ushort4 __attribute__((const, overloadable))
571    clamp(ushort4 value, ushort4 min_value, ushort4 max_value);
572#endif
573
574#if (defined(RS_VERSION) && (RS_VERSION >= 19))
575extern int __attribute__((const, overloadable))
576    clamp(int value, int min_value, int max_value);
577#endif
578
579#if (defined(RS_VERSION) && (RS_VERSION >= 19))
580extern int2 __attribute__((const, overloadable))
581    clamp(int2 value, int2 min_value, int2 max_value);
582#endif
583
584#if (defined(RS_VERSION) && (RS_VERSION >= 19))
585extern int3 __attribute__((const, overloadable))
586    clamp(int3 value, int3 min_value, int3 max_value);
587#endif
588
589#if (defined(RS_VERSION) && (RS_VERSION >= 19))
590extern int4 __attribute__((const, overloadable))
591    clamp(int4 value, int4 min_value, int4 max_value);
592#endif
593
594#if (defined(RS_VERSION) && (RS_VERSION >= 19))
595extern uint __attribute__((const, overloadable))
596    clamp(uint value, uint min_value, uint max_value);
597#endif
598
599#if (defined(RS_VERSION) && (RS_VERSION >= 19))
600extern uint2 __attribute__((const, overloadable))
601    clamp(uint2 value, uint2 min_value, uint2 max_value);
602#endif
603
604#if (defined(RS_VERSION) && (RS_VERSION >= 19))
605extern uint3 __attribute__((const, overloadable))
606    clamp(uint3 value, uint3 min_value, uint3 max_value);
607#endif
608
609#if (defined(RS_VERSION) && (RS_VERSION >= 19))
610extern uint4 __attribute__((const, overloadable))
611    clamp(uint4 value, uint4 min_value, uint4 max_value);
612#endif
613
614#if (defined(RS_VERSION) && (RS_VERSION >= 19))
615extern long __attribute__((const, overloadable))
616    clamp(long value, long min_value, long max_value);
617#endif
618
619#if (defined(RS_VERSION) && (RS_VERSION >= 19))
620extern long2 __attribute__((const, overloadable))
621    clamp(long2 value, long2 min_value, long2 max_value);
622#endif
623
624#if (defined(RS_VERSION) && (RS_VERSION >= 19))
625extern long3 __attribute__((const, overloadable))
626    clamp(long3 value, long3 min_value, long3 max_value);
627#endif
628
629#if (defined(RS_VERSION) && (RS_VERSION >= 19))
630extern long4 __attribute__((const, overloadable))
631    clamp(long4 value, long4 min_value, long4 max_value);
632#endif
633
634#if (defined(RS_VERSION) && (RS_VERSION >= 19))
635extern ulong __attribute__((const, overloadable))
636    clamp(ulong value, ulong min_value, ulong max_value);
637#endif
638
639#if (defined(RS_VERSION) && (RS_VERSION >= 19))
640extern ulong2 __attribute__((const, overloadable))
641    clamp(ulong2 value, ulong2 min_value, ulong2 max_value);
642#endif
643
644#if (defined(RS_VERSION) && (RS_VERSION >= 19))
645extern ulong3 __attribute__((const, overloadable))
646    clamp(ulong3 value, ulong3 min_value, ulong3 max_value);
647#endif
648
649#if (defined(RS_VERSION) && (RS_VERSION >= 19))
650extern ulong4 __attribute__((const, overloadable))
651    clamp(ulong4 value, ulong4 min_value, ulong4 max_value);
652#endif
653
654#if (defined(RS_VERSION) && (RS_VERSION >= 19))
655extern char2 __attribute__((const, overloadable))
656    clamp(char2 value, char min_value, char max_value);
657#endif
658
659#if (defined(RS_VERSION) && (RS_VERSION >= 19))
660extern char3 __attribute__((const, overloadable))
661    clamp(char3 value, char min_value, char max_value);
662#endif
663
664#if (defined(RS_VERSION) && (RS_VERSION >= 19))
665extern char4 __attribute__((const, overloadable))
666    clamp(char4 value, char min_value, char max_value);
667#endif
668
669#if (defined(RS_VERSION) && (RS_VERSION >= 19))
670extern uchar2 __attribute__((const, overloadable))
671    clamp(uchar2 value, uchar min_value, uchar max_value);
672#endif
673
674#if (defined(RS_VERSION) && (RS_VERSION >= 19))
675extern uchar3 __attribute__((const, overloadable))
676    clamp(uchar3 value, uchar min_value, uchar max_value);
677#endif
678
679#if (defined(RS_VERSION) && (RS_VERSION >= 19))
680extern uchar4 __attribute__((const, overloadable))
681    clamp(uchar4 value, uchar min_value, uchar max_value);
682#endif
683
684#if (defined(RS_VERSION) && (RS_VERSION >= 19))
685extern short2 __attribute__((const, overloadable))
686    clamp(short2 value, short min_value, short max_value);
687#endif
688
689#if (defined(RS_VERSION) && (RS_VERSION >= 19))
690extern short3 __attribute__((const, overloadable))
691    clamp(short3 value, short min_value, short max_value);
692#endif
693
694#if (defined(RS_VERSION) && (RS_VERSION >= 19))
695extern short4 __attribute__((const, overloadable))
696    clamp(short4 value, short min_value, short max_value);
697#endif
698
699#if (defined(RS_VERSION) && (RS_VERSION >= 19))
700extern ushort2 __attribute__((const, overloadable))
701    clamp(ushort2 value, ushort min_value, ushort max_value);
702#endif
703
704#if (defined(RS_VERSION) && (RS_VERSION >= 19))
705extern ushort3 __attribute__((const, overloadable))
706    clamp(ushort3 value, ushort min_value, ushort max_value);
707#endif
708
709#if (defined(RS_VERSION) && (RS_VERSION >= 19))
710extern ushort4 __attribute__((const, overloadable))
711    clamp(ushort4 value, ushort min_value, ushort max_value);
712#endif
713
714#if (defined(RS_VERSION) && (RS_VERSION >= 19))
715extern int2 __attribute__((const, overloadable))
716    clamp(int2 value, int min_value, int max_value);
717#endif
718
719#if (defined(RS_VERSION) && (RS_VERSION >= 19))
720extern int3 __attribute__((const, overloadable))
721    clamp(int3 value, int min_value, int max_value);
722#endif
723
724#if (defined(RS_VERSION) && (RS_VERSION >= 19))
725extern int4 __attribute__((const, overloadable))
726    clamp(int4 value, int min_value, int max_value);
727#endif
728
729#if (defined(RS_VERSION) && (RS_VERSION >= 19))
730extern uint2 __attribute__((const, overloadable))
731    clamp(uint2 value, uint min_value, uint max_value);
732#endif
733
734#if (defined(RS_VERSION) && (RS_VERSION >= 19))
735extern uint3 __attribute__((const, overloadable))
736    clamp(uint3 value, uint min_value, uint max_value);
737#endif
738
739#if (defined(RS_VERSION) && (RS_VERSION >= 19))
740extern uint4 __attribute__((const, overloadable))
741    clamp(uint4 value, uint min_value, uint max_value);
742#endif
743
744#if (defined(RS_VERSION) && (RS_VERSION >= 19))
745extern long2 __attribute__((const, overloadable))
746    clamp(long2 value, long min_value, long max_value);
747#endif
748
749#if (defined(RS_VERSION) && (RS_VERSION >= 19))
750extern long3 __attribute__((const, overloadable))
751    clamp(long3 value, long min_value, long max_value);
752#endif
753
754#if (defined(RS_VERSION) && (RS_VERSION >= 19))
755extern long4 __attribute__((const, overloadable))
756    clamp(long4 value, long min_value, long max_value);
757#endif
758
759#if (defined(RS_VERSION) && (RS_VERSION >= 19))
760extern ulong2 __attribute__((const, overloadable))
761    clamp(ulong2 value, ulong min_value, ulong max_value);
762#endif
763
764#if (defined(RS_VERSION) && (RS_VERSION >= 19))
765extern ulong3 __attribute__((const, overloadable))
766    clamp(ulong3 value, ulong min_value, ulong max_value);
767#endif
768
769#if (defined(RS_VERSION) && (RS_VERSION >= 19))
770extern ulong4 __attribute__((const, overloadable))
771    clamp(ulong4 value, ulong min_value, ulong max_value);
772#endif
773
774/*
775 * clz: Number of leading 0 bits
776 *
777 * Returns the number of leading 0-bits in a value.
778 *
779 * For example, clz((char)0x03) returns 6.
780 */
781extern char __attribute__((const, overloadable))
782    clz(char value);
783
784extern char2 __attribute__((const, overloadable))
785    clz(char2 value);
786
787extern char3 __attribute__((const, overloadable))
788    clz(char3 value);
789
790extern char4 __attribute__((const, overloadable))
791    clz(char4 value);
792
793extern uchar __attribute__((const, overloadable))
794    clz(uchar value);
795
796extern uchar2 __attribute__((const, overloadable))
797    clz(uchar2 value);
798
799extern uchar3 __attribute__((const, overloadable))
800    clz(uchar3 value);
801
802extern uchar4 __attribute__((const, overloadable))
803    clz(uchar4 value);
804
805extern short __attribute__((const, overloadable))
806    clz(short value);
807
808extern short2 __attribute__((const, overloadable))
809    clz(short2 value);
810
811extern short3 __attribute__((const, overloadable))
812    clz(short3 value);
813
814extern short4 __attribute__((const, overloadable))
815    clz(short4 value);
816
817extern ushort __attribute__((const, overloadable))
818    clz(ushort value);
819
820extern ushort2 __attribute__((const, overloadable))
821    clz(ushort2 value);
822
823extern ushort3 __attribute__((const, overloadable))
824    clz(ushort3 value);
825
826extern ushort4 __attribute__((const, overloadable))
827    clz(ushort4 value);
828
829extern int __attribute__((const, overloadable))
830    clz(int value);
831
832extern int2 __attribute__((const, overloadable))
833    clz(int2 value);
834
835extern int3 __attribute__((const, overloadable))
836    clz(int3 value);
837
838extern int4 __attribute__((const, overloadable))
839    clz(int4 value);
840
841extern uint __attribute__((const, overloadable))
842    clz(uint value);
843
844extern uint2 __attribute__((const, overloadable))
845    clz(uint2 value);
846
847extern uint3 __attribute__((const, overloadable))
848    clz(uint3 value);
849
850extern uint4 __attribute__((const, overloadable))
851    clz(uint4 value);
852
853/*
854 * copysign: Copies the sign of a number to another
855 *
856 * Copies the sign from sign_value to magnitude_value.
857 *
858 * The value returned is either magnitude_value or -magnitude_value.
859 *
860 * For example, copysign(4.0f, -2.7f) returns -4.0f and copysign(-4.0f, 2.7f) returns 4.0f.
861 */
862extern float __attribute__((const, overloadable))
863    copysign(float magnitude_value, float sign_value);
864
865extern float2 __attribute__((const, overloadable))
866    copysign(float2 magnitude_value, float2 sign_value);
867
868extern float3 __attribute__((const, overloadable))
869    copysign(float3 magnitude_value, float3 sign_value);
870
871extern float4 __attribute__((const, overloadable))
872    copysign(float4 magnitude_value, float4 sign_value);
873
874/*
875 * cos: Cosine
876 *
877 * Returns the cosine of an angle measured in radians.
878 *
879 * See also native_cos().
880 */
881extern float __attribute__((const, overloadable))
882    cos(float v);
883
884extern float2 __attribute__((const, overloadable))
885    cos(float2 v);
886
887extern float3 __attribute__((const, overloadable))
888    cos(float3 v);
889
890extern float4 __attribute__((const, overloadable))
891    cos(float4 v);
892
893/*
894 * cosh: Hypebolic cosine
895 *
896 * Returns the hypebolic cosine of v, where v is measured in radians.
897 *
898 * See also native_cosh().
899 */
900extern float __attribute__((const, overloadable))
901    cosh(float v);
902
903extern float2 __attribute__((const, overloadable))
904    cosh(float2 v);
905
906extern float3 __attribute__((const, overloadable))
907    cosh(float3 v);
908
909extern float4 __attribute__((const, overloadable))
910    cosh(float4 v);
911
912/*
913 * cospi: Cosine of a number multiplied by pi
914 *
915 * Returns the cosine of (v * pi), where (v * pi) is measured in radians.
916 *
917 * To get the cosine of a value measured in degrees, call cospi(v / 180.f).
918 *
919 * See also native_cospi().
920 */
921extern float __attribute__((const, overloadable))
922    cospi(float v);
923
924extern float2 __attribute__((const, overloadable))
925    cospi(float2 v);
926
927extern float3 __attribute__((const, overloadable))
928    cospi(float3 v);
929
930extern float4 __attribute__((const, overloadable))
931    cospi(float4 v);
932
933/*
934 * degrees: Converts radians into degrees
935 *
936 * Converts from radians to degrees.
937 */
938extern float __attribute__((const, overloadable))
939    degrees(float v);
940
941extern float2 __attribute__((const, overloadable))
942    degrees(float2 v);
943
944extern float3 __attribute__((const, overloadable))
945    degrees(float3 v);
946
947extern float4 __attribute__((const, overloadable))
948    degrees(float4 v);
949
950/*
951 * erf: Mathematical error function
952 *
953 * Returns the error function.
954 */
955extern float __attribute__((const, overloadable))
956    erf(float v);
957
958extern float2 __attribute__((const, overloadable))
959    erf(float2 v);
960
961extern float3 __attribute__((const, overloadable))
962    erf(float3 v);
963
964extern float4 __attribute__((const, overloadable))
965    erf(float4 v);
966
967/*
968 * erfc: Mathematical complementary error function
969 *
970 * Returns the complementary error function.
971 */
972extern float __attribute__((const, overloadable))
973    erfc(float v);
974
975extern float2 __attribute__((const, overloadable))
976    erfc(float2 v);
977
978extern float3 __attribute__((const, overloadable))
979    erfc(float3 v);
980
981extern float4 __attribute__((const, overloadable))
982    erfc(float4 v);
983
984/*
985 * exp: e raised to a number
986 *
987 * Returns e raised to v, i.e. e ^ v.
988 *
989 * See also native_exp().
990 */
991extern float __attribute__((const, overloadable))
992    exp(float v);
993
994extern float2 __attribute__((const, overloadable))
995    exp(float2 v);
996
997extern float3 __attribute__((const, overloadable))
998    exp(float3 v);
999
1000extern float4 __attribute__((const, overloadable))
1001    exp(float4 v);
1002
1003/*
1004 * exp10: 10 raised to a number
1005 *
1006 * Returns 10 raised to v, i.e. 10.f ^ v.
1007 *
1008 * See also native_exp10().
1009 */
1010extern float __attribute__((const, overloadable))
1011    exp10(float v);
1012
1013extern float2 __attribute__((const, overloadable))
1014    exp10(float2 v);
1015
1016extern float3 __attribute__((const, overloadable))
1017    exp10(float3 v);
1018
1019extern float4 __attribute__((const, overloadable))
1020    exp10(float4 v);
1021
1022/*
1023 * exp2: 2 raised to a number
1024 *
1025 * Returns 2 raised to v, i.e. 2.f ^ v.
1026 *
1027 * See also native_exp2().
1028 */
1029extern float __attribute__((const, overloadable))
1030    exp2(float v);
1031
1032extern float2 __attribute__((const, overloadable))
1033    exp2(float2 v);
1034
1035extern float3 __attribute__((const, overloadable))
1036    exp2(float3 v);
1037
1038extern float4 __attribute__((const, overloadable))
1039    exp2(float4 v);
1040
1041/*
1042 * expm1: e raised to a number minus one
1043 *
1044 * Returns e raised to v minus 1, i.e. (e ^ v) - 1.
1045 *
1046 * See also native_expm1().
1047 */
1048extern float __attribute__((const, overloadable))
1049    expm1(float v);
1050
1051extern float2 __attribute__((const, overloadable))
1052    expm1(float2 v);
1053
1054extern float3 __attribute__((const, overloadable))
1055    expm1(float3 v);
1056
1057extern float4 __attribute__((const, overloadable))
1058    expm1(float4 v);
1059
1060/*
1061 * fabs: Absolute value of a float
1062 *
1063 * Returns the absolute value of the float v.
1064 *
1065 * For integers, use abs().
1066 */
1067extern float __attribute__((const, overloadable))
1068    fabs(float v);
1069
1070extern float2 __attribute__((const, overloadable))
1071    fabs(float2 v);
1072
1073extern float3 __attribute__((const, overloadable))
1074    fabs(float3 v);
1075
1076extern float4 __attribute__((const, overloadable))
1077    fabs(float4 v);
1078
1079/*
1080 * fdim: Positive difference between two values
1081 *
1082 * Returns the positive difference between two values.
1083 *
1084 * If a > b, returns (a - b) otherwise returns 0f.
1085 */
1086extern float __attribute__((const, overloadable))
1087    fdim(float a, float b);
1088
1089extern float2 __attribute__((const, overloadable))
1090    fdim(float2 a, float2 b);
1091
1092extern float3 __attribute__((const, overloadable))
1093    fdim(float3 a, float3 b);
1094
1095extern float4 __attribute__((const, overloadable))
1096    fdim(float4 a, float4 b);
1097
1098/*
1099 * floor: Smallest integer not greater than a value
1100 *
1101 * Returns the smallest integer not greater than a value.
1102 *
1103 * For example, floor(1.2f) returns 1.f, and floor(-1.2f) returns -2.f.
1104 *
1105 * See also ceil().
1106 */
1107extern float __attribute__((const, overloadable))
1108    floor(float v);
1109
1110extern float2 __attribute__((const, overloadable))
1111    floor(float2 v);
1112
1113extern float3 __attribute__((const, overloadable))
1114    floor(float3 v);
1115
1116extern float4 __attribute__((const, overloadable))
1117    floor(float4 v);
1118
1119/*
1120 * fma: Multiply and add
1121 *
1122 * Multiply and add.  Returns (multiplicand1 * multiplicand2) + offset.
1123 *
1124 * This function is similar to mad().  fma() retains full precision of the
1125 * multiplied result and rounds only after the addition.  mad() rounds after the
1126 * multiplication and the addition.  This extra precision is not guaranteed in
1127 * rs_fp_relaxed mode.
1128 */
1129extern float __attribute__((const, overloadable))
1130    fma(float multiplicand1, float multiplicand2, float offset);
1131
1132extern float2 __attribute__((const, overloadable))
1133    fma(float2 multiplicand1, float2 multiplicand2, float2 offset);
1134
1135extern float3 __attribute__((const, overloadable))
1136    fma(float3 multiplicand1, float3 multiplicand2, float3 offset);
1137
1138extern float4 __attribute__((const, overloadable))
1139    fma(float4 multiplicand1, float4 multiplicand2, float4 offset);
1140
1141/*
1142 * fmax: Maximum of two floats
1143 *
1144 * Returns the maximum of a and b, i.e. (a < b ? b : a).
1145 *
1146 * The max() function returns identical results but can be applied to more data types.
1147 */
1148extern float __attribute__((const, overloadable))
1149    fmax(float a, float b);
1150
1151extern float2 __attribute__((const, overloadable))
1152    fmax(float2 a, float2 b);
1153
1154extern float3 __attribute__((const, overloadable))
1155    fmax(float3 a, float3 b);
1156
1157extern float4 __attribute__((const, overloadable))
1158    fmax(float4 a, float4 b);
1159
1160extern float2 __attribute__((const, overloadable))
1161    fmax(float2 a, float b);
1162
1163extern float3 __attribute__((const, overloadable))
1164    fmax(float3 a, float b);
1165
1166extern float4 __attribute__((const, overloadable))
1167    fmax(float4 a, float b);
1168
1169/*
1170 * fmin: Minimum of two floats
1171 *
1172 * Returns the minimum of a and b, i.e. (a > b ? b : a).
1173 *
1174 * The min() function returns identical results but can be applied to more data types.
1175 */
1176extern float __attribute__((const, overloadable))
1177    fmin(float a, float b);
1178
1179extern float2 __attribute__((const, overloadable))
1180    fmin(float2 a, float2 b);
1181
1182extern float3 __attribute__((const, overloadable))
1183    fmin(float3 a, float3 b);
1184
1185extern float4 __attribute__((const, overloadable))
1186    fmin(float4 a, float4 b);
1187
1188extern float2 __attribute__((const, overloadable))
1189    fmin(float2 a, float b);
1190
1191extern float3 __attribute__((const, overloadable))
1192    fmin(float3 a, float b);
1193
1194extern float4 __attribute__((const, overloadable))
1195    fmin(float4 a, float b);
1196
1197/*
1198 * fmod: Modulo
1199 *
1200 * Returns the remainder of (numerator / denominator), where the quotient is rounded towards zero.
1201 *
1202 * The function remainder() is similar but rounds toward the closest interger.
1203 * For example, fmod(-3.8f, 2.f) returns -1.8f (-3.8f - -1.f * 2.f)
1204 * while remainder(-3.8f, 2.f) returns 0.2f (-3.8f - -2.f * 2.f).
1205 */
1206extern float __attribute__((const, overloadable))
1207    fmod(float numerator, float denominator);
1208
1209extern float2 __attribute__((const, overloadable))
1210    fmod(float2 numerator, float2 denominator);
1211
1212extern float3 __attribute__((const, overloadable))
1213    fmod(float3 numerator, float3 denominator);
1214
1215extern float4 __attribute__((const, overloadable))
1216    fmod(float4 numerator, float4 denominator);
1217
1218/*
1219 * fract: Positive fractional part
1220 *
1221 * Returns the positive fractional part of v, i.e. v - floor(v).
1222 *
1223 * For example, fract(1.3f, &val) returns 0.3f and sets val to 1.f.
1224 * fract(-1.3f, &val) returns 0.7f and sets val to -2.f.
1225 *
1226 * Parameters:
1227 *   v Input value.
1228 *   floor If floor is not null, *floor will be set to the floor of v.
1229 */
1230extern float __attribute__((overloadable))
1231    fract(float v, float* floor);
1232
1233extern float2 __attribute__((overloadable))
1234    fract(float2 v, float2* floor);
1235
1236extern float3 __attribute__((overloadable))
1237    fract(float3 v, float3* floor);
1238
1239extern float4 __attribute__((overloadable))
1240    fract(float4 v, float4* floor);
1241
1242static inline float __attribute__((const, overloadable))
1243    fract(float v) {
1244    float unused;
1245    return fract(v, &unused);
1246}
1247
1248static inline float2 __attribute__((const, overloadable))
1249    fract(float2 v) {
1250    float2 unused;
1251    return fract(v, &unused);
1252}
1253
1254static inline float3 __attribute__((const, overloadable))
1255    fract(float3 v) {
1256    float3 unused;
1257    return fract(v, &unused);
1258}
1259
1260static inline float4 __attribute__((const, overloadable))
1261    fract(float4 v) {
1262    float4 unused;
1263    return fract(v, &unused);
1264}
1265
1266/*
1267 * frexp: Binary mantissa and exponent
1268 *
1269 * Returns the binary mantissa and exponent of v, i.e. v == mantissa * 2 ^ exponent.
1270 *
1271 * The mantissa is always between 0.5 (inclusive) and 1.0 (exclusive).
1272 *
1273 * See ldexp() for the reverse operation.  See also logb() and ilogb().
1274 *
1275 * Parameters:
1276 *   v Input value.
1277 *   exponent If exponent is not null, *exponent will be set to the exponent of v.
1278 */
1279extern float __attribute__((overloadable))
1280    frexp(float v, int* exponent);
1281
1282extern float2 __attribute__((overloadable))
1283    frexp(float2 v, int2* exponent);
1284
1285extern float3 __attribute__((overloadable))
1286    frexp(float3 v, int3* exponent);
1287
1288extern float4 __attribute__((overloadable))
1289    frexp(float4 v, int4* exponent);
1290
1291/*
1292 * half_recip: Reciprocal computed to 16 bit precision
1293 *
1294 * Returns the approximate reciprocal of a value.
1295 *
1296 * The precision is that of a 16 bit floating point value.
1297 *
1298 * See also native_recip().
1299 */
1300#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1301extern float __attribute__((const, overloadable))
1302    half_recip(float v);
1303#endif
1304
1305#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1306extern float2 __attribute__((const, overloadable))
1307    half_recip(float2 v);
1308#endif
1309
1310#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1311extern float3 __attribute__((const, overloadable))
1312    half_recip(float3 v);
1313#endif
1314
1315#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1316extern float4 __attribute__((const, overloadable))
1317    half_recip(float4 v);
1318#endif
1319
1320/*
1321 * half_rsqrt: Reciprocal of a square root computed to 16 bit precision
1322 *
1323 * Returns the approximate value of (1.f / sqrt(value)).
1324 *
1325 * The precision is that of a 16 bit floating point value.
1326 *
1327 * See also rsqrt(), native_rsqrt().
1328 */
1329#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1330extern float __attribute__((const, overloadable))
1331    half_rsqrt(float v);
1332#endif
1333
1334#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1335extern float2 __attribute__((const, overloadable))
1336    half_rsqrt(float2 v);
1337#endif
1338
1339#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1340extern float3 __attribute__((const, overloadable))
1341    half_rsqrt(float3 v);
1342#endif
1343
1344#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1345extern float4 __attribute__((const, overloadable))
1346    half_rsqrt(float4 v);
1347#endif
1348
1349/*
1350 * half_sqrt: Square root computed to 16 bit precision
1351 *
1352 * Returns the approximate square root of a value.
1353 *
1354 * The precision is that of a 16 bit floating point value.
1355 *
1356 * See also sqrt(), native_sqrt().
1357 */
1358#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1359extern float __attribute__((const, overloadable))
1360    half_sqrt(float v);
1361#endif
1362
1363#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1364extern float2 __attribute__((const, overloadable))
1365    half_sqrt(float2 v);
1366#endif
1367
1368#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1369extern float3 __attribute__((const, overloadable))
1370    half_sqrt(float3 v);
1371#endif
1372
1373#if (defined(RS_VERSION) && (RS_VERSION >= 17))
1374extern float4 __attribute__((const, overloadable))
1375    half_sqrt(float4 v);
1376#endif
1377
1378/*
1379 * hypot: Hypotenuse
1380 *
1381 * Returns the hypotenuse, i.e. sqrt(a * a + b * b).
1382 *
1383 * See also native_hypot().
1384 */
1385extern float __attribute__((const, overloadable))
1386    hypot(float a, float b);
1387
1388extern float2 __attribute__((const, overloadable))
1389    hypot(float2 a, float2 b);
1390
1391extern float3 __attribute__((const, overloadable))
1392    hypot(float3 a, float3 b);
1393
1394extern float4 __attribute__((const, overloadable))
1395    hypot(float4 a, float4 b);
1396
1397/*
1398 * ilogb: Base two exponent
1399 *
1400 * Returns the base two exponent of a value, where the mantissa is between
1401 * 1.f (inclusive) and 2.f (exclusive).
1402 *
1403 * For example, ilogb(8.5f) returns 3.
1404 *
1405 * Because of the difference in mantissa, this number is one less than
1406 * is returned by frexp().
1407 *
1408 * logb() is similar but returns a float.
1409 */
1410extern int __attribute__((const, overloadable))
1411    ilogb(float v);
1412
1413extern int2 __attribute__((const, overloadable))
1414    ilogb(float2 v);
1415
1416extern int3 __attribute__((const, overloadable))
1417    ilogb(float3 v);
1418
1419extern int4 __attribute__((const, overloadable))
1420    ilogb(float4 v);
1421
1422/*
1423 * ldexp: Creates a floating point from mantissa and exponent
1424 *
1425 * Returns the floating point created from the mantissa and exponent,
1426 * i.e. (mantissa * 2 ^ exponent).
1427 *
1428 * See frexp() for the reverse operation.
1429 *
1430 * Parameters:
1431 *   mantissa The mantissa
1432 *   exponent The exponent, a single component or matching vector.
1433 */
1434extern float __attribute__((const, overloadable))
1435    ldexp(float mantissa, int exponent);
1436
1437extern float2 __attribute__((const, overloadable))
1438    ldexp(float2 mantissa, int2 exponent);
1439
1440extern float3 __attribute__((const, overloadable))
1441    ldexp(float3 mantissa, int3 exponent);
1442
1443extern float4 __attribute__((const, overloadable))
1444    ldexp(float4 mantissa, int4 exponent);
1445
1446extern float2 __attribute__((const, overloadable))
1447    ldexp(float2 mantissa, int exponent);
1448
1449extern float3 __attribute__((const, overloadable))
1450    ldexp(float3 mantissa, int exponent);
1451
1452extern float4 __attribute__((const, overloadable))
1453    ldexp(float4 mantissa, int exponent);
1454
1455/*
1456 * lgamma: Natural logarithm of the gamma function
1457 *
1458 * Returns the natural logarithm of the absolute value of the gamma function,
1459 * i.e. log(fabs(tgamma(v))).
1460 *
1461 * See also tgamma().
1462 *
1463 * Parameters:
1464 *   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.
1465 */
1466extern float __attribute__((const, overloadable))
1467    lgamma(float v);
1468
1469extern float2 __attribute__((const, overloadable))
1470    lgamma(float2 v);
1471
1472extern float3 __attribute__((const, overloadable))
1473    lgamma(float3 v);
1474
1475extern float4 __attribute__((const, overloadable))
1476    lgamma(float4 v);
1477
1478extern float __attribute__((overloadable))
1479    lgamma(float v, int* sign_of_gamma);
1480
1481extern float2 __attribute__((overloadable))
1482    lgamma(float2 v, int2* sign_of_gamma);
1483
1484extern float3 __attribute__((overloadable))
1485    lgamma(float3 v, int3* sign_of_gamma);
1486
1487extern float4 __attribute__((overloadable))
1488    lgamma(float4 v, int4* sign_of_gamma);
1489
1490/*
1491 * log: Natural logarithm
1492 *
1493 * Returns the natural logarithm.
1494 *
1495 * See also native_log().
1496 */
1497extern float __attribute__((const, overloadable))
1498    log(float v);
1499
1500extern float2 __attribute__((const, overloadable))
1501    log(float2 v);
1502
1503extern float3 __attribute__((const, overloadable))
1504    log(float3 v);
1505
1506extern float4 __attribute__((const, overloadable))
1507    log(float4 v);
1508
1509/*
1510 * log10: Base 10 logarithm
1511 *
1512 * Returns the base 10 logarithm.
1513 *
1514 * See also native_log10().
1515 */
1516extern float __attribute__((const, overloadable))
1517    log10(float v);
1518
1519extern float2 __attribute__((const, overloadable))
1520    log10(float2 v);
1521
1522extern float3 __attribute__((const, overloadable))
1523    log10(float3 v);
1524
1525extern float4 __attribute__((const, overloadable))
1526    log10(float4 v);
1527
1528/*
1529 * log1p: Natural logarithm of a value plus 1
1530 *
1531 * Returns the natural logarithm of (v + 1.f).
1532 *
1533 * See also native_log1p().
1534 */
1535extern float __attribute__((const, overloadable))
1536    log1p(float v);
1537
1538extern float2 __attribute__((const, overloadable))
1539    log1p(float2 v);
1540
1541extern float3 __attribute__((const, overloadable))
1542    log1p(float3 v);
1543
1544extern float4 __attribute__((const, overloadable))
1545    log1p(float4 v);
1546
1547/*
1548 * log2: Base 2 logarithm
1549 *
1550 * Returns the base 2 logarithm.
1551 *
1552 * See also native_log2().
1553 */
1554extern float __attribute__((const, overloadable))
1555    log2(float v);
1556
1557extern float2 __attribute__((const, overloadable))
1558    log2(float2 v);
1559
1560extern float3 __attribute__((const, overloadable))
1561    log2(float3 v);
1562
1563extern float4 __attribute__((const, overloadable))
1564    log2(float4 v);
1565
1566/*
1567 * logb: Base two exponent
1568 *
1569 * Returns the base two exponent of a value, where the mantissa is between
1570 * 1.f (inclusive) and 2.f (exclusive).
1571 *
1572 * For example, logb(8.5f) returns 3.f.
1573 *
1574 * Because of the difference in mantissa, this number is one less than
1575 * is returned by frexp().
1576 *
1577 * ilogb() is similar but returns an integer.
1578 */
1579extern float __attribute__((const, overloadable))
1580    logb(float v);
1581
1582extern float2 __attribute__((const, overloadable))
1583    logb(float2 v);
1584
1585extern float3 __attribute__((const, overloadable))
1586    logb(float3 v);
1587
1588extern float4 __attribute__((const, overloadable))
1589    logb(float4 v);
1590
1591/*
1592 * mad: Multiply and add
1593 *
1594 * Multiply and add.  Returns (multiplicand1 * multiplicand2) + offset.
1595 *
1596 * This function is similar to fma().  fma() retains full precision of the
1597 * multiplied result and rounds only after the addition.  mad() rounds after the
1598 * multiplication and the addition.  In rs_fp_relaxed mode, mad() may not do the
1599 * rounding after multiplicaiton.
1600 */
1601extern float __attribute__((const, overloadable))
1602    mad(float multiplicand1, float multiplicand2, float offset);
1603
1604extern float2 __attribute__((const, overloadable))
1605    mad(float2 multiplicand1, float2 multiplicand2, float2 offset);
1606
1607extern float3 __attribute__((const, overloadable))
1608    mad(float3 multiplicand1, float3 multiplicand2, float3 offset);
1609
1610extern float4 __attribute__((const, overloadable))
1611    mad(float4 multiplicand1, float4 multiplicand2, float4 offset);
1612
1613/*
1614 * max: Maximum
1615 *
1616 * Returns the maximum value of two arguments.
1617 */
1618extern float __attribute__((const, overloadable))
1619    max(float a, float b);
1620
1621extern float2 __attribute__((const, overloadable))
1622    max(float2 a, float2 b);
1623
1624extern float3 __attribute__((const, overloadable))
1625    max(float3 a, float3 b);
1626
1627extern float4 __attribute__((const, overloadable))
1628    max(float4 a, float4 b);
1629
1630#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1631static inline char __attribute__((const, overloadable))
1632    max(char a, char b) {
1633    return (a > b ? a : b);
1634}
1635#endif
1636
1637#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1638static inline uchar __attribute__((const, overloadable))
1639    max(uchar a, uchar b) {
1640    return (a > b ? a : b);
1641}
1642#endif
1643
1644#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1645static inline short __attribute__((const, overloadable))
1646    max(short a, short b) {
1647    return (a > b ? a : b);
1648}
1649#endif
1650
1651#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1652static inline ushort __attribute__((const, overloadable))
1653    max(ushort a, ushort b) {
1654    return (a > b ? a : b);
1655}
1656#endif
1657
1658#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1659static inline int __attribute__((const, overloadable))
1660    max(int a, int b) {
1661    return (a > b ? a : b);
1662}
1663#endif
1664
1665#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1666static inline uint __attribute__((const, overloadable))
1667    max(uint a, uint b) {
1668    return (a > b ? a : b);
1669}
1670#endif
1671
1672#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1673static inline char2 __attribute__((const, overloadable))
1674    max(char2 a, char2 b) {
1675    char2 tmp;
1676    tmp.x = (a.x > b.x ? a.x : b.x);
1677    tmp.y = (a.y > b.y ? a.y : b.y);
1678    return tmp;
1679}
1680#endif
1681
1682#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1683static inline uchar2 __attribute__((const, overloadable))
1684    max(uchar2 a, uchar2 b) {
1685    uchar2 tmp;
1686    tmp.x = (a.x > b.x ? a.x : b.x);
1687    tmp.y = (a.y > b.y ? a.y : b.y);
1688    return tmp;
1689}
1690#endif
1691
1692#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1693static inline short2 __attribute__((const, overloadable))
1694    max(short2 a, short2 b) {
1695    short2 tmp;
1696    tmp.x = (a.x > b.x ? a.x : b.x);
1697    tmp.y = (a.y > b.y ? a.y : b.y);
1698    return tmp;
1699}
1700#endif
1701
1702#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1703static inline ushort2 __attribute__((const, overloadable))
1704    max(ushort2 a, ushort2 b) {
1705    ushort2 tmp;
1706    tmp.x = (a.x > b.x ? a.x : b.x);
1707    tmp.y = (a.y > b.y ? a.y : b.y);
1708    return tmp;
1709}
1710#endif
1711
1712#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1713static inline int2 __attribute__((const, overloadable))
1714    max(int2 a, int2 b) {
1715    int2 tmp;
1716    tmp.x = (a.x > b.x ? a.x : b.x);
1717    tmp.y = (a.y > b.y ? a.y : b.y);
1718    return tmp;
1719}
1720#endif
1721
1722#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1723static inline uint2 __attribute__((const, overloadable))
1724    max(uint2 a, uint2 b) {
1725    uint2 tmp;
1726    tmp.x = (a.x > b.x ? a.x : b.x);
1727    tmp.y = (a.y > b.y ? a.y : b.y);
1728    return tmp;
1729}
1730#endif
1731
1732#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1733static inline char3 __attribute__((const, overloadable))
1734    max(char3 a, char3 b) {
1735    char3 tmp;
1736    tmp.x = (a.x > b.x ? a.x : b.x);
1737    tmp.y = (a.y > b.y ? a.y : b.y);
1738    tmp.z = (a.z > b.z ? a.z : b.z);
1739    return tmp;
1740}
1741#endif
1742
1743#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1744static inline uchar3 __attribute__((const, overloadable))
1745    max(uchar3 a, uchar3 b) {
1746    uchar3 tmp;
1747    tmp.x = (a.x > b.x ? a.x : b.x);
1748    tmp.y = (a.y > b.y ? a.y : b.y);
1749    tmp.z = (a.z > b.z ? a.z : b.z);
1750    return tmp;
1751}
1752#endif
1753
1754#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1755static inline short3 __attribute__((const, overloadable))
1756    max(short3 a, short3 b) {
1757    short3 tmp;
1758    tmp.x = (a.x > b.x ? a.x : b.x);
1759    tmp.y = (a.y > b.y ? a.y : b.y);
1760    tmp.z = (a.z > b.z ? a.z : b.z);
1761    return tmp;
1762}
1763#endif
1764
1765#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1766static inline ushort3 __attribute__((const, overloadable))
1767    max(ushort3 a, ushort3 b) {
1768    ushort3 tmp;
1769    tmp.x = (a.x > b.x ? a.x : b.x);
1770    tmp.y = (a.y > b.y ? a.y : b.y);
1771    tmp.z = (a.z > b.z ? a.z : b.z);
1772    return tmp;
1773}
1774#endif
1775
1776#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1777static inline int3 __attribute__((const, overloadable))
1778    max(int3 a, int3 b) {
1779    int3 tmp;
1780    tmp.x = (a.x > b.x ? a.x : b.x);
1781    tmp.y = (a.y > b.y ? a.y : b.y);
1782    tmp.z = (a.z > b.z ? a.z : b.z);
1783    return tmp;
1784}
1785#endif
1786
1787#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1788static inline uint3 __attribute__((const, overloadable))
1789    max(uint3 a, uint3 b) {
1790    uint3 tmp;
1791    tmp.x = (a.x > b.x ? a.x : b.x);
1792    tmp.y = (a.y > b.y ? a.y : b.y);
1793    tmp.z = (a.z > b.z ? a.z : b.z);
1794    return tmp;
1795}
1796#endif
1797
1798#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1799static inline char4 __attribute__((const, overloadable))
1800    max(char4 a, char4 b) {
1801    char4 tmp;
1802    tmp.x = (a.x > b.x ? a.x : b.x);
1803    tmp.y = (a.y > b.y ? a.y : b.y);
1804    tmp.z = (a.z > b.z ? a.z : b.z);
1805    tmp.w = (a.w > b.w ? a.w : b.w);
1806    return tmp;
1807}
1808#endif
1809
1810#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1811static inline uchar4 __attribute__((const, overloadable))
1812    max(uchar4 a, uchar4 b) {
1813    uchar4 tmp;
1814    tmp.x = (a.x > b.x ? a.x : b.x);
1815    tmp.y = (a.y > b.y ? a.y : b.y);
1816    tmp.z = (a.z > b.z ? a.z : b.z);
1817    tmp.w = (a.w > b.w ? a.w : b.w);
1818    return tmp;
1819}
1820#endif
1821
1822#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1823static inline short4 __attribute__((const, overloadable))
1824    max(short4 a, short4 b) {
1825    short4 tmp;
1826    tmp.x = (a.x > b.x ? a.x : b.x);
1827    tmp.y = (a.y > b.y ? a.y : b.y);
1828    tmp.z = (a.z > b.z ? a.z : b.z);
1829    tmp.w = (a.w > b.w ? a.w : b.w);
1830    return tmp;
1831}
1832#endif
1833
1834#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1835static inline ushort4 __attribute__((const, overloadable))
1836    max(ushort4 a, ushort4 b) {
1837    ushort4 tmp;
1838    tmp.x = (a.x > b.x ? a.x : b.x);
1839    tmp.y = (a.y > b.y ? a.y : b.y);
1840    tmp.z = (a.z > b.z ? a.z : b.z);
1841    tmp.w = (a.w > b.w ? a.w : b.w);
1842    return tmp;
1843}
1844#endif
1845
1846#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1847static inline int4 __attribute__((const, overloadable))
1848    max(int4 a, int4 b) {
1849    int4 tmp;
1850    tmp.x = (a.x > b.x ? a.x : b.x);
1851    tmp.y = (a.y > b.y ? a.y : b.y);
1852    tmp.z = (a.z > b.z ? a.z : b.z);
1853    tmp.w = (a.w > b.w ? a.w : b.w);
1854    return tmp;
1855}
1856#endif
1857
1858#if !defined(RS_VERSION) || (RS_VERSION <= 20)
1859static inline uint4 __attribute__((const, overloadable))
1860    max(uint4 a, uint4 b) {
1861    uint4 tmp;
1862    tmp.x = (a.x > b.x ? a.x : b.x);
1863    tmp.y = (a.y > b.y ? a.y : b.y);
1864    tmp.z = (a.z > b.z ? a.z : b.z);
1865    tmp.w = (a.w > b.w ? a.w : b.w);
1866    return tmp;
1867}
1868#endif
1869
1870#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1871extern char __attribute__((const, overloadable))
1872    max(char a, char b);
1873#endif
1874
1875#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1876extern char2 __attribute__((const, overloadable))
1877    max(char2 a, char2 b);
1878#endif
1879
1880#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1881extern char3 __attribute__((const, overloadable))
1882    max(char3 a, char3 b);
1883#endif
1884
1885#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1886extern char4 __attribute__((const, overloadable))
1887    max(char4 a, char4 b);
1888#endif
1889
1890#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1891extern uchar __attribute__((const, overloadable))
1892    max(uchar a, uchar b);
1893#endif
1894
1895#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1896extern uchar2 __attribute__((const, overloadable))
1897    max(uchar2 a, uchar2 b);
1898#endif
1899
1900#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1901extern uchar3 __attribute__((const, overloadable))
1902    max(uchar3 a, uchar3 b);
1903#endif
1904
1905#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1906extern uchar4 __attribute__((const, overloadable))
1907    max(uchar4 a, uchar4 b);
1908#endif
1909
1910#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1911extern short __attribute__((const, overloadable))
1912    max(short a, short b);
1913#endif
1914
1915#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1916extern short2 __attribute__((const, overloadable))
1917    max(short2 a, short2 b);
1918#endif
1919
1920#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1921extern short3 __attribute__((const, overloadable))
1922    max(short3 a, short3 b);
1923#endif
1924
1925#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1926extern short4 __attribute__((const, overloadable))
1927    max(short4 a, short4 b);
1928#endif
1929
1930#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1931extern ushort __attribute__((const, overloadable))
1932    max(ushort a, ushort b);
1933#endif
1934
1935#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1936extern ushort2 __attribute__((const, overloadable))
1937    max(ushort2 a, ushort2 b);
1938#endif
1939
1940#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1941extern ushort3 __attribute__((const, overloadable))
1942    max(ushort3 a, ushort3 b);
1943#endif
1944
1945#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1946extern ushort4 __attribute__((const, overloadable))
1947    max(ushort4 a, ushort4 b);
1948#endif
1949
1950#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1951extern int __attribute__((const, overloadable))
1952    max(int a, int b);
1953#endif
1954
1955#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1956extern int2 __attribute__((const, overloadable))
1957    max(int2 a, int2 b);
1958#endif
1959
1960#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1961extern int3 __attribute__((const, overloadable))
1962    max(int3 a, int3 b);
1963#endif
1964
1965#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1966extern int4 __attribute__((const, overloadable))
1967    max(int4 a, int4 b);
1968#endif
1969
1970#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1971extern uint __attribute__((const, overloadable))
1972    max(uint a, uint b);
1973#endif
1974
1975#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1976extern uint2 __attribute__((const, overloadable))
1977    max(uint2 a, uint2 b);
1978#endif
1979
1980#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1981extern uint3 __attribute__((const, overloadable))
1982    max(uint3 a, uint3 b);
1983#endif
1984
1985#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1986extern uint4 __attribute__((const, overloadable))
1987    max(uint4 a, uint4 b);
1988#endif
1989
1990#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1991extern long __attribute__((const, overloadable))
1992    max(long a, long b);
1993#endif
1994
1995#if (defined(RS_VERSION) && (RS_VERSION >= 21))
1996extern long2 __attribute__((const, overloadable))
1997    max(long2 a, long2 b);
1998#endif
1999
2000#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2001extern long3 __attribute__((const, overloadable))
2002    max(long3 a, long3 b);
2003#endif
2004
2005#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2006extern long4 __attribute__((const, overloadable))
2007    max(long4 a, long4 b);
2008#endif
2009
2010#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2011extern ulong __attribute__((const, overloadable))
2012    max(ulong a, ulong b);
2013#endif
2014
2015#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2016extern ulong2 __attribute__((const, overloadable))
2017    max(ulong2 a, ulong2 b);
2018#endif
2019
2020#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2021extern ulong3 __attribute__((const, overloadable))
2022    max(ulong3 a, ulong3 b);
2023#endif
2024
2025#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2026extern ulong4 __attribute__((const, overloadable))
2027    max(ulong4 a, ulong4 b);
2028#endif
2029
2030/*
2031 * min: Minimum
2032 *
2033 * Returns the minimum value of two arguments.
2034 */
2035extern float __attribute__((const, overloadable))
2036    min(float a, float b);
2037
2038extern float2 __attribute__((const, overloadable))
2039    min(float2 a, float2 b);
2040
2041extern float3 __attribute__((const, overloadable))
2042    min(float3 a, float3 b);
2043
2044extern float4 __attribute__((const, overloadable))
2045    min(float4 a, float4 b);
2046
2047#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2048static inline char __attribute__((const, overloadable))
2049    min(char a, char b) {
2050    return (a < b ? a : b);
2051}
2052#endif
2053
2054#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2055static inline uchar __attribute__((const, overloadable))
2056    min(uchar a, uchar b) {
2057    return (a < b ? a : b);
2058}
2059#endif
2060
2061#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2062static inline short __attribute__((const, overloadable))
2063    min(short a, short b) {
2064    return (a < b ? a : b);
2065}
2066#endif
2067
2068#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2069static inline ushort __attribute__((const, overloadable))
2070    min(ushort a, ushort b) {
2071    return (a < b ? a : b);
2072}
2073#endif
2074
2075#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2076static inline int __attribute__((const, overloadable))
2077    min(int a, int b) {
2078    return (a < b ? a : b);
2079}
2080#endif
2081
2082#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2083static inline uint __attribute__((const, overloadable))
2084    min(uint a, uint b) {
2085    return (a < b ? a : b);
2086}
2087#endif
2088
2089#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2090static inline char2 __attribute__((const, overloadable))
2091    min(char2 a, char2 b) {
2092    char2 tmp;
2093    tmp.x = (a.x < b.x ? a.x : b.x);
2094    tmp.y = (a.y < b.y ? a.y : b.y);
2095    return tmp;
2096}
2097#endif
2098
2099#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2100static inline uchar2 __attribute__((const, overloadable))
2101    min(uchar2 a, uchar2 b) {
2102    uchar2 tmp;
2103    tmp.x = (a.x < b.x ? a.x : b.x);
2104    tmp.y = (a.y < b.y ? a.y : b.y);
2105    return tmp;
2106}
2107#endif
2108
2109#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2110static inline short2 __attribute__((const, overloadable))
2111    min(short2 a, short2 b) {
2112    short2 tmp;
2113    tmp.x = (a.x < b.x ? a.x : b.x);
2114    tmp.y = (a.y < b.y ? a.y : b.y);
2115    return tmp;
2116}
2117#endif
2118
2119#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2120static inline ushort2 __attribute__((const, overloadable))
2121    min(ushort2 a, ushort2 b) {
2122    ushort2 tmp;
2123    tmp.x = (a.x < b.x ? a.x : b.x);
2124    tmp.y = (a.y < b.y ? a.y : b.y);
2125    return tmp;
2126}
2127#endif
2128
2129#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2130static inline int2 __attribute__((const, overloadable))
2131    min(int2 a, int2 b) {
2132    int2 tmp;
2133    tmp.x = (a.x < b.x ? a.x : b.x);
2134    tmp.y = (a.y < b.y ? a.y : b.y);
2135    return tmp;
2136}
2137#endif
2138
2139#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2140static inline uint2 __attribute__((const, overloadable))
2141    min(uint2 a, uint2 b) {
2142    uint2 tmp;
2143    tmp.x = (a.x < b.x ? a.x : b.x);
2144    tmp.y = (a.y < b.y ? a.y : b.y);
2145    return tmp;
2146}
2147#endif
2148
2149#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2150static inline char3 __attribute__((const, overloadable))
2151    min(char3 a, char3 b) {
2152    char3 tmp;
2153    tmp.x = (a.x < b.x ? a.x : b.x);
2154    tmp.y = (a.y < b.y ? a.y : b.y);
2155    tmp.z = (a.z < b.z ? a.z : b.z);
2156    return tmp;
2157}
2158#endif
2159
2160#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2161static inline uchar3 __attribute__((const, overloadable))
2162    min(uchar3 a, uchar3 b) {
2163    uchar3 tmp;
2164    tmp.x = (a.x < b.x ? a.x : b.x);
2165    tmp.y = (a.y < b.y ? a.y : b.y);
2166    tmp.z = (a.z < b.z ? a.z : b.z);
2167    return tmp;
2168}
2169#endif
2170
2171#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2172static inline short3 __attribute__((const, overloadable))
2173    min(short3 a, short3 b) {
2174    short3 tmp;
2175    tmp.x = (a.x < b.x ? a.x : b.x);
2176    tmp.y = (a.y < b.y ? a.y : b.y);
2177    tmp.z = (a.z < b.z ? a.z : b.z);
2178    return tmp;
2179}
2180#endif
2181
2182#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2183static inline ushort3 __attribute__((const, overloadable))
2184    min(ushort3 a, ushort3 b) {
2185    ushort3 tmp;
2186    tmp.x = (a.x < b.x ? a.x : b.x);
2187    tmp.y = (a.y < b.y ? a.y : b.y);
2188    tmp.z = (a.z < b.z ? a.z : b.z);
2189    return tmp;
2190}
2191#endif
2192
2193#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2194static inline int3 __attribute__((const, overloadable))
2195    min(int3 a, int3 b) {
2196    int3 tmp;
2197    tmp.x = (a.x < b.x ? a.x : b.x);
2198    tmp.y = (a.y < b.y ? a.y : b.y);
2199    tmp.z = (a.z < b.z ? a.z : b.z);
2200    return tmp;
2201}
2202#endif
2203
2204#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2205static inline uint3 __attribute__((const, overloadable))
2206    min(uint3 a, uint3 b) {
2207    uint3 tmp;
2208    tmp.x = (a.x < b.x ? a.x : b.x);
2209    tmp.y = (a.y < b.y ? a.y : b.y);
2210    tmp.z = (a.z < b.z ? a.z : b.z);
2211    return tmp;
2212}
2213#endif
2214
2215#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2216static inline char4 __attribute__((const, overloadable))
2217    min(char4 a, char4 b) {
2218    char4 tmp;
2219    tmp.x = (a.x < b.x ? a.x : b.x);
2220    tmp.y = (a.y < b.y ? a.y : b.y);
2221    tmp.z = (a.z < b.z ? a.z : b.z);
2222    tmp.w = (a.w < b.w ? a.w : b.w);
2223    return tmp;
2224}
2225#endif
2226
2227#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2228static inline uchar4 __attribute__((const, overloadable))
2229    min(uchar4 a, uchar4 b) {
2230    uchar4 tmp;
2231    tmp.x = (a.x < b.x ? a.x : b.x);
2232    tmp.y = (a.y < b.y ? a.y : b.y);
2233    tmp.z = (a.z < b.z ? a.z : b.z);
2234    tmp.w = (a.w < b.w ? a.w : b.w);
2235    return tmp;
2236}
2237#endif
2238
2239#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2240static inline short4 __attribute__((const, overloadable))
2241    min(short4 a, short4 b) {
2242    short4 tmp;
2243    tmp.x = (a.x < b.x ? a.x : b.x);
2244    tmp.y = (a.y < b.y ? a.y : b.y);
2245    tmp.z = (a.z < b.z ? a.z : b.z);
2246    tmp.w = (a.w < b.w ? a.w : b.w);
2247    return tmp;
2248}
2249#endif
2250
2251#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2252static inline ushort4 __attribute__((const, overloadable))
2253    min(ushort4 a, ushort4 b) {
2254    ushort4 tmp;
2255    tmp.x = (a.x < b.x ? a.x : b.x);
2256    tmp.y = (a.y < b.y ? a.y : b.y);
2257    tmp.z = (a.z < b.z ? a.z : b.z);
2258    tmp.w = (a.w < b.w ? a.w : b.w);
2259    return tmp;
2260}
2261#endif
2262
2263#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2264static inline int4 __attribute__((const, overloadable))
2265    min(int4 a, int4 b) {
2266    int4 tmp;
2267    tmp.x = (a.x < b.x ? a.x : b.x);
2268    tmp.y = (a.y < b.y ? a.y : b.y);
2269    tmp.z = (a.z < b.z ? a.z : b.z);
2270    tmp.w = (a.w < b.w ? a.w : b.w);
2271    return tmp;
2272}
2273#endif
2274
2275#if !defined(RS_VERSION) || (RS_VERSION <= 20)
2276static inline uint4 __attribute__((const, overloadable))
2277    min(uint4 a, uint4 b) {
2278    uint4 tmp;
2279    tmp.x = (a.x < b.x ? a.x : b.x);
2280    tmp.y = (a.y < b.y ? a.y : b.y);
2281    tmp.z = (a.z < b.z ? a.z : b.z);
2282    tmp.w = (a.w < b.w ? a.w : b.w);
2283    return tmp;
2284}
2285#endif
2286
2287#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2288extern char __attribute__((const, overloadable))
2289    min(char a, char b);
2290#endif
2291
2292#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2293extern char2 __attribute__((const, overloadable))
2294    min(char2 a, char2 b);
2295#endif
2296
2297#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2298extern char3 __attribute__((const, overloadable))
2299    min(char3 a, char3 b);
2300#endif
2301
2302#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2303extern char4 __attribute__((const, overloadable))
2304    min(char4 a, char4 b);
2305#endif
2306
2307#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2308extern uchar __attribute__((const, overloadable))
2309    min(uchar a, uchar b);
2310#endif
2311
2312#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2313extern uchar2 __attribute__((const, overloadable))
2314    min(uchar2 a, uchar2 b);
2315#endif
2316
2317#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2318extern uchar3 __attribute__((const, overloadable))
2319    min(uchar3 a, uchar3 b);
2320#endif
2321
2322#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2323extern uchar4 __attribute__((const, overloadable))
2324    min(uchar4 a, uchar4 b);
2325#endif
2326
2327#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2328extern short __attribute__((const, overloadable))
2329    min(short a, short b);
2330#endif
2331
2332#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2333extern short2 __attribute__((const, overloadable))
2334    min(short2 a, short2 b);
2335#endif
2336
2337#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2338extern short3 __attribute__((const, overloadable))
2339    min(short3 a, short3 b);
2340#endif
2341
2342#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2343extern short4 __attribute__((const, overloadable))
2344    min(short4 a, short4 b);
2345#endif
2346
2347#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2348extern ushort __attribute__((const, overloadable))
2349    min(ushort a, ushort b);
2350#endif
2351
2352#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2353extern ushort2 __attribute__((const, overloadable))
2354    min(ushort2 a, ushort2 b);
2355#endif
2356
2357#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2358extern ushort3 __attribute__((const, overloadable))
2359    min(ushort3 a, ushort3 b);
2360#endif
2361
2362#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2363extern ushort4 __attribute__((const, overloadable))
2364    min(ushort4 a, ushort4 b);
2365#endif
2366
2367#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2368extern int __attribute__((const, overloadable))
2369    min(int a, int b);
2370#endif
2371
2372#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2373extern int2 __attribute__((const, overloadable))
2374    min(int2 a, int2 b);
2375#endif
2376
2377#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2378extern int3 __attribute__((const, overloadable))
2379    min(int3 a, int3 b);
2380#endif
2381
2382#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2383extern int4 __attribute__((const, overloadable))
2384    min(int4 a, int4 b);
2385#endif
2386
2387#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2388extern uint __attribute__((const, overloadable))
2389    min(uint a, uint b);
2390#endif
2391
2392#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2393extern uint2 __attribute__((const, overloadable))
2394    min(uint2 a, uint2 b);
2395#endif
2396
2397#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2398extern uint3 __attribute__((const, overloadable))
2399    min(uint3 a, uint3 b);
2400#endif
2401
2402#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2403extern uint4 __attribute__((const, overloadable))
2404    min(uint4 a, uint4 b);
2405#endif
2406
2407#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2408extern long __attribute__((const, overloadable))
2409    min(long a, long b);
2410#endif
2411
2412#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2413extern long2 __attribute__((const, overloadable))
2414    min(long2 a, long2 b);
2415#endif
2416
2417#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2418extern long3 __attribute__((const, overloadable))
2419    min(long3 a, long3 b);
2420#endif
2421
2422#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2423extern long4 __attribute__((const, overloadable))
2424    min(long4 a, long4 b);
2425#endif
2426
2427#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2428extern ulong __attribute__((const, overloadable))
2429    min(ulong a, ulong b);
2430#endif
2431
2432#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2433extern ulong2 __attribute__((const, overloadable))
2434    min(ulong2 a, ulong2 b);
2435#endif
2436
2437#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2438extern ulong3 __attribute__((const, overloadable))
2439    min(ulong3 a, ulong3 b);
2440#endif
2441
2442#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2443extern ulong4 __attribute__((const, overloadable))
2444    min(ulong4 a, ulong4 b);
2445#endif
2446
2447/*
2448 * mix: Mixes two values
2449 *
2450 * Returns start + ((stop - start) * fraction).
2451 *
2452 * This can be useful for mixing two values.  For example, to create a new color that is 40% color1 and 60% color2, use mix(color1, color2, 0.6f).
2453 */
2454extern float __attribute__((const, overloadable))
2455    mix(float start, float stop, float fraction);
2456
2457extern float2 __attribute__((const, overloadable))
2458    mix(float2 start, float2 stop, float2 fraction);
2459
2460extern float3 __attribute__((const, overloadable))
2461    mix(float3 start, float3 stop, float3 fraction);
2462
2463extern float4 __attribute__((const, overloadable))
2464    mix(float4 start, float4 stop, float4 fraction);
2465
2466extern float2 __attribute__((const, overloadable))
2467    mix(float2 start, float2 stop, float fraction);
2468
2469extern float3 __attribute__((const, overloadable))
2470    mix(float3 start, float3 stop, float fraction);
2471
2472extern float4 __attribute__((const, overloadable))
2473    mix(float4 start, float4 stop, float fraction);
2474
2475/*
2476 * modf: Integral and fractional components
2477 *
2478 * Returns the integral and fractional components of a number.
2479 *
2480 * 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.
2481 *
2482 * Parameters:
2483 *   v Source value
2484 *   integral_part *integral_part will be set to the integral portion of the number.
2485 *
2486 * Returns: The floating point portion of the value.
2487 */
2488extern float __attribute__((overloadable))
2489    modf(float v, float* integral_part);
2490
2491extern float2 __attribute__((overloadable))
2492    modf(float2 v, float2* integral_part);
2493
2494extern float3 __attribute__((overloadable))
2495    modf(float3 v, float3* integral_part);
2496
2497extern float4 __attribute__((overloadable))
2498    modf(float4 v, float4* integral_part);
2499
2500/*
2501 * nan: Not a Number
2502 *
2503 * Returns a NaN value (Not a Number).
2504 *
2505 * Parameters:
2506 *   v Not used.
2507 */
2508extern float __attribute__((const, overloadable))
2509    nan(uint v);
2510
2511/*
2512 * native_acos: Approximate inverse cosine
2513 *
2514 * Returns the approximate inverse cosine, in radians.
2515 *
2516 * This function yields undefined results from input values less than -1 or greater
2517 * than 1.
2518 *
2519 * See also acos().
2520 */
2521#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2522extern float __attribute__((const, overloadable))
2523    native_acos(float v);
2524#endif
2525
2526#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2527extern float2 __attribute__((const, overloadable))
2528    native_acos(float2 v);
2529#endif
2530
2531#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2532extern float3 __attribute__((const, overloadable))
2533    native_acos(float3 v);
2534#endif
2535
2536#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2537extern float4 __attribute__((const, overloadable))
2538    native_acos(float4 v);
2539#endif
2540
2541/*
2542 * native_acosh: Approximate inverse hyperbolic cosine
2543 *
2544 * Returns the approximate inverse hyperbolic cosine, in radians.
2545 *
2546 * See also acosh().
2547 */
2548#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2549extern float __attribute__((const, overloadable))
2550    native_acosh(float v);
2551#endif
2552
2553#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2554extern float2 __attribute__((const, overloadable))
2555    native_acosh(float2 v);
2556#endif
2557
2558#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2559extern float3 __attribute__((const, overloadable))
2560    native_acosh(float3 v);
2561#endif
2562
2563#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2564extern float4 __attribute__((const, overloadable))
2565    native_acosh(float4 v);
2566#endif
2567
2568/*
2569 * native_acospi: Approximate inverse cosine divided by pi
2570 *
2571 * Returns the approximate inverse cosine in radians, divided by pi.
2572 *
2573 * To get an inverse cosine measured in degrees, use acospi(a) * 180.f.
2574 *
2575 * This function yields undefined results from input values less than -1 or greater
2576 * than 1.
2577 *
2578 * See also acospi().
2579 */
2580#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2581extern float __attribute__((const, overloadable))
2582    native_acospi(float v);
2583#endif
2584
2585#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2586extern float2 __attribute__((const, overloadable))
2587    native_acospi(float2 v);
2588#endif
2589
2590#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2591extern float3 __attribute__((const, overloadable))
2592    native_acospi(float3 v);
2593#endif
2594
2595#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2596extern float4 __attribute__((const, overloadable))
2597    native_acospi(float4 v);
2598#endif
2599
2600/*
2601 * native_asin: Approximate inverse sine
2602 *
2603 * Returns the approximate inverse sine, in radians.
2604 *
2605 * This function yields undefined results from input values less than -1 or greater
2606 * than 1.
2607 *
2608 * See also asin().
2609 */
2610#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2611extern float __attribute__((const, overloadable))
2612    native_asin(float v);
2613#endif
2614
2615#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2616extern float2 __attribute__((const, overloadable))
2617    native_asin(float2 v);
2618#endif
2619
2620#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2621extern float3 __attribute__((const, overloadable))
2622    native_asin(float3 v);
2623#endif
2624
2625#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2626extern float4 __attribute__((const, overloadable))
2627    native_asin(float4 v);
2628#endif
2629
2630/*
2631 * native_asinh: Approximate inverse hyperbolic sine
2632 *
2633 * Returns the approximate inverse hyperbolic sine, in radians.
2634 *
2635 * See also asinh().
2636 */
2637#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2638extern float __attribute__((const, overloadable))
2639    native_asinh(float v);
2640#endif
2641
2642#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2643extern float2 __attribute__((const, overloadable))
2644    native_asinh(float2 v);
2645#endif
2646
2647#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2648extern float3 __attribute__((const, overloadable))
2649    native_asinh(float3 v);
2650#endif
2651
2652#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2653extern float4 __attribute__((const, overloadable))
2654    native_asinh(float4 v);
2655#endif
2656
2657/*
2658 * native_asinpi: Approximate inverse sine divided by pi
2659 *
2660 * Returns the approximate inverse sine in radians, divided by pi.
2661 *
2662 * To get an inverse sine measured in degrees, use asinpi(a) * 180.f.
2663 *
2664 * This function yields undefined results from input values less than -1 or greater
2665 * than 1.
2666 *
2667 * See also asinpi().
2668 */
2669#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2670extern float __attribute__((const, overloadable))
2671    native_asinpi(float v);
2672#endif
2673
2674#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2675extern float2 __attribute__((const, overloadable))
2676    native_asinpi(float2 v);
2677#endif
2678
2679#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2680extern float3 __attribute__((const, overloadable))
2681    native_asinpi(float3 v);
2682#endif
2683
2684#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2685extern float4 __attribute__((const, overloadable))
2686    native_asinpi(float4 v);
2687#endif
2688
2689/*
2690 * native_atan: Approximate inverse tangent
2691 *
2692 * Returns the approximate inverse tangent, in radians.
2693 *
2694 * See also atan().
2695 */
2696#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2697extern float __attribute__((const, overloadable))
2698    native_atan(float v);
2699#endif
2700
2701#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2702extern float2 __attribute__((const, overloadable))
2703    native_atan(float2 v);
2704#endif
2705
2706#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2707extern float3 __attribute__((const, overloadable))
2708    native_atan(float3 v);
2709#endif
2710
2711#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2712extern float4 __attribute__((const, overloadable))
2713    native_atan(float4 v);
2714#endif
2715
2716/*
2717 * native_atan2: Approximate inverse tangent of a ratio
2718 *
2719 * Returns the approximate inverse tangent of (numerator / denominator), in radians.
2720 *
2721 * See also atan2().
2722 *
2723 * Parameters:
2724 *   numerator The numerator
2725 *   denominator The denominator.  Can be 0.
2726 */
2727#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2728extern float __attribute__((const, overloadable))
2729    native_atan2(float numerator, float denominator);
2730#endif
2731
2732#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2733extern float2 __attribute__((const, overloadable))
2734    native_atan2(float2 numerator, float2 denominator);
2735#endif
2736
2737#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2738extern float3 __attribute__((const, overloadable))
2739    native_atan2(float3 numerator, float3 denominator);
2740#endif
2741
2742#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2743extern float4 __attribute__((const, overloadable))
2744    native_atan2(float4 numerator, float4 denominator);
2745#endif
2746
2747/*
2748 * native_atan2pi: Approximate inverse tangent of a ratio, divided by pi
2749 *
2750 * Returns the approximate inverse tangent of (numerator / denominator), in radians, divided by pi.
2751 *
2752 * To get an inverse tangent measured in degrees, use atan2pi(n, d) * 180.f.
2753 *
2754 * See also atan2pi().
2755 *
2756 * Parameters:
2757 *   numerator The numerator
2758 *   denominator The denominator.  Can be 0.
2759 */
2760#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2761extern float __attribute__((const, overloadable))
2762    native_atan2pi(float numerator, float denominator);
2763#endif
2764
2765#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2766extern float2 __attribute__((const, overloadable))
2767    native_atan2pi(float2 numerator, float2 denominator);
2768#endif
2769
2770#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2771extern float3 __attribute__((const, overloadable))
2772    native_atan2pi(float3 numerator, float3 denominator);
2773#endif
2774
2775#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2776extern float4 __attribute__((const, overloadable))
2777    native_atan2pi(float4 numerator, float4 denominator);
2778#endif
2779
2780/*
2781 * native_atanh: Approximate inverse hyperbolic tangent
2782 *
2783 * Returns the approximate inverse hyperbolic tangent, in radians.
2784 *
2785 * See also atanh().
2786 */
2787#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2788extern float __attribute__((const, overloadable))
2789    native_atanh(float v);
2790#endif
2791
2792#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2793extern float2 __attribute__((const, overloadable))
2794    native_atanh(float2 v);
2795#endif
2796
2797#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2798extern float3 __attribute__((const, overloadable))
2799    native_atanh(float3 v);
2800#endif
2801
2802#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2803extern float4 __attribute__((const, overloadable))
2804    native_atanh(float4 v);
2805#endif
2806
2807/*
2808 * native_atanpi: Approximate inverse tangent divided by pi
2809 *
2810 * Returns the approximate inverse tangent in radians, divided by pi.
2811 *
2812 * To get an inverse tangent measured in degrees, use atanpi(a) * 180.f.
2813 *
2814 * See also atanpi().
2815 */
2816#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2817extern float __attribute__((const, overloadable))
2818    native_atanpi(float v);
2819#endif
2820
2821#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2822extern float2 __attribute__((const, overloadable))
2823    native_atanpi(float2 v);
2824#endif
2825
2826#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2827extern float3 __attribute__((const, overloadable))
2828    native_atanpi(float3 v);
2829#endif
2830
2831#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2832extern float4 __attribute__((const, overloadable))
2833    native_atanpi(float4 v);
2834#endif
2835
2836/*
2837 * native_cbrt: Approximate cube root
2838 *
2839 * Returns the approximate cubic root.
2840 *
2841 * See also cbrt().
2842 */
2843#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2844extern float __attribute__((const, overloadable))
2845    native_cbrt(float v);
2846#endif
2847
2848#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2849extern float2 __attribute__((const, overloadable))
2850    native_cbrt(float2 v);
2851#endif
2852
2853#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2854extern float3 __attribute__((const, overloadable))
2855    native_cbrt(float3 v);
2856#endif
2857
2858#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2859extern float4 __attribute__((const, overloadable))
2860    native_cbrt(float4 v);
2861#endif
2862
2863/*
2864 * native_cos: Approximate cosine
2865 *
2866 * Returns the approximate cosine of an angle measured in radians.
2867 *
2868 * See also cos().
2869 */
2870#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2871extern float __attribute__((const, overloadable))
2872    native_cos(float v);
2873#endif
2874
2875#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2876extern float2 __attribute__((const, overloadable))
2877    native_cos(float2 v);
2878#endif
2879
2880#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2881extern float3 __attribute__((const, overloadable))
2882    native_cos(float3 v);
2883#endif
2884
2885#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2886extern float4 __attribute__((const, overloadable))
2887    native_cos(float4 v);
2888#endif
2889
2890/*
2891 * native_cosh: Approximate hypebolic cosine
2892 *
2893 * Returns the approximate hypebolic cosine.
2894 *
2895 * See also cosh().
2896 */
2897#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2898extern float __attribute__((const, overloadable))
2899    native_cosh(float v);
2900#endif
2901
2902#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2903extern float2 __attribute__((const, overloadable))
2904    native_cosh(float2 v);
2905#endif
2906
2907#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2908extern float3 __attribute__((const, overloadable))
2909    native_cosh(float3 v);
2910#endif
2911
2912#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2913extern float4 __attribute__((const, overloadable))
2914    native_cosh(float4 v);
2915#endif
2916
2917/*
2918 * native_cospi: Approximate cosine of a number multiplied by pi
2919 *
2920 * Returns the approximate cosine of (v * pi), where (v * pi) is measured in radians.
2921 *
2922 * To get the cosine of a value measured in degrees, call cospi(v / 180.f).
2923 *
2924 * See also cospi().
2925 */
2926#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2927extern float __attribute__((const, overloadable))
2928    native_cospi(float v);
2929#endif
2930
2931#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2932extern float2 __attribute__((const, overloadable))
2933    native_cospi(float2 v);
2934#endif
2935
2936#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2937extern float3 __attribute__((const, overloadable))
2938    native_cospi(float3 v);
2939#endif
2940
2941#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2942extern float4 __attribute__((const, overloadable))
2943    native_cospi(float4 v);
2944#endif
2945
2946/*
2947 * native_divide: Approximate division
2948 *
2949 * Computes the approximate division of two values.
2950 */
2951#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2952extern float __attribute__((const, overloadable))
2953    native_divide(float left_vector, float right_vector);
2954#endif
2955
2956#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2957extern float2 __attribute__((const, overloadable))
2958    native_divide(float2 left_vector, float2 right_vector);
2959#endif
2960
2961#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2962extern float3 __attribute__((const, overloadable))
2963    native_divide(float3 left_vector, float3 right_vector);
2964#endif
2965
2966#if (defined(RS_VERSION) && (RS_VERSION >= 21))
2967extern float4 __attribute__((const, overloadable))
2968    native_divide(float4 left_vector, float4 right_vector);
2969#endif
2970
2971/*
2972 * native_exp: Approximate e raised to a number
2973 *
2974 * Fast approximate exp.
2975 *
2976 * 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.
2977 *
2978 * See also exp().
2979 */
2980#if (defined(RS_VERSION) && (RS_VERSION >= 18))
2981extern float __attribute__((const, overloadable))
2982    native_exp(float v);
2983#endif
2984
2985#if (defined(RS_VERSION) && (RS_VERSION >= 18))
2986extern float2 __attribute__((const, overloadable))
2987    native_exp(float2 v);
2988#endif
2989
2990#if (defined(RS_VERSION) && (RS_VERSION >= 18))
2991extern float3 __attribute__((const, overloadable))
2992    native_exp(float3 v);
2993#endif
2994
2995#if (defined(RS_VERSION) && (RS_VERSION >= 18))
2996extern float4 __attribute__((const, overloadable))
2997    native_exp(float4 v);
2998#endif
2999
3000/*
3001 * native_exp10: Approximate 10 raised to a number
3002 *
3003 * Fast approximate exp10.
3004 *
3005 * 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.
3006 *
3007 * See also exp10().
3008 */
3009#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3010extern float __attribute__((const, overloadable))
3011    native_exp10(float v);
3012#endif
3013
3014#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3015extern float2 __attribute__((const, overloadable))
3016    native_exp10(float2 v);
3017#endif
3018
3019#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3020extern float3 __attribute__((const, overloadable))
3021    native_exp10(float3 v);
3022#endif
3023
3024#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3025extern float4 __attribute__((const, overloadable))
3026    native_exp10(float4 v);
3027#endif
3028
3029/*
3030 * native_exp2: Approximate 2 raised to a number
3031 *
3032 * Fast approximate exp2.
3033 *
3034 * 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.
3035 *
3036 * See also exp2().
3037 */
3038#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3039extern float __attribute__((const, overloadable))
3040    native_exp2(float v);
3041#endif
3042
3043#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3044extern float2 __attribute__((const, overloadable))
3045    native_exp2(float2 v);
3046#endif
3047
3048#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3049extern float3 __attribute__((const, overloadable))
3050    native_exp2(float3 v);
3051#endif
3052
3053#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3054extern float4 __attribute__((const, overloadable))
3055    native_exp2(float4 v);
3056#endif
3057
3058/*
3059 * native_expm1: Approximate e raised to a number minus one
3060 *
3061 * Returns the approximate (e ^ v) - 1.
3062 *
3063 * See also expm1().
3064 */
3065#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3066extern float __attribute__((const, overloadable))
3067    native_expm1(float v);
3068#endif
3069
3070#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3071extern float2 __attribute__((const, overloadable))
3072    native_expm1(float2 v);
3073#endif
3074
3075#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3076extern float3 __attribute__((const, overloadable))
3077    native_expm1(float3 v);
3078#endif
3079
3080#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3081extern float4 __attribute__((const, overloadable))
3082    native_expm1(float4 v);
3083#endif
3084
3085/*
3086 * native_hypot: Approximate hypotenuse
3087 *
3088 * Returns the approximate native_sqrt(a * a + b * b)
3089 *
3090 * See also hypot().
3091 */
3092#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3093extern float __attribute__((const, overloadable))
3094    native_hypot(float a, float b);
3095#endif
3096
3097#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3098extern float2 __attribute__((const, overloadable))
3099    native_hypot(float2 a, float2 b);
3100#endif
3101
3102#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3103extern float3 __attribute__((const, overloadable))
3104    native_hypot(float3 a, float3 b);
3105#endif
3106
3107#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3108extern float4 __attribute__((const, overloadable))
3109    native_hypot(float4 a, float4 b);
3110#endif
3111
3112/*
3113 * native_log: Approximate natural logarithm
3114 *
3115 * Fast approximate log.
3116 *
3117 * It is not accurate for values very close to zero.
3118 *
3119 * See also log().
3120 */
3121#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3122extern float __attribute__((const, overloadable))
3123    native_log(float v);
3124#endif
3125
3126#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3127extern float2 __attribute__((const, overloadable))
3128    native_log(float2 v);
3129#endif
3130
3131#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3132extern float3 __attribute__((const, overloadable))
3133    native_log(float3 v);
3134#endif
3135
3136#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3137extern float4 __attribute__((const, overloadable))
3138    native_log(float4 v);
3139#endif
3140
3141/*
3142 * native_log10: Approximate base 10 logarithm
3143 *
3144 * Fast approximate log10.
3145 *
3146 * It is not accurate for values very close to zero.
3147 *
3148 * See also log10().
3149 */
3150#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3151extern float __attribute__((const, overloadable))
3152    native_log10(float v);
3153#endif
3154
3155#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3156extern float2 __attribute__((const, overloadable))
3157    native_log10(float2 v);
3158#endif
3159
3160#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3161extern float3 __attribute__((const, overloadable))
3162    native_log10(float3 v);
3163#endif
3164
3165#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3166extern float4 __attribute__((const, overloadable))
3167    native_log10(float4 v);
3168#endif
3169
3170/*
3171 * native_log1p: Approximate natural logarithm of a value plus 1
3172 *
3173 * Returns the approximate natural logarithm of (v + 1.0f)
3174 *
3175 * See also log1p().
3176 */
3177#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3178extern float __attribute__((const, overloadable))
3179    native_log1p(float v);
3180#endif
3181
3182#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3183extern float2 __attribute__((const, overloadable))
3184    native_log1p(float2 v);
3185#endif
3186
3187#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3188extern float3 __attribute__((const, overloadable))
3189    native_log1p(float3 v);
3190#endif
3191
3192#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3193extern float4 __attribute__((const, overloadable))
3194    native_log1p(float4 v);
3195#endif
3196
3197/*
3198 * native_log2: Approximate base 2 logarithm
3199 *
3200 * Fast approximate log2.
3201 *
3202 * It is not accurate for values very close to zero.
3203 *
3204 * See also log2().
3205 */
3206#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3207extern float __attribute__((const, overloadable))
3208    native_log2(float v);
3209#endif
3210
3211#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3212extern float2 __attribute__((const, overloadable))
3213    native_log2(float2 v);
3214#endif
3215
3216#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3217extern float3 __attribute__((const, overloadable))
3218    native_log2(float3 v);
3219#endif
3220
3221#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3222extern float4 __attribute__((const, overloadable))
3223    native_log2(float4 v);
3224#endif
3225
3226/*
3227 * native_powr: Approximate positive base raised to an exponent
3228 *
3229 * Fast approximate (base ^ exponent).
3230 *
3231 * See also powr().
3232 *
3233 * Parameters:
3234 *   base Must be between 0.f and 256.f.  The function is not accurate for values very close to zero.
3235 *   exponent Must be between -15.f and 15.f.
3236 */
3237#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3238extern float __attribute__((const, overloadable))
3239    native_powr(float base, float exponent);
3240#endif
3241
3242#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3243extern float2 __attribute__((const, overloadable))
3244    native_powr(float2 base, float2 exponent);
3245#endif
3246
3247#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3248extern float3 __attribute__((const, overloadable))
3249    native_powr(float3 base, float3 exponent);
3250#endif
3251
3252#if (defined(RS_VERSION) && (RS_VERSION >= 18))
3253extern float4 __attribute__((const, overloadable))
3254    native_powr(float4 base, float4 exponent);
3255#endif
3256
3257/*
3258 * native_recip: Approximate reciprocal
3259 *
3260 * Returns the approximate approximate reciprocal of a value.
3261 *
3262 * See also half_recip().
3263 */
3264#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3265extern float __attribute__((const, overloadable))
3266    native_recip(float v);
3267#endif
3268
3269#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3270extern float2 __attribute__((const, overloadable))
3271    native_recip(float2 v);
3272#endif
3273
3274#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3275extern float3 __attribute__((const, overloadable))
3276    native_recip(float3 v);
3277#endif
3278
3279#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3280extern float4 __attribute__((const, overloadable))
3281    native_recip(float4 v);
3282#endif
3283
3284/*
3285 * native_rootn: Approximate nth root
3286 *
3287 * Compute the approximate Nth root of a value.
3288 *
3289 * See also rootn().
3290 */
3291#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3292extern float __attribute__((const, overloadable))
3293    native_rootn(float v, int n);
3294#endif
3295
3296#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3297extern float2 __attribute__((const, overloadable))
3298    native_rootn(float2 v, int2 n);
3299#endif
3300
3301#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3302extern float3 __attribute__((const, overloadable))
3303    native_rootn(float3 v, int3 n);
3304#endif
3305
3306#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3307extern float4 __attribute__((const, overloadable))
3308    native_rootn(float4 v, int4 n);
3309#endif
3310
3311/*
3312 * native_rsqrt: Approximate reciprocal of a square root
3313 *
3314 * Returns approximate (1 / sqrt(v)).
3315 *
3316 * See also rsqrt(), half_rsqrt().
3317 */
3318#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3319extern float __attribute__((const, overloadable))
3320    native_rsqrt(float v);
3321#endif
3322
3323#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3324extern float2 __attribute__((const, overloadable))
3325    native_rsqrt(float2 v);
3326#endif
3327
3328#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3329extern float3 __attribute__((const, overloadable))
3330    native_rsqrt(float3 v);
3331#endif
3332
3333#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3334extern float4 __attribute__((const, overloadable))
3335    native_rsqrt(float4 v);
3336#endif
3337
3338/*
3339 * native_sin: Approximate sine
3340 *
3341 * Returns the approximate sine of an angle measured in radians.
3342 *
3343 * See also sin().
3344 */
3345#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3346extern float __attribute__((const, overloadable))
3347    native_sin(float v);
3348#endif
3349
3350#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3351extern float2 __attribute__((const, overloadable))
3352    native_sin(float2 v);
3353#endif
3354
3355#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3356extern float3 __attribute__((const, overloadable))
3357    native_sin(float3 v);
3358#endif
3359
3360#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3361extern float4 __attribute__((const, overloadable))
3362    native_sin(float4 v);
3363#endif
3364
3365/*
3366 * native_sincos: Approximate sine and cosine
3367 *
3368 * Returns the approximate sine and cosine of a value.
3369 *
3370 * See also sincos().
3371 *
3372 * Parameters:
3373 *   v The incoming value in radians.
3374 *   cos *cos will be set to the cosine value.
3375 *
3376 * Returns: sine
3377 */
3378#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3379extern float __attribute__((overloadable))
3380    native_sincos(float v, float* cos);
3381#endif
3382
3383#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3384extern float2 __attribute__((overloadable))
3385    native_sincos(float2 v, float2* cos);
3386#endif
3387
3388#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3389extern float3 __attribute__((overloadable))
3390    native_sincos(float3 v, float3* cos);
3391#endif
3392
3393#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3394extern float4 __attribute__((overloadable))
3395    native_sincos(float4 v, float4* cos);
3396#endif
3397
3398/*
3399 * native_sinh: Approximate hyperbolic sine
3400 *
3401 * Returns the approximate hyperbolic sine of a value specified in radians.
3402 *
3403 * See also sinh().
3404 */
3405#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3406extern float __attribute__((const, overloadable))
3407    native_sinh(float v);
3408#endif
3409
3410#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3411extern float2 __attribute__((const, overloadable))
3412    native_sinh(float2 v);
3413#endif
3414
3415#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3416extern float3 __attribute__((const, overloadable))
3417    native_sinh(float3 v);
3418#endif
3419
3420#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3421extern float4 __attribute__((const, overloadable))
3422    native_sinh(float4 v);
3423#endif
3424
3425/*
3426 * native_sinpi: Approximate sine of a number multiplied by pi
3427 *
3428 * Returns the approximate sine of (v * pi), where (v * pi) is measured in radians.
3429 *
3430 * To get the sine of a value measured in degrees, call sinpi(v / 180.f).
3431 *
3432 * See also sinpi().
3433 */
3434#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3435extern float __attribute__((const, overloadable))
3436    native_sinpi(float v);
3437#endif
3438
3439#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3440extern float2 __attribute__((const, overloadable))
3441    native_sinpi(float2 v);
3442#endif
3443
3444#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3445extern float3 __attribute__((const, overloadable))
3446    native_sinpi(float3 v);
3447#endif
3448
3449#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3450extern float4 __attribute__((const, overloadable))
3451    native_sinpi(float4 v);
3452#endif
3453
3454/*
3455 * native_sqrt: Approximate square root
3456 *
3457 * Returns the approximate sqrt(v).
3458 *
3459 * See also sqrt(), half_sqrt().
3460 */
3461#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3462extern float __attribute__((const, overloadable))
3463    native_sqrt(float v);
3464#endif
3465
3466#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3467extern float2 __attribute__((const, overloadable))
3468    native_sqrt(float2 v);
3469#endif
3470
3471#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3472extern float3 __attribute__((const, overloadable))
3473    native_sqrt(float3 v);
3474#endif
3475
3476#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3477extern float4 __attribute__((const, overloadable))
3478    native_sqrt(float4 v);
3479#endif
3480
3481/*
3482 * native_tan: Approximate tangent
3483 *
3484 * Returns the approximate tangent of an angle measured in radians.
3485 */
3486#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3487extern float __attribute__((const, overloadable))
3488    native_tan(float v);
3489#endif
3490
3491#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3492extern float2 __attribute__((const, overloadable))
3493    native_tan(float2 v);
3494#endif
3495
3496#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3497extern float3 __attribute__((const, overloadable))
3498    native_tan(float3 v);
3499#endif
3500
3501#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3502extern float4 __attribute__((const, overloadable))
3503    native_tan(float4 v);
3504#endif
3505
3506/*
3507 * native_tanh: Approximate hyperbolic tangent
3508 *
3509 * Returns the approximate hyperbolic tangent of a value.
3510 *
3511 * See also tanh().
3512 */
3513#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3514extern float __attribute__((const, overloadable))
3515    native_tanh(float v);
3516#endif
3517
3518#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3519extern float2 __attribute__((const, overloadable))
3520    native_tanh(float2 v);
3521#endif
3522
3523#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3524extern float3 __attribute__((const, overloadable))
3525    native_tanh(float3 v);
3526#endif
3527
3528#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3529extern float4 __attribute__((const, overloadable))
3530    native_tanh(float4 v);
3531#endif
3532
3533/*
3534 * native_tanpi: Approximate tangent of a number multiplied by pi
3535 *
3536 * Returns the approximate tangent of (v * pi), where (v * pi) is measured in radians.
3537 *
3538 * To get the tangent of a value measured in degrees, call tanpi(v / 180.f).
3539 *
3540 * See also tanpi().
3541 */
3542#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3543extern float __attribute__((const, overloadable))
3544    native_tanpi(float v);
3545#endif
3546
3547#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3548extern float2 __attribute__((const, overloadable))
3549    native_tanpi(float2 v);
3550#endif
3551
3552#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3553extern float3 __attribute__((const, overloadable))
3554    native_tanpi(float3 v);
3555#endif
3556
3557#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3558extern float4 __attribute__((const, overloadable))
3559    native_tanpi(float4 v);
3560#endif
3561
3562/*
3563 * nextafter: Next floating point number
3564 *
3565 * Returns the next representable floating point number from v towards target.
3566 *
3567 * In rs_fp_relaxed mode, a denormalized input value may not yield the next
3568 * denormalized  value, as support of denormalized values is optional in
3569 * relaxed mode.
3570 */
3571extern float __attribute__((const, overloadable))
3572    nextafter(float v, float target);
3573
3574extern float2 __attribute__((const, overloadable))
3575    nextafter(float2 v, float2 target);
3576
3577extern float3 __attribute__((const, overloadable))
3578    nextafter(float3 v, float3 target);
3579
3580extern float4 __attribute__((const, overloadable))
3581    nextafter(float4 v, float4 target);
3582
3583/*
3584 * pow: Base raised to an exponent
3585 *
3586 * Returns base raised to the power exponent, i.e. base ^ exponent.
3587 *
3588 * pown() and powr() are similar.  pown() takes an integer exponent. powr() assumes the base to be non-negative.
3589 */
3590extern float __attribute__((const, overloadable))
3591    pow(float base, float exponent);
3592
3593extern float2 __attribute__((const, overloadable))
3594    pow(float2 base, float2 exponent);
3595
3596extern float3 __attribute__((const, overloadable))
3597    pow(float3 base, float3 exponent);
3598
3599extern float4 __attribute__((const, overloadable))
3600    pow(float4 base, float4 exponent);
3601
3602/*
3603 * pown: Base raised to an integer exponent
3604 *
3605 * Returns base raised to the power exponent, i.e. base ^ exponent.
3606 *
3607 * pow() and powr() are similar.  The both take a float exponent. powr() also assumes the base to be non-negative.
3608 */
3609extern float __attribute__((const, overloadable))
3610    pown(float base, int exponent);
3611
3612extern float2 __attribute__((const, overloadable))
3613    pown(float2 base, int2 exponent);
3614
3615extern float3 __attribute__((const, overloadable))
3616    pown(float3 base, int3 exponent);
3617
3618extern float4 __attribute__((const, overloadable))
3619    pown(float4 base, int4 exponent);
3620
3621/*
3622 * powr: Positive base raised to an exponent
3623 *
3624 * Returns base raised to the power exponent, i.e. base ^ exponent.  base must be >= 0.
3625 *
3626 * pow() and pown() are similar.  They both make no assumptions about the base.  pow() takes a float exponent while pown() take an integer.
3627 *
3628 * See also native_powr().
3629 */
3630extern float __attribute__((const, overloadable))
3631    powr(float base, float exponent);
3632
3633extern float2 __attribute__((const, overloadable))
3634    powr(float2 base, float2 exponent);
3635
3636extern float3 __attribute__((const, overloadable))
3637    powr(float3 base, float3 exponent);
3638
3639extern float4 __attribute__((const, overloadable))
3640    powr(float4 base, float4 exponent);
3641
3642/*
3643 * radians: Converts degrees into radians
3644 *
3645 * Converts from degrees to radians.
3646 */
3647extern float __attribute__((const, overloadable))
3648    radians(float v);
3649
3650extern float2 __attribute__((const, overloadable))
3651    radians(float2 v);
3652
3653extern float3 __attribute__((const, overloadable))
3654    radians(float3 v);
3655
3656extern float4 __attribute__((const, overloadable))
3657    radians(float4 v);
3658
3659/*
3660 * remainder: Remainder of a division
3661 *
3662 * Returns the remainder of (numerator / denominator), where the quotient is rounded towards the nearest integer.
3663 *
3664 * The function fmod() is similar but rounds toward the closest interger.
3665 * For example, fmod(-3.8f, 2.f) returns -1.8f (-3.8f - -1.f * 2.f)
3666 * while remainder(-3.8f, 2.f) returns 0.2f (-3.8f - -2.f * 2.f).
3667 */
3668extern float __attribute__((const, overloadable))
3669    remainder(float numerator, float denominator);
3670
3671extern float2 __attribute__((const, overloadable))
3672    remainder(float2 numerator, float2 denominator);
3673
3674extern float3 __attribute__((const, overloadable))
3675    remainder(float3 numerator, float3 denominator);
3676
3677extern float4 __attribute__((const, overloadable))
3678    remainder(float4 numerator, float4 denominator);
3679
3680/*
3681 * remquo: Remainder and quotient of a division
3682 *
3683 * Returns the quotient and the remainder of (numerator / denominator).
3684 *
3685 * Only the sign and lowest three bits of the quotient are guaranteed to be accurate.
3686 *
3687 * 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 remquo(x, PI / 2.f, &quadrant) to reduce very large value of x to something within a limited range.
3688 *
3689 * Example: remquo(-23.5f, 8.f, &quot) sets the lowest three bits of quot to 3 and the sign negative.  It returns 0.5f.
3690 *
3691 * Parameters:
3692 *   numerator The numerator.
3693 *   denominator The denominator.
3694 *   quotient *quotient will be set to the integer quotient.
3695 *
3696 * Returns: The remainder, precise only for the low three bits.
3697 */
3698extern float __attribute__((overloadable))
3699    remquo(float numerator, float denominator, int* quotient);
3700
3701extern float2 __attribute__((overloadable))
3702    remquo(float2 numerator, float2 denominator, int2* quotient);
3703
3704extern float3 __attribute__((overloadable))
3705    remquo(float3 numerator, float3 denominator, int3* quotient);
3706
3707extern float4 __attribute__((overloadable))
3708    remquo(float4 numerator, float4 denominator, int4* quotient);
3709
3710/*
3711 * rint: Round to even
3712 *
3713 * Rounds to the nearest integral value.
3714 *
3715 * rint() rounds half values to even.  For example, rint(0.5f) returns 0.f and rint(1.5f) returns 2.f.  Similarly, rint(-0.5f) returns -0.f and rint(-1.5f) returns -2.f.
3716 *
3717 * round() is similar but rounds away from zero.  trunc() truncates the decimal fraction.
3718 */
3719extern float __attribute__((const, overloadable))
3720    rint(float v);
3721
3722extern float2 __attribute__((const, overloadable))
3723    rint(float2 v);
3724
3725extern float3 __attribute__((const, overloadable))
3726    rint(float3 v);
3727
3728extern float4 __attribute__((const, overloadable))
3729    rint(float4 v);
3730
3731/*
3732 * rootn: Nth root
3733 *
3734 * Compute the Nth root of a value.
3735 *
3736 * See also native_rootn().
3737 */
3738extern float __attribute__((const, overloadable))
3739    rootn(float v, int n);
3740
3741extern float2 __attribute__((const, overloadable))
3742    rootn(float2 v, int2 n);
3743
3744extern float3 __attribute__((const, overloadable))
3745    rootn(float3 v, int3 n);
3746
3747extern float4 __attribute__((const, overloadable))
3748    rootn(float4 v, int4 n);
3749
3750/*
3751 * round: Round away from zero
3752 *
3753 * Round to the nearest integral value.
3754 *
3755 * round() rounds half values away from zero.  For example, round(0.5f) returns 1.f and round(1.5f) returns 2.f.  Similarly, round(-0.5f) returns -1.f and round(-1.5f) returns -2.f.
3756 *
3757 * rint() is similar but rounds half values toward even.  trunc() truncates the decimal fraction.
3758 */
3759extern float __attribute__((const, overloadable))
3760    round(float v);
3761
3762extern float2 __attribute__((const, overloadable))
3763    round(float2 v);
3764
3765extern float3 __attribute__((const, overloadable))
3766    round(float3 v);
3767
3768extern float4 __attribute__((const, overloadable))
3769    round(float4 v);
3770
3771/*
3772 * rsqrt: Reciprocal of a square root
3773 *
3774 * Returns (1 / sqrt(v)).
3775 *
3776 * See also half_rsqrt(), native_rsqrt().
3777 */
3778extern float __attribute__((const, overloadable))
3779    rsqrt(float v);
3780
3781extern float2 __attribute__((const, overloadable))
3782    rsqrt(float2 v);
3783
3784extern float3 __attribute__((const, overloadable))
3785    rsqrt(float3 v);
3786
3787extern float4 __attribute__((const, overloadable))
3788    rsqrt(float4 v);
3789
3790/*
3791 * sign: Sign of a value
3792 *
3793 * Returns the sign of a value.
3794 *
3795 * if (v < 0) return -1.f;
3796 * else if (v > 0) return 1.f;
3797 * else return 0.f;
3798 */
3799extern float __attribute__((const, overloadable))
3800    sign(float v);
3801
3802extern float2 __attribute__((const, overloadable))
3803    sign(float2 v);
3804
3805extern float3 __attribute__((const, overloadable))
3806    sign(float3 v);
3807
3808extern float4 __attribute__((const, overloadable))
3809    sign(float4 v);
3810
3811/*
3812 * sin: Sine
3813 *
3814 * Returns the sine of an angle measured in radians.
3815 *
3816 * See also native_sin().
3817 */
3818extern float __attribute__((const, overloadable))
3819    sin(float v);
3820
3821extern float2 __attribute__((const, overloadable))
3822    sin(float2 v);
3823
3824extern float3 __attribute__((const, overloadable))
3825    sin(float3 v);
3826
3827extern float4 __attribute__((const, overloadable))
3828    sin(float4 v);
3829
3830/*
3831 * sincos: Sine and cosine
3832 *
3833 * Returns the sine and cosine of a value.
3834 *
3835 * See also native_sincos().
3836 *
3837 * Parameters:
3838 *   v The incoming value in radians
3839 *   cos *cos will be set to the cosine value.
3840 *
3841 * Returns: sine of v
3842 */
3843extern float __attribute__((overloadable))
3844    sincos(float v, float* cos);
3845
3846extern float2 __attribute__((overloadable))
3847    sincos(float2 v, float2* cos);
3848
3849extern float3 __attribute__((overloadable))
3850    sincos(float3 v, float3* cos);
3851
3852extern float4 __attribute__((overloadable))
3853    sincos(float4 v, float4* cos);
3854
3855/*
3856 * sinh: Hyperbolic sine
3857 *
3858 * Returns the hyperbolic sine of v, where v is measured in radians.
3859 *
3860 * See also native_sinh().
3861 */
3862extern float __attribute__((const, overloadable))
3863    sinh(float v);
3864
3865extern float2 __attribute__((const, overloadable))
3866    sinh(float2 v);
3867
3868extern float3 __attribute__((const, overloadable))
3869    sinh(float3 v);
3870
3871extern float4 __attribute__((const, overloadable))
3872    sinh(float4 v);
3873
3874/*
3875 * sinpi: Sine of a number multiplied by pi
3876 *
3877 * Returns the sine of (v * pi), where (v * pi) is measured in radians.
3878 *
3879 * To get the sine of a value measured in degrees, call sinpi(v / 180.f).
3880 *
3881 * See also native_sinpi().
3882 */
3883extern float __attribute__((const, overloadable))
3884    sinpi(float v);
3885
3886extern float2 __attribute__((const, overloadable))
3887    sinpi(float2 v);
3888
3889extern float3 __attribute__((const, overloadable))
3890    sinpi(float3 v);
3891
3892extern float4 __attribute__((const, overloadable))
3893    sinpi(float4 v);
3894
3895/*
3896 * sqrt: Square root
3897 *
3898 * Returns the square root of a value.
3899 *
3900 * See also half_sqrt(), native_sqrt().
3901 */
3902extern float __attribute__((const, overloadable))
3903    sqrt(float v);
3904
3905extern float2 __attribute__((const, overloadable))
3906    sqrt(float2 v);
3907
3908extern float3 __attribute__((const, overloadable))
3909    sqrt(float3 v);
3910
3911extern float4 __attribute__((const, overloadable))
3912    sqrt(float4 v);
3913
3914/*
3915 * step: 0 if less than a value, 0 otherwise
3916 *
3917 * Returns 0.f if v < edge, 1.f otherwise.
3918 *
3919 * This can be useful to create conditional computations without using loops and branching instructions.  For example, instead of computing (a[i] < b[i]) ? 0.f : atan2(a[i], b[i]) for the corresponding elements of a vector, you could instead use step(a, b) * atan2(a, b).
3920 */
3921extern float __attribute__((const, overloadable))
3922    step(float edge, float v);
3923
3924extern float2 __attribute__((const, overloadable))
3925    step(float2 edge, float2 v);
3926
3927extern float3 __attribute__((const, overloadable))
3928    step(float3 edge, float3 v);
3929
3930extern float4 __attribute__((const, overloadable))
3931    step(float4 edge, float4 v);
3932
3933extern float2 __attribute__((const, overloadable))
3934    step(float2 edge, float v);
3935
3936extern float3 __attribute__((const, overloadable))
3937    step(float3 edge, float v);
3938
3939extern float4 __attribute__((const, overloadable))
3940    step(float4 edge, float v);
3941
3942#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3943extern float2 __attribute__((const, overloadable))
3944    step(float edge, float2 v);
3945#endif
3946
3947#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3948extern float3 __attribute__((const, overloadable))
3949    step(float edge, float3 v);
3950#endif
3951
3952#if (defined(RS_VERSION) && (RS_VERSION >= 21))
3953extern float4 __attribute__((const, overloadable))
3954    step(float edge, float4 v);
3955#endif
3956
3957/*
3958 * tan: Tangent
3959 *
3960 * Returns the tangent of an angle measured in radians.
3961 *
3962 * See also native_tan().
3963 */
3964extern float __attribute__((const, overloadable))
3965    tan(float v);
3966
3967extern float2 __attribute__((const, overloadable))
3968    tan(float2 v);
3969
3970extern float3 __attribute__((const, overloadable))
3971    tan(float3 v);
3972
3973extern float4 __attribute__((const, overloadable))
3974    tan(float4 v);
3975
3976/*
3977 * tanh: Hyperbolic tangent
3978 *
3979 * Returns the hyperbolic tangent of a value.
3980 *
3981 * See also native_tanh().
3982 */
3983extern float __attribute__((const, overloadable))
3984    tanh(float v);
3985
3986extern float2 __attribute__((const, overloadable))
3987    tanh(float2 v);
3988
3989extern float3 __attribute__((const, overloadable))
3990    tanh(float3 v);
3991
3992extern float4 __attribute__((const, overloadable))
3993    tanh(float4 v);
3994
3995/*
3996 * tanpi: Tangent of a number multiplied by pi
3997 *
3998 * Returns the tangent of (v * pi), where (v * pi) is measured in radians.
3999 *
4000 * To get the tangent of a value measured in degrees, call tanpi(v / 180.f).
4001 *
4002 * See also native_tanpi().
4003 */
4004extern float __attribute__((const, overloadable))
4005    tanpi(float v);
4006
4007extern float2 __attribute__((const, overloadable))
4008    tanpi(float2 v);
4009
4010extern float3 __attribute__((const, overloadable))
4011    tanpi(float3 v);
4012
4013extern float4 __attribute__((const, overloadable))
4014    tanpi(float4 v);
4015
4016/*
4017 * tgamma: Gamma function
4018 *
4019 * Returns the gamma function of a value.
4020 *
4021 * See also lgamma().
4022 */
4023extern float __attribute__((const, overloadable))
4024    tgamma(float v);
4025
4026extern float2 __attribute__((const, overloadable))
4027    tgamma(float2 v);
4028
4029extern float3 __attribute__((const, overloadable))
4030    tgamma(float3 v);
4031
4032extern float4 __attribute__((const, overloadable))
4033    tgamma(float4 v);
4034
4035/*
4036 * trunc: Truncates a floating point
4037 *
4038 * Rounds to integral using truncation.
4039 *
4040 * For example, trunc(1.7f) returns 1.f and trunc(-1.7f) returns -1.f.
4041 *
4042 * See rint() and round() for other rounding options.
4043 */
4044extern float __attribute__((const, overloadable))
4045    trunc(float v);
4046
4047extern float2 __attribute__((const, overloadable))
4048    trunc(float2 v);
4049
4050extern float3 __attribute__((const, overloadable))
4051    trunc(float3 v);
4052
4053extern float4 __attribute__((const, overloadable))
4054    trunc(float4 v);
4055
4056/*
4057 * rsClamp: Restrain a value to a range
4058 *
4059 * Clamp a value between low and high.
4060 *
4061 * Deprecated.  Use clamp() instead.
4062 *
4063 * Parameters:
4064 *   amount The value to clamp
4065 *   low Lower bound
4066 *   high Upper bound
4067 */
4068extern char __attribute__((const, always_inline, overloadable))
4069    rsClamp(char amount, char low, char high);
4070
4071extern uchar __attribute__((const, always_inline, overloadable))
4072    rsClamp(uchar amount, uchar low, uchar high);
4073
4074extern short __attribute__((const, always_inline, overloadable))
4075    rsClamp(short amount, short low, short high);
4076
4077extern ushort __attribute__((const, always_inline, overloadable))
4078    rsClamp(ushort amount, ushort low, ushort high);
4079
4080extern int __attribute__((const, always_inline, overloadable))
4081    rsClamp(int amount, int low, int high);
4082
4083extern uint __attribute__((const, always_inline, overloadable))
4084    rsClamp(uint amount, uint low, uint high);
4085
4086/*
4087 * Returns the fractional part of a float
4088 */
4089extern float __attribute__((const, overloadable))
4090    rsFrac(float v);
4091
4092/*
4093 * Return a random value between 0 (or min_value) and max_malue.
4094 */
4095extern int __attribute__((overloadable))
4096    rsRand(int max_value);
4097
4098extern int __attribute__((overloadable))
4099    rsRand(int min_value, int max_value);
4100
4101extern float __attribute__((overloadable))
4102    rsRand(float max_value);
4103
4104extern float __attribute__((overloadable))
4105    rsRand(float min_value, float max_value);
4106
4107#endif // RENDERSCRIPT_RS_MATH_RSH
4108