Repository navigation
StructuredMatrixStyle{OffDiagonal} broadcasting - #458
Merged
Merged
Conversation
Zero-preserving broadcasts over OffDiagonals on the same band return an OffDiagonal, broadcasting over the bands so that lazy bands stay lazy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #458 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 11
Lines 1316 1346 +30
=========================================
+ Hits 1316 1346 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dlfivefifty
added a commit
to JuliaLinearAlgebra/BandedMatrices.jl
that referenced
this pull request
Oct 13, 2026
Keeps BandedMatrix .+ OffDiagonal banded once OffDiagonal has its own broadcast style (JuliaArrays/FillArrays.jl#458). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dlfivefifty
added a commit
to JuliaLinearAlgebra/BandedMatrices.jl
that referenced
this pull request
Oct 15, 2026
…alLayout (require ArrayLayouts v1.15) (#511) * Support FillArrays.OffDiagonal and remove sublayout piracy for DiagonalLayout Require ArrayLayouts v1.15, which adds OffDiagonalLayout and returns it for views of a DiagonalLayout matrix by unit ranges. Remove the pirated sublayout(::DiagonalLayout, ...) methods, which would otherwise overwrite ArrayLayouts' method, and add bandwidths, inbands_getindex/inbands_setindex! and BandedMatrix conversion for OffDiagonalLayout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Update downstream.yml * Update interfaceimpl.jl * Update BandedMatrix.jl * Update BandedMatrix.jl * Update BandedMatrix.jl * BandedStyle wins over StructuredMatrixStyle{OffDiagonal} Keeps BandedMatrix .+ OffDiagonal banded once OffDiagonal has its own broadcast style (JuliaArrays/FillArrays.jl#458). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
OffDiagonalnow hasBroadcastStyleLinearAlgebra.StructuredMatrixStyle{OffDiagonal}, so zero-preserving broadcasts keep the single-band structure:fzeropreserving, as forDiagonaletc. (fzero(::OffDiagonal)is defined like forRectDiagonal).OffDiagonalonly if everyOffDiagonalargument lies on the same band and has the same axes as the result. Otherwise (different bands, a 1×1OffDiagonalbroadcast out, non-scalar non-OffDiagonalarguments, or non-zero-preserving functions such ascosor.+ 1) it falls back to a denseMatrix.copybroadcasts over the bands themselves, so lazy bands stay lazy:sin.(Eye(5)[2:end,:]) ≡ OffDiagonal(Fill(sin(1.0), 4), 1, 4, 5).dest .= f.(A)withdest::OffDiagonalon the same band only writes the band. Other cases fall back to the genericcopyto!, which throws when writing a non-zero entry off the band.structured_broadcast_allocis defined so thatsimilar(bc, T)also gives anOffDiagonal.Tests cover zero-preserving functions (
sin,abs, scaling,.^2,A .+ A,A .* A,round.(Int, A), nested broadcasts), dense fallbacks, mismatched bands, in-place broadcasting and lazy bands. They pass on Julia 1.10 and 1.13. On 1.11 the only failure is Aqua'sambiguitiescheck being an unexpected pass, which also happens onmaster.Downstream: with this change
BandedMatrix .+ OffDiagonalwould become a denseMatrixinstead of aBandedMatrix, as BandedMatrices only definesBroadcastStylerules betweenBandedStyleand theStructuredMatrixStyles of specific types. Adding:OffDiagonalto that list insrc/interfaceimpl.jl(e.g. in JuliaLinearAlgebra/BandedMatrices.jl#511) restores aBandedMatrixresult. ArrayLayouts, LazyArrays and BandedMatrices (#511 plus that one-line change) test suites pass with this PR.🤖 Generated with Claude Code