Skip to content

Commit 7069619

Browse files
lkdvosclaude
andcommitted
Fix zero tangent guard in polar pullback
Guard `C .+= ΔP` with `!iszerotangent(ΔP)` in both `left_polar_pullback!` and `right_polar_pullback!` to handle the case where ΔP is `nothing`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a349aef commit 7069619

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/pullbacks/polar.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function left_polar_pullback!(ΔA::AbstractMatrix, A, WP, ΔWP; kwargs...)
1717
!iszerotangent(ΔW) && mul!(M, W', ΔW, 1, 1)
1818
!iszerotangent(ΔP) && mul!(M, ΔP, P, -1, 1)
1919
C = _sylvester(P, P, M' - M)
20-
C .+= ΔP
20+
!iszerotangent(ΔP) && (C .+= ΔP)
2121
ΔA = mul!(ΔA, W, C, 1, 1)
2222
if !iszerotangent(ΔW)
2323
ΔWP = ΔW / P
@@ -47,7 +47,7 @@ function right_polar_pullback!(ΔA::AbstractMatrix, A, PWᴴ, ΔPWᴴ; kwargs...
4747
!iszerotangent(ΔWᴴ) && mul!(M, ΔWᴴ, Wᴴ', 1, 1)
4848
!iszerotangent(ΔP) && mul!(M, P, ΔP, -1, 1)
4949
C = _sylvester(P, P, M' - M)
50-
C .+= ΔP
50+
!iszerotangent(ΔP) && (C .+= ΔP)
5151
ΔA = mul!(ΔA, C, Wᴴ, 1, 1)
5252
if !iszerotangent(ΔWᴴ)
5353
PΔWᴴ = P \ ΔWᴴ

0 commit comments

Comments
 (0)