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