115 #if defined(WIN32) && (defined(_MSC_VER) || defined(__MINGW32__)) 122 #define NO_NEARBYINTF 169 #if defined(__sun__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__APPLE__) 175 #if defined(__APPLE__) 186 const FXdouble PI=3.1415926535897932384626433833;
189 const FXdouble EULER=2.7182818284590452353602874713;
192 const FXdouble DTOR=0.0174532925199432957692369077;
195 const FXdouble RTOD=57.295779513082320876798154814;
198 const FXdouble FEIGENBAUM=4.6692016091029906718532038215;
201 const FXdouble GOLDENRATIO=1.6180339887498948482045868343;
210 static inline FXuint fpBits(FXfloat x){
211 union{ FXfloat f; FXuint u; } z={x};
216 static inline FXulong fpBits(FXdouble x){
217 union{ FXdouble f; FXulong u; } z={x};
223 static inline FXint fpSign(FXfloat x){
224 FXint sign=fpBits(x)>>31;
229 static inline FXlong fpSign(FXdouble x){
230 FXlong sign=fpBits(x)>>63;
236 static inline FXint fpExponent(FXfloat x){
237 FXint exponent=(fpBits(x)>>23)&0xff;
238 FXint bias=126-(-exponent>>31);
239 return exponent-bias;
243 static inline FXlong fpExponent(FXdouble x){
244 FXlong exponent=(fpBits(x)>>52)&0x7ff;
245 FXlong bias=1022-(-exponent>>63);
246 return exponent-bias;
251 static inline FXint fpMantissa(FXfloat x){
252 FXint mantissa=fpBits(x)&0x007fffff;
253 FXint exponent=fpBits(x)&0x7f800000;
254 FXint extrabit=-(-exponent>>31);
255 return mantissa|(extrabit<<23);
259 static inline FXlong fpMantissa(FXdouble x){
260 FXlong mantissa=fpBits(x)&FXLONG(0x000fffffffffffff);
261 FXlong exponent=fpBits(x)&FXLONG(0x7ff0000000000000);
262 FXlong extrabit=-(-exponent>>63);
263 return mantissa|(extrabit<<52);
268 static inline FXbool fpFinite(FXfloat x){
269 return ((fpBits(x)&0x7fffffff)<0x7f800000);
273 static inline FXbool fpFinite(FXdouble x){
274 return ((fpBits(x)&FXULONG(0x7fffffffffffffff))<FXULONG(0x7ff0000000000000));
279 static inline FXbool fpInfinite(FXfloat x){
280 return ((fpBits(x)&0x7fffffff)==0x7f800000);
284 static inline FXbool fpInfinite(FXdouble x){
285 return ((fpBits(x)&FXULONG(0x7fffffffffffffff))==FXULONG(0x7ff0000000000000));
290 static inline FXbool fpNan(FXfloat x){
291 return (0x7f800000<(fpBits(x)&0x7fffffff));
295 static inline FXbool fpNan(FXdouble x){
296 return (FXULONG(0x7ff0000000000000)<(fpBits(x)&FXULONG(0x7fffffffffffffff)));
301 static inline FXbool fpNormal(FXfloat x){
302 FXuint bits=fpBits(x)&0x7fffffff;
303 return bits==0 || (0x00800000<=bits && bits<0x7f800000);
307 static inline FXbool fpNormal(FXdouble x){
308 FXulong bits=fpBits(x)&FXULONG(0x7fffffffffffffff);
309 return (bits==0) || ((FXULONG(0x0010000000000000)<=bits) && (bits<FXULONG(0x7ff0000000000000)));
314 static inline FXint iblend(FXint a,FXint b,FXint x,FXint y){
319 static inline FXlong iblend(FXlong a,FXlong b,FXlong x,FXlong y){
325 static inline FXint imin(FXint x,FXint y){
330 static inline FXuint imin(FXuint x,FXuint y){
335 static inline FXlong imin(FXlong x,FXlong y){
340 static inline FXulong imin(FXulong x,FXulong y){
346 static inline FXint imax(FXint x,FXint y){
351 static inline FXuint imax(FXuint x,FXuint y){
357 static inline FXlong imax(FXlong x,FXlong y){
362 static inline FXulong imax(FXulong x,FXulong y){
368 static inline FXshort iabs(FXshort x){
373 static inline FXint iabs(FXint x){
378 static inline FXlong iabs(FXlong x){
384 static inline FXint iclamp(FXint lo,FXint x,FXint hi){
385 return Math::imin(Math::imax(x,lo),hi);
389 static inline FXlong iclamp(FXlong lo,FXlong x,FXlong hi){
390 return Math::imin(Math::imax(x,lo),hi);
395 static inline FXint iclamp(FXint x,FXint lim){
396 return imin(imax(x,-lim),lim);
400 static inline FXlong iclamp(FXlong x,FXlong lim){
401 return imin(imax(x,-lim),lim);
406 static inline FXint isign(FXint x){
411 static inline FXlong isign(FXlong x){
417 static inline FXfloat fmin(FXfloat x,FXfloat y){
418 #if defined(NO_FMINF) 427 static inline FXdouble fmin(FXdouble x,FXdouble y){
437 static inline FXfloat fmax(FXfloat x,FXfloat y){
438 #if defined(NO_FMAXF) 446 static inline FXdouble fmax(FXdouble x,FXdouble y){
456 static inline FXfloat fabs(FXfloat x){
457 #if defined(NO_FABSF) 458 return (x<0.0f) ? -x : x;
465 static inline FXdouble fabs(FXdouble x){
471 static inline FXfloat fclamp(FXfloat lo,FXfloat x,FXfloat hi){
472 return Math::fmin(Math::fmax(x,lo),hi);
476 static inline FXdouble fclamp(FXdouble lo,FXdouble x,FXdouble hi){
477 return Math::fmin(Math::fmax(x,lo),hi);
482 static inline FXfloat fclamp(FXfloat x,FXfloat lim){
483 return fmin(fmax(x,-lim),lim);
487 static inline FXdouble fclamp(FXdouble x,FXdouble lim){
488 return fmin(fmax(x,-lim),lim);
493 static inline FXfloat fdim(FXfloat x,FXfloat y){
494 #if defined(NO_FDIMF) 495 return Math::fmax(x-y,0.0f);
502 static inline FXdouble fdim(FXdouble x,FXdouble y){
504 return Math::fmax(x-y,0.0);
512 static inline FXfloat fmod(FXfloat x,FXfloat y){
517 static inline FXdouble fmod(FXdouble x,FXdouble y){
523 static inline FXfloat fblend(FXfloat a,FXfloat b,FXfloat x,FXfloat y){
529 static inline FXdouble fblend(FXdouble a,FXdouble b,FXdouble x,FXdouble y){
535 static inline FXfloat copysign(FXfloat x,FXfloat y){
536 #if defined(NO_COPYSIGNF) 537 union{ FXfloat f; FXuint u; } xx={x},yy={y};
539 xx.u|=(yy.u&0x80000000);
542 return ::copysignf(x,y);
547 static inline FXdouble copysign(FXdouble x,FXdouble y){
548 #if defined(NO_COPYSIGN) 549 union{ FXdouble f; FXulong u; } xx={x},yy={y};
550 xx.u&=FXULONG(0x7fffffffffffffff);
551 xx.u|=(yy.u&FXULONG(0x8000000000000000));
554 return ::copysign(x,y);
560 #if defined(NO_CEILF) 561 extern FXAPI FXfloat ceil(FXfloat x);
563 static inline FXfloat ceil(FXfloat x){ return ::ceilf(x); }
567 static inline FXdouble ceil(FXdouble x){ return ::ceil(x); }
571 #if defined(NO_FLOORF) 572 extern FXAPI FXfloat floor(FXfloat x);
574 static inline FXfloat floor(FXfloat x){ return ::floorf(x); }
578 static inline FXdouble floor(FXdouble x){ return ::floor(x); }
581 #if defined(NO_ROUNDF) 582 extern FXAPI FXfloat round(FXfloat x);
584 static inline FXfloat round(FXfloat x){ return ::roundf(x); }
588 #if defined(NO_ROUND) 589 extern FXAPI FXdouble round(FXdouble x);
591 static inline FXdouble round(FXdouble x){ return ::round(x); }
596 #if defined(NO_TRUNCF) 597 extern FXAPI FXfloat trunc(FXfloat x);
599 static inline FXfloat trunc(FXfloat x){ return ::truncf(x); }
603 #if defined(NO_TRUNC) 604 extern FXAPI FXdouble trunc(FXdouble x);
606 static inline FXdouble trunc(FXdouble x){ return ::trunc(x); }
611 #if defined(NO_NEARBYINTF) 612 extern FXAPI FXfloat nearbyint(FXfloat x);
614 static inline FXfloat nearbyint(FXfloat x){ return ::nearbyintf(x); }
618 #if defined(NO_NEARBYINT) 619 extern FXAPI FXdouble nearbyint(FXdouble x);
621 static inline FXdouble nearbyint(FXdouble x){ return ::nearbyint(x); }
625 #if defined(NO_RINTF) 626 extern FXAPI FXfloat rint(FXfloat x);
628 static inline FXfloat rint(FXfloat x){ return ::rintf(x); }
633 extern FXAPI FXdouble rint(FXdouble x);
635 static inline FXdouble rint(FXdouble x){ return ::rint(x); }
640 static inline FXint lrint(FXfloat x){
641 #if defined(NO_LRINTF) 642 return (FXint)(x+Math::copysign(0.5f,x));
644 return (FXint)::lrintf(x);
649 static inline FXlong lrint(FXdouble x){
650 #if defined(NO_LRINT) 651 return (FXlong)(x+Math::copysign(0.5,x));
653 return (FXlong)::lrint(x);
659 static inline FXfloat wrap(FXfloat x){
660 #if defined(__SSE4_1__) 661 return x-Math::nearbyint(x*0.159154943091895335768883763373f)*6.28318530717958647692528676656f;
663 return x-Math::lrint(x*0.159154943091895335768883763373f)*6.28318530717958647692528676656f;
668 static inline FXdouble wrap(FXdouble x){
669 #if defined(__SSE4_1__) 670 return x-Math::nearbyint(x*0.159154943091895335768883763373)*6.28318530717958647692528676656;
672 return x-Math::lrint(x*0.159154943091895335768883763373)*6.28318530717958647692528676656;
678 static inline FXfloat wrap4(FXfloat x){
679 return x-Math::floor(x*0.159154943091895335768883763373f)*6.28318530717958647692528676656f;
684 static inline FXdouble wrap4(FXdouble x){
685 return x-Math::floor(x*0.159154943091895335768883763373)*6.28318530717958647692528676656;
690 static inline FXfloat stepify(FXfloat x,FXfloat s){
691 return Math::nearbyint(x/s)*s;
695 static inline FXdouble stepify(FXdouble x,FXdouble s){
696 return Math::nearbyint(x/s)*s;
701 static inline FXfloat zigzag(FXfloat x){
702 return Math::fabs(2.0f*(x-Math::nearbyint(x)));
706 static inline FXdouble zigzag(FXdouble x){
707 return Math::fabs(2.0*(x-Math::nearbyint(x)));
712 static inline FXfloat sawtooth(FXfloat x){
713 return x-Math::floor(x);
717 static inline FXdouble sawtooth(FXdouble x){
718 return x-Math::floor(x);
723 static inline FXfloat rsawtooth(FXfloat x){
724 return Math::ceil(x)-x;
728 static inline FXdouble rsawtooth(FXdouble x){
729 return Math::ceil(x)-x;
734 static inline FXfloat sin(FXfloat x){
739 static inline FXdouble sin(FXdouble x){
745 static inline FXfloat cos(FXfloat x){
750 static inline FXdouble cos(FXdouble x){
756 static inline FXfloat tan(FXfloat x){
761 static inline FXdouble tan(FXdouble x){
767 static inline FXfloat asin(FXfloat x){
772 static inline FXdouble asin(FXdouble x){
778 static inline FXfloat acos(FXfloat x){
783 static inline FXdouble acos(FXdouble x){
789 static inline FXfloat atan(FXfloat x){
794 static inline FXdouble atan(FXdouble x){
800 static inline FXfloat atan2(FXfloat y,FXfloat x){
801 return ::atan2f(y,x);
805 static inline FXdouble atan2(FXdouble y,FXdouble x){
811 static inline void sincos(FXfloat x,FXfloat& s,FXfloat& c){
812 #if defined(NO_SINCOSF) 822 static inline void sincos(FXdouble x,FXdouble& s,FXdouble& c){
823 #if defined(NO_SINCOS) 833 #if defined(NO_SINHF) 834 extern FXAPI FXfloat sinh(FXfloat x);
836 static inline FXfloat sinh(FXfloat x){ return ::sinhf(x); }
841 extern FXAPI FXdouble sinh(FXdouble x);
843 static inline FXdouble sinh(FXdouble x){ return ::sinh(x); }
848 #if defined(NO_COSHF) 849 extern FXAPI FXfloat cosh(FXfloat x);
851 static inline FXfloat cosh(FXfloat x){ return ::coshf(x); }
856 extern FXAPI FXdouble cosh(FXdouble x);
858 static inline FXdouble cosh(FXdouble x){ return ::cosh(x); }
863 #if defined(NO_TANHF) 864 extern FXAPI FXfloat tanh(FXfloat x);
866 static inline FXfloat tanh(FXfloat x){ return ::tanhf(x); }
871 extern FXAPI FXdouble tanh(FXdouble x);
873 static inline FXdouble tanh(FXdouble x){ return ::tanh(x); }
878 #if defined(NO_ASINHF) 879 extern FXAPI FXfloat asinh(FXfloat x);
881 static inline FXfloat asinh(FXfloat x){ return ::asinhf(x); }
885 #if defined(NO_ASINH) 886 extern FXAPI FXdouble asinh(FXdouble x);
888 static inline FXdouble asinh(FXdouble x){ return ::asinh(x); }
893 #if defined(NO_ACOSHF) 894 extern FXAPI FXfloat acosh(FXfloat x);
896 static inline FXfloat acosh(FXfloat x){ return ::acoshf(x); }
900 #if defined(NO_ACOSH) 901 extern FXAPI FXdouble acosh(FXdouble x);
903 static inline FXdouble acosh(FXdouble x){ return ::acosh(x); }
908 #if defined(NO_ATANHF) 909 extern FXAPI FXfloat atanh(FXfloat x);
911 static inline FXfloat atanh(FXfloat x){ return ::atanhf(x); }
915 #if defined(NO_ATANH) 916 extern FXAPI FXdouble atanh(FXdouble x);
918 static inline FXdouble atanh(FXdouble x){ return ::atanh(x); }
923 static inline FXfloat sqrt(FXfloat x){
928 static inline FXdouble sqrt(FXdouble x){
934 static inline FXfloat safesqrt(FXfloat x){
935 return Math::sqrt(Math::fmax(x,0.0f));
939 static inline FXdouble safesqrt(FXdouble x){
940 return Math::sqrt(Math::fmax(x,0.0));
945 static inline FXfloat cbrt(FXfloat x){
946 #if defined(NO_CBRTF) 947 return ::powf(x,0.333333333333333333333333333333f);
954 static inline FXdouble cbrt(FXdouble x){
956 return ::pow(x,0.333333333333333333333333333333);
964 static inline FXfloat sqr(FXfloat x){
969 static inline FXdouble sqr(FXdouble x){
975 static inline FXfloat cub(FXfloat x){
980 static inline FXdouble cub(FXdouble x){
986 static inline FXfloat rsqrt(FXfloat x){
987 return 1.0f/Math::sqrt(x);
992 static inline FXdouble rsqrt(FXdouble x){
993 return 1.0/Math::sqrt(x);
998 static inline FXfloat recip(FXfloat x){
1004 static inline FXdouble recip(FXdouble x){
1010 static inline FXfloat hypot(FXfloat x,FXfloat y){
1011 #if defined(NO_HYPOTF) 1012 return Math::sqrt(Math::sqr(x)+Math::sqr(y));
1014 return ::hypotf(x,y);
1019 static inline FXdouble hypot(FXdouble x,FXdouble y){
1020 #if defined(NO_HYPOT) 1021 return Math::sqrt(Math::sqr(x)+Math::sqr(y));
1023 return ::hypot(x,y);
1029 static inline FXfloat lerp(FXfloat u,FXfloat v,FXfloat f){
1035 static inline FXdouble lerp(FXdouble u,FXdouble v,FXdouble f){
1041 static inline FXfloat smoothstep(FXfloat f){
1042 return (3.0f-2.0f*f)*f*f;
1046 static inline FXdouble smoothstep(FXdouble f){
1047 return (3.0-2.0*f)*f*f;
1052 static inline FXfloat exp(FXfloat x){
1057 static inline FXdouble exp(FXdouble x){
1063 static inline FXfloat expm1(FXfloat x){
1064 #if defined(NO_EXPM1F) 1065 return ::expf(x)-1.0f;
1072 static inline FXdouble expm1(FXdouble x){
1073 #if defined(NO_EXPM1) 1074 return ::exp(x)-1.0;
1082 static inline FXfloat pow(FXfloat x,FXfloat y){
1087 static inline FXdouble pow(FXdouble x,FXdouble y){
1093 static inline FXfloat exp2(FXfloat x){
1094 #if defined(NO_EXP2F) 1095 return Math::pow(2.0f,x);
1103 static inline FXdouble exp2(FXdouble x){
1104 #if defined(NO_EXP2) 1105 return Math::pow(2.0,x);
1113 static inline FXfloat exp10(FXfloat x){
1114 #if defined(NO_EXP10F) 1115 return Math::pow(10.0f,x);
1123 static inline FXdouble exp10(FXdouble x){
1124 #if defined(NO_EXP10) 1125 return Math::pow(10.0,x);
1133 static inline FXfloat pow10(FXfloat x){
1134 return Math::exp10(x);
1138 static inline FXdouble pow10(FXdouble x){
1139 return Math::exp10(x);
1144 extern FXAPI FXdouble pow10i(FXint ex);
1148 extern FXAPI FXfloat powi(FXfloat base,FXint ex);
1152 extern FXAPI FXdouble powi(FXdouble base,FXint ex);
1156 static inline FXfloat log(FXfloat x){
1161 static inline FXdouble log(FXdouble x){
1167 static inline FXfloat log1p(FXfloat x){
1168 #if defined(NO_LOG1PF) 1169 return Math::log(1.0f+x);
1177 static inline FXdouble log1p(FXdouble x){
1178 #if defined(NO_LOG1P) 1179 return Math::log(1.0+x);
1187 static inline FXfloat log2(FXfloat x){
1188 #if defined(NO_LOG2F) 1189 return Math::log(x)*1.442695040888963407359924681001892137f;
1197 static inline FXdouble log2(FXdouble x){
1198 #if defined(NO_LOG2) 1199 return Math::log(x)*1.442695040888963407359924681001892137;
1207 static inline FXfloat log10(FXfloat x){
1212 static inline FXdouble log10(FXdouble x){
1218 extern FXAPI FXfloat erf(FXfloat x);
1221 extern FXAPI FXdouble erf(FXdouble x);
1225 extern FXAPI FXfloat erfc(FXfloat x);
1228 extern FXAPI FXdouble erfc(FXdouble x);
1232 extern FXAPI FXfloat inverf(FXfloat x);
1235 extern FXAPI FXdouble inverf(FXdouble x);
1239 extern FXAPI FXfloat inverfc(FXfloat x);
1242 extern FXAPI FXdouble inverfc(FXdouble x);
Definition: FX4Splitter.h:28