Skip to content

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Apr 30, 2025

This adds a custom structured broadcasting style for an UpperHessenberg, which now retains structure on some broadcasting operations.

julia> UH = UpperHessenberg(ones(4,4))
4×4 UpperHessenberg{Float64, Matrix{Float64}}:
 1.0  1.0  1.0  1.0
 1.0  1.0  1.0  1.0
     1.0  1.0  1.0
         1.0  1.0

julia> UH .+ UH
4×4 UpperHessenberg{Float64, Matrix{Float64}}:
 2.0  2.0  2.0  2.0
 2.0  2.0  2.0  2.0
     2.0  2.0  2.0
         2.0  2.0

julia> B = Bidiagonal(1:4, 1:3, :L);

julia> UH .+ B
4×4 UpperHessenberg{Float64, Matrix{Float64}}:
 2.0  1.0  1.0  1.0
 2.0  3.0  1.0  1.0
     3.0  4.0  1.0
         4.0  5.0

Unlike an UpperTriangular, an UpperHessenberg can retain its structure in broadcasting operations involving other banded matrices such an Tridiagonal. We may also, in the future, make ::UpperTriangular .+ ::Bidiagonal produce an UpperHessenberg.

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.81%. Comparing base (c64c328) to head (428d9d8).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/structuredbroadcast.jl 95.23% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1325   +/-   ##
=======================================
  Coverage   93.81%   93.81%           
=======================================
  Files          34       34           
  Lines       15717    15738   +21     
=======================================
+ Hits        14745    14765   +20     
- Misses        972      973    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@dkarrasch dkarrasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome how "little" work needs to be done to make it work.

@@ -388,4 +393,11 @@ end
@test ind == CartesianIndex(1,1)
end

@testset "Rectangular UpperHessenberg" begin
UH = UpperHessenberg(ones(4,3))
UH2 = UH .+ UH .- UH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that even work with

Suggested change
UH2 = UH .+ UH .- UH
UH2 = UH + UH - UH

?

@jishnub jishnub added the feature Indicates new feature / enhancement requests label May 4, 2025
@jishnub jishnub force-pushed the jishnub/hessenberg_bcast branch from b17c415 to 8890486 Compare June 3, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants