12 using std::cosh, std::sinh, std::tanh, std::exp, std::expm1;
17 template <
typename T>
auto __forceinline__ __device__ __host__
Cosh(
const T x) {
return cosh(x); }
18 template <
typename T>
auto __forceinline__ __device__ __host__
Sinh(
const T x) {
return sinh(x); }
19 template <
typename T>
auto __forceinline__ __device__ __host__
Tanh(
const T x) {
return tanh(x); }
20 template <
typename T>
auto __forceinline__ __device__ __host__
Coth(
const T x) {
return 1. / tanh(x); }
21 template <
typename T>
auto __forceinline__ __device__ __host__
Sech(
const T x) {
return 1. / cosh(x); }
22 template <
typename T>
auto __forceinline__ __device__ __host__
Csch(
const T x) {
return 1. / sinh(x); }
28 template <
typename T1,
typename T2>
29 requires(std::is_arithmetic_v<T2>)
30 auto __forceinline__ __device__ __host__
CothFiniteT(
const T1 x,
const T2 T)
32 using R =
decltype(
Coth(x / (2 * T)));
33 return is_close(T / x, T2(0)) ? (R)(
real(x) < 0 ? -1 : 1) :
Coth(x / (2 * T));
35 template <
typename T1,
typename T2>
36 requires(std::is_arithmetic_v<T2>)
37 auto __forceinline__ __device__ __host__
TanhFiniteT(
const T1 x,
const T2 T)
39 using R =
decltype(
Tanh(x / (2 * T)));
40 return is_close(T / x, T2(0)) ? (R)(
real(x) < 0 ? -1 : 1) :
Tanh(x / (2 * T));
42 template <
typename T1,
typename T2>
43 requires(std::is_arithmetic_v<T2>)
44 auto __forceinline__ __device__ __host__
SechFiniteT(
const T1 x,
const T2 T)
46 using R =
decltype(
Cosh(x / (2 * T)));
47 const auto res =
Cosh(x / (2 * T));
48 return !
isfinite(res) ? (R)0 : (R)(1) / res;
50 template <
typename T1,
typename T2>
51 requires(std::is_arithmetic_v<T2>)
52 auto __forceinline__ __device__ __host__
CschFiniteT(
const T1 x,
const T2 T)
54 using R =
decltype(
Sinh(x / (2 * T)));
55 const auto res =
Sinh(x / (2 * T));
56 return !
isfinite(res) ? (R)0 : (R)(1) / res;
63 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
cothS(
const T1 e,
const T2 T)
65 return 1. / tanh(e / (T * 2.));
68 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
dcothS(
const T1 e,
const T2 T)
70 return -1. /
powr<2>(sinh(e / (T * 2.))) / (2. * T);
73 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
ddcothS(
const T1 e,
const T2 T)
78 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
dddcothS(
const T1 e,
const T2 T)
83 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
tanhS(
const T1 e,
const T2 T)
85 return tanh(e / (T * 2.));
88 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
dtanhS(
const T1 e,
const T2 T)
90 return 1. /
powr<2>(cosh(e / (T * 2.))) / (2. * T);
93 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
ddtanhS(
const T1 e,
const T2 T)
98 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
sechS(
const T1 e,
const T2 T)
100 return 1. / cosh(e / (T * 2.));
103 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
cschS(
const T1 e,
const T2 T)
105 return 1. / sinh(e / (T * 2.));
112 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
nB(
const T1 e,
const T2 T)
114 return 1. / expm1(e / T);
117 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
dnB(
const T1 e,
const T2 T)
119 return -exp(e / T) /
powr<2>(expm1(e / T)) / T;
122 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
ddnB(
const T1 e,
const T2 T)
124 return exp(e / T) * (1. + exp(e / T)) /
powr<3>(expm1(e / T)) /
powr<2>(T);
127 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
nF(
const T1 e,
const T2 T)
129 return 1. / (exp(e / T) + 1.);
132 template <
typename T1,
typename T2>
auto __forceinline__ __device__ __host__
dnF(
const T1 e,
const T2 T)
134 return -exp(e / T) /
powr<2>(exp(e / T) + 1.) / T;
Definition complex_math.hh:14
constexpr __forceinline__ __host__ __device__ NumberType powr(const NumberType x)
A compile-time evaluatable power function for whole number exponents.
Definition math.hh:45
auto __forceinline__ __device__ __host__ tanhS(const T1 e, const T2 T)
Definition thermodynamics.hh:83
auto __forceinline__ __device__ __host__ cothS(const T1 e, const T2 T)
Definition thermodynamics.hh:63
auto __forceinline__ __device__ __host__ CothFiniteT(const T1 x, const T2 T)
Definition thermodynamics.hh:30
auto __forceinline__ __device__ __host__ Cosh(const T x)
Definition thermodynamics.hh:17
auto __forceinline__ __device__ __host__ Sech(const T x)
Definition thermodynamics.hh:21
bool __forceinline__ __host__ __device__ is_close(T1 a, T2 b, T3 eps_)
Function to evaluate whether two floats are equal to numerical precision. Tests for both relative and...
Definition math.hh:160
auto __forceinline__ __device__ __host__ Coth(const T x)
Definition thermodynamics.hh:20
auto __forceinline__ __device__ __host__ TanhFiniteT(const T1 x, const T2 T)
Definition thermodynamics.hh:37
AUTODIFF_DEVICE_FUNC auto real(const autodiff::Real< N, T > &a)
Definition complex_math.hh:148
auto __forceinline__ __device__ __host__ dtanhS(const T1 e, const T2 T)
Definition thermodynamics.hh:88
auto __forceinline__ __device__ __host__ CschFiniteT(const T1 x, const T2 T)
Definition thermodynamics.hh:52
auto __forceinline__ __device__ __host__ nB(const T1 e, const T2 T)
Definition thermodynamics.hh:112
auto __forceinline__ __device__ __host__ Csch(const T x)
Definition thermodynamics.hh:22
auto __forceinline__ __device__ __host__ dnF(const T1 e, const T2 T)
Definition thermodynamics.hh:132
auto __forceinline__ __device__ __host__ dddcothS(const T1 e, const T2 T)
Definition thermodynamics.hh:78
auto __forceinline__ __device__ __host__ nF(const T1 e, const T2 T)
Definition thermodynamics.hh:127
auto __forceinline__ __device__ __host__ ddcothS(const T1 e, const T2 T)
Definition thermodynamics.hh:73
auto __forceinline__ __device__ __host__ ddtanhS(const T1 e, const T2 T)
Definition thermodynamics.hh:93
auto __forceinline__ __device__ __host__ SechFiniteT(const T1 x, const T2 T)
Definition thermodynamics.hh:44
auto __forceinline__ __device__ __host__ cschS(const T1 e, const T2 T)
Definition thermodynamics.hh:103
auto __forceinline__ __device__ __host__ Sinh(const T x)
Definition thermodynamics.hh:18
auto __forceinline__ __device__ __host__ dcothS(const T1 e, const T2 T)
Definition thermodynamics.hh:68
auto __forceinline__ __device__ __host__ ddnB(const T1 e, const T2 T)
Definition thermodynamics.hh:122
auto __forceinline__ __device__ __host__ sechS(const T1 e, const T2 T)
Definition thermodynamics.hh:98
auto __forceinline__ __device__ __host__ Tanh(const T x)
Definition thermodynamics.hh:19
bool isfinite(const autodiff::Real< N, T > &x)
Finite-ness check for autodiff::real.
Definition math.hh:26
auto __forceinline__ __device__ __host__ dnB(const T1 e, const T2 T)
Definition thermodynamics.hh:117