Mjolnir Core
Core functionality of the Mjolnir API
is_close.h
Go to the documentation of this file.
1 
7 
8 #pragma once
9 
11 
12 namespace mjolnir
13 {
16 
17 
23 template <typename T_Type>
24 inline constexpr T_Type default_tolerance_abs = static_cast<T_Type>(1E-6);
25 
44 template <typename T_Type>
45 requires Number<T_Type>
46 [[nodiscard]] inline auto
47 is_close_abs(T_Type lhs, T_Type rhs, T_Type tolerance = default_tolerance_abs<T_Type>) noexcept -> bool;
48 
49 
51 } // namespace mjolnir
52 
53 
54 // ====================================================================================================================
55 
56 
57 #include <cmath>
58 
59 namespace mjolnir
60 {
61 // --------------------------------------------------------------------------------------------------------------------
62 
63 
64 template <typename T_Type>
65 requires Number<T_Type>
66 [[nodiscard]] inline auto is_close_abs(T_Type lhs, T_Type rhs, T_Type tolerance) noexcept -> bool
67 {
68  return std::abs(lhs - rhs) <= tolerance;
69 }
70 
71 
72 } // namespace mjolnir
Contains some basic definitions and concepts that are frequently needed.
constexpr T_Type default_tolerance_abs
The default absolute tolerance.
Definition: is_close.h:24
requires Number< T_Type > auto is_close_abs(T_Type lhs, T_Type rhs, T_Type tolerance=default_tolerance_abs< T_Type >) noexcept -> bool
Return ´true´ if the difference between lhs and rhs is inside an absolute tolerance and false otherwi...
Definition: is_close.h:66
auto abs(T_RegisterType src) noexcept -> T_RegisterType
Return a new register with the absolute values of the input register.
Definition: sign_manipulation.h:108