From c4b6ef0bd6a7b7de131786c661c7e3423e318d7e Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Wed, 21 May 2025 01:48:19 -0400 Subject: Add inverse hyperbolic derivatives (#7173) * Add inverse hyperbolic derivatives * Add test --- source/slang/diff.meta.slang | 6 ++++++ source/slang/hlsl.meta.slang | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'source') diff --git a/source/slang/diff.meta.slang b/source/slang/diff.meta.slang index d32584db0..c24a8b11a 100644 --- a/source/slang/diff.meta.slang +++ b/source/slang/diff.meta.slang @@ -1970,6 +1970,12 @@ SIMPLE_UNARY_DERIVATIVE_IMPL(asin, T(1.0) / sqrt(T(1.0) - dpx.p * dpx.p)) SIMPLE_UNARY_DERIVATIVE_IMPL(acos, T(-1.0) / sqrt(T(1.0) - dpx.p * dpx.p)) // Arc-tan SIMPLE_UNARY_DERIVATIVE_IMPL(atan, T(1.0) / (T(1.0) + dpx.p * dpx.p)) +// Arc-sinh +SIMPLE_UNARY_DERIVATIVE_IMPL(asinh, T(1.0) / sqrt(dpx.p * dpx.p + T(1.0))) +// Arc-cosh +SIMPLE_UNARY_DERIVATIVE_IMPL(acosh, T(1.0) / sqrt(dpx.p * dpx.p - T(1.0))) +// Arc-tanh +SIMPLE_UNARY_DERIVATIVE_IMPL(atanh, T(1.0) / (T(1.0) - dpx.p * dpx.p)) // Atan2 __generic diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 57cb188bb..e3d2d9dd2 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -6452,6 +6452,18 @@ vector acosh(vector x) } } +__generic +[__readNone] +[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)] +matrix acosh(matrix x) +{ + __target_switch + { + case hlsl: __intrinsic_asm "acosh"; + default: + MATRIX_MAP_UNARY(T, N, M, acosh, x); + } +} // Test if all components are non-zero. __generic @@ -6955,6 +6967,19 @@ vector asinh(vector x) } } +__generic +[__readNone] +[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)] +matrix asinh(matrix x) +{ + __target_switch + { + case hlsl: __intrinsic_asm "asinh"; + default: + MATRIX_MAP_UNARY(T, N, M, asinh, x); + } +} + /// Reinterpret bits as an int. /// @category conversion [__readNone] @@ -7577,6 +7602,19 @@ vector atanh(vector x) } } +__generic +[__readNone] +[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)] +matrix atanh(matrix x) +{ + __target_switch + { + case hlsl: __intrinsic_asm "atanh"; + default: + MATRIX_MAP_UNARY(T, N, M, atanh, x); + } +} + /// Ceiling. Returns the smallest integer that is greater than or equal to the specified value. /// @param x The value. /// @return The smallest integer that is greater than or equal to the specified value. -- cgit v1.2.3