Skip to content

Commit

Permalink
Update diagonal.jl
Browse files Browse the repository at this point in the history
add test
  • Loading branch information
N5N3 authored Sep 22, 2021
1 parent 9183952 commit eb4b99a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions stdlib/LinearAlgebra/test/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -826,4 +826,31 @@ end
@test \(x, B) == /(B, x)
end

@testset "AbstractTriangular" for (Tri, UTri) in ((UpperTriangular, UnitUpperTriangular), (LowerTriangular, UnitLowerTriangular))
A = randn(4, 4)
TriA = Tri(A)
UTriA = UTri(A)
D = Diagonal(1.0:4.0)
DM = Matrix(D)
DMF = factorize(DM)
outTri = similar(TriA)
out = similar(A)
# 2 args
for fun in (*, rmul!, rdiv!, /)
@test fun(copy(TriA), D)::Tri == fun(Matrix(TriA), D)
@test fun(copy(UTriA), D)::Tri == fun(Matrix(UTriA), D)
end
for fun in (*, lmul!, ldiv!, \)
@test fun(D, copy(TriA))::Tri == fun(D, Matrix(TriA))
@test fun(D, copy(UTriA))::Tri == fun(D, Matrix(UTriA))
end
# 3 args
@test ldiv!(outTri, D, TriA)::Tri == ldiv!(out, D, Matrix(TriA))
@test ldiv!(outTri, D, UTriA)::Tri == ldiv!(out, D, Matrix(UTriA))
@test mul!(outTri, D, TriA)::Tri == mul!(out, D, Matrix(TriA))
@test mul!(outTri, D, UTriA)::Tri == mul!(out, D, Matrix(UTriA))
@test mul!(outTri, TriA, D)::Tri == mul!(out, Matrix(TriA), D)
@test mul!(outTri, UTriA, D)::Tri == mul!(out, Matrix(UTriA), D)
end

end # module TestDiagonal

0 comments on commit eb4b99a

Please sign in to comment.