Skip to content

Depwarn when mix ReverseDiff with ForwardDiff #78

Closed
@YingboMa

Description

@YingboMa

I have the following code

using ReverseDiff

m,g = 1, 9.8
t = 1
p = [5.,6]
q = [1.,2]

L(t,q,q̇) = m/2 * dot(q̇,q̇) - m*g*q[2]

function Legendre_transformation(F, w)
    wv = a->ForwardDiff.gradient(F, a)
    z = zeros(w)
    M = ForwardDiff.jacobian(wv, z)
    b = wv(z)
    v = M\(w-b)
    w'v - F(v)
end

function Lagrangian2Hamiltonian(Lagrangian, t, q, p)
    L =-> Lagrangian(t, q, q̇)
    Legendre_transformation(L, p)
end

H = (q, p)->Lagrangian2Hamiltonian(L, t, q, p)

(p, q) = ReverseDiff.gradient(a->-H(a, p), q)
(p, q)

that will produce the following depwarn

WARNING: `invoke(f, (types...), ...)` is deprecated, use `invoke(f, Tuple{types...}, ...)` instead                                                             
Stacktrace:                            
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70                                                                                                         
 [2] -(::ForwardDiff.Dual{2,ForwardDiff.Dual{2,Float64}}, ::ReverseDiff.TrackedReal{Float64,Float64,Void}) at /home/arch/.julia/v0.6/ReverseDiff/src/derivative
s/scalars.jl:20
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions