27 template <
typename gradient_type>
58 template <
typename gradient_type>
65 template <
typename gradient_type>
72 template <
typename gradient_type_a,
typename gradient_type_b>
79 template <
typename gradient_type>
86 template <
typename gradient_type>
93 template <
typename gradient_type>
100 template <
typename gradient_type_a,
typename gradient_type_b>
107 template <
typename gradient_type>
114 template <
typename gradient_type>
121 template <
typename gradient_type_a,
typename gradient_type_b>
128 template <
typename gradient_type>
135 template <
typename gradient_type>
142 template <
typename gradient_type_a,
typename gradient_type_b>
153 #define binary_comparator_overload(x) \
154 template <typename T> \
155 SMITH_HOST_DEVICE constexpr bool operator x(const dual<T>& a, double b) \
157 return a.value x b; \
160 template <typename T> \
161 SMITH_HOST_DEVICE constexpr bool operator x(double a, const dual<T>& b) \
163 return a x b.value; \
166 template <typename T, typename U> \
167 SMITH_HOST_DEVICE constexpr bool operator x(const dual<T>& a, const dual<U>& b) \
169 return a.value x b.value; \
178 #undef binary_comparator_overload
181 template <
typename gradient_type>
190 template <
typename gradient_type>
199 template <
typename gradient_type>
207 template <
typename gradient_type>
218 template <
typename gradient_type>
221 return (x.
value >= 0) ? x : -x;
228 template <
typename gradient_type>
232 return (a > b_dual) ? a : b_dual;
236 template <
typename gradient_type>
240 return (a_dual > b) ? a_dual : b;
244 template <
typename gradient_type>
247 return (a > b) ? a : b;
254 template <
typename gradient_type>
258 return (a < b_dual) ? a : b_dual;
262 template <
typename gradient_type>
266 return (a_dual < b) ? a_dual : b;
270 template <
typename gradient_type>
273 return (a < b) ? a : b;
280 template <
typename S,
typename T>
290 template <
typename T>
300 template <
typename S>
307 template <
typename gradient_type>
315 template <
typename gradient_type>
323 template <
typename gradient_type>
331 template <
typename gradient_type>
339 template <
typename gradient_type>
348 template <
typename gradient_type>
356 template <
typename gradient_type>
364 template <
typename gradient_type>
372 template <
typename gradient_type>
380 template <
typename gradient_type>
388 template <
typename gradient_type>
396 template <
typename gradient_type>
404 template <
typename gradient_type>
414 template <
typename gradient_type>
423 template <
typename gradient_type>
433 template <
typename T,
int... n>
444 template <
typename T>
451 template <
typename T>
458 template <
typename gradient_type>
465 template <
typename T>
467 static constexpr
bool value =
false;
471 template <
typename T>
478 #include "smith/numerics/functional/tuple_tensor_dual_functions.hpp"
This file contains the interface used for initializing/terminating any hardware accelerator-related f...
#define SMITH_HOST_DEVICE
Macro that evaluates to __host__ __device__ when compiling with nvcc or amdclang and does nothing on ...
Accelerator functionality.
SMITH_HOST_DEVICE auto log(dual< gradient_type > a)
implementation of the natural logarithm function for dual numbers
SMITH_HOST_DEVICE auto atan(dual< gradient_type > a)
implementation of atan for dual numbers
SMITH_HOST_DEVICE auto asin(dual< gradient_type > a)
implementation of asin for dual numbers
SMITH_HOST_DEVICE auto acos(dual< gradient_type > a)
implementation of acos for dual numbers
binary_comparator_overload(<)
implement operator< for dual numbers
SMITH_HOST_DEVICE auto exp(dual< gradient_type > a)
implementation of exponential function for dual numbers
constexpr SMITH_HOST_DEVICE auto & operator+=(dual< gradient_type > &a, const dual< gradient_type > &b)
compound assignment (+) for dual numbers
FieldStateWeightedSum operator+(const FieldState &x, const FieldState &y)
add two FieldState
SMITH_HOST_DEVICE auto atan2(dual< gradient_type > y, double x)
implementation of atan2 for dual numbers
SMITH_HOST_DEVICE auto pow(dual< gradient_type > a, double b)
implementation of a (dual) raised to the b (non-dual) power
std::ostream & operator<<(std::ostream &out, DoF dof)
stream output for DoF
dual(double, T) -> dual< T >
class template argument deduction guide for type dual.
SMITH_HOST_DEVICE auto sqrt(dual< gradient_type > x)
implementation of square root for dual numbers
SMITH_HOST_DEVICE auto cos(dual< gradient_type > a)
implementation of cosine for dual numbers
SMITH_HOST_DEVICE auto max(dual< gradient_type > a, double b)
Implementation of max for dual numbers.
constexpr SMITH_HOST_DEVICE auto get_gradient(dual< gradient_type > arg)
return the "gradient" part from a dual number type
SMITH_HOST_DEVICE auto pow(dual< gradient_type > a, dual< gradient_type > b)
implementation of a (dual) raised to the b (dual) power
constexpr SMITH_HOST_DEVICE auto get_value(const T &arg)
return the "value" part from a given type. For non-dual types, this is just the identity function
SMITH_HOST_DEVICE auto abs(dual< gradient_type > x)
Implementation of absolute value function for dual numbers.
FieldStateWeightedSum operator*(double a, const FieldState &b)
multiply scalar by a FieldState to get a temporary FieldStateWeightedSum which can cast back to a Fie...
constexpr SMITH_HOST_DEVICE auto inner(const dual< S > &A, const dual< T > &B)
SMITH_HOST_DEVICE auto log1p(dual< gradient_type > a)
implementation of the natural logarithm of one plus the argument function for dual numbers
constexpr SMITH_HOST_DEVICE auto & operator-=(dual< gradient_type > &a, const dual< gradient_type > &b)
compound assignment (-) for dual numbers
SMITH_HOST_DEVICE auto sin(dual< gradient_type > a)
implementation of sine for dual numbers
SMITH_HOST_DEVICE auto min(dual< gradient_type > a, double b)
Implementation of min for dual numbers.
FieldStateWeightedSum operator-(const FieldState &x, const FieldState &y)
subtract two FieldState
constexpr SMITH_HOST_DEVICE auto operator/(const dual< gradient_type > &a, double b)
division of a dual number by a non-dual number
SMITH_HOST_DEVICE auto atan2(dual< gradient_type > y, dual< gradient_type > x)
implementation of atan2 for dual numbers
constexpr SMITH_HOST_DEVICE auto make_dual(double x)
promote a value to a dual number of the appropriate type
Dual number struct (value plus gradient)
gradient_type gradient
the partial derivatives of value w.r.t. some other quantity
double value
the actual numerical value
constexpr SMITH_HOST_DEVICE auto & operator=(double b)
Copy assignment operator.
class for checking if a type is a dual number or not
static constexpr bool value
whether or not type T is a dual number