Closed
Description
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 = q̇ -> 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
Labels
No labels