Template Function librapid::isClose#

Function Documentation#

template<typename V1, typename V2, typename T = double>
bool librapid::isClose(const V1 &val1, const V2 &val2, const T &absTol = 1e-5, const T &relTol = 1e-5)#

Compare the absolute and relative difference between two values, and return true if they are close enough to be considered equal.

\( \left| x-y \right| \leq \max\left( \mathrm{absTol}, \mathrm{relTol} \cdot \max\left( \left| x \right|, \left| y \right| \right) \right) \)

This is more precise than using an absolute tolerance alone, since it also takes into account the magnitude of the values being compared.

Template Parameters
  • V1 – Data type of the first value

  • V2 – Data type of the second value

  • T – Data type of the tolerance value

  • T – Data type of the tolerance value

Parameters
  • val1 – First value

  • val2 – Second value

  • absTol – Absolute tolerance

  • relTol – Relative tolerance

Returns

True if values are close