tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
atan2.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_ATAN2_HPP
5#define TETL_CMATH_ATAN2_HPP
6
7#include <etl/_3rd_party/gcem/gcem.hpp>
8#include <etl/_type_traits/is_constant_evaluated.hpp>
9
10namespace etl {
11
12namespace detail {
13
14inline constexpr struct atan2 {
15 template <typename Float>
16 [[nodiscard]] constexpr auto operator()(Float x, Float y) const noexcept -> Float
17 {
19#if __has_builtin(__builtin_atan2f)
20 if constexpr (etl::same_as<Float, float>) {
21 return __builtin_atan2f(x, y);
22 }
23#endif
24#if __has_builtin(__builtin_atan2)
25 if constexpr (etl::same_as<Float, double>) {
26 return __builtin_atan2(x, y);
27 }
28#endif
29 }
30 return etl::detail::gcem::atan2(x, y);
31 }
32} atan2;
33
34} // namespace detail
35
36/// \ingroup cmath
37/// @{
38
39/// Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
40/// \details https://en.cppreference.com/w/cpp/numeric/math/atan2
41[[nodiscard]] constexpr auto atan2(float x, float y) noexcept -> float
42{
43 return etl::detail::atan2(x, y);
44}
45
46[[nodiscard]] constexpr auto atan2f(float x, float y) noexcept -> float
47{
48 return etl::detail::atan2(x, y);
49}
50
51[[nodiscard]] constexpr auto atan2(double x, double y) noexcept -> double
52{
53 return etl::detail::atan2(x, y);
54}
55
56[[nodiscard]] constexpr auto atan2(long double x, long double y) noexcept -> long double
57{
58 return etl::detail::atan2(x, y);
59}
60
61[[nodiscard]] constexpr auto atan2l(long double x, long double y) noexcept -> long double
62{
63 return etl::detail::atan2(x, y);
64}
65
66/// @}
67
68} // namespace etl
69
70#endif // TETL_CMATH_ATAN2_HPP
constexpr auto atan2f(float x, float y) noexcept -> float
Definition atan2.hpp:46
constexpr auto atan2(long double x, long double y) noexcept -> long double
Definition atan2.hpp:56
constexpr auto atan2l(long double x, long double y) noexcept -> long double
Definition atan2.hpp:61
constexpr auto atan2(float x, float y) noexcept -> float
Definition atan2.hpp:41
constexpr auto atan2(double x, double y) noexcept -> double
Definition atan2.hpp:51
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