You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying ForwardDiff and found I have this simple function where calculating jacobian fails:
function g(x::Array{Float64,1})
c1_x1mostneg = x[1] .- x[2:end]
c2_x4mostpos = x[[1,2,3,5]] .- x[4]
return [c1_x1mostneg;c2_x4mostpos]
end
dg = x -> ForwardDiff.jacobian(g, x)
dg(randn(5))
with error message:
julia> dg(randn(5))
ERROR: MethodError: no method matching g(::Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1})
Closest candidates are:
g(::Array{Float64,1}) at none:2
Stacktrace:
[1] vector_mode_dual_eval(::typeof(g), ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/apiutils.jl:37
[2] vector_mode_jacobian(::typeof(g), ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:140
[3] jacobian(::Function, ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}, ::Val{true}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:17
[4] jacobian(::Function, ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:15 (repeats 2 times)
[5] (::var"#82#83")(::Array{Float64,1}) at ./none:1
[6] top-level scope at none:0
What do I misunderstand here?
The text was updated successfully, but these errors were encountered:
I was trying ForwardDiff and found I have this simple function where calculating jacobian fails:
function g(x::Array{Float64,1})
c1_x1mostneg = x[1] .- x[2:end]
c2_x4mostpos = x[[1,2,3,5]] .- x[4]
return [c1_x1mostneg;c2_x4mostpos]
end
dg = x -> ForwardDiff.jacobian(g, x)
dg(randn(5))
with error message:
julia> dg(randn(5))
ERROR: MethodError: no method matching g(::Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1})
Closest candidates are:
g(::Array{Float64,1}) at none:2
Stacktrace:
[1] vector_mode_dual_eval(::typeof(g), ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/apiutils.jl:37
[2] vector_mode_jacobian(::typeof(g), ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:140
[3] jacobian(::Function, ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}, ::Val{true}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:17
[4] jacobian(::Function, ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{typeof(g),Float64},Float64,5,Array{ForwardDiff.Dual{ForwardDiff.Tag{typeof(g),Float64},Float64,5},1}}) at /Users/havard/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:15 (repeats 2 times)
[5] (::var"#82#83")(::Array{Float64,1}) at ./none:1
[6] top-level scope at none:0
What do I misunderstand here?
The text was updated successfully, but these errors were encountered: