Specialize functions on f parameter for trim compatibility #686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Similar to #684 and SciML/OrdinaryDiffEq.jl#2854, this PR adds type specialization for the
f
parameter in several functions across NonlinearSolve.jl to improve compatibility with--trim
and reduce dynamic dispatch.Functions specialized
_make_py_residual
inlib/NonlinearSolveSciPy/src/NonlinearSolveSciPy.jl:97
_make_py_scalar
inlib/NonlinearSolveSciPy/src/NonlinearSolveSciPy.jl:108
dogleg_method!!
inlib/SimpleNonlinearSolve/src/trust_region.jl:196
construct_jacobian
inlib/NonlinearSolveHomotopyContinuation/src/jacobian_handling.jl:114
(general version)construct_jacobian
inlib/NonlinearSolveHomotopyContinuation/src/jacobian_handling.jl:185
(AutoEnzyme version)Rationale
These functions either:
f
directly as a functionf
to other functions (like ComplexJacobianWrapper)f
in ways that benefit from type specializationAdding
where F
type parameters enables better compiler optimizations and reduces dynamic dispatch, following the same pattern established in PR #684.Testing
The package compiles and loads successfully with these changes.