Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented Feb 26, 2025

This improves performance, as we only need to loop over one half of the matrix. On master, rmul! for an UpperTriangular forwards the multiplication to the parent, so the entire array is looped over. We therefore obtain identical performance for rmul!(::Matrix, ::Diagonal) and rmul!(::UpperTriangular{<:Any, <:Matrix}, ::Diagonal).

julia> using LinearAlgebra, Chairmarks

julia> D = Diagonal(rand(4000));

julia> A = rand(size(D)...);

julia> U = UpperTriangular(A);

julia> @b (A, D) rmul!(_[1], _[2])
10.309 ms

julia> @b (U, D) rmul!(_[1], _[2])
10.370 ms

On this PR, the latter is faster, as the loop is only over half the indices:

julia> @b (U, D) rmul!(_[1], _[2])
7.216 ms

@jishnub jishnub added the performance Must go faster label Feb 26, 2025
@jishnub jishnub force-pushed the jishnub/tri_diag_rmul branch from ba99148 to b5473ee Compare February 27, 2025 08:12
@codecov
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.98%. Comparing base (508e77f) to head (b5473ee).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1228      +/-   ##
==========================================
+ Coverage   91.97%   91.98%   +0.01%     
==========================================
  Files          34       34              
  Lines       15400    15430      +30     
==========================================
+ Hits        14164    14194      +30     
  Misses       1236     1236              

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

@jishnub jishnub merged commit eb7daee into master Feb 27, 2025
4 checks passed
@jishnub jishnub deleted the jishnub/tri_diag_rmul branch February 27, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants