Skip to content

extract_gradient! does not work for outputting to an Array #163

Closed

Description

@KristofferC

While this is an internal function, I think this behavior is weird. It should just extract the partials into the passed vector I presume?

julia> ForwardDiff.extract_gradient!(zeros(3), ForwardDiff.Dual(1.0, (2.0,3.0,4.0)))
------ MethodError --------------------- Stacktrace (most recent call last)

 [1] — extract_gradient!(::Array{Float64,1}, ::ForwardDiff.Dual{3,Float64}) at gradient.jl:40
 [2] — copy!(::Array{Float64,1}, ::ForwardDiff.Partials{3,Float64}) at multidimensional.jl:614

MethodError: no method matching getindex(::Tuple{Float64,Float64,Float64}, ::CartesianIndex{1})

Activity

  1. KristofferC commented on Dec 2, 2016

    @KristofferC
    CollaboratorAuthor

    Maybe a Base issue if getindex should be defined on tuples for CartesianIndex{1}?

  2. KristofferC commented on Dec 3, 2016

    @KristofferC
    CollaboratorAuthor
  3. jrevels commented on Dec 3, 2016

    @jrevels
    Member

    Good catch; it's because I forgot to define inearindexing for Partials as LinearFast. Fixed in #162 (probably should've been a separate PR but I was lazy).

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

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