tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
atan.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_ATAN_HPP
5#define TETL_CMATH_ATAN_HPP
6
7#include <etl/_config/all.hpp>
8
9#include <etl/_3rd_party/gcem/gcem.hpp>
10#include <etl/_concepts/integral.hpp>
11#include <etl/_concepts/same_as.hpp>
12#include <etl/_type_traits/is_constant_evaluated.hpp>
13
14namespace etl {
15
16namespace detail {
17
18inline constexpr struct atan {
19 template <typename Float>
20 [[nodiscard]] constexpr auto operator()(Float arg) const noexcept -> Float
21 {
23#if __has_builtin(__builtin_atanf)
24 if constexpr (etl::same_as<Float, float>) {
25 return __builtin_atanf(arg);
26 }
27#endif
28#if __has_builtin(__builtin_atan)
29 if constexpr (etl::same_as<Float, double>) {
30 return __builtin_atan(arg);
31 }
32#endif
33 }
34 return etl::detail::gcem::atan(arg);
35 }
36} atan;
37
38} // namespace detail
39
40/// \ingroup cmath
41/// @{
42
43/// Computes the principal value of the arc tangent of arg.
44/// \details https://en.cppreference.com/w/cpp/numeric/math/atan
45[[nodiscard]] constexpr auto atan(float arg) noexcept -> float
46{
47 return etl::detail::atan(arg);
48}
49[[nodiscard]] constexpr auto atanf(float arg) noexcept -> float
50{
51 return etl::detail::atan(arg);
52}
53[[nodiscard]] constexpr auto atan(double arg) noexcept -> double
54{
55 return etl::detail::atan(arg);
56}
57[[nodiscard]] constexpr auto atan(long double arg) noexcept -> long double
58{
59 return etl::detail::atan(arg);
60}
61[[nodiscard]] constexpr auto atanl(long double arg) noexcept -> long double
62{
63 return etl::detail::atan(arg);
64}
65[[nodiscard]] constexpr auto atan(integral auto arg) noexcept -> double
66{
67 return etl::detail::atan(double(arg));
68}
69
70/// @}
71
72} // namespace etl
73
74#endif // TETL_CMATH_ATAN_HPP
constexpr auto atan(float arg) noexcept -> float
Definition atan.hpp:45
constexpr auto atanl(long double arg) noexcept -> long double
Definition atan.hpp:61
constexpr auto atan(long double arg) noexcept -> long double
Definition atan.hpp:57
constexpr auto atan(double arg) noexcept -> double
Definition atan.hpp:53
constexpr auto atanf(float arg) noexcept -> float
Definition atan.hpp:49
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