Skip to content

Commit fea3939

Browse files
authored
Use LinearAlgbera.axpy uniformly (#372)
1 parent c0b7a5e commit fea3939

File tree

11 files changed

+37
-36
lines changed

11 files changed

+37
-36
lines changed

src/ApproxFunBase.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ import Combinatorics: multiexponents
4141
import LinearAlgebra: BlasInt, BlasFloat, norm, ldiv!, mul!, det, cross,
4242
qr, qr!, rank, isdiag, istril, istriu, issymmetric,
4343
Tridiagonal, diagm, diagm_container, factorize,
44-
nullspace, Hermitian, Symmetric, adjoint, transpose, char_uplo
44+
nullspace, Hermitian, Symmetric, adjoint, transpose, char_uplo,
45+
axpy!
4546

4647
import SparseArrays: blockdiag
4748

src/Caching/almostbanded.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function resizedata!(co::CachedOperator{T,AlmostBandedMatrix{T},
202202

203203
kr=co.datasize[1]+1:n
204204
jr=max(1,kr[1]-l):n+u
205-
BLAS.axpy!(1.0,view(co.op.ops[ind],kr .- r,jr),
205+
axpy!(1.0,view(co.op.ops[ind],kr .- r,jr),
206206
view(co.data.bands,kr,jr))
207207

208208
co.datasize=(n,n+u)
@@ -252,7 +252,7 @@ function resizedata!(co::CachedOperator{T,AlmostBandedMatrix{T},
252252
jr=max(ncols+1,kr[1]-l):n+u
253253
io∞=InterlaceOperator(io.ops[r∞,d∞])
254254

255-
BLAS.axpy!(1.0,view(io∞,kr.-r,jr.-ncols),view(co.data.bands,kr,jr))
255+
axpy!(1.0,view(io∞,kr.-r,jr.-ncols),view(co.data.bands,kr,jr))
256256

257257
co.datasize=(n,n+u)
258258
co
@@ -318,7 +318,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,AlmostBandedMatrix{T},
318318
dind=R.u+1+k-j
319319
v=view(R.data,dind:dind+M-1,j)
320320
dt=dot(wp,v)
321-
LinearAlgebra.axpy!(-2*dt,wp,v)
321+
axpy!(-2*dt,wp,v)
322322
end
323323

324324
# scale banded/filled entries
@@ -331,15 +331,15 @@ function resizedata!(QR::QROperator{CachedOperator{T,AlmostBandedMatrix{T},
331331
@inbounds dt=muladd(conj(W[ℓ-k+1,k]),
332332
unsafe_getindex(MO.data.fill,ℓ,j),dt)
333333
end
334-
LinearAlgebra.axpy!(-2*dt,wp2,v)
334+
axpy!(-2*dt,wp2,v)
335335
end
336336

337337
# scale filled entries
338338

339339
for j=1:size(F,2)
340340
v=view(F,k:k+M-1,j) # the k,jth entry of F
341341
dt=dot(wp,v)
342-
LinearAlgebra.axpy!(-2*dt,wp,v)
342+
axpy!(-2*dt,wp,v)
343343
end
344344
end
345345
QR.ncols=col

src/Caching/banded.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function resizedata!(B::CachedOperator{T,<:BandedMatrix{T}},n::Integer,m_in::Int
1919

2020
kr=B.datasize[1]+1:n
2121
jr=max(B.datasize[1]+1-B.data.l,1):min(n+B.data.u,M)
22-
BLAS.axpy!(1.0,view(B.op,kr,jr),view(B.data,kr,jr))
22+
axpy!(1.0,view(B.op,kr,jr),view(B.data,kr,jr))
2323

2424
B.datasize = (n,m)
2525
end
@@ -72,7 +72,7 @@ function resizedata!(QR::QROperator{<:CachedOperator{T,<:BandedMatrix{T},
7272
dind=R.u+1+k-j
7373
v=view(R.data,dind:dind+M-1,j)
7474
dt=dot(wp,v)
75-
LinearAlgebra.axpy!(-2*dt,wp,v)
75+
axpy!(-2*dt,wp,v)
7676
end
7777

7878
# scale banded/filled entries
@@ -81,7 +81,7 @@ function resizedata!(QR::QROperator{<:CachedOperator{T,<:BandedMatrix{T},
8181
v=view(R.data,1:M-p,j) # shift down each time
8282
wp2=view(wp,p+1:M)
8383
dt=dot(wp2,v)
84-
LinearAlgebra.axpy!(-2*dt,wp2,v)
84+
axpy!(-2*dt,wp2,v)
8585
end
8686
end
8787
QR.ncols=col

src/Caching/bandedblockbanded.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function resizedata!(B::CachedOperator{T,<:BandedBlockBandedMatrix{T}}, ::Colon,
3131
jr=B.datasize[2]+1:col
3232
kr=colstart(B.data,jr[1]):colstop(B.data,jr[end])
3333

34-
isempty(kr) || BLAS.axpy!(1.0,view(B.op,kr,jr),view(B.data,kr,jr))
34+
isempty(kr) || axpy!(1.0,view(B.op,kr,jr),view(B.data,kr,jr))
3535

3636
B.datasize = (last(kr),col)
3737
end

src/Caching/blockbanded.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ QROperator(R::CachedOperator{T,BlockBandedMatrix{T}}) where {T} =
180180
# for j=k:rowstop(R,k)
181181
# v=view(R,k:cs,j)
182182
# dt=dot(wp,v)
183-
# LinearAlgebra.axpy!(-2*dt,wp,v)
183+
# axpy!(-2*dt,wp,v)
184184
# end
185185
#
186186
# # scale banded/filled entries
@@ -189,7 +189,7 @@ QROperator(R::CachedOperator{T,BlockBandedMatrix{T}}) where {T} =
189189
# v=view(R,csrt:cs,j) # shift down each time
190190
# wp2=view(wp,csrt-k+1:cs-k+1)
191191
# dt=dot(wp2,v)
192-
# LinearAlgebra.axpy!(-2*dt,wp2,v)
192+
# axpy!(-2*dt,wp2,v)
193193
# end
194194
# end
195195
# QR.ncols=col
@@ -309,7 +309,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,BlockBandedMatrix{T},
309309

310310
dt = dot(view(W.data, w_j:w_j+M-1) ,
311311
view(R.data, shft + st*(ξ_2-1) +1:shft + st*(ξ_2-1) +M))
312-
BLAS.axpy!(-2*dt, view(W.data, w_j:w_j+M-1) ,
312+
axpy!(-2*dt, view(W.data, w_j:w_j+M-1) ,
313313
view(R.data, shft + st*(ξ_2-1) +1:shft + st*(ξ_2-1) +M))
314314
end
315315
end

src/Caching/matrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function mulpars(Ac::Adjoint{T,<:QROperatorQ{QROperator{RR,Matrix{T},T},T}},
7474
yp=view(Y,k:k+M-1)
7575

7676
dt=dot(wp,yp)
77-
LinearAlgebra.axpy!(-2*dt,wp,yp)
77+
axpy!(-2*dt,wp,yp)
7878
k+=1
7979
end
8080
nz = findlast(!iszero, Y)

src/Caching/ragged.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function resizedata!(B::CachedOperator{T,RaggedMatrix{T}},::Colon,n::Integer) wh
4141

4242
jr=B.datasize[2]+1:n
4343
kr=1:K
44-
BLAS.axpy!(1.0,view(B.op,kr,jr),view(B.data,kr,jr))
44+
axpy!(1.0,view(B.op,kr,jr),view(B.data,kr,jr))
4545

4646
B.datasize = (K,n)
4747

@@ -84,7 +84,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,RaggedMatrix{T},
8484
kr=J:J+length(wp)-1
8585
v=view(MO.data,kr,j)
8686
dt=dot(wp,v)
87-
LinearAlgebra.axpy!(-2*dt,wp,v)
87+
axpy!(-2*dt,wp,v)
8888
end
8989
end
9090
end
@@ -115,7 +115,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,RaggedMatrix{T},
115115
for j=k:MO.datasize[2]
116116
v=view(MO.data,kr,j)
117117
dt=dot(wp,v)
118-
LinearAlgebra.axpy!(-2*dt,wp,v)
118+
axpy!(-2*dt,wp,v)
119119
end
120120
end
121121
QR.ncols=col
@@ -221,7 +221,7 @@ for ArrTyp in (:AbstractVector, :AbstractMatrix)
221221
for k=n:-1:1
222222
@inbounds ck = A.cols[k]
223223
@inbounds u[k,c] /= A.data[ck+k-1]
224-
BLAS.axpy!(-u[k,c], view(A.data,ck:ck+k-2), view(u,1:k-1,c))
224+
axpy!(-u[k,c], view(A.data,ck:ck+k-2), view(u,1:k-1,c))
225225
end
226226
end
227227
u
@@ -270,7 +270,7 @@ function mulpars(Ac::Adjoint{T,<:QROperatorQ{QROperator{RR,RaggedMatrix{T},T},T}
270270
yp=view(Y,k-1+(cr))
271271

272272
dt=dot(wp,yp)
273-
LinearAlgebra.axpy!(-2*dt,wp,yp)
273+
axpy!(-2*dt,wp,yp)
274274
k+=1
275275
end
276276
nz = findlast(!iszero, Y)

src/LinearAlgebra/RaggedMatrix.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,19 @@ function mul!(y::Vector, A::RaggedMatrix, b::Vector)
153153
fill!(y,zero(T))
154154
for j=1:m
155155
kr=A.cols[j]:A.cols[j+1]-1
156-
BLAS.axpy!(b[j],view(A.data,kr),view(y,1:length(kr)))
156+
axpy!(b[j],view(A.data,kr),view(y,1:length(kr)))
157157
end
158158
y
159159
end
160160

161161

162-
function BLAS.axpy!(a, X::RaggedMatrix, Y::RaggedMatrix)
162+
function axpy!(a, X::RaggedMatrix, Y::RaggedMatrix)
163163
if size(X) size(Y)
164164
throw(BoundsError())
165165
end
166166

167167
if X.cols == Y.cols
168-
BLAS.axpy!(a,X.data,Y.data)
168+
axpy!(a,X.data,Y.data)
169169
else
170170
for j = 1:size(X,2)
171171
Xn = colstop(X,j)
@@ -176,7 +176,7 @@ function BLAS.axpy!(a, X::RaggedMatrix, Y::RaggedMatrix)
176176
end
177177
end
178178
cs = min(Xn,Yn)
179-
BLAS.axpy!(a,view(X.data,X.cols[j]:X.cols[j]+cs-1),
179+
axpy!(a,view(X.data,X.cols[j]:X.cols[j]+cs-1),
180180
view(Y.data,Y.cols[j]:Y.cols[j]+cs-1))
181181
end
182182
end
@@ -188,7 +188,7 @@ colstop(X::SubArray{T,2,RaggedMatrix{T},Tuple{UnitRange{Int},UnitRange{Int}}},
188188
first(parentindices(X)[1]) + 1,
189189
size(X,1))
190190

191-
function BLAS.axpy!(a,X::RaggedMatrix,
191+
function axpy!(a,X::RaggedMatrix,
192192
Y::SubArray{T,2,RaggedMatrix{T},Tuple{UnitRange{Int},UnitRange{Int}}}) where T
193193
if size(X) size(Y)
194194
throw(BoundsError())
@@ -213,7 +213,7 @@ function BLAS.axpy!(a,X::RaggedMatrix,
213213
end
214214

215215

216-
BLAS.axpy!(a,view(X.data,kr),
216+
axpy!(a,view(X.data,kr),
217217
view(P.data,(P.cols[j + jsh] + ksh-1) .+ (1:length(kr))))
218218
end
219219

@@ -235,7 +235,7 @@ function unsafe_mul!(Y::RaggedMatrix,A::RaggedMatrix,B::RaggedMatrix)
235235
fill!(Y.data,0)
236236

237237
for j=1:size(B,2),k=1:colstop(B,j)
238-
LinearAlgebra.axpy!(B[k,j], view(A,1:colstop(A,k),k),
238+
axpy!(B[k,j], view(A,1:colstop(A,k),k),
239239
view(Y.data,Y.cols[j] .- 1 .+ (1:colstop(A,k))))
240240
end
241241

src/Operators/Operator.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ end
484484

485485

486486
# Convenience for wrapper ops
487-
unwrap_axpy!(α,P,A) = BLAS.axpy!(α,view(parent(P).op,P.indexes[1],P.indexes[2]),A)
487+
unwrap_axpy!(α,P,A) = axpy!(α,view(parent(P).op,P.indexes[1],P.indexes[2]),A)
488488
iswrapper(_) = false
489489
haswrapperstructure(_) = false
490490

@@ -539,7 +539,7 @@ macro wrappergetindex(Wrap)
539539
Base.getindex(OP::$Wrap,k::Colon, j::ApproxFunBase.InfRanges) = view(OP, k, j)
540540
Base.getindex(OP::$Wrap,k::Colon, j::Colon) = view(OP, k, j)
541541

542-
BLAS.axpy!(α,P::ApproxFunBase.SubOperator{T,OP},A::AbstractMatrix) where {T,OP<:$Wrap} =
542+
axpy!(α,P::ApproxFunBase.SubOperator{T,OP},A::AbstractMatrix) where {T,OP<:$Wrap} =
543543
ApproxFunBase.unwrap_axpy!(α,P,A)
544544

545545
ApproxFunBase.mul_coefficients(A::$Wrap,b) = ApproxFunBase.mul_coefficients(A.op,b)
@@ -729,7 +729,7 @@ const WrapperOperator = Union{SpaceOperator,MultiplicationWrapper,DerivativeWrap
729729
## BLAS and matrix routines
730730
# We assume that copy may be overriden
731731

732-
BLAS.axpy!(a, X::Operator, Y::AbstractMatrix) = (Y .= a .* AbstractMatrix(X) .+ Y)
732+
axpy!(a, X::Operator, Y::AbstractMatrix) = (Y .= a .* AbstractMatrix(X) .+ Y)
733733
copyto!(dest::AbstractMatrix, src::Operator) = copyto!(dest, AbstractMatrix(src))
734734

735735
# this is for operators that implement copy via axpy!
@@ -751,7 +751,7 @@ RaggedMatrix(::Type{Zeros}, V::Operator) =
751751

752752

753753
convert_axpy!(::Type{MT}, S::Operator) where {MT <: AbstractMatrix} =
754-
BLAS.axpy!(one(eltype(S)), S, MT(Zeros, S))
754+
axpy!(one(eltype(S)), S, MT(Zeros, S))
755755

756756

757757

src/Operators/general/InterlaceOperator.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ function getindex(L::InterlaceOperator{T},kr::UnitRange) where T
298298
if !isempty(ret_kr)
299299
sub_kr=cr[ret_kr[1]][2]:cr[ret_kr[end]][2]
300300

301-
LinearAlgebra.axpy!(1.0,L.ops[ν][sub_kr],view(ret,ret_kr))
301+
axpy!(1.0,L.ops[ν][sub_kr],view(ret,ret_kr))
302302
end
303303
end
304304
ret
@@ -349,7 +349,7 @@ for TYP in (:BandedMatrix, :BlockBandedMatrix, :BandedBlockBandedMatrix, :Ragged
349349
if !isempty(ret_kr)
350350
sub_kr=cr[ret_kr[1]][2]:cr[ret_kr[end]][2]
351351

352-
BLAS.axpy!(1.0,view(L.ops[ν],sub_kr,jr),view(ret,ret_kr,:))
352+
axpy!(1.0,view(L.ops[ν],sub_kr,jr),view(ret,ret_kr,:))
353353
end
354354
end
355355
ret
@@ -380,7 +380,7 @@ for TYP in (:BandedMatrix, :BlockBandedMatrix, :BandedBlockBandedMatrix, :Ragged
380380
sub_kr=cr[ret_kr[1]][2]:cr[ret_kr[end]][2]
381381
sub_jr=cd[ret_jr[1]][2]:cd[ret_jr[end]][2]
382382

383-
BLAS.axpy!(1.0,view(L.ops[ν,μ],sub_kr,sub_jr),
383+
axpy!(1.0,view(L.ops[ν,μ],sub_kr,sub_jr),
384384
view(ret,ret_kr,ret_jr))
385385
end
386386
end

src/Operators/general/algebra.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ for TYP in (:RaggedMatrix, :Matrix, :BandedMatrix,
116116
end
117117
end
118118

119-
function BLAS.axpy!(α, P::SubOperator{<:Any,<:PlusOperator}, A::AbstractMatrix)
119+
function axpy!(α, P::SubOperator{<:Any,<:PlusOperator}, A::AbstractMatrix)
120120
for op in parent(P).ops
121-
BLAS.axpy!(α, view(op, P.indexes[1], P.indexes[2]), A)
121+
axpy!(α, view(op, P.indexes[1], P.indexes[2]), A)
122122
end
123123

124124
A
@@ -216,7 +216,7 @@ end
216216

217217

218218

219-
BLAS.axpy!(α, S::SubOperator{T,OP}, A::AbstractMatrix) where {T,OP<:ConstantTimesOperator} =
219+
axpy!(α, S::SubOperator{T,OP}, A::AbstractMatrix) where {T,OP<:ConstantTimesOperator} =
220220
unwrap_axpy!* parent(S).λ, S, A)
221221

222222

0 commit comments

Comments
 (0)