Blender  V3.3
math_base_inline.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #ifndef __MATH_BASE_INLINE_C__
9 #define __MATH_BASE_INLINE_C__
10 
11 #include <float.h>
12 #include <limits.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 
16 #include "BLI_math_base.h"
17 #include "BLI_simd.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /* copied from BLI_utildefines.h */
24 #ifdef __GNUC__
25 # define UNLIKELY(x) __builtin_expect(!!(x), 0)
26 #else
27 # define UNLIKELY(x) (x)
28 #endif
29 
30 MINLINE float pow2f(float x)
31 {
32  return x * x;
33 }
34 MINLINE float pow3f(float x)
35 {
36  return pow2f(x) * x;
37 }
38 MINLINE float pow4f(float x)
39 {
40  return pow2f(pow2f(x));
41 }
42 MINLINE float pow5f(float x)
43 {
44  return pow4f(x) * x;
45 }
46 MINLINE float pow7f(float x)
47 {
48  return pow2f(pow3f(x)) * x;
49 }
50 
51 MINLINE float sqrt3f(float f)
52 {
53  if (UNLIKELY(f == 0.0f)) {
54  return 0.0f;
55  }
56  else if (UNLIKELY(f < 0.0f)) {
57  return -(float)(exp(log(-f) / 3.0));
58  }
59  else {
60  return (float)(exp(log(f) / 3.0));
61  }
62 }
63 
64 MINLINE double sqrt3d(double d)
65 {
66  if (UNLIKELY(d == 0.0)) {
67  return 0.0;
68  }
69  else if (UNLIKELY(d < 0.0)) {
70  return -exp(log(-d) / 3.0);
71  }
72  else {
73  return exp(log(d) / 3.0);
74  }
75 }
76 
77 MINLINE float sqrtf_signed(float f)
78 {
79  return (f >= 0.0f) ? sqrtf(f) : -sqrtf(-f);
80 }
81 
82 MINLINE float saacos(float fac)
83 {
84  if (UNLIKELY(fac <= -1.0f)) {
85  return (float)M_PI;
86  }
87  else if (UNLIKELY(fac >= 1.0f)) {
88  return 0.0f;
89  }
90  else {
91  return acosf(fac);
92  }
93 }
94 
95 MINLINE float saasin(float fac)
96 {
97  if (UNLIKELY(fac <= -1.0f)) {
98  return (float)-M_PI_2;
99  }
100  else if (UNLIKELY(fac >= 1.0f)) {
101  return (float)M_PI_2;
102  }
103  else {
104  return asinf(fac);
105  }
106 }
107 
108 MINLINE float sasqrt(float fac)
109 {
110  if (UNLIKELY(fac <= 0.0f)) {
111  return 0.0f;
112  }
113  else {
114  return sqrtf(fac);
115  }
116 }
117 
118 MINLINE float saacosf(float fac)
119 {
120  if (UNLIKELY(fac <= -1.0f)) {
121  return (float)M_PI;
122  }
123  else if (UNLIKELY(fac >= 1.0f)) {
124  return 0.0f;
125  }
126  else {
127  return acosf(fac);
128  }
129 }
130 
131 MINLINE float saasinf(float fac)
132 {
133  if (UNLIKELY(fac <= -1.0f)) {
134  return (float)-M_PI_2;
135  }
136  else if (UNLIKELY(fac >= 1.0f)) {
137  return (float)M_PI_2;
138  }
139  else {
140  return asinf(fac);
141  }
142 }
143 
144 MINLINE float sasqrtf(float fac)
145 {
146  if (UNLIKELY(fac <= 0.0f)) {
147  return 0.0f;
148  }
149  else {
150  return sqrtf(fac);
151  }
152 }
153 
154 MINLINE float interpf(float target, float origin, float fac)
155 {
156  return (fac * target) + (1.0f - fac) * origin;
157 }
158 
159 MINLINE double interpd(double target, double origin, double fac)
160 {
161  return (fac * target) + (1.0f - fac) * origin;
162 }
163 
164 MINLINE float ratiof(float min, float max, float pos)
165 {
166  float range = max - min;
167  return range == 0 ? 0 : ((pos - min) / range);
168 }
169 
170 MINLINE double ratiod(double min, double max, double pos)
171 {
172  double range = max - min;
173  return range == 0 ? 0 : ((pos - min) / range);
174 }
175 
176 MINLINE float scalenorm(float a, float b, float x)
177 {
178  BLI_assert(x <= 1 && x >= 0);
179  return (x * (b - a)) + a;
180 }
181 
182 MINLINE double scalenormd(double a, double b, double x)
183 {
184  BLI_assert(x <= 1 && x >= 0);
185  return (x * (b - a)) + a;
186 }
187 
188 MINLINE float power_of_2(float val)
189 {
190  return (float)pow(2.0, ceil(log((double)val) / M_LN2));
191 }
192 
194 {
195  return (n & (n - 1)) == 0;
196 }
197 
199 {
200  if (is_power_of_2_i(n)) {
201  return n;
202  }
203 
204  do {
205  n = n & (n - 1);
206  } while (!is_power_of_2_i(n));
207 
208  return n * 2;
209 }
210 
212 {
213  while (!is_power_of_2_i(n)) {
214  n = n & (n - 1);
215  }
216 
217  return n;
218 }
219 
220 MINLINE unsigned int power_of_2_max_u(unsigned int x)
221 {
222  x -= 1;
223  x |= (x >> 1);
224  x |= (x >> 2);
225  x |= (x >> 4);
226  x |= (x >> 8);
227  x |= (x >> 16);
228  return x + 1;
229 }
230 
231 MINLINE unsigned int power_of_2_min_u(unsigned int x)
232 {
233  x |= (x >> 1);
234  x |= (x >> 2);
235  x |= (x >> 4);
236  x |= (x >> 8);
237  x |= (x >> 16);
238  return x - (x >> 1);
239 }
240 
241 MINLINE unsigned int log2_floor_u(unsigned int x)
242 {
243  return x <= 1 ? 0 : 1 + log2_floor_u(x >> 1);
244 }
245 
246 MINLINE unsigned int log2_ceil_u(unsigned int x)
247 {
248  if (is_power_of_2_i((int)x)) {
249  return log2_floor_u(x);
250  }
251  else {
252  return log2_floor_u(x) + 1;
253  }
254 }
255 
256 /* rounding and clamping */
257 
258 #define _round_clamp_fl_impl(arg, ty, min, max) \
259  { \
260  float r = floorf(arg + 0.5f); \
261  if (UNLIKELY(r <= (float)min)) { \
262  return (ty)min; \
263  } \
264  else if (UNLIKELY(r >= (float)max)) { \
265  return (ty)max; \
266  } \
267  else { \
268  return (ty)r; \
269  } \
270  }
271 
272 #define _round_clamp_db_impl(arg, ty, min, max) \
273  { \
274  double r = floor(arg + 0.5); \
275  if (UNLIKELY(r <= (double)min)) { \
276  return (ty)min; \
277  } \
278  else if (UNLIKELY(r >= (double)max)) { \
279  return (ty)max; \
280  } \
281  else { \
282  return (ty)r; \
283  } \
284  }
285 
286 #define _round_fl_impl(arg, ty) \
287  { \
288  return (ty)floorf(arg + 0.5f); \
289  }
290 #define _round_db_impl(arg, ty) \
291  { \
292  return (ty)floor(arg + 0.5); \
293  }
294 
295 MINLINE signed char round_fl_to_char(float a){_round_fl_impl(a, signed char)} MINLINE
296  unsigned char round_fl_to_uchar(float a){_round_fl_impl(a, unsigned char)} MINLINE
298  unsigned short round_fl_to_ushort(float a){_round_fl_impl(a, unsigned short)} MINLINE
300  unsigned int round_fl_to_uint(float a){_round_fl_impl(a, unsigned int)}
301 
302 MINLINE signed char round_db_to_char(double a){_round_db_impl(a, signed char)} MINLINE
303  unsigned char round_db_to_uchar(double a){_round_db_impl(a, unsigned char)} MINLINE
304  short round_db_to_short(double a){_round_db_impl(a, short)} MINLINE
305  unsigned short round_db_to_ushort(double a){_round_db_impl(a, unsigned short)} MINLINE
307  unsigned int round_db_to_uint(double a)
308 {
309  _round_db_impl(a, unsigned int)
310 }
311 
312 #undef _round_fl_impl
313 #undef _round_db_impl
314 
315 MINLINE signed char round_fl_to_char_clamp(float a){
316  _round_clamp_fl_impl(a, signed char, SCHAR_MIN, SCHAR_MAX)} MINLINE
317  unsigned char round_fl_to_uchar_clamp(float a){
318  _round_clamp_fl_impl(a, unsigned char, 0, UCHAR_MAX)} MINLINE
320  _round_clamp_fl_impl(a, short, SHRT_MIN, SHRT_MAX)} MINLINE
321  unsigned short round_fl_to_ushort_clamp(float a){
322  _round_clamp_fl_impl(a, unsigned short, 0, USHRT_MAX)} MINLINE
323  int round_fl_to_int_clamp(float a){_round_clamp_fl_impl(a, int, INT_MIN, INT_MAX)} MINLINE
324  unsigned int round_fl_to_uint_clamp(float a){
325  _round_clamp_fl_impl(a, unsigned int, 0, UINT_MAX)}
326 
327 MINLINE signed char round_db_to_char_clamp(double a){
328  _round_clamp_db_impl(a, signed char, SCHAR_MIN, SCHAR_MAX)} MINLINE
329  unsigned char round_db_to_uchar_clamp(double a){
330  _round_clamp_db_impl(a, unsigned char, 0, UCHAR_MAX)} MINLINE
331  short round_db_to_short_clamp(double a){
332  _round_clamp_db_impl(a, short, SHRT_MIN, SHRT_MAX)} MINLINE
333  unsigned short round_db_to_ushort_clamp(double a){
334  _round_clamp_db_impl(a, unsigned short, 0, USHRT_MAX)} MINLINE
335  int round_db_to_int_clamp(double a){_round_clamp_db_impl(a, int, INT_MIN, INT_MAX)} MINLINE
336  unsigned int round_db_to_uint_clamp(double a)
337 {
338  _round_clamp_db_impl(a, unsigned int, 0, UINT_MAX)
339 }
340 
341 #undef _round_clamp_fl_impl
342 #undef _round_clamp_db_impl
343 
344 MINLINE float round_to_even(float f)
345 {
346  return roundf(f * 0.5f) * 2.0f;
347 }
348 
349 MINLINE int divide_round_i(int a, int b)
350 {
351  return (2 * a + b) / (2 * b);
352 }
353 
358 MINLINE int divide_floor_i(int a, int b)
359 {
360  int d = a / b;
361  int r = a % b; /* Optimizes into a single division. */
362  return r ? d - ((a < 0) ^ (b < 0)) : d;
363 }
364 
369 {
370  return (a + b - 1) / b;
371 }
372 
374 {
375  return (a + b - 1) / b;
376 }
377 
382 {
383  return divide_ceil_u(a, b) * b;
384 }
385 
387 {
388  return divide_ceil_ul(a, b) * b;
389 }
390 
391 MINLINE int mod_i(int i, int n)
392 {
393  return (i % n + n) % n;
394 }
395 
396 MINLINE float fractf(float a)
397 {
398  return a - floorf(a);
399 }
400 
401 /* Adapted from `godot-engine` math_funcs.h. */
402 MINLINE float wrapf(float value, float max, float min)
403 {
404  float range = max - min;
405  return (range != 0.0f) ? value - (range * floorf((value - min) / range)) : min;
406 }
407 
408 MINLINE float pingpongf(float value, float scale)
409 {
410  if (scale == 0.0f) {
411  return 0.0f;
412  }
413  return fabsf(fractf((value - scale) / (scale * 2.0f)) * scale * 2.0f - scale);
414 }
415 
416 /* Square. */
417 
418 MINLINE int square_s(short a)
419 {
420  return a * a;
421 }
422 
424 {
425  return a * a;
426 }
427 
428 MINLINE unsigned int square_uint(unsigned int a)
429 {
430  return a * a;
431 }
432 
433 MINLINE int square_uchar(unsigned char a)
434 {
435  return a * a;
436 }
437 
438 MINLINE float square_f(float a)
439 {
440  return a * a;
441 }
442 
443 MINLINE double square_d(double a)
444 {
445  return a * a;
446 }
447 
448 /* Cube. */
449 
450 MINLINE int cube_s(short a)
451 {
452  return a * a * a;
453 }
454 
455 MINLINE int cube_i(int a)
456 {
457  return a * a * a;
458 }
459 
460 MINLINE unsigned int cube_uint(unsigned int a)
461 {
462  return a * a * a;
463 }
464 
465 MINLINE int cube_uchar(unsigned char a)
466 {
467  return a * a * a;
468 }
469 
470 MINLINE float cube_f(float a)
471 {
472  return a * a * a;
473 }
474 
475 MINLINE double cube_d(double a)
476 {
477  return a * a * a;
478 }
479 
480 /* Min/max */
481 
482 MINLINE float min_ff(float a, float b)
483 {
484  return (a < b) ? a : b;
485 }
486 MINLINE float max_ff(float a, float b)
487 {
488  return (a > b) ? a : b;
489 }
490 /* See: https://www.iquilezles.org/www/articles/smin/smin.htm. */
491 MINLINE float smoothminf(float a, float b, float c)
492 {
493  if (c != 0.0f) {
494  float h = max_ff(c - fabsf(a - b), 0.0f) / c;
495  return min_ff(a, b) - h * h * h * c * (1.0f / 6.0f);
496  }
497  else {
498  return min_ff(a, b);
499  }
500 }
501 
502 MINLINE float smoothstep(float edge0, float edge1, float x)
503 {
504  float result;
505  if (x < edge0) {
506  result = 0.0f;
507  }
508  else if (x >= edge1) {
509  result = 1.0f;
510  }
511  else {
512  float t = (x - edge0) / (edge1 - edge0);
513  result = (3.0f - 2.0f * t) * (t * t);
514  }
515  return result;
516 }
517 
518 MINLINE double min_dd(double a, double b)
519 {
520  return (a < b) ? a : b;
521 }
522 MINLINE double max_dd(double a, double b)
523 {
524  return (a > b) ? a : b;
525 }
526 
527 MINLINE int min_ii(int a, int b)
528 {
529  return (a < b) ? a : b;
530 }
531 MINLINE int max_ii(int a, int b)
532 {
533  return (b < a) ? a : b;
534 }
535 
537 {
538  return (a < b) ? a : b;
539 }
541 {
542  return (b < a) ? a : b;
543 }
544 
545 MINLINE unsigned long long min_ulul(unsigned long long a, unsigned long long b)
546 {
547  return (a < b) ? a : b;
548 }
549 MINLINE unsigned long long max_ulul(unsigned long long a, unsigned long long b)
550 {
551  return (b < a) ? a : b;
552 }
553 
554 MINLINE float min_fff(float a, float b, float c)
555 {
556  return min_ff(min_ff(a, b), c);
557 }
558 MINLINE float max_fff(float a, float b, float c)
559 {
560  return max_ff(max_ff(a, b), c);
561 }
562 
563 MINLINE int min_iii(int a, int b, int c)
564 {
565  return min_ii(min_ii(a, b), c);
566 }
567 MINLINE int max_iii(int a, int b, int c)
568 {
569  return max_ii(max_ii(a, b), c);
570 }
571 
572 MINLINE float min_ffff(float a, float b, float c, float d)
573 {
574  return min_ff(min_fff(a, b, c), d);
575 }
576 MINLINE float max_ffff(float a, float b, float c, float d)
577 {
578  return max_ff(max_fff(a, b, c), d);
579 }
580 
581 MINLINE int min_iiii(int a, int b, int c, int d)
582 {
583  return min_ii(min_iii(a, b, c), d);
584 }
585 MINLINE int max_iiii(int a, int b, int c, int d)
586 {
587  return max_ii(max_iii(a, b, c), d);
588 }
589 
590 MINLINE size_t min_zz(size_t a, size_t b)
591 {
592  return (a < b) ? a : b;
593 }
594 MINLINE size_t max_zz(size_t a, size_t b)
595 {
596  return (b < a) ? a : b;
597 }
598 
599 MINLINE char min_cc(char a, char b)
600 {
601  return (a < b) ? a : b;
602 }
603 MINLINE char max_cc(char a, char b)
604 {
605  return (b < a) ? a : b;
606 }
607 
608 MINLINE int clamp_i(int value, int min, int max)
609 {
610  return min_ii(max_ii(value, min), max);
611 }
612 
613 MINLINE float clamp_f(float value, float min, float max)
614 {
615  if (value > max) {
616  return max;
617  }
618  else if (value < min) {
619  return min;
620  }
621  return value;
622 }
623 
624 MINLINE size_t clamp_z(size_t value, size_t min, size_t max)
625 {
626  return min_zz(max_zz(value, min), max);
627 }
628 
629 MINLINE int compare_ff(float a, float b, const float max_diff)
630 {
631  return fabsf(a - b) <= max_diff;
632 }
633 
634 MINLINE int compare_ff_relative(float a, float b, const float max_diff, const int max_ulps)
635 {
636  union {
637  float f;
638  int i;
639  } ua, ub;
640 
641  BLI_assert(sizeof(float) == sizeof(int));
642  BLI_assert(max_ulps < (1 << 22));
643 
644  if (fabsf(a - b) <= max_diff) {
645  return 1;
646  }
647 
648  ua.f = a;
649  ub.f = b;
650 
651  /* Important to compare sign from integers, since (-0.0f < 0) is false
652  * (though this shall not be an issue in common cases)... */
653  return ((ua.i < 0) != (ub.i < 0)) ? 0 : (abs(ua.i - ub.i) <= max_ulps) ? 1 : 0;
654 }
655 
656 MINLINE bool compare_threshold_relative(const float value1, const float value2, const float thresh)
657 {
658  const float abs_diff = fabsf(value1 - value2);
659  /* Avoid letting the threshold get too small just because the values happen to be close to zero.
660  */
661  if (fabsf(value2) < 1) {
662  return abs_diff > thresh;
663  }
664  /* Using relative threshold in general. */
665  return abs_diff > thresh * fabsf(value2);
666 }
667 
668 MINLINE float signf(float f)
669 {
670  return (f < 0.0f) ? -1.0f : 1.0f;
671 }
672 
673 MINLINE float compatible_signf(float f)
674 {
675  if (f > 0.0f) {
676  return 1.0f;
677  }
678  if (f < 0.0f) {
679  return -1.0f;
680  }
681  else {
682  return 0.0f;
683  }
684 }
685 
686 MINLINE int signum_i_ex(float a, float eps)
687 {
688  if (a > eps) {
689  return 1;
690  }
691  if (a < -eps) {
692  return -1;
693  }
694  else {
695  return 0;
696  }
697 }
698 
699 MINLINE int signum_i(float a)
700 {
701  if (a > 0.0f) {
702  return 1;
703  }
704  if (a < 0.0f) {
705  return -1;
706  }
707  else {
708  return 0;
709  }
710 }
711 
712 MINLINE int integer_digits_f(const float f)
713 {
714  return (f == 0.0f) ? 0 : (int)floor(log10(fabs(f))) + 1;
715 }
716 
717 MINLINE int integer_digits_d(const double d)
718 {
719  return (d == 0.0) ? 0 : (int)floor(log10(fabs(d))) + 1;
720 }
721 
722 MINLINE int integer_digits_i(const int i)
723 {
724  return (int)log10((double)i) + 1;
725 }
726 
727 /* Internal helpers for SSE2 implementation.
728  *
729  * NOTE: Are to be called ONLY from inside `#ifdef BLI_HAVE_SSE2` !!!
730  */
731 
732 #ifdef BLI_HAVE_SSE2
733 
744 MALWAYS_INLINE __m128 _bli_math_fastpow(const int exp, const int e2coeff, const __m128 arg)
745 {
746  __m128 ret;
747  ret = _mm_mul_ps(arg, _mm_castsi128_ps(_mm_set1_epi32(e2coeff)));
748  ret = _mm_cvtepi32_ps(_mm_castps_si128(ret));
749  ret = _mm_mul_ps(ret, _mm_castsi128_ps(_mm_set1_epi32(exp)));
750  ret = _mm_castsi128_ps(_mm_cvtps_epi32(ret));
751  return ret;
752 }
753 
755 MALWAYS_INLINE __m128 _bli_math_improve_5throot_solution(const __m128 old_result, const __m128 x)
756 {
757  __m128 approx2 = _mm_mul_ps(old_result, old_result);
758  __m128 approx4 = _mm_mul_ps(approx2, approx2);
759  __m128 t = _mm_div_ps(x, approx4);
760  __m128 summ = _mm_add_ps(_mm_mul_ps(_mm_set1_ps(4.0f), old_result), t); /* FMA. */
761  return _mm_mul_ps(summ, _mm_set1_ps(1.0f / 5.0f));
762 }
763 
765 MALWAYS_INLINE __m128 _bli_math_fastpow24(const __m128 arg)
766 {
767  /* max, avg and |avg| errors were calculated in gcc without FMA instructions
768  * The final precision should be better than powf in glibc */
769 
770  /* Calculate x^4/5, coefficient 0.994 was constructed manually to minimize
771  * avg error.
772  */
773  /* 0x3F4CCCCD = 4/5 */
774  /* 0x4F55A7FB = 2^(127/(4/5) - 127) * 0.994^(1/(4/5)) */
775  /* error max = 0.17, avg = 0.0018, |avg| = 0.05 */
776  __m128 x = _bli_math_fastpow(0x3F4CCCCD, 0x4F55A7FB, arg);
777  __m128 arg2 = _mm_mul_ps(arg, arg);
778  __m128 arg4 = _mm_mul_ps(arg2, arg2);
779  /* error max = 0.018 avg = 0.0031 |avg| = 0.0031 */
780  x = _bli_math_improve_5throot_solution(x, arg4);
781  /* error max = 0.00021 avg = 1.6e-05 |avg| = 1.6e-05 */
782  x = _bli_math_improve_5throot_solution(x, arg4);
783  /* error max = 6.1e-07 avg = 5.2e-08 |avg| = 1.1e-07 */
784  x = _bli_math_improve_5throot_solution(x, arg4);
785  return _mm_mul_ps(x, _mm_mul_ps(x, x));
786 }
787 
788 MALWAYS_INLINE __m128 _bli_math_rsqrt(__m128 in)
789 {
790  __m128 r = _mm_rsqrt_ps(in);
791  /* Only do additional Newton-Raphson iterations when using actual SSE
792  * code path. When we are emulating SSE on NEON via sse2neon, the
793  * additional NR iterations are already done inside _mm_rsqrt_ps
794  * emulation. */
795 # if defined(__SSE2__)
796  r = _mm_add_ps(_mm_mul_ps(_mm_set1_ps(1.5f), r),
797  _mm_mul_ps(_mm_mul_ps(_mm_mul_ps(in, _mm_set1_ps(-0.5f)), r), _mm_mul_ps(r, r)));
798 # endif
799  return r;
800 }
801 
802 /* Calculate powf(x, 1.0f / 2.4) */
803 MALWAYS_INLINE __m128 _bli_math_fastpow512(const __m128 arg)
804 {
805  /* 5/12 is too small, so compute the 4th root of 20/12 instead.
806  * 20/12 = 5/3 = 1 + 2/3 = 2 - 1/3. 2/3 is a suitable argument for fastpow.
807  * weighting coefficient: a^-1/2 = 2 a; a = 2^-2/3
808  */
809  __m128 xf = _bli_math_fastpow(0x3f2aaaab, 0x5eb504f3, arg);
810  __m128 xover = _mm_mul_ps(arg, xf);
811  __m128 xfm1 = _bli_math_rsqrt(xf);
812  __m128 x2 = _mm_mul_ps(arg, arg);
813  __m128 xunder = _mm_mul_ps(x2, xfm1);
814  /* sqrt2 * over + 2 * sqrt2 * under */
815  __m128 xavg = _mm_mul_ps(_mm_set1_ps(1.0f / (3.0f * 0.629960524947437f) * 0.999852f),
816  _mm_add_ps(xover, xunder));
817  xavg = _mm_mul_ps(xavg, _bli_math_rsqrt(xavg));
818  xavg = _mm_mul_ps(xavg, _bli_math_rsqrt(xavg));
819  return xavg;
820 }
821 
822 MALWAYS_INLINE __m128 _bli_math_blend_sse(const __m128 mask, const __m128 a, const __m128 b)
823 {
824  return _mm_or_ps(_mm_and_ps(mask, a), _mm_andnot_ps(mask, b));
825 }
826 
827 #endif /* BLI_HAVE_SSE2 */
828 
829 /* Low level conversion functions */
830 MINLINE unsigned char unit_float_to_uchar_clamp(float val)
831 {
832  return (unsigned char)((
833  (val <= 0.0f) ? 0 : ((val > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * val) + 0.5f))));
834 }
835 #define unit_float_to_uchar_clamp(val) \
836  ((CHECK_TYPE_INLINE(val, float)), unit_float_to_uchar_clamp(val))
837 
838 MINLINE unsigned short unit_float_to_ushort_clamp(float val)
839 {
840  return (unsigned short)((val >= 1.0f - 0.5f / 65535) ? 65535 :
841  (val <= 0.0f) ? 0 :
842  (val * 65535.0f + 0.5f));
843 }
844 #define unit_float_to_ushort_clamp(val) \
845  ((CHECK_TYPE_INLINE(val, float)), unit_float_to_ushort_clamp(val))
846 
847 MINLINE unsigned char unit_ushort_to_uchar(unsigned short val)
848 {
849  return (unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8);
850 }
851 #define unit_ushort_to_uchar(val) \
852  ((CHECK_TYPE_INLINE(val, unsigned short)), unit_ushort_to_uchar(val))
853 
854 #define unit_float_to_uchar_clamp_v3(v1, v2) \
855  { \
856  (v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
857  (v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
858  (v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
859  } \
860  ((void)0)
861 #define unit_float_to_uchar_clamp_v4(v1, v2) \
862  { \
863  (v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
864  (v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
865  (v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
866  (v1)[3] = unit_float_to_uchar_clamp((v2[3])); \
867  } \
868  ((void)0)
869 
870 #ifdef __cplusplus
871 }
872 #endif
873 
874 #endif /* __MATH_BASE_INLINE_C__ */
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define M_LN2
Definition: BLI_math_base.h:53
#define M_PI_2
Definition: BLI_math_base.h:23
#define M_PI
Definition: BLI_math_base.h:20
#define MALWAYS_INLINE
#define MINLINE
unsigned int uint
Definition: BLI_sys_types.h:67
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
uint pos
#define UINT_MAX
Definition: hash_md5.c:43
MINLINE int round_fl_to_int_clamp(float a)
MINLINE unsigned char round_fl_to_uchar(float a)
MINLINE float max_fff(float a, float b, float c)
MINLINE uint ceil_to_multiple_u(uint a, uint b)
MINLINE float saacos(float fac)
#define _round_clamp_fl_impl(arg, ty, min, max)
MINLINE unsigned short round_fl_to_ushort_clamp(float a)
MINLINE uint min_uu(uint a, uint b)
MINLINE float max_ffff(float a, float b, float c, float d)
MINLINE unsigned int round_db_to_uint_clamp(double a)
MINLINE unsigned int log2_ceil_u(unsigned int x)
MINLINE signed char round_fl_to_char(float a)
MINLINE int power_of_2_min_i(int n)
MINLINE int round_fl_to_int(float a)
MINLINE short round_db_to_short_clamp(double a)
MINLINE signed char round_db_to_char_clamp(double a)
MINLINE float max_ff(float a, float b)
MINLINE unsigned int cube_uint(unsigned int a)
MINLINE size_t min_zz(size_t a, size_t b)
MINLINE int min_ii(int a, int b)
MINLINE uint divide_ceil_u(uint a, uint b)
MINLINE short round_db_to_short(double a)
MINLINE float saasinf(float fac)
MINLINE int power_of_2_max_i(int n)
MINLINE float fractf(float a)
MINLINE int compare_ff(float a, float b, const float max_diff)
MINLINE float power_of_2(float val)
MINLINE float sasqrtf(float fac)
MINLINE float min_ffff(float a, float b, float c, float d)
MINLINE unsigned int power_of_2_max_u(unsigned int x)
MINLINE uint max_uu(uint a, uint b)
MINLINE bool compare_threshold_relative(const float value1, const float value2, const float thresh)
#define _round_fl_impl(arg, ty)
MINLINE int cube_i(int a)
#define _round_db_impl(arg, ty)
MINLINE unsigned short round_fl_to_ushort(float a)
MINLINE float pow2f(float x)
MINLINE unsigned int round_fl_to_uint_clamp(float a)
MINLINE double square_d(double a)
#define unit_float_to_ushort_clamp(val)
MINLINE double ratiod(double min, double max, double pos)
MINLINE float clamp_f(float value, float min, float max)
MINLINE int divide_floor_i(int a, int b)
MINLINE float min_ff(float a, float b)
MINLINE double scalenormd(double a, double b, double x)
MINLINE size_t max_zz(size_t a, size_t b)
MINLINE unsigned long long min_ulul(unsigned long long a, unsigned long long b)
MINLINE unsigned long long max_ulul(unsigned long long a, unsigned long long b)
MINLINE int cube_s(short a)
MINLINE int integer_digits_d(const double d)
MINLINE int square_i(int a)
MINLINE short round_fl_to_short_clamp(float a)
MINLINE float pow5f(float x)
MINLINE int max_ii(int a, int b)
MINLINE short round_fl_to_short(float a)
MINLINE uint64_t divide_ceil_ul(uint64_t a, uint64_t b)
MINLINE unsigned int round_db_to_uint(double a)
#define unit_float_to_uchar_clamp(val)
MINLINE unsigned int power_of_2_min_u(unsigned int x)
MINLINE double min_dd(double a, double b)
MINLINE signed char round_fl_to_char_clamp(float a)
MINLINE float smoothminf(float a, float b, float c)
MINLINE float cube_f(float a)
MINLINE unsigned short round_db_to_ushort_clamp(double a)
MINLINE float scalenorm(float a, float b, float x)
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
MINLINE double cube_d(double a)
MINLINE int min_iii(int a, int b, int c)
MINLINE int divide_round_i(int a, int b)
MINLINE int integer_digits_f(const float f)
MINLINE int integer_digits_i(const int i)
MINLINE int mod_i(int i, int n)
#define unit_ushort_to_uchar(val)
MINLINE double interpd(double target, double origin, double fac)
MINLINE float square_f(float a)
MINLINE unsigned int round_fl_to_uint(float a)
MINLINE float pingpongf(float value, float scale)
#define UNLIKELY(x)
MINLINE float interpf(float target, float origin, float fac)
MINLINE float sqrtf_signed(float f)
MINLINE double max_dd(double a, double b)
MINLINE int round_db_to_int_clamp(double a)
MINLINE char min_cc(char a, char b)
MINLINE signed char round_db_to_char(double a)
MINLINE int is_power_of_2_i(int n)
MINLINE float pow3f(float x)
MINLINE int compare_ff_relative(float a, float b, const float max_diff, const int max_ulps)
MINLINE double sqrt3d(double d)
MINLINE int round_db_to_int(double a)
MINLINE int max_iiii(int a, int b, int c, int d)
MINLINE float min_fff(float a, float b, float c)
MINLINE int signum_i_ex(float a, float eps)
MINLINE int min_iiii(int a, int b, int c, int d)
MINLINE float saasin(float fac)
MINLINE unsigned int log2_floor_u(unsigned int x)
MINLINE float signf(float f)
MINLINE int max_iii(int a, int b, int c)
MINLINE size_t clamp_z(size_t value, size_t min, size_t max)
MINLINE unsigned short round_db_to_ushort(double a)
MINLINE int clamp_i(int value, int min, int max)
MINLINE int signum_i(float a)
MINLINE float ratiof(float min, float max, float pos)
MINLINE float smoothstep(float edge0, float edge1, float x)
MINLINE float round_to_even(float f)
#define _round_clamp_db_impl(arg, ty, min, max)
MINLINE int cube_uchar(unsigned char a)
MINLINE unsigned int square_uint(unsigned int a)
MINLINE int square_s(short a)
MINLINE uint64_t ceil_to_multiple_ul(uint64_t a, uint64_t b)
MINLINE float compatible_signf(float f)
MINLINE float sasqrt(float fac)
MINLINE unsigned char round_db_to_uchar_clamp(double a)
MINLINE int square_uchar(unsigned char a)
MINLINE float pow4f(float x)
MINLINE float sqrt3f(float f)
MINLINE char max_cc(char a, char b)
MINLINE float pow7f(float x)
MINLINE float wrapf(float value, float max, float min)
MINLINE unsigned char round_db_to_uchar(double a)
MINLINE float saacosf(float fac)
ccl_device_inline float2 fabs(const float2 &a)
Definition: math_float2.h:222
ccl_device_inline float3 exp(float3 v)
Definition: math_float3.h:392
ccl_device_inline float3 ceil(const float3 &a)
Definition: math_float3.h:363
ccl_device_inline float3 pow(float3 v, float e)
Definition: math_float3.h:533
ccl_device_inline float3 log(float3 v)
Definition: math_float3.h:397
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
#define asinf(x)
Definition: metal/compat.h:221
#define floorf(x)
Definition: metal/compat.h:224
#define acosf(x)
Definition: metal/compat.h:222
#define fabsf(x)
Definition: metal/compat.h:219
#define sqrtf(x)
Definition: metal/compat.h:243
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
T floor(const T &a)
T abs(const T &a)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
const btScalar eps
Definition: poly34.cpp:11
return ret
#define min(a, b)
Definition: sort.c:35
unsigned __int64 uint64_t
Definition: stdint.h:90
float max