Skip to content

Commit 5c2d962

Browse files
committed
extend "kron! for Diagonal" testset
1 parent 063ee3d commit 5c2d962

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/diagonal.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,14 +1396,25 @@ end
13961396
end
13971397

13981398
@testset "kron! for Diagonal" begin
1399-
a = Diagonal([2,2])
1400-
b = Diagonal([1,1])
1399+
a = Diagonal([1,2])
1400+
b = Diagonal([3,4])
1401+
# Diagonal out
14011402
c = Diagonal([0,0,0,0])
14021403
kron!(c,b,a)
1403-
@test c == Diagonal([2,2,2,2])
1404+
@test c == Diagonal([3, 6, 4, 8])
1405+
@test c == kron!(fill(0, 4, 4), Matrix(b), Matrix(a)) # against dense kron!
14041406
c=Diagonal(Vector{Float64}(undef, 4))
14051407
kron!(c,a,b)
1406-
@test c == Diagonal([2,2,2,2])
1408+
@test c == Diagonal([3.0, 4.0, 6.0, 8.0])
1409+
1410+
# AbstractArray out
1411+
c = fill(0, 4, 4)
1412+
kron!(c, b, a)
1413+
@test c == diagm([3, 6, 4, 8])
1414+
@test c == kron!(fill(0, 4, 4), Matrix(b), Matrix(a)) # against dense kron!
1415+
c = Matrix{Float64}(undef, 4, 4)
1416+
kron!(c, a, b)
1417+
@test c == diagm([3.0, 4.0, 6.0, 8.0])
14071418
end
14081419

14091420
@testset "uppertriangular/lowertriangular" begin

0 commit comments

Comments
 (0)