@@ -472,13 +472,13 @@ struct Tridiagonal{T,V<:AbstractVector{T}} <: AbstractMatrix{T}
472472 " lengths of subdiagonal, diagonal and superdiagonal: " ,
473473 " ($(length (dl)) , $(length (d)) , $(length (du)) )" )))
474474 end
475- new {T,V} (dl, d, du )
475+ new {T,V} (dl, d, Base . unalias (dl, du) )
476476 end
477477 # constructor used in lu!
478478 function Tridiagonal {T,V} (dl, d, du, du2) where {T,V<: AbstractVector{T} }
479479 require_one_based_indexing (dl, d, du, du2)
480480 # length checks?
481- new {T,V} (dl, d, du , du2)
481+ new {T,V} (dl, d, Base . unalias (dl, du) , du2)
482482 end
483483end
484484
@@ -491,6 +491,10 @@ solvers, but may be converted into a regular matrix with
491491[`convert(Array, _)`](@ref) (or `Array(_)` for short).
492492The lengths of `dl` and `du` must be one less than the length of `d`.
493493
494+ !!! note
495+ The subdiagonal `dl` and the superdiagonal `du` must not be aliased to each other.
496+ If aliasing is detected, the constructor will use a copy of `du` as its argument.
497+
494498# Examples
495499```jldoctest
496500julia> dl = [1, 2, 3];
@@ -912,9 +916,6 @@ function ldiv!(A::Tridiagonal, B::AbstractVecOrMat)
912916 dl = A. dl
913917 d = A. d
914918 du = A. du
915- if dl === du
916- throw (ArgumentError (" off-diagonals of `A` must not alias" ))
917- end
918919
919920 @inbounds begin
920921 for i in 1 : n- 1
0 commit comments