1#ifndef NW_MATH_ARITHMETIC_H_
2#define NW_MATH_ARITHMETIC_H_
4#include <nw/math/math_Config.h>
5#include <nw/math/math_Constant.h>
9namespace nw {
namespace math {
15 ret = (cond >= 0) ? ifPos: ifNeg;
41 return FSelect(sign, pos, neg);
59 return ::std::log10(x);
65 return ::std::fmod(x, y);
71 return ::std::modff(x, y);
77 return ::std::ceil(x);
83 return ::std::floor(x);
122 return ::std::sqrt(x);
128 return ::std::pow(x, 1/3.f);
141 f32 SS_S = s * s - s;
142 f32 b1 = SS_S * s - SS_S;
144 f32 a2 = SS - 2.f * b2;
146 return v0 - a2 * v0 + a2 * v1 + b1 * t0 + b2 * t1;
150Hermite(f32 v0, f32 t0, f32 v1, f32 t1, f32 p, f32 d)
155 return v0 + (v0 - v1) * (2 * s - 3) * s * s + s * s_1 * (s_1 * t0 + s * t1);
158inline bool IsPwr2(
int x) {
return 0 == (x & (x - 1)); }
Definition math_Constant.cpp:5
f32 FSqrt(f32 x)
Definition math_Arithmetic.h:120
f32 FSelect(f32 cond, f32 ifPos, f32 ifNeg)
Definition math_Arithmetic.h:12
f32 FModf(f32 x, f32 *y)
Definition math_Arithmetic.h:69
f32 FCeil(f32 x)
Definition math_Arithmetic.h:75
f32 FInv(f32 x)
Definition math_Arithmetic.h:112
f32 FLog10(f32 x)
Definition math_Arithmetic.h:57
f32 FAbs(f32 x)
Definition math_Arithmetic.h:20
f32 FCopySign(f32 abs, f32 sign)
Definition math_Arithmetic.h:36
f32 FExp(f32 x)
Definition math_Arithmetic.h:45
NW_FORCE_INLINE f32 Hermite(f32 v0, f32 t0, f32 v1, f32 t1, f32 p, f32 d)
Definition math_Arithmetic.h:150
f32 S16ToF32(s16 x)
Definition math_Arithmetic.h:106
bool IsPwr2(int x)
Definition math_Arithmetic.h:158
int Rightmost1(int x)
Definition math_Arithmetic.h:160
f32 FMod(f32 x, f32 y)
Definition math_Arithmetic.h:63
s16 F32ToS16(f32 x)
Definition math_Arithmetic.h:87
u16 F32ToU16(f32 x)
Definition math_Arithmetic.h:94
f32 Reciprocal(f32 x)
Definition math_Arithmetic.h:132
f32 FNAbs(f32 x)
Definition math_Arithmetic.h:28
f32 FFloor(f32 x)
Definition math_Arithmetic.h:81
f32 FLog(f32 x)
Definition math_Arithmetic.h:51
f32 FCbrt(f32 x)
Definition math_Arithmetic.h:126
f32 Hermite(f32 v0, f32 t0, f32 v1, f32 t1, f32 s)
Definition math_Arithmetic.h:138
f32 U16ToF32(u16 x)
Definition math_Arithmetic.h:100
int Rightmost0(int x)
Definition math_Arithmetic.h:162
Definition math_Constant.cpp:5
#define NW_FORCE_INLINE
Definition types.h:18