Skip to content

Commit 2b7474f

Browse files
authored
Homogenize use of Base functions (#445)
1 parent 630197f commit 2b7474f

File tree

11 files changed

+31
-31
lines changed

11 files changed

+31
-31
lines changed

src/ApproxFunBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Base: values, convert, getindex, setindex!, *, +, -, ==, <, <=, >, |, !,
2525
setdiff, isless, union, angle, join, isnan, isapprox, isempty,
2626
sort, merge, minimum, maximum, extrema, argmax,
2727
argmin, findmax, findmin, isfinite,
28-
zeros, zero, one, promote_rule, repeat, length, resize!, isinf,
28+
zeros, zero, one, promote_rule, repeat, length, resize!, reshape, isinf,
2929
getproperty, findfirst, unsafe_getindex, fld, div,
3030
eachindex, firstindex, lastindex, isreal,
3131
OneTo, Array, Vector, Matrix, view, ones, @propagate_inbounds,

src/Multivariate/ProductFun.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ ProductFun(cfs::Vector{VFun{S,T}},sp::AbstractProductSpace{Tuple{W,V},DD}) where
4141
W<:UnivariateSpace,T<:Number,DD} =
4242
ProductFun{W,V,typeof(sp),T}(VFun{W,T}[Fun(cfs[k],columnspace(sp,k)) for k=1:length(cfs)],sp)
4343

44-
Base.size(f::ProductFun,k::Integer) =
44+
size(f::ProductFun,k::Integer) =
4545
k==1 ? mapreduce(ncoefficients,max,f.coefficients) : length(f.coefficients)
46-
Base.size(f::ProductFun) = (size(f,1),size(f,2))
46+
size(f::ProductFun) = (size(f,1),size(f,2))
4747

4848
## Construction in an AbstractProductSpace via a Matrix of coefficients
4949

src/Multivariate/TensorSpace.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ components(sp::TensorSpace{Tuple{S1,S2}}) where {S1<:Space{D,R},S2} where {D,R<:
382382
components(sp::TensorSpace{Tuple{S1,S2}}) where {S1,S2<:Space{D,R}} where {D,R<:AbstractArray} =
383383
[sp.spaces[1] s for s in components(sp.spaces[2])]
384384

385-
Base.size(sp::TensorSpace{Tuple{S1,S2}}) where {S1<:Space{D,R},S2} where {D,R<:AbstractArray} =
385+
size(sp::TensorSpace{Tuple{S1,S2}}) where {S1<:Space{D,R},S2} where {D,R<:AbstractArray} =
386386
size(sp.spaces[1])
387387

388-
Base.size(sp::TensorSpace{Tuple{S1,S2}}) where {S1,S2<:Space{D,R}} where {D,R<:AbstractArray} =
388+
size(sp::TensorSpace{Tuple{S1,S2}}) where {S1,S2<:Space{D,R}} where {D,R<:AbstractArray} =
389389
size(sp.spaces[2])
390390

391391
# TODO: Generalize to higher dimensions

src/Operators/Operator.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ blocksize(A::Operator,k) = k==1 ? length(blocklengths(rangespace(A))) : length(b
110110
blocksize(A::Operator) = (blocksize(A,1),blocksize(A,2))
111111

112112

113-
Base.size(A::Operator) = (size(A,1),size(A,2))
114-
Base.size(A::Operator,k::Integer) = k==1 ? dimension(rangespace(A)) : dimension(domainspace(A))
115-
Base.length(A::Operator) = size(A,1) * size(A,2)
113+
size(A::Operator) = (size(A,1),size(A,2))
114+
size(A::Operator,k::Integer) = k==1 ? dimension(rangespace(A)) : dimension(domainspace(A))
115+
length(A::Operator) = size(A,1) * size(A,2)
116116

117117

118118
# used to compute "end" for last index

src/Operators/almostbanded/LowRankOperator.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ rangespace(L::LowRankOperator) = space(first(L.U))
5151
promoterangespace(L::LowRankOperator,sp::Space) = LowRankOperator(map(u->Fun(u,sp),L.U),L.V)
5252
promotedomainspace(L::LowRankOperator,sp::Space) = LowRankOperator(L.U,map(v->promotedomainspace(v,sp),L.V))
5353

54-
function Base.getindex(L::LowRankOperator, k::Integer,j::Integer)
54+
function getindex(L::LowRankOperator, k::Integer,j::Integer)
5555
ret=zero(eltype(L))
5656
for (p, LUp) in enumerate(L.U)
5757
if k ncoefficients(LUp)

src/Operators/banded/ConstantOperator.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ domainspace(B::BasisFunctional) = B.space
9494

9595
convert(::Type{Operator{T}},B::BasisFunctional) where {T} = BasisFunctional{T,typeof(B.space)}(B.k,B.space)
9696

97-
Base.getindex(op::BasisFunctional{T},k::Integer) where {T} = (k==op.k) ? one(T) : zero(T)
98-
Base.getindex(op::BasisFunctional{T},k::AbstractRange) where {T} = strictconvert(Vector{T},k.==op.k)
97+
getindex(op::BasisFunctional{T},k::Integer) where {T} = (k==op.k) ? one(T) : zero(T)
98+
getindex(op::BasisFunctional{T},k::AbstractRange) where {T} = strictconvert(Vector{T},k.==op.k)
9999

100100
struct FillFunctional{T} <: Operator{T}
101101
λ::T
@@ -105,8 +105,8 @@ end
105105

106106
domainspace(B::FillFunctional) = ℓ⁰
107107

108-
Base.getindex(op::FillFunctional,k::Integer)=op.λ
109-
Base.getindex(op::FillFunctional,k::AbstractRange)=fill(op.λ,length(k))
108+
getindex(op::FillFunctional,k::Integer)=op.λ
109+
getindex(op::FillFunctional,k::AbstractRange)=fill(op.λ,length(k))
110110

111111
## Zero is a special operator: it makes sense on all spaces, and between all spaces
112112

src/Operators/banded/ToeplitzOperator.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bandwidths(T::ToeplitzOperator)=(length(T.negative),length(T.nonnegative)-1)
7575

7676
# slice of a ToeplitzOPerator is a ToeplitzOperator
7777

78-
function Base.getindex(T::ToeplitzOperator,kr::InfRanges,jr::InfRanges)
78+
function getindex(T::ToeplitzOperator,kr::InfRanges,jr::InfRanges)
7979
sh=first(jr)-first(kr)
8080
st=step(jr)
8181
@assert st==step(kr)

src/Operators/general/CachedOperator.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ blockbandwidths(C::CachedOperator{T,BM,M}) where {T<:Number,BM<:BandedMatrix,M<:
7373
@wrapperstructure CachedOperator
7474

7575

76-
@propagate_inbounds function Base.getindex(B::CachedOperator,k::Integer,j::Integer)
76+
@propagate_inbounds function getindex(B::CachedOperator,k::Integer,j::Integer)
7777
resizedata!(B,k,j)
7878
if k size(B.data,1) && j size(B.data,2)
7979
B.data[k,j]
@@ -82,7 +82,7 @@ blockbandwidths(C::CachedOperator{T,BM,M}) where {T<:Number,BM<:BandedMatrix,M<:
8282
end
8383
end
8484

85-
function Base.getindex(B::CachedOperator,k::AbstractRange,j::AbstractRange)
85+
function getindex(B::CachedOperator,k::AbstractRange,j::AbstractRange)
8686
if !isempty(k) && !isempty(j)
8787
resizedata!(B,maximum(k),maximum(j))
8888
B.data[k,j]
@@ -91,7 +91,7 @@ function Base.getindex(B::CachedOperator,k::AbstractRange,j::AbstractRange)
9191
end
9292
end
9393

94-
function Base.getindex(B::CachedOperator,k::Integer)
94+
function getindex(B::CachedOperator,k::Integer)
9595
if size(B,1)==1
9696
B[1,k]
9797
elseif size(B,2)==1
@@ -101,12 +101,12 @@ function Base.getindex(B::CachedOperator,k::Integer)
101101
end
102102
end
103103

104-
@propagate_inbounds function Base.setindex!(B::CachedOperator,v,k,j)
104+
@propagate_inbounds function setindex!(B::CachedOperator,v,k,j)
105105
resizedata!(B,k,j)
106106
B.data[k,j] = v
107107
end
108108

109-
@propagate_inbounds function Base.setindex!(B::CachedOperator,v,k::Integer)
109+
@propagate_inbounds function setindex!(B::CachedOperator,v,k::Integer)
110110
if size(B,1)==1
111111
B[1,k] = v
112112
elseif size(B,2)==1

src/PDE/KroneckerOperator.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,18 @@ function mul_coefficients(A::SubOperator{T,KKO,NTuple{2,UnitRange{Int}}}, b) whe
425425
M*pad(b, size(M,2))
426426
end
427427

428-
Base.getindex(A::KroneckerOperator, B::MultivariateFun) = A[Fun(B)]
429-
function Base.getindex(K::KroneckerOperator, f::LowRankFun)
428+
getindex(A::KroneckerOperator, B::MultivariateFun) = A[Fun(B)]
429+
function getindex(K::KroneckerOperator, f::LowRankFun)
430430
op1, op2 = K.ops
431431
sum(zip(f.A, f.B)) do (A,B)
432432
op1[A] op2[B]
433433
end
434434
end
435-
Base.getindex(K::KroneckerOperator, B::ProductFun) = K[LowRankFun(B)]
435+
getindex(K::KroneckerOperator, B::ProductFun) = K[LowRankFun(B)]
436436

437437
for F in [:MultivariateFun, :ProductFun, :LowRankFun]
438438
for O in WrapperList
439-
@eval Base.getindex(K::$O{<:KroneckerOperator}, f::$F) = K.op[f]
439+
@eval getindex(K::$O{<:KroneckerOperator}, f::$F) = K.op[f]
440440
@eval (*)(A::$O{<:KroneckerOperator}, B::$F) = A.op * B
441441
@eval (*)(A::$F, B::$O{<:KroneckerOperator}) = A * B.op
442442
end

src/Spaces/ArraySpace.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ getindex(f::ArraySpace,k...) = Space(component(f,k...))
5858
iterate(f::Fun{<:ArraySpace}) = iterate(components(f))
5959

6060

61-
Base.reshape(AS::ArraySpace,k...) = ArraySpace(reshape(AS.spaces,k...))
61+
reshape(AS::ArraySpace,k...) = ArraySpace(reshape(AS.spaces,k...))
6262
dimension(AS::ArraySpace) = mapreduce(dimension,+,AS.spaces,init=0)
6363

6464
# TODO: union domain
@@ -112,14 +112,14 @@ repeat(A::ArraySpace,n,m) = ArraySpace(repeat(A.spaces,n,m))
112112

113113
component(A::MatrixSpace,k::Integer,j::Integer) = A.spaces[k,j]
114114

115-
Base.getindex(f::Fun{DSS},k::Integer) where {DSS<:ArraySpace} = component(f,k)
115+
getindex(f::Fun{DSS},k::Integer) where {DSS<:ArraySpace} = component(f,k)
116116

117117

118-
Base.getindex(f::Fun{<:MatrixSpace},k::Integer,j::Integer) =
118+
getindex(f::Fun{<:MatrixSpace},k::Integer,j::Integer) =
119119
f[k+stride(f,2)*(j-1)]
120120

121-
Base.getindex(f::Fun{DSS},kj::CartesianIndex{1}) where {DSS<:ArraySpace} = f[kj[1]]
122-
Base.getindex(f::Fun{DSS},kj::CartesianIndex{2}) where {DSS<:ArraySpace} = f[kj[1],kj[2]]
121+
getindex(f::Fun{DSS},kj::CartesianIndex{1}) where {DSS<:ArraySpace} = f[kj[1]]
122+
getindex(f::Fun{DSS},kj::CartesianIndex{2}) where {DSS<:ArraySpace} = f[kj[1],kj[2]]
123123

124124

125125
function Fun(A::AbstractMatrix{<:Fun{<:VectorSpace{S},V,VV}}) where {S,V,VV}
@@ -189,7 +189,7 @@ function choosedomainspace(A::VectorInterlaceOperator, sp::ArraySpace)
189189
end
190190

191191

192-
Base.reshape(f::Fun{AS},k...) where {AS<:ArraySpace} = Fun(reshape(space(f),k...),f.coefficients)
192+
reshape(f::Fun{AS},k...) where {AS<:ArraySpace} = Fun(reshape(space(f),k...),f.coefficients)
193193

194194
Base.diff(f::Fun{AS,T},n...) where {AS<:ArraySpace,T} = Fun(diff(Array(f),n...))
195195

src/Spaces/ProductSpaceOperators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ DefiniteLineIntegral(sp::PiecewiseSpace) =
357357

358358
## TensorSpace of two PiecewiseSpaces
359359

360-
Base.getindex(d::TensorSpace{Tuple{PWS1,PWS2}},i::Integer,j::Integer) where {PWS1<:PiecewiseSpace,PWS2<:PiecewiseSpace} =
360+
getindex(d::TensorSpace{Tuple{PWS1,PWS2}},i::Integer,j::Integer) where {PWS1<:PiecewiseSpace,PWS2<:PiecewiseSpace} =
361361
d[1][i]d[2][j]
362-
Base.getindex(d::TensorSpace{Tuple{PWS1,PWS2}},i::AbstractRange,j::AbstractRange) where {PWS1<:PiecewiseSpace,PWS2<:PiecewiseSpace} =
362+
getindex(d::TensorSpace{Tuple{PWS1,PWS2}},i::AbstractRange,j::AbstractRange) where {PWS1<:PiecewiseSpace,PWS2<:PiecewiseSpace} =
363363
PiecewiseSpace(d[1][i])PiecewiseSpace(d[2][j])
364364

365365
## ProductFun

0 commit comments

Comments
 (0)