19#define M_PI 3.14159265358979323846
23#define M_PI_2 1.57079632679489661923
27#define M_SQRT2 1.41421356237309504880
31#define M_SQRT1_2 0.707106781186547524401
68Array
abs(
const Array &array);
85Array
abs_smooth(
const Array &array,
float mu,
const Array &vshift);
86Array
abs_smooth(
const Array &array,
float mu,
float vshift);
123 if (a > b) std::swap(a, b);
124 return 0.414f * a + b;
140 conv.i = 0x5f3759df - (conv.i >> 1);
141 conv.f *= 1.5F - (a * 0.5F * conv.f * conv.f);
151Array
atan(
const Array &array);
167Array
atan2(
const Array &y,
const Array &x);
175Array
cos(
const Array &array);
183Array
exp(
const Array &array);
185float gain(
float x,
float factor);
236 float *p_profile_avg =
nullptr);
258Array
hypot(
const Array &array1,
const Array &array2);
268Array
lerp(
const Array &array1,
const Array &array2,
const Array &t);
269Array
lerp(
const Array &array1,
const Array &array2,
float t);
270float lerp(
float a,
float b,
float t);
278Array
log10(
const Array &array);
286Array
pow(
const Array &array,
float exp);
307 float smoothing = 1.f,
308 Vec2<float> center = {0.5f, 0.5f},
309 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
317Array
sin(
const Array &array);
333Array
smoothstep3(
const Array &array,
float vmin = 0.f,
float vmax = 1.f);
377Array
smoothstep5(
const Array &array,
float vmin = 0.f,
float vmax = 1.f);
425Array
sqrt(
const Array &array);
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Definition algebra.hpp:28
Array sin(const Array &array)
Return the sine of the array elements.
Definition math.cpp:222
Array pow(const Array &array, float exp)
Return the array elements raised to the power 'exp'.
Definition math.cpp:185
Array atan2(const Array &y, const Array &x)
Computes the element-wise arctangent of two arrays, considering the signs of both inputs.
Definition math.cpp:98
Array almost_unit_identity(const Array &array)
Return the almost unit identity function.
Definition math.cpp:71
Array sqrt_safe(const Array &array)
Definition math.cpp:399
std::function< float(float, float)> get_distance_function(DistanceFunction dist_fct)
Return the requested distance function.
Definition distance_function.cpp:12
Array smoothstep3(const Array &array, float vmin=0.f, float vmax=1.f)
Return the 3rd order smoothstep function of the array elements.
Definition math.cpp:232
Array cos(const Array &array)
Return the cosine of the array elements.
Definition math.cpp:110
float smoothstep3_lower(float x)
Return the 3rd order smoothstep function, with zero derivative only at 0.
Definition math.cpp:259
Array abs(const Array &array)
Return the absolute value of the array elements.
Definition math.cpp:13
DistanceFunction
Distance function type.
Definition math.hpp:43
@ CHEBYSHEV
Chebyshev.
Definition math.hpp:44
@ EUCLISHEV
Euclidian and Chebyshev mix.
Definition math.hpp:46
@ EUCLIDIAN
Euclidian.
Definition math.hpp:45
@ MANHATTAN
Manhattan.
Definition math.hpp:47
PhasorProfile
Phasor angular profile type.
Definition math.hpp:54
@ COSINE_SQUARE
Definition math.hpp:57
@ TRIANGLE
Definition math.hpp:59
@ COSINE_STD
Definition math.hpp:58
@ COSINE_PEAKY
Definition math.hpp:56
@ COSINE_BULKY
Definition math.hpp:55
Array sqrt(const Array &array)
Return the square root of the array elements.
Definition math.cpp:389
std::function< float(float)> get_phasor_profile_function(const PhasorProfile &phasor_profile, float delta, float *p_profile_avg=nullptr)
Generates a function representing a phasor profile based on the specified type and parameters.
Definition phasor_profile_function.cpp:14
Array log10(const Array &array)
Return the log10 of the array elements.
Definition math.cpp:175
float approx_rsqrt(float a)
Return the approximate inverse square root of a number.
Definition math.hpp:133
float approx_hypot(float a, float b)
Return the approximate hypothenuse of two numbers.
Definition math.hpp:119
void radial_displacement_to_xy(const Array &dr, Array &dx, Array &dy, float smoothing=1.f, Vec2< float > center={0.5f, 0.5f}, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Interpret the input array dr as a radial displacement and convert it to a pair of displacements dx an...
Definition math.cpp:195
Array gaussian_decay(const Array &array, float sigma)
Return the Gaussian of the array elements.
Definition math.cpp:136
int highest_power_of_2(int n)
Computes the highest power of 2 less than or equal to the given number.
Definition pyramid_decomposition.cpp:193
Array smoothstep5(const Array &array, float vmin=0.f, float vmax=1.f)
Return the 5rd order smoothstep function of the array elements.
Definition math.cpp:289
Array abs_smooth(const Array &array, float mu, const Array &vshift)
Return the smooth absolute value of the array elements.
Definition math.cpp:49
Array exp(const Array &array)
Return the exponantial of the array elements.
Definition math.cpp:120
float smoothstep5_upper(float x)
Return the 5rd order smoothstep function, with zero derivative only at 1.
Definition math.cpp:353
float almost_unit_identity_c2(float x)
Return the almost unit identity function (with a second-order derivative equals 0 at x = 1 also to av...
Definition math.cpp:81
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:347
Array atan(const Array &array)
Return the arctan of the array elements.
Definition math.cpp:88
Point lerp(const Point &p1, const Point &p2, float t)
Linearly interpolates between two points.
Definition points.cpp:185
float smoothstep5_lower(float x)
Return the 5rd order smoothstep function, with zero derivative only at 0.
Definition math.cpp:338
Array hypot(const Array &array1, const Array &array2)
Definition math.cpp:147
float smoothstep7(float x)
Return the 7th order smoothstep function.
Definition math.cpp:368
float smoothstep3_upper(float x)
Return the 3rd order smoothstep function, with zero derivative only at 1.
Definition math.cpp:274