Skip to content

Commit 8cae8d1

Browse files
authored
Remove redundant conversion in structured matrix broadcasting (#55695)
The additional construction is unnecessary, as we are already constructing a `Matrix`. Performance: ```julia julia> using LinearAlgebra julia> U = UpperTriangular(rand(1000,1000)); julia> L = LowerTriangular(rand(1000,1000)); julia> @Btime $U .+ $L; 1.956 ms (6 allocations: 15.26 MiB) # nightly 1.421 ms (3 allocations: 7.63 MiB) # This PR ```
1 parent 61be4de commit 8cae8d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stdlib/LinearAlgebra/src/structuredbroadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ structured_broadcast_alloc(bc, ::Type{UnitLowerTriangular}, ::Type{ElType}, n) w
9696
structured_broadcast_alloc(bc, ::Type{UnitUpperTriangular}, ::Type{ElType}, n) where {ElType} =
9797
UnitUpperTriangular(Array{ElType}(undef, n, n))
9898
structured_broadcast_alloc(bc, ::Type{Matrix}, ::Type{ElType}, n) where {ElType} =
99-
Matrix(Array{ElType}(undef, n, n))
99+
Array{ElType}(undef, n, n)
100100

101101
# A _very_ limited list of structure-preserving functions known at compile-time. This list is
102102
# derived from the formerly-implemented `broadcast` methods in 0.6. Note that this must

0 commit comments

Comments
 (0)