Skip to content

Commit f13e0a4

Browse files
goerzsethaxen
andauthored
Fix rrule for complex-valued determinants (#601)
* Fix rrule for det of complex matrix * Add test of rules for complex determinant * `ΔΩ * inv(x)'` ⇒ `inv(x)' * dot(Ω, ΔΩ)` Co-authored-by: Seth Axen <[email protected]> * Use a random matrix as a seed for the unitary * Bump patch number * Use `U = exp(B - B')` as complex `det` test matrix Co-authored-by: Seth Axen <[email protected]> Co-authored-by: Seth Axen <[email protected]>
1 parent 9023d89 commit f13e0a4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ChainRules"
22
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
3-
version = "1.28.0"
3+
version = "1.28.1"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/rulesets/LinearAlgebra/dense.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ frule((_, Δx), ::typeof(det), x::Number) = (det(x), Δx)
129129
function rrule(::typeof(det), x::Union{Number, AbstractMatrix})
130130
Ω = det(x)
131131
function det_pullback(ΔΩ)
132-
∂x = x isa Number ? ΔΩ : Ω * ΔΩ * inv(x)'
132+
∂x = x isa Number ? ΔΩ : inv(x)' * dot(Ω, ΔΩ)
133133
return (NoTangent(), ∂x)
134134
end
135135
return Ω, det_pullback

test/rulesets/LinearAlgebra/dense.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@
119119
test_rrule(f, B)
120120
end
121121
end
122+
@testset "$f(complex determinant)" begin
123+
B = randn(ComplexF64, 4, 4)
124+
U = exp(B - B')
125+
test_frule(f, U)
126+
test_rrule(f, U)
127+
end
122128
end
123129
@testset "logabsdet(::Matrix{$T})" for T in (Float64, ComplexF64)
124130
B = randn(T, 4, 4)

0 commit comments

Comments
 (0)