Skip to content

Commit 476e68c

Browse files
authored
update for new BlockArrays (#9)
* updates * updates for ApproxFunBase v0.3 * Update Project.toml
1 parent 96b08b5 commit 476e68c

File tree

11 files changed

+48
-52
lines changed

11 files changed

+48
-52
lines changed

Project.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ApproxFun = "28f2ccd6-bb30-5033-b560-165f7b14dc2f"
77
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
88
ApproxFunFourier = "59844689-9c9d-51bf-9583-5b794ec66d30"
99
ApproxFunOrthogonalPolynomials = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
10+
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
1011
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
1112
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
1213
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
@@ -30,18 +31,19 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3031

3132
[compat]
3233
ApproxFun = "0.11"
34+
ApproxFunBase = "0.3"
3335
ApproxFunFourier = "0.2"
3436
ApproxFunOrthogonalPolynomials = "0.3"
35-
ApproxFunBase = "0.2.3"
37+
ArrayLayouts = "0.1"
3638
BandedMatrices = "0.14"
37-
BlockArrays = "0.10"
38-
BlockBandedMatrices = "0.6"
39+
BlockArrays = "0.11"
40+
BlockBandedMatrices = "0.7"
3941
DomainSets = "0.1"
4042
FastGaussQuadrature = "0.4"
4143
FastTransforms = "0.8"
4244
FillArrays = "0.8"
43-
InfiniteArrays = "0.5"
44-
LazyArrays = "0.14"
45+
InfiniteArrays = "0.6"
46+
LazyArrays = "0.14, 0.15"
4547
RecipesBase = "0.5, 0.6, 0.7"
4648
SpecialFunctions = "0.7, 0.8, 0.9"
4749
StaticArrays = "0.11, 0.12"

src/Cone/Cone.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function fromtensor(::ConicTensorizer, A::AbstractMatrix{T}) where T
3737
@assert size(A,2) == M
3838
B = PseudoBlockArray(A, Ones{Int}(N), [1; Fill(2,N-1)])
3939
a = Vector{T}()
40-
for N = 1:nblocks(B,2), K=1:N
40+
for N = 1:blocksize(B,2), K=1:N
4141
append!(a, vec(view(B,Block(K,N-K+1))))
4242
end
4343
a
@@ -49,7 +49,7 @@ function totensor(::ConicTensorizer, a::AbstractVector{T}) where T
4949
= zeros(eltype(a), N, M)
5050
B = PseudoBlockArray(Ã, Ones{Int}(N), [1; Fill(2,N-1)])
5151
k = 1
52-
for N = 1:nblocks(B,2), K=1:N
52+
for N = 1:blocksize(B,2), K=1:N
5353
V = view(B, Block(K,N-K+1))
5454
for j = 1:length(V)
5555
V[j] = a[k]

src/Disk/Disk.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function fromtensor(::DiskTensorizer, A::AbstractMatrix{T}) where T
6161
@assert size(A,2) == M
6262
B = PseudoBlockArray(A, Ones{Int}(N), [1; Fill(2,2*(N-1))])
6363
a = Vector{T}()
64-
for N = 1:nblocks(B,2), K=1:(N+1)÷2
64+
for N = 1:blocksize(B,2), K=1:(N+1)÷2
6565
append!(a, vec(view(B,Block(K,N-2K+2))))
6666
end
6767
a
@@ -76,7 +76,7 @@ function totensor(::DiskTensorizer, a::AbstractVector{T}) where T
7676
= zeros(eltype(a), N, M)
7777
B = PseudoBlockArray(Ã, Ones{Int}(N), [1; Fill(2,2*(N-1))])
7878
k = 1
79-
for N = 1:nblocks(B,2), K=1:(N+1)÷2
79+
for N = 1:blocksize(B,2), K=1:(N+1)÷2
8080
V = view(B, Block(K,N-2K+2))
8181
for j = 1:length(V)
8282
V[j] = a[k]

src/MultivariateOrthogonalPolynomials.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module MultivariateOrthogonalPolynomials
22
using Base, RecipesBase, ApproxFun, BandedMatrices, BlockArrays, BlockBandedMatrices,
33
FastTransforms, FastGaussQuadrature, StaticArrays, FillArrays,
44
LinearAlgebra, Libdl, SpecialFunctions, LazyArrays, InfiniteArrays,
5-
DomainSets
5+
DomainSets, ArrayLayouts
66

77
# package code goes here
88
import Base: values,getindex,setindex!,*, +, -, ==,<,<=,>,
@@ -11,12 +11,12 @@ import Base: values,getindex,setindex!,*, +, -, ==,<,<=,>,
1111

1212
import BandedMatrices: inbands_getindex, inbands_setindex!
1313

14-
import BlockArrays: blocksizes, BlockSizes, getblock, global2blockindex, Block
14+
import BlockArrays: getblock, Block, blocksize
1515

1616
import BlockBandedMatrices: blockbandwidths, subblockbandwidths
1717

1818
# ApproxFun general import
19-
import ApproxFunBase: BandedMatrix, blocksize,
19+
import ApproxFunBase: BandedMatrix,
2020
linesum,complexlength, BandedBlockBandedMatrix,
2121
real, eps, isapproxinteger, FiniteRange, DFunction,
2222
TransformPlan, ITransformPlan, plan_transform!

src/Triangle/DirichletTriangle.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function Conversion(A::DirichletTriangle{a,b,c}, B::JacobiTriangle) where {a,b,c
6565
end
6666

6767
function coefficients(u::AbstractVector, ds::DirichletTriangle, rs::JacobiTriangle)
68-
N = nblocks(Fun(ds, u))
68+
N = Int(block(ds,length(u)))
6969
C = Conversion(ds, rs)[Block.(1:N), Block.(1:N)]
7070
C * pad(u, size(C,2))
7171
end

src/Triangle/Triangle.jl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,10 @@ function clenshaw2D(Jx,Jy,cfs::Vector{Vector{T}},x,y) where T
361361

362362
bk1 = (x*Abk1x) ::Vector{T}
363363
LinearAlgebra.axpy!(y,Abk1y,bk1)
364-
bk1 .= (-one(T)).*Mul(Bx,Abk1x) .+ bk1
365-
bk1 .= (-one(T)).*Mul(By,Abk1y) .+ bk1
366-
bk1 .= (-one(T)).*Mul(Cx,Abk2x) .+ bk1
367-
bk1 .= (-one(T)).*Mul(Cy,Abk2y) .+ bk1
364+
muladd!(-one(T),Bx,Abk1x, one(T), bk1)
365+
muladd!(-one(T),By,Abk1y, one(T), bk1)
366+
muladd!(-one(T),Cx,Abk2x, one(T), bk1)
367+
muladd!(-one(T),Cy,Abk2y, one(T), bk1)
368368
LinearAlgebra.axpy!(one(T),cfs[Int(K)],bk1)
369369
end
370370

@@ -414,7 +414,7 @@ jacobioperators(S::JacobiTriangle) = fromcanonical(S, canonicaljacobioperators(S
414414

415415

416416
function plan_evaluate(f::Fun{JacobiTriangle},x...)
417-
N = nblocks(f)
417+
N = Int(block(space(f),ncoefficients(f)))
418418
S = space(f)
419419
# we cannot use true Jacobi operators because that changes the band
420420
# structure used in clenshaw2D to determine pseudoinverses
@@ -514,7 +514,7 @@ function Base.convert(::Type{BandedBlockBandedMatrix},
514514
α,β,γ = sp.α,sp.β,sp.γ
515515
K_sh = first(parentindices(S)[1])-1
516516
J_sh = first(parentindices(S)[2])-1
517-
N,M=nblocks(ret)::Tuple{Int,Int}
517+
N,M=blocksize(ret)::Tuple{Int,Int}
518518

519519
if D.order == [1,0]
520520
for K=Block.(1:N)
@@ -674,7 +674,7 @@ function Base.convert(::Type{BandedBlockBandedMatrix}, S::SubOperator{T,Concrete
674674
α,β,γ = K1.α,K1.β,K1.γ
675675
K_sh = first(parentindices(S)[1])-1
676676
J_sh = first(parentindices(S)[2])-1
677-
N,M=nblocks(ret)::Tuple{Int,Int}
677+
N,M=blocksize(ret)::Tuple{Int,Int}
678678

679679
if K2.α == α+1 && K2.β == β && K2.γ == γ
680680
for KK=Block.(1:N)
@@ -906,7 +906,7 @@ function Base.convert(::Type{BandedBlockBandedMatrix},S::SubOperator{T,Lowering{
906906
α,β,γ=R.space.α,R.space.β,R.space.γ
907907
K_sh = first(parentindices(S)[1])-1
908908
J_sh = first(parentindices(S)[2])-1
909-
N,M=nblocks(ret)::Tuple{Int,Int}
909+
N,M=blocksize(ret)::Tuple{Int,Int}
910910

911911
for KK=Block.(1:N)
912912
JJ = KK+K_sh-J_sh-1 # super-diagonal
@@ -939,7 +939,7 @@ function Base.convert(::Type{BandedBlockBandedMatrix},S::SubOperator{T,Lowering{
939939
α,β,γ=R.space.α,R.space.β,R.space.γ
940940
K_sh = first(parentindices(S)[1])-1
941941
J_sh = first(parentindices(S)[2])-1
942-
N,M = nblocks(ret)::Tuple{Int,Int}
942+
N,M = blocksize(ret)::Tuple{Int,Int}
943943

944944

945945
for KK=Block.(1:N)
@@ -977,7 +977,7 @@ function Base.convert(::Type{BandedBlockBandedMatrix},S::SubOperator{T,Lowering{
977977
α,β,γ=R.space.α,R.space.β,R.space.γ
978978
K_sh = first(parentindices(S)[1])-1
979979
J_sh = first(parentindices(S)[2])-1
980-
N,M=nblocks(ret)::Tuple{Int,Int}
980+
N,M=blocksize(ret)::Tuple{Int,Int}
981981

982982
for KK=Block.(1:N)
983983
JJ = KK+K_sh-J_sh-1 # super-diagonal
@@ -1372,8 +1372,6 @@ end
13721372

13731373

13741374
# temporary work around
1375-
import ApproxFun: block, blockbandwidth, Block
1376-
import Base: *
13771375
function *(A_in::Operator, f::Fun{<:JacobiTriangle})
13781376
A = A_in : space(f)
13791377
N = Int(block(space(f), ncoefficients(f)))

src/clenshaw.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ convert(::Type{Operator{T}}, C::ClenshawMultiplication{D,S}) where {D,S,T} =
121121
convert(AbstractVector{T}, C.cfs), C.space)
122122

123123
function ClenshawMultiplication(f::Fun{D,T}, sp::S) where {D,S,T}
124-
N = nblocks(f)
124+
N = Int(block(space(f), ncoefficients(f)))
125125
ClenshawMultiplication{D,S,T}(ClenshawRecurrenceData(space(f),N),
126126
PseudoBlockArray(pad(f.coefficients, sum(1:N)),1:N),
127127
sp)
@@ -141,8 +141,8 @@ end
141141
domainspace(M::ClenshawMultiplication) = M.space
142142
rangespace(M::ClenshawMultiplication) = M.space
143143
isbandedblockbanded(::ClenshawMultiplication) = true
144-
blockbandwidths(M::ClenshawMultiplication) = (nblocks(M.cfs)[1]-1,nblocks(M.cfs)[1]-1)
145-
subblockbandwidths(M::ClenshawMultiplication) = (nblocks(M.cfs)[1]-1,nblocks(M.cfs)[1]-1)
144+
blockbandwidths(M::ClenshawMultiplication) = (blocksize(M.cfs,1)-1,blocksize(M.cfs,1)-1)
145+
subblockbandwidths(M::ClenshawMultiplication) = (blocksize(M.cfs,1)-1,blocksize(M.cfs,1)-1)
146146

147147
function getindex(M::ClenshawMultiplication, k::Int, j::Int)
148148
K,J = block(M.space,k), block(M.space,j)
@@ -153,13 +153,13 @@ function BandedBlockBandedMatrix(V::SubOperator{T,<:ClenshawMultiplication,Tuple
153153
KR,JR = parentindices(V)
154154
M = parent(V)
155155
sp,cfs,C = M.space, M.cfs, M.data
156-
N = nblocks(cfs)[1]
156+
N = blocksize(cfs,1)
157157
JKR = Block.(max(1,min(Int(JR[1]),Int(KR[1]))-(N-1)÷2):max(Int(JR[end]),Int(KR[end]))+(N-1)÷2)
158158

159159
Jx_∞, Jy_∞ = convert.(Operator{T}, jacobioperators(sp))
160160
Jx, Jy = Jx_∞[JKR, JKR], Jy_∞[JKR,JKR]
161161

162-
Q = BandedBlockBandedMatrix(Eye{eltype(Jx)}(size(Jx)...), blocksizes(Jx), (0,0), (0,0))
162+
Q = BandedBlockBandedMatrix(Eye{eltype(Jx)}(size(Jx)...), axes(Jx), (0,0), (0,0))
163163
B2 = Fill(Q,N) .* view(cfs,Block(N))
164164
if N == 1
165165
B1 = B2

test/test_cone.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MultivariateOrthogonalPolynomials: rectspace, totensor, duffy2legendrecon
1313
B = PseudoBlockArray(A, Ones{Int}(3), [1; Fill(2,2)])
1414

1515
a = Vector{eltype(A)}()
16-
for N = 1:nblocks(B,2), K=1:N
16+
for N = 1:blocksize(B,2), K=1:N
1717
append!(a, vec(B[Block(K,N-K+1)]))
1818
end
1919

@@ -24,7 +24,7 @@ import MultivariateOrthogonalPolynomials: rectspace, totensor, duffy2legendrecon
2424
= zeros(eltype(a), N, M)
2525
B = PseudoBlockArray(Ã, Ones{Int}(3), [1; Fill(2,2)])
2626
k = 1
27-
for N = 1:nblocks(B,2), K=1:N
27+
for N = 1:blocksize(B,2), K=1:N
2828
V = view(B, Block(K,N-K+1))
2929
for j = 1:length(V)
3030
V[j] = a[k]

test/test_dirichlettriangle.jl

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,57 +188,55 @@ x,y=0.1,0.2
188188
@test C[1:20,1:20] C̃[1:20,1:20]
189189
end
190190

191-
192191
@testset "Dirichlet evaluation" begin
193192
f=Fun((x,y)->exp(x-0.12*cos(y)),JacobiTriangle(0,0,0))
194193

195194
C=Conversion(DirichletTriangle{1,0,0}(),JacobiTriangle(0,0,0))
196-
R=Conversion(domainspace(C),Legendre(Vec(0.,0.)..Vec(0.,1.)))
195+
R=Conversion(domainspace(C),Legendre(Segment(Vec(0.,0.),Vec(0.,1.))))
197196
u=C\f
198197
@test (R*u)(0.,0.3) f(0.,0.3)
199198
@test u(0.1,0.2) f(0.1,0.2)
200199

201200

202201
C=Conversion(DirichletTriangle{0,1,0}(),JacobiTriangle(0,0,0))
203-
R=Conversion(domainspace(C),Legendre(Vec(0.,0.)..Vec(1.,0.)))
202+
R=Conversion(domainspace(C),Legendre(Segment(Vec(0.,0.),Vec(1.,0.))))
204203
u=C\f
205204
@test (R*u)(0.3,0.) f(0.3,0.)
206205
@test u(0.1,0.2) f(0.1,0.2)
207206

208207
C=Conversion(DirichletTriangle{0,0,1}(),JacobiTriangle(0,0,0))
209-
R=Conversion(domainspace(C),Legendre(Vec(0.,1.)..Vec(1.,0.)))
208+
R=Conversion(domainspace(C),Legendre(Segment(Vec(0.,1.),Vec(1.,0.))))
210209
u=C\f
211210
@test (R*u)(0.3,1-0.3) f(0.3,1-0.3)
212211
@test u(0.1,0.2) f(0.1,0.2)
213212

214213
C=Conversion(DirichletTriangle{1,1,0}(),DirichletTriangle{1,0,0}(),JacobiTriangle(0,0,0))
215-
Rx=Conversion(DirichletTriangle{1,1,0}(),DirichletTriangle{1,0,0}(),Legendre(Vec(0.,0.)..Vec(0.,1.)))
216-
Ry=Conversion(DirichletTriangle{1,1,0}(),DirichletTriangle{0,1,0}(),Legendre(Vec(0.,0.)..Vec(1.,0.)))
214+
Rx=Conversion(DirichletTriangle{1,1,0}(),DirichletTriangle{1,0,0}(),Legendre(Segment(Vec(0.,0.),Vec(0.,1.))))
215+
Ry=Conversion(DirichletTriangle{1,1,0}(),DirichletTriangle{0,1,0}(),Legendre(Segment(Vec(0.,0.),Vec(1.,0.))))
217216
u=C\f
218217
@test (Rx*u)(0.,0.3) f(0.,0.3)
219218
@test (Ry*u)(0.3,0.) f(0.3,0.)
220219
@test u(0.1,0.2) f(0.1,0.2)
221220

222221
C=Conversion(DirichletTriangle{1,0,1}(),DirichletTriangle{1,0,0}(),JacobiTriangle(0,0,0))
223-
Rx=Conversion(DirichletTriangle{1,0,1}(),DirichletTriangle{1,0,0}(),Legendre(Vec(0.,0.)..Vec(0.,1.)))
224-
Rz=Conversion(DirichletTriangle{1,0,1}(),DirichletTriangle{0,0,1}(),Legendre(Vec(0.,1.)..Vec(1.,0.)))
222+
Rx=Conversion(DirichletTriangle{1,0,1}(),DirichletTriangle{1,0,0}(),Legendre(Segment(Vec(0.,0.),Vec(0.,1.))))
223+
Rz=Conversion(DirichletTriangle{1,0,1}(),DirichletTriangle{0,0,1}(),Legendre(Segment(Vec(0.,1.),Vec(1.,0.))))
225224
u=C\f
226225
@test (Rx*u)(0.,0.3) f(0.,0.3)
227226
@test (Rz*u)(0.3,1-0.3) f(0.3,1-0.3)
228227
@test u(0.1,0.2) f(0.1,0.2)
229228

230229
C=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{1,1,0}(),DirichletTriangle{1,0,0}(),JacobiTriangle(0,0,0))
231-
Rx=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{1,1,0}(),DirichletTriangle{1,0,0}(),Legendre(Vec(0.,0.)..Vec(0.,1.)))
232-
Ry=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{1,1,0}(),DirichletTriangle{0,1,0}(),Legendre(Vec(0.,0.)..Vec(1.,0.)))
233-
Rz=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{0,1,1}(),DirichletTriangle{0,0,1}(),Legendre(Vec(0.,1.)..Vec(1.,0.)))
230+
Rx=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{1,1,0}(),DirichletTriangle{1,0,0}(),Legendre(Segment(Vec(0.,0.),Vec(0.,1.))))
231+
Ry=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{1,1,0}(),DirichletTriangle{0,1,0}(),Legendre(Segment(Vec(0.,0.),Vec(1.,0.))))
232+
Rz=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{0,1,1}(),DirichletTriangle{0,0,1}(),Legendre(Segment(Vec(0.,1.),Vec(1.,0.))))
234233
u=C\f
235234
@test (Rx*u)(0.,0.3) f(0.,0.3)
236235
@test (Ry*u)(0.3,0.) f(0.3,0.)
237236
@test (Rz*u)(0.3,1-0.3) f(0.3,1-0.3)
238237
@test u(0.1,0.2) f(0.1,0.2)
239238
end
240239

241-
242240
@testset "Dirichlet restriction" begin
243241
f=Fun((x,y)->exp(x-0.12*cos(y)),JacobiTriangle(0,0,0))
244242
C=Conversion(DirichletTriangle{1,1,1}(),DirichletTriangle{1,1,0}(),DirichletTriangle{1,0,0}(),JacobiTriangle(0,0,0))
@@ -265,7 +263,6 @@ end
265263

266264
end
267265

268-
269266
@testset "Triangle Dirichlet Derivatives" begin
270267
@testset "Triangle() Derivative" begin
271268
S = DirichletTriangle{1,0,1}()
@@ -375,7 +372,6 @@ end
375372
end
376373
end
377374

378-
379375
@testset "Triangle Dirichlet Laplacian" begin
380376
@testset "Triangle Laplace" begin
381377
S = DirichletTriangle{1,1,1}()

test/test_disk.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ end
2626
B = PseudoBlockArray(A, Ones{Int}(3), [1; Fill(2,4)])
2727

2828
a = Vector{eltype(A)}()
29-
for N = 1:nblocks(B,2), K=1:(N+1)÷2
29+
for N = 1:blocksize(B,2), K=1:(N+1)÷2
3030
append!(a, vec(B[Block(K,N-2K+2)]))
3131
end
3232

@@ -44,7 +44,7 @@ end
4444
= zeros(eltype(a), N, M)
4545
B = PseudoBlockArray(Ã, Ones{Int}(3), [1; Fill(2,4)])
4646
k = 1
47-
for N = 1:nblocks(B,2), K=1:(N+1)÷2
47+
for N = 1:blocksize(B,2), K=1:(N+1)÷2
4848
V = view(B, Block(K,N-2K+2))
4949
for j = 1:length(V)
5050
V[j] = a[k]

0 commit comments

Comments
 (0)