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

Support for derivatives and Jacobians of complex-valued callables #17

Merged
merged 6 commits into from
Nov 9, 2017

Conversation

dextorious
Copy link
Contributor

This is far from perfect and requires major refactoring in the future (particularly when the constant propagation issues are resolved), but the new features generally work, the tests pass and there shouldn't be any regressions.

@codecov
Copy link

codecov bot commented Nov 7, 2017

Codecov Report

Merging #17 into master will increase coverage by 5.99%.
The diff coverage is 39.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #17      +/-   ##
==========================================
+ Coverage   34.34%   40.33%   +5.99%     
==========================================
  Files           1        4       +3     
  Lines         198      295      +97     
==========================================
+ Hits           68      119      +51     
- Misses        130      176      +46
Impacted Files Coverage Δ
src/diffeqwrappers.jl 0% <0%> (ø)
src/derivatives.jl 32.47% <32.47%> (ø)
src/finitediff.jl 63.15% <50%> (+28.81%) ⬆️
src/jacobians.jl 70.4% <70.4%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff050f4...9a8afdc. Read the comment docs.

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.7%) to 37.895% when pulling 4803b91 on complexdiff into ff050f4 on master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 8, 2017

Coverage Status

Coverage decreased (-5.7%) to 37.895% when pulling 4803b91 on complexdiff into ff050f4 on master.

@coveralls
Copy link

coveralls commented Nov 9, 2017

Coverage Status

Coverage decreased (-3.7%) to 39.933% when pulling f788176 on complexdiff into ff050f4 on master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 9, 2017

Coverage Status

Coverage decreased (-3.7%) to 39.933% when pulling f788176 on complexdiff into ff050f4 on master.

if fdtype==Val{:forward}
return sqrt(eps(T))
elseif fdtype==Val{:central}
return cbrt(eps(T))
else
error("Unrecognized fdtype: must be Val{:forward} or Val{:central}.")
end
nothing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why nothing here? Shouldn't this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nothing is redundant there, it will never do anything, but it won't prevent the error. I probably just wrote it by reflex.

elseif eltype(x) <: Real
return eltype(x)
elseif eltype(x) <: Complex
return eltype(x).parameters[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this type-inferrable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to:

julia> real(typeof(1.0+im))
Float64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, changed it to real(eltype(x)).

fx::Union{Void,AbstractArray{<:Real}}=nothing, epsilon::Union{Void,AbstractArray{<:Real}}=nothing, returntype=eltype(x),
df::Union{Void,AbstractArray{<:Real}}=nothing)

# TODO: test and rework this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test and rework what? Just this abstract dispatch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the implementation. It currently uses stuff like J[:,i], which will fail for matrix types that don't allow indexing. It's not a regression because we've never supported it, but it's not quite general enough for completely arbitrary matrices yet, and hasn't been tested on sufficiently exotic types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks.

@ChrisRackauckas
Copy link
Member

I agree that it's a little messy, but it's probably better to keep iterating it in subsequent PRs instead of trying to stuff it into one "perfect PR" (that's how things never finish...). So I left a few comments and we can go from there.

@ChrisRackauckas
Copy link
Member

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.3%) to 40.339% when pulling 9a8afdc on complexdiff into ff050f4 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-3.3%) to 40.339% when pulling 9a8afdc on complexdiff into ff050f4 on master.

@ChrisRackauckas ChrisRackauckas merged commit 114b946 into master Nov 9, 2017
@ChrisRackauckas ChrisRackauckas deleted the complexdiff branch November 9, 2017 14:28
@ChrisRackauckas ChrisRackauckas mentioned this pull request Nov 9, 2017
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

Successfully merging this pull request may close these issues.

None yet

3 participants