Version: SMASH-3.2.2
numerics.h File Reference

Generic numerical functions. More...

#include <algorithm>
#include <cassert>
#include <cmath>
#include <initializer_list>
#include <limits>
#include <type_traits>
#include "constants.h"

Go to the source code of this file.

Namespaces

 smash
 
 smash::detail
 

Functions

template<typename N , typename = std::enable_if_t<std::is_floating_point_v<N>>>
bool smash::detail::almost_equal_knuthish (const N x, const N y, const N epsilon, const N threshold=N{0.0}) noexcept
 Compare whether two floating-point numbers are approximately equal à la Knuth up to a given tolerance. More...
 
template<typename N , typename = std::enable_if_t<std::is_floating_point_v<N>>>
bool smash::almost_equal (const N x, const N y)
 Checks whether two floating-point numbers are almost equal. More...
 
template<typename N , typename = std::enable_if_t<std::is_floating_point_v<N>>>
bool smash::almost_equal_physics (const N x, const N y)
 Like smash::almost_equal, but using a less strict tolerance, smash::small_number. More...
 
template<typename T = std::initializer_list<double>>
bool smash::is_any_nan (const T &collection)
 Returns whether any element in a collection is NaN. More...
 

Detailed Description

Generic numerical functions.

This file collects generic numerical functions such as for approximate equality checks between two floating point values.

Definition in file numerics.h.