jaulib v1.4.1-46-gef495a4
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
float_math.hpp File Reference
#include <cmath>
#include <climits>
#include <concepts>
#include <type_traits>
#include <jau/float_types.hpp>
#include <jau/base_math.hpp>
#include <jau/string_util.hpp>
#include <jau/string_cfmt.hpp>
#include <jau/type_concepts.hpp>
Include dependency graph for float_math.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 

Functions

template<std::floating_point T>
constexpr T jau::adeg_to_rad (const T arc_degree) noexcept
 Converts arc-degree to radians.
 
template<std::floating_point T>
constexpr bool jau::almost_equal (const T &a, const T &b, int ulp=1, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true, if both floating point values are equal in the sense that their potential difference is less or equal epsilon * |a+b| * ulp, where |a+b| scales epsilon to the magnitude of used values.
 
template<std::floating_point T>
constexpr int jau::compare (const T a, const T b) noexcept
 Returns -1, 0 or 1 if a is less, equal or greater than b, disregarding epsilon but considering NaN, -Inf and +Inf.
 
template<std::floating_point T>
constexpr int jau::compare (const T a, const T b, const T epsilon) noexcept
 Returns -1, 0 or 1 if a is less, equal or greater than b, considering epsilon and NaN, -Inf and +Inf.
 
template<std::floating_point T>
constexpr bool jau::equals (const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if both values are equal, i.e.
 
template<std::floating_point T>
constexpr bool jau::equals (const T &a, const T &b, int ulp, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true, if both floating point values are equal in the sense that their potential difference is less or equal epsilon * ulp.
 
template<std::floating_point T>
constexpr bool jau::equals2 (const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if both values are equal, i.e.
 
template<std::floating_point T>
constexpr bool jau::equals_raw (const T &a, const T &b) noexcept
 Returns true if both values are equal disregarding epsilon but considering NaN, -Inf and +Inf.
 
template<std::floating_point T>
constexpr bool jau::is_zero (const T &a, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if the given value is less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero2f (const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if all given values a and b are less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero3f (const T &a, const T &b, const T &c, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if all given values a, b and c are less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero4f (const T &a, const T &b, const T &c, const T &d, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
 Returns true if all given values a, b, c and d are less than epsilon, w/ epsilon > 0.
 
template<std::floating_point T>
constexpr bool jau::is_zero_raw (const T &a) noexcept
 Returns true if the given value is zero, disregarding epsilon but considering NaN, -Inf and +Inf.
 
template<std::floating_point T>
jau::machineEpsilon () noexcept
 Calculates the smallest floating point value approximation the given type T can represent, the machine epsilon of T.
 
template<std::floating_point T>
std::string & jau::mat_to_string (std::string &sb, const std::string &rowPrefix, const std::string_view f, const T a[], const jau::nsize_t rows, const jau::nsize_t columns, const bool rowMajorOrder) noexcept
 Appends a matrix of floating points to the given string sb
 
template<std::floating_point T>
constexpr T jau::rad_to_adeg (const T rad) noexcept
 Converts radians to arc-degree.
 
template<std::floating_point T>
constexpr jau::sint_bytes_t< sizeof(T)> jau::round_to_int (const T v) noexcept
 Returns the rounded value cast to signed int.
 
template<std::floating_point T>
constexpr jau::uint_bytes_t< sizeof(T)> jau::round_to_uint (const T v) noexcept
 Returns the rounded value cast to unsigned int.
 
template<std::floating_point T>
std::string & jau::row_to_string (std::string &sb, const std::string_view f, const T a[], const jau::nsize_t rows, const jau::nsize_t columns, const bool rowMajorOrder, const jau::nsize_t row) noexcept
 Appends a row of floating points to the given string sb
 

Variables

template<std::floating_point T>
constexpr T jau::EPSILON = std::numeric_limits<T>::epsilon()
 Alias for epsilon constant, i.e. std::numeric_limits<T>::epsilon()
 
template<std::floating_point T>
constexpr T jau::inv_PI = std::numbers::inv_pi_v<T>
 Alias for 1/π or inverse of π, i.e. T(1)/std::numbers::pi_v<T> or std::numbers::inv_pi_v<T>
 
template<std::floating_point T>
constexpr T jau::PI = std::numbers::pi_v<T>
 Alias for π or half-circle radians (180 degrees), i.e. std::numbers::pi_v<T>
 
template<std::floating_point T>
constexpr T jau::PI_2 = std::numbers::pi_v<T>/T(2)
 Alias for π/2 or right-angle radians (90 degrees), i.e. std::numbers::pi_v<T>/T(2)
 
template<std::floating_point T>
constexpr T jau::PI_4 = std::numbers::pi_v<T>/T(4)
 Alias for π/4 or half right-angle radians (45 degrees), i.e. std::numbers::pi_v<T>/T(4)