tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
pow.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_CMATH_POW_HPP
4#define TETL_CMATH_POW_HPP
5
6#include <etl/_config/all.hpp>
7
8#include <etl/_3rd_party/gcem/gcem.hpp>
10
11namespace etl {
12
16[[nodiscard]] constexpr auto pow(float base, float exp) -> float
17{
19#if __has_constexpr_builtin(__builtin_powf)
20 return __builtin_powf(base, exp);
21#else
22 return etl::detail::gcem::pow(base, exp);
23#endif
24 }
25#if __has_builtin(__builtin_powf)
26 return __builtin_powf(base, exp);
27#else
28 return etl::detail::gcem::pow(base, exp);
29#endif
30}
31
35[[nodiscard]] constexpr auto powf(float base, float exp) -> float { return etl::pow(base, exp); }
36
40[[nodiscard]] constexpr auto pow(double base, double exp) -> double
41{
43#if __has_constexpr_builtin(__builtin_pow)
44 return __builtin_pow(base, exp);
45#else
46 return etl::detail::gcem::pow(base, exp);
47#endif
48 }
49#if __has_builtin(__builtin_pow)
50 return __builtin_pow(base, exp);
51#else
52 return etl::detail::gcem::pow(base, exp);
53#endif
54}
55
59[[nodiscard]] constexpr auto pow(long double base, long double exp) -> long double
60{
61 return detail::gcem::pow(base, exp);
62}
63
67[[nodiscard]] constexpr auto powl(long double base, long double exp) -> long double { return etl::pow(base, exp); }
68
72[[nodiscard]] constexpr auto pow(float base, int iexp) -> float { return etl::pow(base, static_cast<float>(iexp)); }
73
77[[nodiscard]] constexpr auto pow(double base, int iexp) -> double { return etl::pow(base, static_cast<double>(iexp)); }
78
82[[nodiscard]] constexpr auto pow(long double base, int iexp) -> long double
83{
84 return etl::pow(base, static_cast<long double>(iexp));
85}
86
87} // namespace etl
88
89#endif // TETL_CMATH_POW_HPP
constexpr auto powl(long double base, long double exp) -> long double
Computes the value of base raised to the power exp.
Definition pow.hpp:67
constexpr auto pow(float base, float exp) -> float
Computes the value of base raised to the power exp.
Definition pow.hpp:16
constexpr auto powf(float base, float exp) -> float
Computes the value of base raised to the power exp.
Definition pow.hpp:35
constexpr auto exp(float arg) noexcept -> float
Computes e (Euler's number, 2.7182...) raised to the given power arg.
Definition exp.hpp:44
Definition adjacent_find.hpp:8
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:16