IDS peak genericC++ v1.13.0
Loading...
Searching...
No Matches
peak_common_math.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <type_traits>
14#include <algorithm>
15#include <cstdint>
16#include <cstdlib>
17#include <limits>
18
19namespace peak
20{
21namespace common
22{
23namespace detail
24{
25
44template <typename H
46 ,
47 typename std::enable_if_t<std::is_floating_point<H>::value, int> = 0
49 >
50constexpr bool AreAlmostEqual(H lhs, H rhs, uint32_t ulp)
51{
52 return std::abs(lhs - rhs) <= std::numeric_limits<H>::epsilon() * (std::max)(std::abs(lhs), std::abs(rhs)) * static_cast<H>(ulp);
53}
54
55} // namespace detail
56} // namespace common
57} // namespace peak
constexpr bool AreAlmostEqual(H lhs, H rhs, uint32_t ulp)
Compares two floating-point values for approximate equality using a ULP-based tolerance.
Definition peak_common_math.hpp:50
Namespace for internal implementation details and low-level types.
Definition peak_common_math.hpp:24
Root namespace for common types and interfaces shared across multiple libraries.
Definition peak_common_math.hpp:22
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33