Skip to content

Commit c1d2db5

Browse files
committed
Accomodate for rectangular matrices in copytrito!
1 parent 1b3741c commit c1d2db5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/host/linalg.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ if isdefined(LinearAlgebra, :copytrito!)
133133
LinearAlgebra.BLAS.chkuplo(uplo)
134134
m,n = size(A)
135135
m1,n1 = size(B)
136-
(m1 < m || n1 < n) && throw(DimensionMismatch("B of size ($m1,$n1) should have at least the same number of rows and columns than A of size ($m,$n)"))
137136
if uplo == 'U'
137+
if n < m
138+
(m1 < n || n1 < n) && throw(DimensionMismatch("B of size ($m1,$n1) should have at least size ($n,$n)"))
139+
else
140+
(m1 < m || n1 < n) && throw(DimensionMismatch("B of size ($m1,$n1) should have at least size ($m,$n)"))
141+
end
138142
gpu_call(A, B) do ctx, _A, _B
139143
I = @cartesianidx _A
140144
i, j = Tuple(I)
@@ -144,6 +148,11 @@ if isdefined(LinearAlgebra, :copytrito!)
144148
return
145149
end
146150
else # uplo == 'L'
151+
if m < n
152+
(m1 < m || n1 < m) && throw(DimensionMismatch("B of size ($m1,$n1) should have at least size ($m,$m)"))
153+
else
154+
(m1 < m || n1 < n) && throw(DimensionMismatch("B of size ($m1,$n1) should have at least size ($m,$n)"))
155+
end
147156
gpu_call(A, B) do ctx, _A, _B
148157
I = @cartesianidx _A
149158
i, j = Tuple(I)

0 commit comments

Comments
 (0)