Skip to content

Commit

Permalink
small fix in backward rule for leftorth, rightorth (#123)
Browse files Browse the repository at this point in the history
* small fix in backward rule for leftorth, rightorth

* Apply suggestions from code review

Co-authored-by: Lukas <[email protected]>

---------

Co-authored-by: Lukas <[email protected]>
  • Loading branch information
tangwei94 and lkdvos authored May 12, 2024
1 parent 79c2ae0 commit 7ee775b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/TensorKitChainRulesCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ function qr_pullback!(ΔA::AbstractMatrix, Q::AbstractMatrix, R::AbstractMatrix,

M = similar(R, (p, p))
ΔR isa AbstractZero || mul!(M, ΔR1, R1')
ΔQ isa AbstractZero || mul!(M, Q1', ΔQ1, -1, +1)
ΔQ isa AbstractZero || mul!(M, Q1', ΔQ1, -1, !(ΔR isa AbstractZero))
view(M, lowertriangularind(M)) .= conj.(view(M, uppertriangularind(M)))
if eltype(M) <: Complex
Md = view(M, diagind(M))
Expand Down Expand Up @@ -595,7 +595,7 @@ function lq_pullback!(ΔA::AbstractMatrix, L::AbstractMatrix, Q::AbstractMatrix,

M = similar(L, (p, p))
ΔL isa AbstractZero || mul!(M, L1', ΔL1)
ΔQ isa AbstractZero || mul!(M, ΔQ1, Q1', -1, +1)
ΔQ isa AbstractZero || mul!(M, ΔQ1, Q1', -1, !(ΔL isa AbstractZero))
view(M, uppertriangularind(M)) .= conj.(view(M, lowertriangularind(M)))
if eltype(M) <: Complex
Md = view(M, diagind(M))
Expand Down

0 comments on commit 7ee775b

Please sign in to comment.