Skip to content

Junk returned with functions returning reinterpret #209

Closed

Description

@mattsignorelli
using DifferentiationInterface
using FiniteDiff

foo(x) = reinterpret(Float64, [x[1] + 2*im*x[2], 3*x[1] + 4*im*x[2]])

This works with the default (forward finite differences):

jac = jacobian(foo, AutoFiniteDiff(), zeros(2))
#= Output:
4×2 Matrix{Float64}:
 1.0  0.0
 0.0  2.0
 3.0  0.0
 0.0  4.0
=#

But includes junk with central:

jac = jacobian(foo, AutoFiniteDiff(fdjtype=Val(:central)), zeros(2))
#= Output:
4×2 Matrix{Float64}:
 1.0           1.87254e-309
 1.87254e-309  2.0
 3.0           5.61763e-309
 7.49017e-309  4.0
=#

Activity

  1. mattsignorelli commented on Mar 31, 2026

    @mattsignorelli
    Author

    This is an issue with DI

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