4#ifndef TETL_CMATH_FDIM_HPP
5#define TETL_CMATH_FDIM_HPP
7#include <etl/_config/all.hpp>
9#include <etl/_cmath/fmax.hpp>
10#include <etl/_type_traits/is_constant_evaluated.hpp>
16inline constexpr struct fdim {
17 template <
typename Float>
18 [[nodiscard]]
constexpr auto operator()(Float x, Float y)
const noexcept -> Float
21#if __has_builtin(__builtin_fdimf)
22 if constexpr (etl::same_as<Float,
float>) {
23 return __builtin_fdimf(x, y);
26#if __has_builtin(__builtin_fdim)
27 if constexpr (etl::same_as<Float,
double>) {
28 return __builtin_fdim(x, y);
32 return etl::fmax(x - y,
static_cast<Float>(0));
46 return etl::detail::fdim(x, y);
50 return etl::detail::fdim(x, y);
54 return etl::detail::fdim(x, y);
56[[
nodiscard]]
constexpr auto fdim(
long double x,
long double y)
noexcept ->
long double
58 return etl::detail::fdim(x, y);
60[[
nodiscard]]
constexpr auto fdiml(
long double x,
long double y)
noexcept ->
long double
62 return etl::detail::fdim(x, y);
constexpr auto fdiml(long double x, long double y) noexcept -> long double
Definition fdim.hpp:60
constexpr auto fdim(long double x, long double y) noexcept -> long double
Definition fdim.hpp:56
constexpr auto fdim(double x, double y) noexcept -> double
Definition fdim.hpp:52
constexpr auto fdimf(float x, float y) noexcept -> float
Definition fdim.hpp:48
constexpr auto fdim(float x, float y) noexcept -> float
Definition fdim.hpp:44
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