Skip to content

Commit

Permalink
Implement isdiag(::Bidiagonal), add tests (#32694)
Browse files Browse the repository at this point in the history
(cherry picked from commit 25eb8c6)
  • Loading branch information
garrison authored and JeffBezanson committed Aug 5, 2019
1 parent 74312a0 commit 5f4a567
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/LinearAlgebra/src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ iszero(M::Bidiagonal) = iszero(M.dv) && iszero(M.ev)
isone(M::Bidiagonal) = all(isone, M.dv) && iszero(M.ev)
istriu(M::Bidiagonal) = M.uplo == 'U' || iszero(M.ev)
istril(M::Bidiagonal) = M.uplo == 'L' || iszero(M.ev)
isdiag(M::Bidiagonal) = iszero(M.ev)

function tril!(M::Bidiagonal, k::Integer=0)
n = length(M.dv)
Expand Down
4 changes: 4 additions & 0 deletions stdlib/LinearAlgebra/test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ Random.seed!(1)
@test triu!(bidiagcopy(dv,ev,:U)) == Bidiagonal(dv,ev,:U)
@test_throws ArgumentError triu!(bidiagcopy(dv, ev, :U), -n)
@test_throws ArgumentError triu!(bidiagcopy(dv, ev, :U), n + 2)
@test !isdiag(Bidiagonal(dv,ev,:U))
@test !isdiag(Bidiagonal(dv,ev,:L))
@test isdiag(Bidiagonal(dv,zerosev,:U))
@test isdiag(Bidiagonal(dv,zerosev,:L))
end

@testset "iszero and isone" begin
Expand Down

0 comments on commit 5f4a567

Please sign in to comment.