Open oameye opened 5 months ago
Thanks for the info. I would totally agree on switching to an implementation with complex output, but it should work with at least ForwardDiff, ReverseDiff and Zygote. Can you please check for that?
I cannot seem to let it work with ReverseDiff yet.
However, Zygote has native eigen support:
using Zygote, LinearAlgebra
function test_eigen(x)
A = [x[1] x[2]; x[3] 2.0]
λ = eigen(A).values
return sum(abs.(λ))
end
function test_eigvals(x)
A = [x[1] x[2]; x[3] 2.0]
λ = eigvals(A)
return sum(abs.(λ))
end
x = [-4.0, -17.0, 2.0]
G1_zyg = Zygote.gradient(test_eigen, x)[1]
G2_zyg = Zygote.gradient(test_eigvals, x)[1]
The implementation taken from here, has complex number output.
Code can be tested with: