From 36de4fe6e974cd5bfebc40fc6a2d70452043e5e5 Mon Sep 17 00:00:00 2001 From: Rinzii Date: Sun, 3 Mar 2024 09:20:34 -0500 Subject: [PATCH] cleanup of log details and add more comments. --- .../exponential/details/log_double_impl.hpp | 11 ++++++++- .../exponential/details/log_float_impl.hpp | 24 +++++++++++++++++++ .../exponential/details/log_ldouble_impl.hpp | 9 ------- 3 files changed, 34 insertions(+), 10 deletions(-) delete mode 100644 include/ccmath/detail/exponential/details/log_ldouble_impl.hpp diff --git a/include/ccmath/detail/exponential/details/log_double_impl.hpp b/include/ccmath/detail/exponential/details/log_double_impl.hpp index 59c60ef3..92f8754d 100644 --- a/include/ccmath/detail/exponential/details/log_double_impl.hpp +++ b/include/ccmath/detail/exponential/details/log_double_impl.hpp @@ -17,6 +17,8 @@ #include "ccmath/internal/predef/unlikely.hpp" + + namespace ccm::internal { namespace @@ -31,9 +33,16 @@ namespace ccm::internal { double ln2hi{0x1.62e42fefa3800p-1}; double ln2lo{0x1.ef35793c76730p-45}; + + // relative error: 0x1.926199e8p-56 + // abs error: 0x1.882ff33p-65 + // in -0x1.fp-9 0x1.fp-9 std::array poly{ -0x1.0000000000001p-1, 0x1.555555551305bp-2, -0x1.fffffffeb459p-3, 0x1.999b324f10111p-3, -0x1.55575e506c89fp-3, }; + + // relative error: 0x1.c04d76cp-63 + // in -0x1p-4 0x1.09p-4 (|log(1+x)| > 0x1p-4 outside the interval) std::array poly1{ -0x1p-1, 0x1.5555555555577p-2, @@ -262,7 +271,7 @@ namespace ccm::internal if (CCM_UNLIKELY(top - 0x0010 >= 0x7ff0 - 0x0010)) { // x < 0x1p-1022 or inf or nan. - // TODO: This actually like never will be hit, but double check this. + // TODO: This actually likely never will be hit, but double check this. if (intX * 2 == 0) { // Handle division by zero diff --git a/include/ccmath/detail/exponential/details/log_float_impl.hpp b/include/ccmath/detail/exponential/details/log_float_impl.hpp index 8057491f..49d07789 100644 --- a/include/ccmath/detail/exponential/details/log_float_impl.hpp +++ b/include/ccmath/detail/exponential/details/log_float_impl.hpp @@ -7,3 +7,27 @@ */ #pragma once + + +#include "ccmath/detail/compare/isnan.hpp" + +#include +#include +#include +#include + +#include "ccmath/internal/predef/unlikely.hpp" + + + +namespace ccm::internal +{ + namespace + { + namespace impl + { + // TODO: Implement float version of log + // TODO: Decide if we instead just default to double version always. + } // namespace impl + } // namespace +} // namespace ccm::internal diff --git a/include/ccmath/detail/exponential/details/log_ldouble_impl.hpp b/include/ccmath/detail/exponential/details/log_ldouble_impl.hpp deleted file mode 100644 index 8057491f..00000000 --- a/include/ccmath/detail/exponential/details/log_ldouble_impl.hpp +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2024-Present Ian Pike - * Copyright (c) 2024-Present ccmath contributors - * - * This library is provided under the MIT License. - * See LICENSE for more information. - */ - -#pragma once