Fix jacobian2W! DimensionMismatch for ScalarOperator mass matrix (#3915)#3916
Open
singhharsh1708 wants to merge 1 commit into
Open
Fix jacobian2W! DimensionMismatch for ScalarOperator mass matrix (#3915)#3916singhharsh1708 wants to merge 1 commit into
singhharsh1708 wants to merge 1 commit into
Conversation
singhharsh1708
force-pushed
the
fix-scalaroperator-massmatrix-buildJW
branch
2 times, most recently
from
July 18, 2026 07:33
2d951f4 to
5063be8
Compare
ScalarOperator reports axes(mm) == (), unlike UniformScaling which jacobian2W! already special-cases, so it fell into the boundscheck meant for full matrices. Fixes SciML#3915.
singhharsh1708
force-pushed
the
fix-scalaroperator-massmatrix-buildJW
branch
from
July 21, 2026 14:31
5063be8 to
08be517
Compare
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.
Fixes #3915.
Bug
jacobian2W!/jacobian2Wspecial-casemass_matrix isa UniformScalingto skip theaxes(mass_matrix) == axes(W)boundscheck and use the scalar directly.ScalarOperatoris the same thing (λ·I) but isn't aUniformScaling, and reportsaxes(mm) == (), so it falls through to the boundscheck meant for full matrices and throws.IdentityOperatordoesn't hit this since itsaxeshappen to matchW.Fix
Treat
ScalarOperatorthe same asUniformScalingin bothjacobian2W!methods andjacobian2W, via_is_scalar_massmatrix/_scalar_massmatrix_λ. Follows #3814 → SciMLOperators#400 → #3837, the same operator-mass-matrix chain, one step further (this is the first place aScalarOperatormass matrix reaches once the entry crash andget_differential_varsare both already fixed).Tests
New
scalar_operator_massmatrix_tests.jl:jacobian2W!/jacobian2WonScalarOperatormatch theUniformScalingresult directly. Also verified end-to-end (not in the test suite, checked locally):TRBDF2()on Lorenz withmass_matrix = ScalarOperator(2.0)now succeeds and matchesmass_matrix = 2.0*Ito the solver's tolerance.OrdinaryDiffEqDifferentiationCore suite passes (24/24, including the new tests).AI Disclosure
Claude assisted with this work.