GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/constants/invlog_2.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 14 14 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //======================================================================================================================
2 /*
3 POLYFLOAT - Extended precision floating points
4 Copyright : POLYFLOAT Contributors & Maintainers
5 SPDX-License-Identifier: BSL-1.0
6 */
7 //======================================================================================================================
8 #pragma once
9
10 #include <polyfloat/details/callable.hpp>
11 #include <polyfloat/types/concepts.hpp>
12 #include <polyfloat/types/traits.hpp>
13 #include <eve/module/math/constant/invlog_2.hpp>
14
15 namespace plf
16 {
17
18 template<typename Options>
19 struct invlog_2_t : plf::constant_callable<invlog_2_t, eve::invlog_2_t, Options, lower_option, upper_option>
20 {
21 82 template<typename T> POLYFLOAT_ABI static constexpr T value(eve::as<T> const&, auto const&)
22 {
23 using u_t = plf::as_component_type_t<T>;
24 if constexpr (plf::dimension_v<T> == 2)
25 {
26 22 if constexpr (std::same_as<u_t, float>) return plf::_::from_pair<float>(0x1.715476p+0, 0x1.4ae0cp-26);
27 else if constexpr (std::same_as<u_t, double>)
28 20 return plf::_::from_pair<double>(0x1.71547652b82fep+0, 0x1.777d0ffda0d24p-56);
29 }
30 else if constexpr (plf::dimension_v<T> == 3)
31 {
32 if constexpr (std::same_as<u_t, float>)
33 20 return plf::_::from_triple<float>(0x1.715476p+0, 0x1.4ae0cp-26, -0x1.e8883p-52);
34 else if constexpr (std::same_as<u_t, double>)
35 20 return plf::_::from_triple<double>(0x1.71547652b82fep+0, 0x1.777d0ffda0d24p-56, -0x1.60bb8a5442ab9p-110);
36 }
37 }
38
39 94 template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const
40 {
41 94 return POLYFLOAT_CALL(v);
42 }
43
44 POLYFLOAT_CALLABLE_OBJECT(invlog_2_t, invlog_2_);
45 };
46 //======================================================================================================================
47 //! @addtogroup constants
48 //! @{
49 //! @var invlog_2
50 //! @brief return the log(2) inverse value.
51 //!
52 //! @groupheader{Header file}
53 //!
54 //! @code
55 //! #include <polyfloat/math.hpp>
56 //! @endcode
57 //!
58 //! @groupheader{Callable Signatures}
59 //!
60 //! @code
61 //! namespace polyfloat
62 //! {
63 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto invlog_2(T z) noexcept;
64 //! }
65 //! @endcode
66 //!
67 //!
68 //! **Return value**
69 //!
70 //! Returns the inverse of log(2).
71 //!
72 //! @groupheader{Example}
73 //!
74 //! @godbolt_todo{doc/invlog_2.cpp}
75 //======================================================================================================================
76
77 inline constexpr auto invlog_2 = eve::functor<invlog_2_t>;
78 //======================================================================================================================
79 //! @}
80 //======================================================================================================================
81 }
82