Skip to content

Commit 5b14dcc

Browse files
committed
Copy matrices in triu/tril if no zero exists for the eltype (#1320)
This fixes a regression in the `triu`/`tril` implementation on v1.12 and nightly. After this, the following works again: ```julia julia> M = fill(ones(2,2), 3, 3) 3×3 Matrix{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 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; 1.0 1.0] [1.0 1.0; 1.0 1.0] [1.0 1.0; 1.0 1.0] julia> using Test: GenericArray julia> triu(GenericArray(M),1) 3×3 GenericArray{Matrix{Float64}, 2}: [0.0 0.0; 0.0 0.0] [1.0 1.0; 1.0 1.0] [1.0 1.0; 1.0 1.0] [0.0 0.0; 0.0 0.0] [0.0 0.0; 0.0 0.0] [1.0 1.0; 1.0 1.0] [0.0 0.0; 0.0 0.0] [0.0 0.0; 0.0 0.0] [0.0 0.0; 0.0 0.0] ``` (cherry picked from commit c33045c)
1 parent aefab75 commit 5b14dcc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/dense.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,4 +1384,14 @@ end
13841384
@test tril(GenericArray(M),-1) == res'
13851385
end
13861386

1387+
@testset "triu/tril for block matrices" begin
1388+
O = ones(2,2)
1389+
Z = zero(O)
1390+
M = fill(O, 3, 3)
1391+
res = fill(Z, size(M))
1392+
res[1,2] = res[1,3] = res[2,3] = O
1393+
@test triu(GenericArray(M),1) == res
1394+
@test tril(GenericArray(M),-1) == res'
1395+
end
1396+
13871397
end # module TestDense

0 commit comments

Comments
 (0)