diff --git a/include/clad/Differentiator/BuiltinDerivatives.h b/include/clad/Differentiator/BuiltinDerivatives.h index 55a1be918..8ebc681b5 100644 --- a/include/clad/Differentiator/BuiltinDerivatives.h +++ b/include/clad/Differentiator/BuiltinDerivatives.h @@ -152,6 +152,36 @@ __builtin_expf_pushforward(float x, float d_x) { return {__builtin_expf(x), __builtin_expf(x) * d_x}; } +CUDA_HOST_DEVICE inline ValueAndPushforward +__builtin_sinf_pushforward(float x, float d_x) { + return {__builtin_sinf(x), __builtin_cosf(x) * d_x}; +} + +CUDA_HOST_DEVICE inline ValueAndPushforward +__builtin_sin_pushforward(double x, double d_x) { + return {__builtin_sin(x), __builtin_cos(x) * d_x}; +} + +CUDA_HOST_DEVICE inline ValueAndPushforward +__builtin_cosf_pushforward(float x, float d_x) { + return {__builtin_cosf(x), (-1) * __builtin_sinf(x) * d_x}; +} + +CUDA_HOST_DEVICE inline ValueAndPushforward +__builtin_cos_pushforward(double x, double d_x) { + return {__builtin_cos(x), (-1) * __builtin_sin(x) * d_x}; +} + +CUDA_HOST_DEVICE inline ValueAndPushforward +__builtin_sqrtf_pushforward(float x, float d_x) { + return {builtin_sqrtf(x), (((T)1) / (((T)2) * builtin_sqrtf(x))) * d_x}; +} + +CUDA_HOST_DEVICE inline ValueAndPushforward +__builtin_sqrt_pushforward(double x, double d_x) { + return {builtin_sqrt(x), (((T)1) / (((T)2) * builtin_sqrt(x))) * d_x}; +} + CUDA_HOST_DEVICE inline void __builtin_expf_pullback(float x, float* d_x) { *d_x = __builtin_expf(x); }