Fix RecombineMatrix for asymmetric boundary conditions#116
Merged
jipolanco merged 1 commit intoFeb 16, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #116 +/- ##
=======================================
Coverage 95.17% 95.18%
=======================================
Files 36 36
Lines 2344 2346 +2
=======================================
+ Hits 2231 2233 +2
Misses 113 113 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fix two bugs in RecombineMatrix (src/Recombinations/matrices.jl) that
manifest when the left and right boundary conditions differ (cl != cr).
Bug 1: getindex - wrong row offset for right-boundary block
The right-block row index was computed as ii = i - h - cr, but the
correct offset uses the left constraint count: ii = i - h - cl.
This caused Matrix(R) and any R[i,j] call to return wrong values,
while 3-arg mul!(y, R, x) remained correct. Also affected downstream
methods: replace_in_print_matrix, evaluate, and evaluate_all.
Bug 2: 5-arg mul! - wrong SVector size for right-boundary block
The right-boundary block used SVector{n1} where n1 = nl + cl (the
LEFT corner size), but the right corner has nr + cr elements.
When nl + cl != nr + cr, this threw DimensionMismatch.
Fix: use n2 = nr + cr for the right-boundary SVector.
Both are one-line fixes. Symmetric BCs (cl = cr) are unaffected.
Add tests covering asymmetric BC cases for getindex, Matrix conversion,
and 5-arg mul! across multiple spline orders and BC combinations.
5a73ba4 to
4676d9b
Compare
Owner
|
This looks great! Thanks for catching the issue and fixing it. |
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.
Summary
Two bugs in
RecombineMatrix(src/Recombinations/matrices.jl) that manifest when the left and right boundary conditions differ (cₗ ≠ cᵣ). Both are one-line fixes; symmetric BCs (cₗ = cᵣ) are unaffected.Bug 1:
getindex— wrong row offset for right-boundary blockThe right-block row index into the lower-right submatrix
Lᵣshould bei - h - cₗ(matching what 3-argmul!computes), noti - h - cᵣ. Whencₗ ≠ cᵣ,getindexreturns incorrect values, which corrupts:Matrix{T}(R)(dense conversion)replace_in_print_matrix(display)evaluateandevaluate_allinbases.jl(basis function evaluation)Derivation: The first row of
Lᵣcorresponds to parent B-spline rowN - nᵣ - cᵣ + 1. SubstitutingN = M + cₗ + cᵣandh = M - nᵣ:Bug 2: 5-arg
mul!— wrongSVectorsize for right-boundary blockThe right-boundary range
jshas lengthnr + cr, but the code wrapped it inSVector{n1}wheren1 = nl + cl. Whennl + cl ≠ nr + cr, this throwsDimensionMismatch.Why existing tests don't catch this
test_recombine_matrixexplicitly assertsbcleft === bcrightandnl == nr && cl == cr. The only asymmetric test ("Hybrid BCs") tests spline evaluation but never testsgetindex,mul!, or matrix conversion.Tests added
New
"Asymmetric BC RecombineMatrix"test set covering 6 asymmetric BC combinations × 2 spline orders (4, 6). For each case:Matrix{Float64}(R)matches ground-truth from 3-argmul!R[i,j]entry is verified individuallymul!(y, R, x, α, β)runs without error and produces correct resultsMinimal working example (click to expand)