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// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_CMATH_POW_HPP
5#define TETL_CMATH_POW_HPP
6
7#include <etl/_config/all.hpp>
8
9#include <etl/_3rd_party/gcem/gcem.hpp>
10#include <etl/_type_traits/is_constant_evaluated.hpp>
11
12namespace etl {
13
14/// Computes the value of base raised to the power exp
15/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
16/// \ingroup cmath
17[[nodiscard]] constexpr auto pow(float base, float exp) -> float
18{
20#if __has_constexpr_builtin(__builtin_powf)
21 return __builtin_powf(base, exp);
22#else
23 return etl::detail::gcem::pow(base, exp);
24#endif
25 }
26#if __has_builtin(__builtin_powf)
27 return __builtin_powf(base, exp);
28#else
29 return etl::detail::gcem::pow(base, exp);
30#endif
31}
32
33/// Computes the value of base raised to the power exp
34/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
35/// \ingroup cmath
36[[nodiscard]] constexpr auto powf(float base, float exp) -> float
37{
38 return etl::pow(base, exp);
39}
40
41/// Computes the value of base raised to the power exp
42/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
43/// \ingroup cmath
44[[nodiscard]] constexpr auto pow(double base, double exp) -> double
45{
47#if __has_constexpr_builtin(__builtin_pow)
48 return __builtin_pow(base, exp);
49#else
50 return etl::detail::gcem::pow(base, exp);
51#endif
52 }
53#if __has_builtin(__builtin_pow)
54 return __builtin_pow(base, exp);
55#else
56 return etl::detail::gcem::pow(base, exp);
57#endif
58}
59
60/// Computes the value of base raised to the power exp
61/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
62/// \ingroup cmath
63[[nodiscard]] constexpr auto pow(long double base, long double exp) -> long double
64{
65 return detail::gcem::pow(base, exp);
66}
67
68/// Computes the value of base raised to the power exp
69/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
70/// \ingroup cmath
71[[nodiscard]] constexpr auto powl(long double base, long double exp) -> long double
72{
73 return etl::pow(base, exp);
74}
75
76/// Computes the value of base raised to the power exp
77/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
78/// \ingroup cmath
79[[nodiscard]] constexpr auto pow(float base, int iexp) -> float
80{
81 return etl::pow(base, static_cast<float>(iexp));
82}
83
84/// Computes the value of base raised to the power exp
85/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
86/// \ingroup cmath
87[[nodiscard]] constexpr auto pow(double base, int iexp) -> double
88{
89 return etl::pow(base, static_cast<double>(iexp));
90}
91
92/// Computes the value of base raised to the power exp
93/// \details https://en.cppreference.com/w/cpp/numeric/math/pow
94/// \ingroup cmath
95[[nodiscard]] constexpr auto pow(long double base, int iexp) -> long double
96{
97 return etl::pow(base, static_cast<long double>(iexp));
98}
99
100} // namespace etl
101
102#endif // TETL_CMATH_POW_HPP
constexpr auto pow(long double base, int iexp) -> long double
Computes the value of base raised to the power exp.
Definition pow.hpp:95
constexpr auto powl(long double base, long double exp) -> long double
Computes the value of base raised to the power exp.
Definition pow.hpp:71
constexpr auto pow(float base, int iexp) -> float
Computes the value of base raised to the power exp.
Definition pow.hpp:79
constexpr auto pow(long double base, long double exp) -> long double
Computes the value of base raised to the power exp.
Definition pow.hpp:63
constexpr auto pow(double base, int iexp) -> double
Computes the value of base raised to the power exp.
Definition pow.hpp:87
constexpr auto pow(float base, float exp) -> float
Computes the value of base raised to the power exp.
Definition pow.hpp:17
constexpr auto pow(double base, double exp) -> double
Computes the value of base raised to the power exp.
Definition pow.hpp:44
constexpr auto powf(float base, float exp) -> float
Computes the value of base raised to the power exp.
Definition pow.hpp:36
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