|
Mundy: Multibody Nonlocal Dynamics Version of the Day
|
Math-function dispatch and scalar utilities compatible with custom scalar types. More...
Classes | |
| struct | mundy::passive_scalar< T > |
| Trait: underlying passive (non-AD) type of T. For an autodiff scalar (is_autodiff_scalar): passive_scalar_t<T> == typename T::value_type. For any other scalar (arithmetic types and custom non-autodiff scalars): passive_scalar_t<T> == T. More... | |
| struct | mundy::passive_scalar< T > |
Namespaces | |
| namespace | mundy |
Macros | |
| #define | MUNDY_MATH_DISPATCH_UNARY(func) |
| Unary: arithmetic -> Kokkos::func(x); AD -> ADL + using std::func. | |
| #define | MUNDY_MATH_DISPATCH_BINARY(func) |
| Binary (possibly mixed types): arithmetic -> Kokkos::func(a,b); AD -> ADL + using std::func. | |
Typedefs | |
| template<typename T> | |
| using | mundy::passive_scalar_t = typename passive_scalar<T>::type |
Functions | |
| mundy::MUNDY_MATH_DISPATCH_UNARY (cbrt) MUNDY_MATH_DISPATCH_UNARY(sin) MUNDY_MATH_DISPATCH_UNARY(cos) MUNDY_MATH_DISPATCH_UNARY(tan) MUNDY_MATH_DISPATCH_UNARY(asin) MUNDY_MATH_DISPATCH_UNARY(acos) MUNDY_MATH_DISPATCH_UNARY(atan) MUNDY_MATH_DISPATCH_UNARY(exp) MUNDY_MATH_DISPATCH_UNARY(log) MUNDY_MATH_DISPATCH_UNARY(log10) MUNDY_MATH_DISPATCH_UNARY(floor) MUNDY_MATH_DISPATCH_UNARY(ceil) MUNDY_MATH_DISPATCH_UNARY(round) MUNDY_MATH_DISPATCH_BINARY(atan2) MUNDY_MATH_DISPATCH_BINARY(pow) MUNDY_MATH_DISPATCH_BINARY(copysign) MUNDY_MATH_DISPATCH_BINARY(min) MUNDY_MATH_DISPATCH_BINARY(max) template< typename To | |
| Reinterprets the bits of From as To. | |
| From constexpr To | mundy::bit_cast (const From &from) |
| template<typename T> | |
| constexpr auto | mundy::abs (const T &x) |
| Absolute value (constexpr-compatible for arithmetic types, ADL for others). | |
| template<typename T> | |
| constexpr auto | mundy::fabs (const T &x) |
| Absolute value of a floating-point argument. Equivalent to abs() here. | |
| template<typename T> | |
| constexpr auto | mundy::sqrt (const T &x) |
| Square root (constexpr-compatible for float and double, ADL for non-arithmetic types). | |
| template<typename T> | |
| constexpr auto | mundy::rsqrt (const T &x) |
| Reciprocal square root 1 / sqrt(x) (constexpr-compatible for float and double, ADL for non-arithmetic types). | |
Variables | |
| template<typename T> | |
| constexpr auto | mundy::mundy_infinity_v = NumTraits<passive_scalar_t<T>>::infinity() |
| template<typename T> | |
| constexpr auto | mundy::mundy_epsilon_v = NumTraits<passive_scalar_t<T>>::epsilon() |
| template<typename T> | |
| constexpr auto | mundy::mundy_norm_min_v = NumTraits<passive_scalar_t<T>>::norm_min() |
For arithmetic types the dispatch routes through Kokkos (device-compatible).
For all other types (autodiff duals and other custom scalars) it uses using std::func; func(x) so that ADL finds whatever overload the scalar type provides in its own namespace.
abs and sqrt of float and double are also usable in constant expressions, with the same results as at run time. So is rsqrt, with the host's results.
| #define MUNDY_MATH_DISPATCH_UNARY | ( | func | ) |
| #define MUNDY_MATH_DISPATCH_BINARY | ( | func | ) |