@@ -80,17 +80,16 @@ function Base.copyto!(A::Array{T,N}, B::Transpose{T, <:AbstractGPUArray{T,N}}) w
80
80
copyto! (A, Transpose (Array (parent (B))))
81
81
end
82
82
83
-
84
83
# # copy upper triangle to lower and vice versa
85
84
86
- function LinearAlgebra. copytri! (A:: AbstractGPUMatrix{T} , uplo:: AbstractChar , conjugate:: Bool = false ) where T
85
+ function LinearAlgebra. copytri! (A:: AbstractGPUMatrix , uplo:: AbstractChar , conjugate:: Bool = false )
87
86
n = LinearAlgebra. checksquare (A)
88
87
if uplo == ' U' && conjugate
89
88
gpu_call (A) do ctx, _A
90
89
I = @cartesianidx _A
91
90
i, j = Tuple (I)
92
91
if j > i
93
- _A[j,i] = conj (_A[i,j])
92
+ @inbounds _A[j,i] = conj (_A[i,j])
94
93
end
95
94
return
96
95
end
@@ -99,7 +98,7 @@ function LinearAlgebra.copytri!(A::AbstractGPUMatrix{T}, uplo::AbstractChar, con
99
98
I = @cartesianidx _A
100
99
i, j = Tuple (I)
101
100
if j > i
102
- _A[j,i] = _A[i,j]
101
+ @inbounds _A[j,i] = _A[i,j]
103
102
end
104
103
return
105
104
end
@@ -108,7 +107,7 @@ function LinearAlgebra.copytri!(A::AbstractGPUMatrix{T}, uplo::AbstractChar, con
108
107
I = @cartesianidx _A
109
108
i, j = Tuple (I)
110
109
if j > i
111
- _A[i,j] = conj (_A[j,i])
110
+ @inbounds _A[i,j] = conj (_A[j,i])
112
111
end
113
112
return
114
113
end
@@ -117,7 +116,7 @@ function LinearAlgebra.copytri!(A::AbstractGPUMatrix{T}, uplo::AbstractChar, con
117
116
I = @cartesianidx _A
118
117
i, j = Tuple (I)
119
118
if j > i
120
- _A[i,j] = _A[j,i]
119
+ @inbounds _A[i,j] = _A[j,i]
121
120
end
122
121
return
123
122
end
@@ -127,6 +126,36 @@ function LinearAlgebra.copytri!(A::AbstractGPUMatrix{T}, uplo::AbstractChar, con
127
126
A
128
127
end
129
128
129
+ # # copy a triangular part of a matrix to another matrix
130
+
131
+ if isdefined (LinearAlgebra, :copytrito! )
132
+ function LinearAlgebra. copytrito! (B:: AbstractGPUMatrix , A:: AbstractGPUMatrix , uplo:: AbstractChar )
133
+ LinearAlgebra. BLAS. chkuplo (uplo)
134
+ m,n = size (A)
135
+ 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 )" ))
137
+ if uplo == ' U'
138
+ gpu_call (A, B) do ctx, _A, _B
139
+ I = @cartesianidx _A
140
+ i, j = Tuple (I)
141
+ if j >= i
142
+ @inbounds _B[i,j] = _A[i,j]
143
+ end
144
+ return
145
+ end
146
+ else # uplo == 'L'
147
+ gpu_call (A, B) do ctx, _A, _B
148
+ I = @cartesianidx _A
149
+ i, j = Tuple (I)
150
+ if j <= i
151
+ @inbounds _B[i,j] = _A[i,j]
152
+ end
153
+ return
154
+ end
155
+ end
156
+ return B
157
+ end
158
+ end
130
159
131
160
# # triangular
132
161
@@ -146,7 +175,7 @@ function LinearAlgebra.tril!(A::AbstractGPUMatrix{T}, d::Integer = 0) where T
146
175
I = @cartesianidx _A
147
176
i, j = Tuple (I)
148
177
if i < j - _d
149
- _A[i, j] = 0
178
+ @inbounds _A[i, j] = zero (T)
150
179
end
151
180
return
152
181
end
@@ -158,7 +187,7 @@ function LinearAlgebra.triu!(A::AbstractGPUMatrix{T}, d::Integer = 0) where T
158
187
I = @cartesianidx _A
159
188
i, j = Tuple (I)
160
189
if j < i + _d
161
- _A[i, j] = 0
190
+ @inbounds _A[i, j] = zero (T)
162
191
end
163
192
return
164
193
end
0 commit comments