|
2 | 2 | function finite_difference_jacobian(f, x::AbstractArray{<:Number},
|
3 | 3 | fdtype::DataType=Val{:central}, funtype::DataType=Val{:Real},
|
4 | 4 | wrappertype::DataType=Val{:Default},
|
5 |
| - fx::Union{Void,AbstractArray{<:Number}}=nothing, epsilon::Union{Void,AbstractArray{<:Real}}=nothing, returntype=eltype(x)) |
| 5 | + fx::Union{Void,AbstractArray{<:Number}}=nothing, epsilon::Union{Void,AbstractArray{<:Real}}=nothing, returntype=eltype(x), |
| 6 | + inplace::DataType=Val{true}) |
6 | 7 |
|
7 | 8 | J = zeros(returntype, length(x), length(x))
|
8 | 9 | finite_difference_jacobian!(J, f, x, fdtype, funtype, wrappertype, fx,
|
9 |
| - epsilon, returntype) |
| 10 | + epsilon, returntype,inplace) |
10 | 11 | end
|
11 | 12 |
|
12 | 13 | function finite_difference_jacobian!(J::AbstractMatrix{<:Number}, f,
|
13 | 14 | x::AbstractArray{<:Number},
|
14 | 15 | fdtype::DataType=Val{:central}, funtype::DataType=Val{:Real},
|
15 | 16 | wrappertype::DataType=Val{:Default},
|
16 | 17 | fx::Union{Void,AbstractArray{<:Number}}=nothing,
|
17 |
| - epsilon::Union{Void,AbstractArray{<:Number}}=nothing, returntype=eltype(x)) |
| 18 | + epsilon::Union{Void,AbstractArray{<:Number}}=nothing, returntype=eltype(x), |
| 19 | + inplace::DataType=Val{true}) |
18 | 20 |
|
19 |
| - finite_difference_jacobian!(J, f, x, fdtype, funtype, wrappertype, fx, epsilon, returntype) |
| 21 | + finite_difference_jacobian!(J, f, x, fdtype, funtype, wrappertype, fx, |
| 22 | + epsilon, returntype, inplace) |
20 | 23 | end
|
21 | 24 |
|
22 | 25 | function finite_difference_jacobian!(J::AbstractMatrix{<:Real}, f,
|
23 | 26 | x::AbstractArray{<:Real},
|
24 | 27 | fdtype::DataType, ::Type{Val{:Real}}, ::Type{Val{:Default}},
|
25 |
| - fx::Union{Void,AbstractArray{<:Real}}=nothing, |
26 |
| - epsilon::Union{Void,AbstractArray{<:Real}}=nothing, returntype=eltype(x)) |
| 28 | + fx, epsilon, returntype=eltype(x), inplace::Type{Val{true}}) |
27 | 29 |
|
28 | 30 | # TODO: test and rework this to support GPUArrays and non-indexable types, if possible
|
29 | 31 | m, n = size(J)
|
|
69 | 71 | function finite_difference_jacobian!(J::AbstractMatrix{<:Number}, f,
|
70 | 72 | x::AbstractArray{<:Number},
|
71 | 73 | fdtype::DataType, ::Type{Val{:Complex}}, ::Type{Val{:Default}},
|
72 |
| - fx::Union{Void,AbstractArray{<:Number}}=nothing, epsilon::Union{Void,AbstractArray{<:Real}}=nothing, returntype=eltype(x)) |
| 74 | + fx, epsilon, returntype, inplace::Type{Val{true}}) |
73 | 75 |
|
74 | 76 | # TODO: test and rework this to support GPUArrays and non-indexable types, if possible
|
75 | 77 | m, n = size(J)
|
|
0 commit comments