Repository navigation
Disambiguate *(::AbstractMatrix, ::AbstractNoTimeSolution) against LinearAlgebra/StaticArrays - #1365
Merged
ChrisRackauckas merged 2 commits intoMay 26, 2026
Conversation
…tractNoTimeSolution)` After SciML#1363 added `Base.:*(A::AbstractMatrix, sol::AbstractNoTimeSolution) = A * sol.u`, LinearSolve's `test/nopre/static_arrays.jl` started failing with a MethodError ambiguity between that method and StaticArrays' `*(::StaticMatrix, ::AbstractVector)`. This adds a weakdep extension on StaticArrays that defines the disambiguating method `*(::StaticMatrix, ::AbstractNoTimeSolution{<:Any, 1})`, which Julia's dispatcher selects unambiguously. Co-Authored-By: Chris Rackauckas <[email protected]>
…oTimeSolution)` The broad `*(A::AbstractMatrix, sol::AbstractNoTimeSolution) = A * sol.u` method introduced in SciML#1363 had unresolved ambiguities with LinearAlgebra's specialized methods (Diagonal, AbstractTriangular, Adjoint/Transpose-of-vector) that surfaced as Aqua `detect_ambiguities` failures and a MethodError in LinearSolve.jl's static_arrays test. Add disambiguators in solution_interface.jl that forward each conflicting signature to `A * sol.u`, preserving the LinearAlgebra fast paths. Also broaden the StaticArrays extension to cover both N=1 and N=2 sol shapes (StaticMatrix * AbstractMatrix exists in StaticArrays too). Verified locally: `Test.detect_ambiguities(SciMLBase)` returns empty on both Julia 1.10 and 1.12 with these methods. Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas
marked this pull request as ready for review
May 26, 2026 21:53
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/SciMLBase.jl
that referenced
this pull request
May 26, 2026
Empty commit to nudge GitHub to refresh PR SciML#1365 head — webhook didn't fire for the previous runic-fix push. Co-Authored-By: Chris Rackauckas <[email protected]>
1 task
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.
Note
Please ignore this PR until reviewed by @ChrisRackauckas.
Summary
The broad
method introduced in #1363 has ambiguities with LinearAlgebra's specialized
*methods (Diagonal, AbstractTriangular, Adjoint/Transpose-of-vector) and with StaticArrays'*(::StaticMatrix, ::AbstractVecOrMat). These surface as:detect_ambiguities(SciMLBase)failures on master (Tests / QA, both Julia 1.10 lts and 1.12)MethodError: ... is ambiguousin LinearSolve.jl'stest/nopre/static_arrays.jlPer discussion, we want to keep the broad overload (the AbstractArray fallback is slow because every
getindexgoes through the solution wrapper) and just disambiguate.Approach
In
src/solutions/solution_interface.jl, add per-conflict disambiguators that all forward toA * sol.u, preserving the LinearAlgebra fast paths:And a new
SciMLBaseStaticArraysExtextension that adds:The extension only loads when
StaticArraysis loaded, so users not using static arrays pay nothing.Verification
Local, both Julia 1.10 (LTS) and 1.12:
Local
include("test/solution_interface.jl")— all testsets pass, including the new 8-test "A * sol for AbstractNoTimeSolution" testset that exercises:Matrix * solDiagonal * sol,LowerTriangular * sol,UpperTriangular * solv' * sol,transpose(v) * solSMatrix * sol(LinearSolve regression)Files changed
src/solutions/solution_interface.jl— 7 LinearAlgebra disambiguatorsext/SciMLBaseStaticArraysExt.jl(new) — 1-method StaticMatrix disambiguatorProject.toml—StaticArraysweakdep + extension entry; version 3.15.0 → 3.15.1test/solution_interface.jl— regression testsetTest plan
test/nopre/static_arrays.jlpasses against this branch