File indexing completed on 2025-01-18 09:54:48
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Macros.hh"
0011
0012 namespace celeritas
0013 {
0014 namespace detail
0015 {
0016
0017
0018
0019
0020
0021
0022 template<class T>
0023 struct SoftEqualTraits
0024 {
0025 using value_type = T;
0026
0027
0028 static CELER_CONSTEXPR_FUNCTION value_type rel_prec()
0029 {
0030 static_assert(sizeof(T) == 0, "Invalid type for softeq!");
0031 return T();
0032 }
0033
0034
0035 static CELER_CONSTEXPR_FUNCTION value_type abs_thresh()
0036 {
0037 static_assert(sizeof(T) == 0, "Invalid type for softeq!");
0038 return T();
0039 }
0040 };
0041
0042 template<>
0043 struct SoftEqualTraits<double>
0044 {
0045 using value_type = double;
0046 static CELER_CONSTEXPR_FUNCTION value_type sqrt_prec() { return 1.0e-6; }
0047 static CELER_CONSTEXPR_FUNCTION value_type rel_prec() { return 1.0e-12; }
0048 static CELER_CONSTEXPR_FUNCTION value_type abs_thresh() { return 1.0e-14; }
0049 };
0050
0051 template<>
0052 struct SoftEqualTraits<float>
0053 {
0054 using value_type = float;
0055 static CELER_CONSTEXPR_FUNCTION value_type sqrt_prec() { return 1.0e-3f; }
0056 static CELER_CONSTEXPR_FUNCTION value_type rel_prec() { return 1.0e-6f; }
0057 static CELER_CONSTEXPR_FUNCTION value_type abs_thresh() { return 1.0e-6f; }
0058 };
0059
0060
0061 }
0062 }