|
1 | | -@concrete struct JacobianWrapper{iip} <: Function |
2 | | - f |
3 | | - p |
4 | | -end |
5 | | - |
6 | | -# Previous Implementation did not hold onto `iip`, but this causes problems in packages |
7 | | -# where we check for the presence of function signatures to check which dispatch to call |
8 | | -(uf::JacobianWrapper{false})(u) = uf.f(u, uf.p) |
9 | | -(uf::JacobianWrapper{false})(res, u) = (vec(res) .= vec(uf.f(u, uf.p))) |
10 | | -(uf::JacobianWrapper{true})(res, u) = uf.f(res, u, uf.p) |
11 | | - |
12 | 1 | sparsity_detection_alg(_, _) = NoSparsityDetection() |
13 | 2 | function sparsity_detection_alg(f, ad::AbstractSparseADType) |
14 | 3 | if f.sparsity === nothing |
@@ -52,7 +41,7 @@ jacobian!!(::Number, cache) = last(value_derivative(cache.uf, cache.u)) |
52 | 41 | function jacobian_caches(alg::AbstractNonlinearSolveAlgorithm, f::F, u, p, ::Val{iip}; |
53 | 42 | linsolve_kwargs = (;), lininit::Val{linsolve_init} = Val(true), |
54 | 43 | linsolve_with_JᵀJ::Val{needsJᵀJ} = Val(false)) where {iip, needsJᵀJ, linsolve_init, F} |
55 | | - uf = JacobianWrapper{iip}(f, p) |
| 44 | + uf = SciMLBase.JacobianWrapper{iip}(f, p) |
56 | 45 |
|
57 | 46 | haslinsolve = hasfield(typeof(alg), :linsolve) |
58 | 47 |
|
@@ -152,7 +141,7 @@ function jacobian_caches(alg::AbstractNonlinearSolveAlgorithm, f::F, u::Number, |
152 | 141 | ::Val{false}; linsolve_with_JᵀJ::Val{needsJᵀJ} = Val(false), |
153 | 142 | kwargs...) where {needsJᵀJ, F} |
154 | 143 | # NOTE: Scalar `u` assumes scalar output from `f` |
155 | | - uf = JacobianWrapper{false}(f, p) |
| 144 | + uf = SciMLBase.JacobianWrapper{false}(f, p) |
156 | 145 | needsJᵀJ && return uf, nothing, u, nothing, nothing, u, u, u |
157 | 146 | return uf, nothing, u, nothing, nothing, u |
158 | 147 | end |
0 commit comments