@@ -6,7 +6,7 @@ Approximate the Jacobian of `f` at `x` using `fdm`. Results will be returned as
6
6
version of `x`, and `y_vec` the flattened version of `f(x...)`. Flattening performed by
7
7
[`to_vec`](@ref).
8
8
"""
9
- function jacobian (fdm, f, x:: Vector {<:Real} ; len= nothing )
9
+ function jacobian (fdm, f, x:: AbstractVector {<:Real} ; len= nothing )
10
10
len != = nothing && Base. depwarn (
11
11
" `len` keyword argument to `jacobian` is no longer required " *
12
12
" and will not be permitted in the future." ,
40
40
replace_arg (x, xs:: Tuple , k:: Int ) = ntuple (p -> p == k ? x : xs[p], length (xs))
41
41
42
42
"""
43
- _jvp(fdm, f, x::Vector {<:Real}, ẋ::AbstractVector{<:Real})
43
+ _jvp(fdm, f, x::AbstractVector {<:Real}, ẋ::AbstractVector{<:Real})
44
44
45
45
Convenience function to compute `jacobian(f, x) * ẋ`.
46
46
"""
47
- function _jvp (fdm, f, x:: Vector {<:Real} , ẋ:: Vector {<:Real} )
47
+ function _jvp (fdm, f, x:: AbstractVector {<:Real} , ẋ:: AbstractVector {<:Real} )
48
48
return fdm (ε -> f (x .+ ε .* ẋ), zero (eltype (x)))
49
49
end
50
50
79
79
80
80
j′vp (fdm, f, ȳ, xs... ) = j′vp (fdm, xs-> f (xs... ), ȳ, xs)[1 ]
81
81
82
- function _j′vp (fdm, f, ȳ:: Vector {<:Real} , x:: Vector {<:Real} )
82
+ function _j′vp (fdm, f, ȳ:: AbstractVector {<:Real} , x:: AbstractVector {<:Real} )
83
83
isempty (x) && return eltype (ȳ)[] # if x is empty, then so is the jacobian and x̄
84
84
return transpose (first (jacobian (fdm, f, x))) * ȳ
85
85
end
0 commit comments