Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rrule for complex-valued determinants #601

Merged
merged 6 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rulesets/LinearAlgebra/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ frule((_, Δx), ::typeof(det), x::Number) = (det(x), Δx)
function rrule(::typeof(det), x::Union{Number, AbstractMatrix})
Ω = det(x)
function det_pullback(ΔΩ)
∂x = x isa Number ? ΔΩ : Ω * ΔΩ * inv(x)'
∂x = x isa Number ? ΔΩ : inv(x)' * dot(Ω, ΔΩ)
return (NoTangent(), ∂x)
end
return Ω, det_pullback
Expand Down
6 changes: 6 additions & 0 deletions test/rulesets/LinearAlgebra/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
test_rrule(f, B)
end
end
@testset "$f(unitary matrix)" begin
B = randn(ComplexF64, 4, 4)
U = exp(1im * (B + B'))
goerz marked this conversation as resolved.
Show resolved Hide resolved
test_frule(f, U)
test_rrule(f, U)
end
end
@testset "logabsdet(::Matrix{$T})" for T in (Float64, ComplexF64)
B = randn(T, 4, 4)
Expand Down