jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
291 stars 35 forks source link

ReverseDiff with scalar components broken #125

Closed jonniedie closed 2 years ago

jonniedie commented 2 years ago
using ForwardDiff, ReverseDiff

F(x, θ, deg) = (θ[1] - x[1])^deg + θ[2] * (x[2] - x[1]^deg)^deg

ca = ComponentArray(x = [1, 20], θ = [10.0, 100.0], deg = 2.0)

ForwardDiff.gradient(F_idx, ca)
# ComponentVector{Float64}(x = [-7618.0, 3800.0], θ = [18.0, 361.0], deg = 106472.22233867274)

ReverseDiff.gradient(F_idx, ca)
# ComponentVector{Float64}(x = [-7618.0, 3800.0], θ = [18.0, 361.0], deg = 0.0)