Skip to content

Commit

Permalink
check dl===du in lu! for Tridiagonal (JuliaLang#35197)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha authored and oxinabox committed Apr 8, 2020
1 parent 60708f5 commit 6968292
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/src/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ function lu!(A::Tridiagonal{T,V}, pivot::Union{Val{false}, Val{true}} = Val(true
dl = A.dl
d = A.d
du = A.du
if dl === du
throw(ArgumentError("off-diagonals of `A` must not alias"))
end
du2 = fill!(similar(d, n-2), 0)::V

@inbounds begin
Expand Down
6 changes: 6 additions & 0 deletions stdlib/LinearAlgebra/test/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ dimg = randn(n)/2
@test lud.L*lud.U Array(d)[lud.p,:]
@test AbstractArray(lud) d
@test Array(lud) d
if eltya != Int
dlu = convert.(eltya, [1, 1])
dia = convert.(eltya, [-2, -2, -2])
tri = Tridiagonal(dlu, dia, dlu)
@test_throws ArgumentError lu!(tri)
end
end
@testset for eltyb in (Float32, Float64, ComplexF32, ComplexF64, Int)
b = eltyb == Int ? rand(1:5, n, 2) :
Expand Down

0 comments on commit 6968292

Please sign in to comment.