gfx.math.approx

This module is about comparison of floating point arithmetics. Supported by this very informative article: https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Members

Aliases

approxRel
alias approxRel = approx!(ApproxMethod.rel)

Compare two data sets with ApproxMethod.rel. That is call scalarApproxRel on each couple of the data sets.

approxRelAndAbs
alias approxRelAndAbs = approx!(ApproxMethod.relAndAbs)

Compare two data sets with ApproxMethod.relAndAbs. That is call scalarApproxRelAndAbs on each couple of the data sets.

approxUlp
alias approxUlp = approx!(ApproxMethod.ulp)

Compare two data sets with ApproxMethod.ulp. That is call scalarApproxUlp on each couple of the data sets.

approxUlpAndAbs
alias approxUlpAndAbs = approx!(ApproxMethod.ulpAndAbs)

Compare two data sets with ApproxMethod.ulpAndAbs. That is call scalarApproxUlpAndAbs on each couple of the data sets.

Enums

ApproxMethod
enum ApproxMethod

Different methods to check if two floating point values are close to each other.

Functions

approx
bool approx(ApproxMethod method, T a, T b)

Check with method given at runtime with default parameters a and b can be any data sets supported by the approx template

Templates

approx
template approx(ApproxMethod method)

Generic template to check approx method on different sets of data.

scalarApproxRel
template scalarApproxRel(T)

Check whether the relative error between a and b is smaller than maxEps

scalarApproxRelAndAbs
template scalarApproxRelAndAbs(T)

Check whether the relative error between a and b is smaller than maxEps. If the absolute error is less than maxAbs, the test succeeds however. This is useful when comparing against zero the result of a subtraction.

scalarApproxUlp
template scalarApproxUlp(T)

Determines if two floating point scalars are maxUlps close to each other.

scalarApproxUlpAndAbs
template scalarApproxUlpAndAbs(T)

Determines if two floating point scalars are maxUlps close to each other. If the absolute error is less than maxAbs, the test succeeds however. This is useful when comparing against zero the result of a subtraction.

ulpDiff
template ulpDiff(T)

Compute the ULP difference between two floating point numbers Negative result indicates that b has higher ULP value than a.

Meta