Skip to content

Commit

Permalink
Reuse size-check function from lacpy! in copytrito! (JuliaLang#55664
Browse files Browse the repository at this point in the history
)

Since there is a size-check function in `lacpy!` that does the same
thing, we may reuse it instead of duplicating the check
  • Loading branch information
jishnub authored Sep 2, 2024
1 parent 6170c4b commit ae050a6
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions stdlib/LinearAlgebra/src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2014,20 +2014,12 @@ function copytrito!(B::AbstractMatrix, A::AbstractMatrix, uplo::AbstractChar)
m1,n1 = size(B)
A = Base.unalias(B, A)
if uplo == 'U'
if n < m
(m1 < n || n1 < n) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($n,$n)"))
else
(m1 < m || n1 < n) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($m,$n)"))
end
LAPACK.lacpy_size_check((m1, n1), (n < m ? n : m, n))
for j in 1:n, i in 1:min(j,m)
@inbounds B[i,j] = A[i,j]
end
else # uplo == 'L'
if m < n
(m1 < m || n1 < m) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($m,$m)"))
else
(m1 < m || n1 < n) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($m,$n)"))
end
LAPACK.lacpy_size_check((m1, n1), (m, m < n ? m : n))
for j in 1:n, i in j:m
@inbounds B[i,j] = A[i,j]
end
Expand Down

0 comments on commit ae050a6

Please sign in to comment.