Fix SplitFunction to use user-provided jvp function #1162
Merged
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
This PR fixes issue SciML/DifferentialEquations.jl#1109 where
SplitFunctionwas not using user-provided jvp (Jacobian-vector product) functions even when supplied.Problem
When a user provides a jvp function to
SplitFunction, it should be used instead of falling back to automatic differentiation. However, thehas_jvpcheck forSplitFunctionwas only checkingf.f1instead of first checking theSplitFunction's own jvp field.This caused the solver to use ForwardDiff with Dual numbers even when an analytical jvp was provided, leading to MethodErrors when the function signatures were restricted to
Vector{Float64}.Solution
Modified the
has_*functions forSplitFunctionandSplitSDEFunctionto check their own fields first before delegating tof.f1. This allows user-provided analytical derivatives (jvp, vjp, jac, tgrad, Wfact, etc.) to be properly detected and used with matrix-free Krylov solvers.Testing
Related Issue
Fixes SciML/DifferentialEquations.jl#1109
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]