Skip to content

Commit ff050f4

Browse files
authored
Merge pull request #15 from YingboMa/master
Use AbstractArray if JacobianWrapper is provided
2 parents 1156c83 + 6757a5e commit ff050f4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/finitediff.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ function finite_difference_jacobian!(J::StridedArray{T}, f, x::StridedArray{T},
235235
J
236236
end
237237

238-
# efficient implementations for OrdinaryDiffEq Jacobian wrappers, assuming the system function supplies StridedArrays
239-
function finite_difference_jacobian!(J::StridedArray{T}, f, x::StridedArray{T}, ::Type{Val{:forward}}, fx::StridedArray{T}, ::Type{Val{:JacobianWrapper}}) where T<:Real
238+
# efficient implementations for OrdinaryDiffEq Jacobian wrappers
239+
# AbstractArray{T} should be OK if JacobianWrapper is provided
240+
function finite_difference_jacobian!(J::AbstractArray{T}, f, x::StridedArray{T}, ::Type{Val{:forward}}, fx::StridedArray{T}, ::Type{Val{:JacobianWrapper}}) where T<:Real
240241
m, n = size(J)
241242
epsilon_factor = compute_epsilon_factor(Val{:forward}, T)
242243
x1, fx1 = f.x1, f.fx1
@@ -254,7 +255,7 @@ function finite_difference_jacobian!(J::StridedArray{T}, f, x::StridedArray{T},
254255
J
255256
end
256257

257-
function finite_difference_jacobian!(J::StridedArray{T}, f, x::StridedArray{T}, ::Type{Val{:central}}, fx::StridedArray{T}, ::Type{Val{:JacobianWrapper}}) where T<:Real
258+
function finite_difference_jacobian!(J::AbstractArray{T}, f, x::StridedArray{T}, ::Type{Val{:central}}, fx::StridedArray{T}, ::Type{Val{:JacobianWrapper}}) where T<:Real
258259
m, n = size(J)
259260
epsilon_factor = compute_epsilon_factor(Val{:central}, T)
260261
x1, fx1 = f.x1, f.fx1

0 commit comments

Comments
 (0)