diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-09-20 15:22:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-20 12:22:51 -0700 |
| commit | 25c79ada2c0fcc6c5ecb3e71ca073109adc1d7eb (patch) | |
| tree | 47f244aef7b89bf7ebeddac8c63c936531fb0b49 /source/slang | |
| parent | 73292d9f3a1c790f72802dfe4cce57a1353dece6 (diff) | |
Fix `atan2` stdlib derivative + add tests. (#3218)
* Fix atan2 stdlib derivative. Add tests for atan2
* Create dstdlib-atan2.slang.expected.txt
* Update tests
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/diff.meta.slang | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/slang/diff.meta.slang b/source/slang/diff.meta.slang index 495b6b989..75c57018c 100644 --- a/source/slang/diff.meta.slang +++ b/source/slang/diff.meta.slang @@ -1259,7 +1259,7 @@ __generic<T : __BuiltinFloatingPointType> DifferentialPair<T> __d_atan2(DifferentialPair<T> dpy, DifferentialPair<T> dpx) { T.Differential dx = __mul_p_d(-dpy.p / (dpx.p * dpx.p + dpy.p * dpy.p), dpx.d); - T.Differential dy = __mul_p_d(-dpx.p / (dpx.p * dpx.p + dpy.p * dpy.p), dpy.d); + T.Differential dy = __mul_p_d(dpx.p / (dpx.p * dpx.p + dpy.p * dpy.p), dpy.d); return DifferentialPair<T>( atan2(dpy.p, dpx.p), T.dadd(dx, dy)); @@ -1271,8 +1271,8 @@ __generic<T : __BuiltinFloatingPointType> [BackwardDerivativeOf(atan2)] void __d_atan2(inout DifferentialPair<T> dpy, inout DifferentialPair<T> dpx, T.Differential dOut) { - dpx = diffPair(dpx.p, __mul_p_d(-dpy.p / (dpx.p * dpx.p + dpy.p * dpy.p), dpx.d)); - dpy = diffPair(dpy.p, __mul_p_d(-dpx.p / (dpx.p * dpx.p + dpy.p * dpy.p), dpy.d)); + dpx = diffPair(dpx.p, __mul_p_d(-dpy.p / (dpx.p * dpx.p + dpy.p * dpy.p), dOut)); + dpy = diffPair(dpy.p, __mul_p_d(dpx.p / (dpx.p * dpx.p + dpy.p * dpy.p), dOut)); } VECTOR_MATRIX_BINARY_DIFF_IMPL(atan2) |
