23template<
typename T>
inline bool is_zero(
const T &a)
33template<
typename T>
inline T abs(
const T &a)
38template<
typename T>
inline T sign(
const T &a)
40 return (
T(0) < a) - (a <
T(0));
43template<
typename T>
inline T min(
const T &a,
const T &
b)
45 return std::min(a,
b);
48template<
typename T>
inline T max(
const T &a,
const T &
b)
50 return std::max(a,
b);
65 return std::clamp(a,
min,
max);
68template<
typename T>
inline T step(
const T &edge,
const T &value)
70 return value < edge ? 0 : 1;
73template<
typename T>
inline T mod(
const T &a,
const T &
b)
75 return std::fmod(a,
b);
80 return (
b != 0) ? std::fmod(a,
b) : 0;
91 return (
b != 0) ? a /
b :
T(0.0f);
94template<
typename T>
inline T floor(
const T &a)
99template<
typename T>
inline T round(
const T &a)
101 return std::round(a);
112 if constexpr (std::is_integral_v<T>) {
114 return ((a %
b) +
b) %
b;
120template<
typename T>
inline T ceil(
const T &a)
127 return std::abs(a -
b);
130template<
typename T>
inline T fract(
const T &a)
132 return a - std::floor(a);
135template<
typename T>
inline T sqrt(
const T &a)
142template<
typename T>
inline T rcp(
const T &a)
151 return a ?
T(1) / a :
T(0);
154template<
typename T>
inline T cos(
const T &a)
159template<
typename T>
inline T sin(
const T &a)
164template<
typename T>
inline T tan(
const T &a)
169template<
typename T>
inline T acos(
const T &a)
176 return std::pow(
x,
power);
184template<
typename T>
inline T exp(
const T &
x)
203 const float f = std::abs(
x);
205 const float m = (f < 1.0f) ? 1.0f - (1.0f - f) : 1.0f;
213 const float a = std::sqrt(1.0f - m) *
214 (1.5707963267f + m * (-0.213300989f + m * (0.077980478f + m * -0.02164095f)));
218template<
typename T>
inline T asin(
const T &a)
223template<
typename T>
inline T atan(
const T &a)
230 return std::atan2(
y,
x);
235 return std::hypot(
y,
x);
238template<
typename T,
typename FactorT>
241 auto result = a * (1 - t) +
b * t;
242 if constexpr (std::is_integral_v<T> && std::is_floating_point_v<FactorT>) {
250 if constexpr (std::is_integral_v<T>) {
252 using Unsigned = std::make_unsigned_t<T>;
254 Unsigned smaller = a;
261 return a +
sign *
T(Unsigned(larger - smaller) / 2);
264 return (a +
b) *
T(0.5);
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
ccl_device_inline float2 power(float2 v, float e)
T cos(const AngleRadianBase< T > &a)
float safe_acos_approx(float x)
T pow(const T &x, const T &power)
constexpr bool is_math_float_type
T clamp(const T &a, const T &min, const T &max)
bool is_any_zero(const T &a)
T safe_divide(const T &a, const T &b)
constexpr bool is_math_integral_type
T distance(const T &a, const T &b)
void min_inplace(T &a, const T &b)
T min(const T &a, const T &b)
T step(const T &edge, const T &value)
T midpoint(const T &a, const T &b)
T safe_mod(const T &a, const T &b)
T interpolate(const T &a, const T &b, const FactorT &t)
T atan2(const T &y, const T &x)
void min_max(const T &value, T &min, T &max)
T mod_periodic(const T &a, const T &b)
T sin(const AngleRadianBase< T > &a)
T max(const T &a, const T &b)
T mod(const T &a, const T &b)
T tan(const AngleRadianBase< T > &a)
T hypot(const T &y, const T &x)
void max_inplace(T &a, const T &b)