Skip to content

Conversation

ChrisRackauckas-Claude
Copy link

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 in lib/NonlinearSolveSciPy/src/NonlinearSolveSciPy.jl:97
  • _make_py_scalar in lib/NonlinearSolveSciPy/src/NonlinearSolveSciPy.jl:108
  • dogleg_method!! in lib/SimpleNonlinearSolve/src/trust_region.jl:196
  • construct_jacobian in lib/NonlinearSolveHomotopyContinuation/src/jacobian_handling.jl:114 (general version)
  • construct_jacobian in lib/NonlinearSolveHomotopyContinuation/src/jacobian_handling.jl:185 (AutoEnzyme version)

Rationale

These functions either:

  • Call f directly as a function
  • Pass f to other functions (like ComplexJacobianWrapper)
  • Work with f in ways that benefit from type specialization

Adding 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.

Similar to SciML#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 in NonlinearSolveSciPy.jl
- _make_py_scalar in NonlinearSolveSciPy.jl
- dogleg_method!! in trust_region.jl
- construct_jacobian in jacobian_handling.jl (both general and AutoEnzyme versions)

These functions either call f directly, pass f to other functions, or work with f in ways that benefit from type specialization for better compiler optimizations.
@ChrisRackauckas ChrisRackauckas merged commit 6c9fbac into SciML:master Aug 21, 2025
27 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants