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