Skip to content

Conversation

@KnutAM
Copy link
Contributor

@KnutAM KnutAM commented Feb 13, 2022

This seemed nicely solved by @dlfivefifty in #513 (Discussed in #111 ), but I got an error when applying to the eigen function and not the eigvals functions that was tested.

f(x) = eigen(Symmetric(x*x')).vectors[:,1];
x0 = [1.,2.];
ForwardDiff.jacobian(f, x0)
ERROR: type Array has no field dv
Stacktrace:
 [1] getproperty
   @ .\Base.jl:42 [inlined]
 [2] eigen(A::Symmetric{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}, Matrix{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}}})
   @ ForwardDiff C:\Users\meyer\.julia\packages\ForwardDiff\PBzup\src\dual.jl:685
 [3] f(x::Vector{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}})
   @ Main .\REPL[37]:1
 [4] vector_mode_dual_eval!(f::typeof(f), cfg::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}}}, x::Vector{Float64})
   @ ForwardDiff C:\Users\meyer\.julia\packages\ForwardDiff\PBzup\src\apiutils.jl:37
 [5] vector_mode_jacobian(f::typeof(f), x::Vector{Float64}, cfg::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}}})   @ ForwardDiff C:\Users\meyer\.julia\packages\ForwardDiff\PBzup\src\jacobian.jl:148
 [6] jacobian(f::Function, x::Vector{Float64}, cfg::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}}}, ::Val{true})   @ ForwardDiff C:\Users\meyer\.julia\packages\ForwardDiff\PBzup\src\jacobian.jl:21
 [7] jacobian(f::Function, x::Vector{Float64}, cfg::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Float64}, Float64, 2}}}) (repeats 2 times)
   @ ForwardDiff C:\Users\meyer\.julia\packages\ForwardDiff\PBzup\src\jacobian.jl:19
 [8] top-level scope
   @ REPL[39]:1

This PR takes the original code suggested in #111, as I think there is a mixup between SymTridiagonal and Symmetric in the current implementation in master.
Edit: It also enables the differentiation of a Symmetric StaticMatrix.

@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2022

Codecov Report

Merging #575 (85c79a0) into master (29332b1) will increase coverage by 1.17%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #575      +/-   ##
==========================================
+ Coverage   85.39%   86.57%   +1.17%     
==========================================
  Files           9        9              
  Lines         856      894      +38     
==========================================
+ Hits          731      774      +43     
+ Misses        125      120       -5     
Impacted Files Coverage Δ
src/dual.jl 79.21% <100.00%> (+4.72%) ⬆️
src/derivative.jl 94.44% <0.00%> (-5.56%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29332b1...85c79a0. Read the comment docs.

@KnutAM
Copy link
Contributor Author

KnutAM commented Mar 31, 2022

@andreasnoack, since you reviewed #513, may I ask for your opinion on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants