Skip to content

Commit 3f22e9c

Browse files
authored
Interlace coeffs by blocks in Fourier integrate (#86)
1 parent 11df9e6 commit 3f22e9c

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunFourier"
22
uuid = "59844689-9c9d-51bf-9583-5b794ec66d30"
3-
version = "0.3.16"
3+
version = "0.3.17"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -17,7 +17,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1717

1818
[compat]
1919
AbstractFFTs = "0.5, 1"
20-
ApproxFunBase = "0.8.6"
20+
ApproxFunBase = "0.8.9"
2121
ApproxFunBaseTest = "0.1"
2222
ApproxFunOrthogonalPolynomials = "0.6"
2323
Aqua = "0.5"

src/ApproxFunFourier.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import ApproxFunBase: Fun, SumSpace, SubSpace, NoSpace, IntervalOrSegment,
3131
setcanonicaldomain, mappoint, reverseorientation, checkpoints,
3232
evaluate, mul_coefficients, coefficients, clenshaw, ClenshawPlan,
3333
sineshaw, toeplitz_getindex, ToeplitzOperator, hankel_getindex,
34-
SpaceOperator, ZeroOperator, InterlaceOperator, interlace!,
34+
SpaceOperator, ZeroOperator, InterlaceOperator, interlace!, interlace,
3535
reverseeven!, negateeven!, cfstype, alternatesign!, extremal_args,
3636
hesseneigvals, chebyshev_clenshaw, roots, EmptyDomain,
3737
chebmult_getindex, components, affine_setdiff, complexroots,

src/calculus.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function integrate(f::Fun{CS}) where CS<:CosSpace
8181
fconstant = (f.coefficients[1]*x)
8282
fperiodic = integrate(Fun(f,space(f)|(2:∞)))
8383
SS = SumSpace(space(fconstant), space(fperiodic))
84-
Fun(SS, ApproxFunBase.interlace(coefficients(fconstant), coefficients(fperiodic)))
84+
Fun(SS, interlace(coefficients(fconstant), coefficients(fperiodic)))
8585
else
8686
throw(ArgumentError("not implemented"))
8787
end
@@ -107,8 +107,11 @@ function integrate(f::Fun{Fourier{D,R},T}) where {T,D<:PeriodicSegment,R}
107107
g1 = integrate(component(f,2))
108108
g2 = integrate(component(f,1))
109109
# g1 ⊕ g2, but we construct the space directly to improve type-stability
110-
SS = SumSpace(space(g1), space(g2))
111-
Fun(SS, ApproxFunBase.interlace(coefficients(g1), coefficients(g2)))
110+
S1 = space(g1)
111+
S2 = space(g2)
112+
SS = SumSpace(S1, S2)
113+
nc = map(ncomponents, (S1,S2))
114+
Fun(SS, interlace(coefficients(g1), coefficients(g2), nc))
112115
end
113116

114117

test/runtests.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,13 @@ end
301301
@test norm(integrate(f)'-f)<10eps()
302302
end
303303
@test iszero(integrate(Fun(CosSpace(), Float64[])))
304-
f = Fun->1+cos(θ), CosSpace())
305-
g = integrate(f)
306-
θ = 0.4
307-
@test g(θ) θ + sin(θ)
308-
@test Fun(g', space(f)) f
304+
for S in (CosSpace(), Fourier())
305+
f = Fun->1+cos(θ), S)
306+
g = integrate(f)
307+
θ = 0.4
308+
@test g(θ) θ + sin(θ)
309+
@test Fun(g', S) f
310+
end
309311
end
310312

311313

0 commit comments

Comments
 (0)