@@ -6,7 +6,7 @@ Approximate the Jacobian of `f` at `x` using `fdm`. Results will be returned as
66version of `x`, and `y_vec` the flattened version of `f(x...)`. Flattening performed by
77[`to_vec`](@ref).
88"""
9- function jacobian (fdm, f, x:: Vector {<:Real} ; len= nothing )
9+ function jacobian (fdm, f, x:: AbstractVector {<:Real} ; len= nothing )
1010 len != = nothing && Base. depwarn (
1111 " `len` keyword argument to `jacobian` is no longer required " *
1212 " and will not be permitted in the future." ,
4040replace_arg (x, xs:: Tuple , k:: Int ) = ntuple (p -> p == k ? x : xs[p], length (xs))
4141
4242"""
43- _jvp(fdm, f, x::Vector {<:Real}, ẋ::AbstractVector{<:Real})
43+ _jvp(fdm, f, x::AbstractVector {<:Real}, ẋ::AbstractVector{<:Real})
4444
4545Convenience function to compute `jacobian(f, x) * ẋ`.
4646"""
47- function _jvp (fdm, f, x:: Vector {<:Real} , ẋ:: Vector {<:Real} )
47+ function _jvp (fdm, f, x:: AbstractVector {<:Real} , ẋ:: AbstractVector {<:Real} )
4848 return fdm (ε -> f (x .+ ε .* ẋ), zero (eltype (x)))
4949end
5050
7979
8080j′vp (fdm, f, ȳ, xs... ) = j′vp (fdm, xs-> f (xs... ), ȳ, xs)[1 ]
8181
82- function _j′vp (fdm, f, ȳ:: Vector {<:Real} , x:: Vector {<:Real} )
82+ function _j′vp (fdm, f, ȳ:: AbstractVector {<:Real} , x:: AbstractVector {<:Real} )
8383 isempty (x) && return eltype (ȳ)[] # if x is empty, then so is the jacobian and x̄
8484 return transpose (first (jacobian (fdm, f, x))) * ȳ
8585end
0 commit comments