FFmpeg
Functions
Floating-Point Comparison

Utilities for comparing floating-point values with tolerance. More...

Functions

CHECKASM_API int checkasm_float_near_ulp (float a, float b, unsigned max_ulp)
 Compare floats using ULP (Units in Last Place) tolerance. More...
 
CHECKASM_API int checkasm_float_near_abs_eps (float a, float b, float eps)
 Compare floats using absolute epsilon tolerance. More...
 
CHECKASM_API int checkasm_float_near_abs_eps_ulp (float a, float b, float eps, unsigned max_ulp)
 Compare floats using both epsilon and ULP tolerances. More...
 
CHECKASM_API int checkasm_float_near_ulp_array (const float *a, const float *b, unsigned max_ulp, int len)
 Compare float arrays using ULP tolerance. More...
 
CHECKASM_API int checkasm_float_near_abs_eps_array (const float *a, const float *b, float eps, int len)
 Compare float arrays using absolute epsilon tolerance. More...
 
CHECKASM_API int checkasm_float_near_abs_eps_array_ulp (const float *a, const float *b, float eps, unsigned max_ulp, int len)
 Compare float arrays using both epsilon and ULP tolerances. More...
 
CHECKASM_API int checkasm_double_near_abs_eps (double a, double b, double eps)
 Compare doubles using absolute epsilon tolerance. More...
 
CHECKASM_API int checkasm_double_near_abs_eps_array (const double *a, const double *b, double eps, unsigned len)
 Compare double arrays using absolute epsilon tolerance. More...
 

Detailed Description

Utilities for comparing floating-point values with tolerance.

These functions compare floating-point values allowing for acceptable differences due to rounding, precision loss, or different computation orders.

Function Documentation

◆ checkasm_float_near_ulp()

CHECKASM_API int checkasm_float_near_ulp ( float  a,
float  b,
unsigned  max_ulp 
)

Compare floats using ULP (Units in Last Place) tolerance.

Parameters
[in]aFirst value
[in]bSecond value
[in]max_ulpMaximum acceptable ULP distance
Returns
Non-zero if values are within tolerance, 0 otherwise

Definition at line 511 of file utils.c.

◆ checkasm_float_near_abs_eps()

CHECKASM_API int checkasm_float_near_abs_eps ( float  a,
float  b,
float  eps 
)

Compare floats using absolute epsilon tolerance.

Parameters
[in]aFirst value
[in]bSecond value
[in]epsMaximum acceptable absolute difference
Returns
Non-zero if |a-b| < eps, 0 otherwise

Definition at line 539 of file utils.c.

Referenced by selftest_test_float().

◆ checkasm_float_near_abs_eps_ulp()

CHECKASM_API int checkasm_float_near_abs_eps_ulp ( float  a,
float  b,
float  eps,
unsigned  max_ulp 
)

Compare floats using both epsilon and ULP tolerances.

Parameters
[in]aFirst value
[in]bSecond value
[in]epsMaximum acceptable absolute difference
[in]max_ulpMaximum acceptable ULP distance
Returns
Non-zero if within either tolerance, 0 otherwise

Definition at line 554 of file utils.c.

◆ checkasm_float_near_ulp_array()

CHECKASM_API int checkasm_float_near_ulp_array ( const float a,
const float b,
unsigned  max_ulp,
int  len 
)

Compare float arrays using ULP tolerance.

Parameters
[in]aFirst array
[in]bSecond array
[in]max_ulpMaximum acceptable ULP distance
[in]lenNumber of elements to compare
Returns
Non-zero if all elements are within tolerance, 0 otherwise

Definition at line 529 of file utils.c.

◆ checkasm_float_near_abs_eps_array()

CHECKASM_API int checkasm_float_near_abs_eps_array ( const float a,
const float b,
float  eps,
int  len 
)

Compare float arrays using absolute epsilon tolerance.

Parameters
[in]aFirst array
[in]bSecond array
[in]epsMaximum acceptable absolute difference per element
[in]lenNumber of elements to compare
Returns
Non-zero if all elements are within tolerance, 0 otherwise

Definition at line 544 of file utils.c.

◆ checkasm_float_near_abs_eps_array_ulp()

CHECKASM_API int checkasm_float_near_abs_eps_array_ulp ( const float a,
const float b,
float  eps,
unsigned  max_ulp,
int  len 
)

Compare float arrays using both epsilon and ULP tolerances.

Parameters
[in]aFirst array
[in]bSecond array
[in]epsMaximum acceptable absolute difference per element
[in]max_ulpMaximum acceptable ULP distance
[in]lenNumber of elements to compare
Returns
Non-zero if all elements are within tolerance, 0 otherwise

Definition at line 560 of file utils.c.

◆ checkasm_double_near_abs_eps()

CHECKASM_API int checkasm_double_near_abs_eps ( double  a,
double  b,
double  eps 
)

Compare doubles using absolute epsilon tolerance.

Parameters
[in]aFirst value
[in]bSecond value
[in]epsMaximum acceptable absolute difference
Returns
Non-zero if |a-b| <= eps, 0 otherwise

Definition at line 571 of file utils.c.

Referenced by selftest_test_double().

◆ checkasm_double_near_abs_eps_array()

CHECKASM_API int checkasm_double_near_abs_eps_array ( const double a,
const double b,
double  eps,
unsigned  len 
)

Compare double arrays using absolute epsilon tolerance.

Parameters
[in]aFirst array
[in]bSecond array
[in]epsMaximum acceptable absolute difference per element
[in]lenNumber of elements to compare
Returns
Non-zero if all elements are within tolerance, 0 otherwise

Definition at line 576 of file utils.c.