Boost-Graph
view release on metacpan or search on metacpan
include/boost/test/floating_point_comparison.hpp view on Meta::CPAN
// ************** close_at_tolerance ************** //
// ************************************************************************** //
template<typename FPT, typename PersentType = FPT >
class close_at_tolerance {
public:
// Public typedefs
typedef bool result_type;
// Constructor
explicit close_at_tolerance( PersentType percentage_tolerance, floating_point_comparison_type fpc_type = FPC_STRONG )
: p_fraction_tolerance( static_cast<FPT>(0.01)*percentage_tolerance ), p_strong_or_weak( fpc_type == FPC_STRONG ) {}
bool operator()( FPT left, FPT right ) const
{
FPT diff = tt_detail::fpt_abs( left - right );
FPT d1 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( right ) );
FPT d2 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( left ) );
return p_strong_or_weak ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get())
: (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get());
}
include/boost/test/floating_point_comparison.hpp view on Meta::CPAN
// ************************************************************************** //
// ************** check_is_close ************** //
// ************************************************************************** //
struct check_is_close_t {
// Public typedefs
typedef bool result_type;
template<typename FPT, typename PersentType>
bool
operator()( FPT left, FPT right, PersentType percentage_tolerance, floating_point_comparison_type fpc_type = FPC_STRONG )
{
close_at_tolerance<FPT,PersentType> pred( percentage_tolerance, fpc_type );
return pred( left, right );
}
};
namespace {
check_is_close_t check_is_close;
}
//____________________________________________________________________________//
( run in 0.401 second using v1.01-cache-2.11-cpan-709fd43a63f )