Repository navigation
Solve with a SciMLStructures right-hand side - #1210
Merged
Merged
Conversation
A right-hand side that implements the SciMLStructures interface but is not an array could not be solved with at all. It failed in `__init` at `real(eltype(b))` while computing tolerance defaults, before any algorithm was reached, so it affected every algorithm rather than only the Krylov wrappers. `canonicalize` gives a flat buffer of the tunable values that the existing machinery already handles, and the interface's own `repack` rebuilds the container. The buffer is built once at `init`, and the solve writes back with `replace!` so a repeated solve does not allocate a new container. The answer goes into its own container rather than into `b`, which must survive the solve, and the solution is constructed directly because `build_linear_solution` reads `size(u)`, which a container that is not an array does not answer. Three entry points needed it: `init`, the `defaultalg` choice in `solve(prob, ::Nothing)` which reads `size(b)` before a cache exists, and `solve!`. Closes SciML#1208.
ChrisRackauckas
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
initlevel #1208, the follow-up to Krylov: support an ArrayPartition right-hand side #1206 for a right-hand side that implements the SciMLStructures interface but is not an array, such as theParametersobject from the SciMLStructures docs or anMTKParameters.__initatreal(eltype(b))while computing the tolerance defaults, before any algorithm was reached, so this affected every algorithm rather than only the Krylov wrappers.canonicalizegives a flat buffer of the tunable values that the existing machinery already handles, and the interface's ownrepackrebuilds the container. The buffer is built once atinitand the solve writes back withreplace!, so a repeated solve does not allocate a new container.b, which has to survive the solve. There is a test asserting the right-hand side is unchanged, since the first version of this did overwrite it.build_linear_solution, which derivesNfromsize(u)and has nothing to read from a container that is not an array.init, thedefaultalgchoice insidesolve(prob, ::Nothing)which readssize(b)before a cache exists, andsolve!.bis not overwritten,initwith repeated solves against a newband a newA, and that ordinary array right-hand sides are not diverted through this path.AI Disclosure: Used Opus 5