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