Skip to content

Commit e4922b7

Browse files
authored
Avoid pirating dot (#106)
1 parent db71c33 commit e4922b7

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

src/ApproxFunBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Base.Broadcast: BroadcastStyle, Broadcasted, AbstractArrayStyle, broadcas
3333

3434
import Statistics: mean
3535

36-
import LinearAlgebra: BlasInt, BlasFloat, norm, ldiv!, mul!, det, eigvals, dot, cross,
36+
import LinearAlgebra: BlasInt, BlasFloat, norm, ldiv!, mul!, det, eigvals, cross,
3737
qr, qr!, rank, isdiag, istril, istriu, issymmetric, ishermitian,
3838
Tridiagonal, diagm, diagm_container, factorize, nullspace,
3939
Hermitian, Symmetric, adjoint, transpose, char_uplo

src/Caching/almostbanded.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,14 @@ function resizedata!(QR::QROperator{CachedOperator{T,AlmostBandedMatrix{T},
390390

391391
for j=k:k+R.u
392392
v=r+sz*(R.u + (k-1)*st + (j-k)*(st-1))
393-
dt = BandedMatrices.dot(M,wp,1,v,1)
393+
dt = dot(M,wp,1,v,1)
394394
BLAS.axpy!(M,-2*dt,wp,1,v,1)
395395
end
396396

397397
for j=k+R.u+1:k+R.u+M-1
398398
p=j-k-R.u
399399
v=r+sz*((j-1)*st) # shift down each time
400-
dt = BandedMatrices.dot(M-p,wp+p*sz,1,v,1)
400+
dt = dot(M-p,wp+p*sz,1,v,1)
401401
for=k:k+p-1
402402
@inbounds dt=muladd(conj(W[ℓ-k+1,k]),
403403
unsafe_getindex(MO.data.fill,ℓ,j),dt)
@@ -409,7 +409,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,AlmostBandedMatrix{T},
409409
fst=stride(F,2)
410410
for j=1:size(F,2)
411411
v=fp+fst*(j-1)*sz # the k,jth entry of F
412-
dt = BandedMatrices.dot(M,wp,1,v,1)
412+
dt = dot(M,wp,1,v,1)
413413
BLAS.axpy!(M,-2*dt,wp,1,v,1)
414414
end
415415
end

src/Caching/banded.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ function resizedata!(QR::QROperator{<:CachedOperator{T,<:BandedMatrix{T},
132132

133133
for j=k:k+R.u
134134
v=r+sz*(R.u + (k-1)*st + (j-k)*(st-1))
135-
dt = BandedMatrices.dot(M,wp,1,v,1)
135+
dt = dot(M,wp,1,v,1)
136136
BLAS.axpy!(M,-2*dt,wp,1,v,1)
137137
end
138138

139139
for j=k+R.u+1:k+R.u+M-1
140140
p=j-k-R.u
141141
v=r+sz*((j-1)*st) # shift down each time
142-
dt = BandedMatrices.dot(M-p,wp+p*sz,1,v,1)
142+
dt = dot(M-p,wp+p*sz,1,v,1)
143143
BLAS.axpy!(M-p,-2*dt,wp+p*sz,1,v,1)
144144
end
145145
end

src/Caching/blockbanded.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,BlockBandedMatrix{T},
283283
for ξ_2 = ξ:length(bs.axes[2][Block(J1)])
284284
# we now apply I-2v*v' in place
285285
r_sh = r+sz*(shft + st*(ξ_2-ξ)) # the pointer the (j,ξ_2)-th entry
286-
dt = BandedMatrices.dot(M, wp, 1, r_sh, 1)
286+
dt = dot(M, wp, 1, r_sh, 1)
287287
BLAS.axpy!(M, -2*dt, wp, 1, r_sh ,1)
288288
end
289289

src/Caching/matrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function mulpars(Ac::Adjoint{T,<:QROperatorQ{QROperator{RR,Matrix{T},T},T}},
139139
wp=h+sz*st*(k-1)
140140
yp=y+sz*(k-1)
141141

142-
dt = BandedMatrices.dot(M,wp,1,yp,1)
142+
dt = dot(M,wp,1,yp,1)
143143
BLAS.axpy!(M,-2*dt,wp,1,yp,1)
144144
k+=1
145145
end

src/Caching/ragged.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,RaggedMatrix{T},
8383
for j=m+1:MO.datasize[2]
8484
kr=J:J+length(wp)-1
8585
v=view(MO.data,kr,j)
86-
dt=BandedMatrices.dot(wp,v)
86+
dt=dot(wp,v)
8787
LinearAlgebra.axpy!(-2*dt,wp,v)
8888
end
8989
end
@@ -114,7 +114,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,RaggedMatrix{T},
114114
kr=k:k+length(wp)-1
115115
for j=k:MO.datasize[2]
116116
v=view(MO.data,kr,j)
117-
dt=BandedMatrices.dot(wp,v)
117+
dt=dot(wp,v)
118118
LinearAlgebra.axpy!(-2*dt,wp,v)
119119
end
120120
end
@@ -156,7 +156,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,RaggedMatrix{T},
156156

157157
for j=m+1:MO.datasize[2]
158158
v=r+(R.cols[j]+k-2)*sz
159-
dt=BandedMatrices.dot(M,wp,1,v,1)
159+
dt=dot(M,wp,1,v,1)
160160
BLAS.axpy!(M,-2*dt,wp,1,v,1)
161161
end
162162
end
@@ -192,7 +192,7 @@ function resizedata!(QR::QROperator{CachedOperator{T,RaggedMatrix{T},
192192
# scale rows entries
193193
for j=k:MO.datasize[2]
194194
v=r+(R.cols[j]+k-2)*sz
195-
dt=BandedMatrices.dot(M,wp,1,v,1)
195+
dt=dot(M,wp,1,v,1)
196196
BLAS.axpy!(M,-2*dt,wp,1,v,1)
197197
end
198198
end
@@ -269,7 +269,7 @@ function mulpars(Ac::Adjoint{T,<:QROperatorQ{QROperator{RR,RaggedMatrix{T},T},T}
269269
wp=view(H,cr,k)
270270
yp=view(Y,k-1+(cr))
271271

272-
dt=BandedMatrices.dot(wp,yp)
272+
dt=dot(wp,yp)
273273
LinearAlgebra.axpy!(-2*dt,wp,yp)
274274
k+=1
275275
end
@@ -325,7 +325,7 @@ function mulpars(Ac::Adjoint{T,<:QROperatorQ{QROperator{RR,RaggedMatrix{T},T},T}
325325
wp=h + sz*(H.cols[k]-1)
326326
yp=y+sz*(k-1)
327327

328-
dt = BandedMatrices.dot(M,wp,1,yp,1)
328+
dt = dot(M,wp,1,yp,1)
329329
BLAS.axpy!(M,-2*dt,wp,1,yp,1)
330330
k+=1
331331
end

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ import ApproxFunBase: ∞
3636
@test ApproxFunBase.hasnumargs(onearg, 1)
3737
@test ApproxFunBase.hasnumargs(twoargs, 2)
3838
end
39+
@testset "don't pirate dot" begin
40+
@test ApproxFunBase.dot !== LinearAlgebra.dot
41+
struct DotTester end
42+
# check that unknown types don't lead to a stack overflow
43+
@test_throws MethodError ApproxFunBase.dot(DotTester())
44+
end
3945

4046
# TODO: Tensorizer tests
4147
end

0 commit comments

Comments
 (0)