tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
atanh.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_CMATH_ATANH_HPP
5#define TETL_CMATH_ATANH_HPP
6
7#include <etl/_3rd_party/gcem/gcem.hpp>
8#include <etl/_concepts/integral.hpp>
9#include <etl/_type_traits/is_constant_evaluated.hpp>
10
11namespace etl {
12
13namespace detail {
14
15inline constexpr struct atanh {
16 template <typename Float>
17 [[nodiscard]] constexpr auto operator()(Float arg) const noexcept -> Float
18 {
19#if not defined(__AVR__)
21 #if __has_builtin(__builtin_atanhf)
22 if constexpr (etl::same_as<Float, float>) {
23 return __builtin_atanhf(arg);
24 }
25 #endif
26 #if __has_builtin(__builtin_atanh)
27 if constexpr (etl::same_as<Float, double>) {
28 return __builtin_atanh(arg);
29 }
30 #endif
31 }
32#endif
33 return etl::detail::gcem::atanh(arg);
34 }
35} atanh;
36
37} // namespace detail
38
39/// \ingroup cmath
40/// @{
41
42/// Computes the inverse hyperbolic tangent of arg.
43/// \details https://en.cppreference.com/w/cpp/numeric/math/atanh
44[[nodiscard]] constexpr auto atanh(float arg) noexcept -> float
45{
46 return etl::detail::atanh(arg);
47}
48[[nodiscard]] constexpr auto atanhf(float arg) noexcept -> float
49{
50 return etl::detail::atanh(arg);
51}
52[[nodiscard]] constexpr auto atanh(double arg) noexcept -> double
53{
54 return etl::detail::atanh(arg);
55}
56[[nodiscard]] constexpr auto atanh(long double arg) noexcept -> long double
57{
58 return etl::detail::atanh(arg);
59}
60[[nodiscard]] constexpr auto atanhl(long double arg) noexcept -> long double
61{
62 return etl::detail::atanh(arg);
63}
64[[nodiscard]] constexpr auto atanh(integral auto arg) noexcept -> double
65{
66 return etl::detail::atanh(static_cast<double>(arg));
67}
68
69/// @}
70
71} // namespace etl
72
73#endif // TETL_CMATH_ATANH_HPP
constexpr auto atanh(float arg) noexcept -> float
Definition atanh.hpp:44
constexpr auto atanh(double arg) noexcept -> double
Definition atanh.hpp:52
constexpr auto atanh(long double arg) noexcept -> long double
Definition atanh.hpp:56
constexpr auto atanhl(long double arg) noexcept -> long double
Definition atanh.hpp:60
constexpr auto atanhf(float arg) noexcept -> float
Definition atanh.hpp:48
Definition adjacent_find.hpp:9
constexpr auto is_constant_evaluated() noexcept -> bool
Detects whether the function call occurs within a constant-evaluated context. Returns true if the eva...
Definition is_constant_evaluated.hpp:17