Skip to content

Commit ae050a6

Browse files
authored
Reuse size-check function from lacpy! in copytrito! (#55664)
Since there is a size-check function in `lacpy!` that does the same thing, we may reuse it instead of duplicating the check
1 parent 6170c4b commit ae050a6

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

stdlib/LinearAlgebra/src/generic.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,20 +2014,12 @@ function copytrito!(B::AbstractMatrix, A::AbstractMatrix, uplo::AbstractChar)
20142014
m1,n1 = size(B)
20152015
A = Base.unalias(B, A)
20162016
if uplo == 'U'
2017-
if n < m
2018-
(m1 < n || n1 < n) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($n,$n)"))
2019-
else
2020-
(m1 < m || n1 < n) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($m,$n)"))
2021-
end
2017+
LAPACK.lacpy_size_check((m1, n1), (n < m ? n : m, n))
20222018
for j in 1:n, i in 1:min(j,m)
20232019
@inbounds B[i,j] = A[i,j]
20242020
end
20252021
else # uplo == 'L'
2026-
if m < n
2027-
(m1 < m || n1 < m) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($m,$m)"))
2028-
else
2029-
(m1 < m || n1 < n) && throw(DimensionMismatch(lazy"B of size ($m1,$n1) should have at least size ($m,$n)"))
2030-
end
2022+
LAPACK.lacpy_size_check((m1, n1), (m, m < n ? m : n))
20312023
for j in 1:n, i in j:m
20322024
@inbounds B[i,j] = A[i,j]
20332025
end

0 commit comments

Comments
 (0)