GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/absmax.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 63 63 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 <type_traits>
14 #include <polyfloat/module/core/abs.hpp>
15 #include <polyfloat/module/core/max.hpp>
16
17 namespace plf
18 {
19
20 template<typename Options>
21 struct absmax_t : eve::strict_tuple_callable<absmax_t, Options, raw_option, pedantic_option>
22 {
23 template<typename... Ts> struct result : as_polyfloat_like<Ts...>
24 {
25 };
26
27 template<concepts::polyfloat_like... Ts>
28 requires(eve::same_lanes_or_scalar<Ts...>)
29 84 POLYFLOAT_ABI typename result<Ts...>::type constexpr operator()(Ts... ts) const noexcept
30 {
31 84 return POLYFLOAT_CALL(ts...);
32 }
33
34 template<eve::non_empty_product_type Tup>
35 requires(eve::same_lanes_or_scalar_tuple<Tup> && !concepts::polyfloat_like<Tup>)
36 POLYFLOAT_ABI constexpr kumi::apply_traits_t<result, Tup> operator()(Tup const& t) const noexcept
37 requires(kumi::size_v<Tup> >= 1)
38 {
39 return POLYFLOAT_CALL(t);
40 }
41
42 84 POLYFLOAT_CALLABLE_OBJECT(absmax_t, absmax_);
43 };
44 //======================================================================================================================
45 //! @addtogroup core
46 //! @{
47 //! @var absmax
48 //! @brief return the absolute value of the maximum of the parameters.
49 //!
50 //! @groupheader{Header file}
51 //!
52 //! @code
53 //! #include <polyfloat/core.hpp>
54 //! @endcode
55 //!
56 //! @groupheader{Callable Signatures}
57 //!
58 //! @code
59 //! namespace polyfloat
60 //! {
61 //! template<polyfloat::concepts::polyfloat_like Z1, polyfloat_like Z2> constexpr auto absmax(Z1 z1, Z2 z2) noexcept;
62 //! }
63 //! @endcode
64 //!
65 //! **Parameters**
66 //!
67 //! * `z1`, `z2`: Values to process.
68 //!
69 //! **Return value**
70 //!
71 //! Returns the absolute value of the maximum of the arguments.
72 //!
73 //! @groupheader{Example}
74 //!
75 //! @godbolt{doc/core/absmax.cpp}
76 //======================================================================================================================
77
78 inline constexpr auto absmax = eve::functor<absmax_t>;
79 //======================================================================================================================
80 //! @}
81 //======================================================================================================================
82 }
83
84 namespace plf::_
85 {
86
87 template<eve::callable_options O, concepts::polyfloat_like T0, concepts::polyfloat_like... Ts>
88 84 constexpr auto absmax_(POLYFLOAT_DELAY(), O const& o, T0 const& t0, Ts const&... ts) noexcept
89 {
90 84 return plf::abs[o.drop(pedantic, numeric)](plf::max(t0, ts...));
91 }
92
93 }
94