Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
cmath.hpp File Reference

Math-function dispatch and scalar utilities compatible with auto-diff scalar types. More...

Classes

struct  mundy::passive_scalar< T >
 Trait: underlying passive (non-AD) type of T. For arithmetic T: passive_scalar_t<T> == T. For AD types exposing T::value_type: passive_scalar_t<T> == typename T::value_type. 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

Variables

template<typename T>
constexpr auto mundy::mundy_infinity_v = Kokkos::Experimental::infinity_v<passive_scalar_t<T>>
template<typename T>
constexpr auto mundy::mundy_epsilon_v = Kokkos::Experimental::epsilon_v<passive_scalar_t<T>>
template<typename T>
constexpr auto mundy::mundy_norm_min_v = Kokkos::Experimental::norm_min_v<passive_scalar_t<T>>

Detailed Description

For arithmetic types the dispatch routes through Kokkos (device-compatible). For all other types (AD duals, complex, ...) it uses using std::func; func(x) so that ADL finds whatever overload the AD library provides in its own namespace.

Macro Definition Documentation

◆ MUNDY_MATH_DISPATCH_UNARY

#define MUNDY_MATH_DISPATCH_UNARY ( func)
Value:
template <typename T> \
KOKKOS_INLINE_FUNCTION constexpr auto func(const T& x) { \
if constexpr (std::is_arithmetic_v<T>) { \
return Kokkos::func(x); \
} else { \
using std::func; \
return func(x); \
} \
}

◆ MUNDY_MATH_DISPATCH_BINARY

#define MUNDY_MATH_DISPATCH_BINARY ( func)
Value:
template <typename T> \
KOKKOS_INLINE_FUNCTION constexpr auto func(const T& a, const T& b) { \
if constexpr (std::is_arithmetic_v<T>) { \
return Kokkos::func(a, b); \
} else { \
using std::func; \
return func(a, b); \
} \
}