Skip to content

Commit

Permalink
Access only stored inds in copy for strided AbstractTriangular (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Jan 31, 2024
1 parent 444e14e commit 08e3c2e
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/src/triangular.jl
Original file line number Diff line number Diff line change
@@ -181,6 +181,9 @@ end
Array(A::AbstractTriangular) = Matrix(A)
parent(A::UpperOrLowerTriangular) = A.data

# For strided matrices, we may only loop over the filled triangle
copy(A::UpperOrLowerTriangular{<:Any, <:StridedMaybeAdjOrTransMat}) = copyto!(similar(A), A)

# then handle all methods that requires specific handling of upper/lower and unit diagonal

function Matrix{T}(A::LowerTriangular) where T
2 changes: 2 additions & 0 deletions stdlib/LinearAlgebra/test/triangular.jl
Original file line number Diff line number Diff line change
@@ -1007,6 +1007,7 @@ end
L = MT(A)
B .= 0
copyto!(B, L)
@test copy(L) == B
@test L * 2 == 2 * L == 2B
@test L/2 == B/2
@test 2\L == 2\B
@@ -1032,6 +1033,7 @@ end
U = MT(A)
B .= 0
copyto!(B, U)
@test copy(U) == B
@test U * 2 == 2 * U == 2B
@test U/2 == B/2
@test 2\U == 2\B

0 comments on commit 08e3c2e

Please sign in to comment.