Skip to content

Commit

Permalink
Fixed a dispatch bug that would break derivatives of R->R^n functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dextorious committed Nov 20, 2017
1 parent a2466d9 commit 5b65ff8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Compute the derivative df of a callable f on a collection of points x.
Generic fallbacks for AbstractArrays that are not StridedArrays.
=#
function finite_difference(f, x::AbstractArray{<:Number},
function finite_difference(f, x::Union{<:Number,AbstractArray{<:Number}},
fdtype::DataType=Val{:central}, funtype::DataType=Val{:Real}, wrappertype::DataType=Val{:Default},
fx::Union{Void,AbstractArray{<:Number}}=nothing, epsilon::Union{Void,AbstractArray{<:Real}}=nothing, return_type::DataType=eltype(x))

df = zeros(return_type, size(x))
finite_difference!(df, f, x, fdtype, funtype, wrappertype, fx, epsilon, return_type)
end

function finite_difference!(df::AbstractArray{<:Number}, f, x::AbstractArray{<:Number},
function finite_difference!(df::AbstractArray{<:Number}, f, x::Union{<:Number,AbstractArray{<:Number}},
fdtype::DataType=Val{:central}, funtype::DataType=Val{:Real}, wrappertype::DataType=Val{:Default},
fx::Union{Void,AbstractArray{<:Number}}=nothing, epsilon::Union{Void,AbstractArray{<:Real}}=nothing, return_type::DataType=eltype(x))

Expand Down

0 comments on commit 5b65ff8

Please sign in to comment.