TDLS 0.2.0
Tiny Device-callable Linear Solvers
Loading...
Searching...
No Matches
math.hpp File Reference

Scalar math helpers usable in constant expressions. More...

#include <cmath>
#include <tdls/core/macros.hpp>
Include dependency graph for math.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
TDLS_HOST_DEVICE TDLS_FORCEINLINE constexpr T tdls::detail::abs (const T x) noexcept
 Absolute value usable in constant expressions.
 

Detailed Description

Scalar math helpers usable in constant expressions.

Author
Tristan Chenaille

Function Documentation

◆ abs()

template<typename T >
TDLS_HOST_DEVICE TDLS_FORCEINLINE constexpr T tdls::detail::abs ( const T x)
nodiscardconstexprnoexcept

Absolute value usable in constant expressions.

std::fabs is not constexpr before C++23, so constant evaluation falls back to a ternary, indistinguishable from std::fabs in the magnitude comparisons of the solvers (signed zeros compare equal, NaNs propagate either way). At run time the function IS std::fabs: the naive ternary alone would forbid the single sign-bit instruction (it must preserve -0.0) and was measured 3% heavier in device code on the pivot search.

Template Parameters
Tscalar type
Parameters
[in]xvalue
Returns
the absolute value of x