Skip to content

Commit dd50a79

Browse files
author
Roger-luo
committed
fix test & add an upper bound
1 parent 4fa67c9 commit dd50a79

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/grad.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Approximate the gradient of `f` at `xs...` using `fdm`. Assumes that `f(xs...)`
88
"""
99
function grad end
1010

11-
function grad(fdm, f, x::AbstractArray{T}) where T
11+
function grad(fdm, f, x::AbstractArray{T}) where T <: Number
1212
dx = similar(x)
1313
tmp = similar(x)
1414
for k in eachindex(x)
@@ -49,7 +49,7 @@ end
4949
Approximate the Jacobian of `f` at `x` using `fdm`. `f(x)` must be a length `D` vector. If
5050
`D` is not provided, then `f(x)` is computed once to determine the output size.
5151
"""
52-
function jacobian(fdm, f, x::Union{T, AbstractArray{T}}; len::Int=length(f(x))) where {T <: Real}
52+
function jacobian(fdm, f, x::Union{T, AbstractArray{T}}; len::Int=length(f(x))) where {T <: Number}
5353
J = Matrix{float(T)}(undef, len, length(x))
5454
for d in 1:len
5555
gs = grad(fdm, x->f(x)[d], x)

0 commit comments

Comments
 (0)