spice::function namespace

Contains implementations of commonly used mathematical functions.

Contents

Functions

auto gaussian(float std_deviation, float x) -> float
Calculates the gaussian function at the given point.
auto gaussian(float std_deviation, float x, float y) -> float
Calculates the gaussian function at the given point.
template<typename T_arg, typename T_vals, typename Fn>
void evaluate_unary(Fn fn, T_arg begin, T_arg end, T_arg step, T_vals*const fn_vals)
Calculate the values of the unary function fn over the interval $[begin, end)$ .
template<typename T_arg, typename T_vals, typename Fn>
auto evaluate_unary(Fn fn, T_arg begin, T_arg end, T_arg step) -> std::vector<T_vals>
Calculate the values of the unary function fn over the interval $[begin, end)$ .
template<typename T_arg, typename T_vals, typename Fn>
void evaluate_binary(Fn fn, T_arg begin_x, T_arg end_x, T_arg step_x, T_arg begin_y, T_arg end_y, T_arg step_y, T_vals*const fn_vals)
Calculate the values of the binary function fn over the area $[(begin\_x, begin\_y), (end\_x, end\_y))$ .
template<typename T_arg, typename T_vals, typename Fn>
auto evaluate_binary(Fn fn, T_arg begin_x, T_arg end_x, T_arg step_x, T_arg begin_y, T_arg end_y, T_arg step_y) -> std::vector<T_vals>
Calculate the values of the binary function fn over the area $[(begin\_x, begin\_y), (end\_x, end\_y))$ .

Variables

const auto sqrt_2_pi
Square root of 2 * PI.

Function documentation

float spice::function::gaussian(float std_deviation, float x)

Calculates the gaussian function at the given point.

Parameters
std_deviation
x
Returns float

The implemented function is a simplified gaussian function suitable for use as an impulse response for convolution:

\[ g(x, y) = \frac{1}{2\pi\sigma^2} \cdot e^{\frac{x^2}{2\sigma^2}} \]

where $\sigma$ is the standard deviation and $e$ is Euler's constant.

float spice::function::gaussian(float std_deviation, float x, float y)

Calculates the gaussian function at the given point.

Parameters
std_deviation
x
y
Returns float

The implemented function is a simplified gaussian function suitable for use as an impulse response for convolution:

\[ g(x, y) = \frac{1}{2\pi\sigma^2} \cdot e^{\frac{x^2 + y^2}{2\sigma^2}} \]

where $\sigma$ is the standard deviation and $e$ is Euler's constant.

template<typename T_arg, typename T_vals, typename Fn>
void spice::function::evaluate_unary(Fn fn, T_arg begin, T_arg end, T_arg step, T_vals*const fn_vals)

Calculate the values of the unary function fn over the interval $[begin, end)$ .

Template parameters
T_arg type of arguments to fn
T_vals type of values of fn
Fn unary function type
Parameters
fn
begin
end
step
fn_vals a buffer of length std::ceil((end - begin) / step) to write the result to

If the steps do not divide this interval evenly, an additional sample is added at the end.

template<typename T_arg, typename T_vals, typename Fn>
std::vector<T_vals> spice::function::evaluate_unary(Fn fn, T_arg begin, T_arg end, T_arg step)

Calculate the values of the unary function fn over the interval $[begin, end)$ .

Template parameters
T_arg type of arguments to fn
T_vals type of values of fn
Fn unary function type
Parameters
fn
begin
end
step
Returns std::vector<T> a vector of length std::ceil((end - begin) / step)

If the steps do not divide this interval evenly, an additional sample is added at the end.

template<typename T_arg, typename T_vals, typename Fn>
void spice::function::evaluate_binary(Fn fn, T_arg begin_x, T_arg end_x, T_arg step_x, T_arg begin_y, T_arg end_y, T_arg step_y, T_vals*const fn_vals)

Calculate the values of the binary function fn over the area $[(begin\_x, begin\_y), (end\_x, end\_y))$ .

Template parameters
T_arg type of arguments to fn
T_vals type of values of fn
Fn binary function type
Parameters
fn
begin_x
end_x
step_x
begin_y
end_y
step_y
fn_vals a buffer of length std::ceil((end_x - begin_x) / step_x) * std::ceil((end_y - begin_y) / step_y) to write the result to

If the steps do not divide this area evenly, an additional column and/or row is added at the end.

template<typename T_arg, typename T_vals, typename Fn>
std::vector<T_vals> spice::function::evaluate_binary(Fn fn, T_arg begin_x, T_arg end_x, T_arg step_x, T_arg begin_y, T_arg end_y, T_arg step_y)

Calculate the values of the binary function fn over the area $[(begin\_x, begin\_y), (end\_x, end\_y))$ .

Template parameters
T_arg type of arguments to fn
T_vals type of values of fn
Fn binary function type
Parameters
fn
begin_x
end_x
step_x
begin_y
end_y
step_y
Returns std::vector<T> a vector of length std::ceil((end_x - begin_x) / step_x) * std::ceil((end_y - begin_y) / step_y)

If the steps do not divide this area evenly, an additional column and/or row is added at the end.

Variable documentation

const auto spice::function::sqrt_2_pi

Square root of 2 * PI.