Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impossible to differentiate over integer array #10

Open
lliill opened this issue Apr 10, 2019 · 2 comments
Open

impossible to differentiate over integer array #10

lliill opened this issue Apr 10, 2019 · 2 comments

Comments

@lliill
Copy link

lliill commented Apr 10, 2019

l(xu) = sum(sqrt(i^2 + 1) for i in xu)
xu = Vector(1:6)
result = DiffResults.HessianResult(xu)

result = ForwardDiff.hessian!(result, l, xu) will give
InexactError: Int64(Int64, 22.11744686954993)

Problem will be solve if xu = Vector{Float64}(1:6)

@gdalle
Copy link
Member

gdalle commented Mar 15, 2024

You're right, this gives an error, but there is a good reason. The result is created from integers, but the output of the function is promoted to float.

Enforcing that the result keeps the same number types is a good thing for type-stability, and that's why I don't think it would be a good idea to change that

@gdalle gdalle closed this as completed Mar 15, 2024
@gdalle
Copy link
Member

gdalle commented Mar 15, 2024

Reopening because a warning in the docs might make sense

@gdalle gdalle reopened this Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants