ql/Math/comparison.hpp File Reference


Detailed Description

floating-point comparisons

#include <ql/types.hpp>

Include dependency graph for comparison.hpp:


Namespaces

namespace  QuantLib

Functions

bool close (Real x, Real y)
bool close (Real x, Real y, Size n)
bool close_enough (Real x, Real y)
bool close_enough (Real x, Real y, Size n)

Function Documentation

bool close Real  x,
Real  y
 

Follows somewhat the advice of Knuth on checking for floating-point equality. The closeness relationship is:

\[ \mathrm{close}(x,y,n) \equiv |x-y| \leq \varepsilon |x| \wedge |x-y| \leq \varepsilon |y| \]

where $ \varepsilon $ is $ n $ times the machine accuracy; $ n $ equals 42 if not given.

bool close_enough Real  x,
Real  y
 

Follows somewhat the advice of Knuth on checking for floating-point equality. The closeness relationship is:

\[ \mathrm{close}(x,y,n) \equiv |x-y| \leq \varepsilon |x| \vee |x-y| \leq \varepsilon |y| \]

where $ \varepsilon $ is $ n $ times the machine accuracy; $ n $ equals 42 if not given.


QuantLib.org
QuantLib
Hosted by
SourceForge.net Logo
Documentation generated by
doxygen