Skip to content

Commit 5b65ff8

Browse files
committed
Fixed a dispatch bug that would break derivatives of R->R^n functions
1 parent a2466d9 commit 5b65ff8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/derivatives.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
Compute the derivative df of a callable f on a collection of points x.
33
Generic fallbacks for AbstractArrays that are not StridedArrays.
44
=#
5-
function finite_difference(f, x::AbstractArray{<:Number},
5+
function finite_difference(f, x::Union{<:Number,AbstractArray{<:Number}},
66
fdtype::DataType=Val{:central}, funtype::DataType=Val{:Real}, wrappertype::DataType=Val{:Default},
77
fx::Union{Void,AbstractArray{<:Number}}=nothing, epsilon::Union{Void,AbstractArray{<:Real}}=nothing, return_type::DataType=eltype(x))
88

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

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

0 commit comments

Comments
 (0)