Skip to content

Commit 7811b92

Browse files
authored
updates for new FastTransforms (#7)
* updates for new FastTransforms * Update MultivariateTest.jl * Update MultivariateTest.jl * tests pass! * Add install * Support for FastTransforms 0.6.1 * update
1 parent 5867548 commit 7811b92

File tree

9 files changed

+78
-61
lines changed

9 files changed

+78
-61
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ julia:
1212
matrix:
1313
allow_failures:
1414
- julia: nightly
15+
- julia: "1.3"
16+
1517
notifications:
1618
email: false
1719
codecov: true

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ BlockBandedMatrices = "0.5, 0.6"
2828
DomainSets = "0.1"
2929
FFTW = "0.3, 1"
3030
FastGaussQuadrature = "0.3.2, 0.4"
31-
FastTransforms = "0.5, 0.6"
31+
FastTransforms = "0.6.1"
3232
FillArrays = "0.7, 0.8"
3333
IntervalSets = "0.3.1"
3434
Reexport = "0.2"
35-
SpecialFunctions = "0.7, 0.8"
35+
SpecialFunctions = "0.7, 0.8, 0.9"
3636
julia = "1"
3737

3838
[extras]

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ platform:
1515
matrix:
1616
allow_failures:
1717
- julia_version: nightly
18+
- julia_version: 1.3
1819
- platform: x86
1920

2021
branches:

src/ApproxFunOrthogonalPolynomials.jl

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import LinearAlgebra: BlasInt, BlasFloat, norm, ldiv!, mul!, det, eigvals, dot,
7474

7575
import FastTransforms: ChebyshevTransformPlan, IChebyshevTransformPlan, plan_chebyshevtransform,
7676
plan_chebyshevtransform!, plan_ichebyshevtransform, plan_ichebyshevtransform!,
77-
pochhammer, lgamma
77+
pochhammer, lgamma, chebyshevtransform!, ichebyshevtransform!
7878

7979
import BlockBandedMatrices: blockbandwidths, subblockbandwidths
8080

@@ -94,51 +94,11 @@ import SpecialFunctions: sinpi, cospi, airy, besselh,
9494
atan, acos, asin, erfc, inv
9595

9696
points(d::IntervalOrSegmentDomain{T},n::Integer; kind::Int=1) where {T} =
97-
fromcanonical.(Ref(d), chebyshevpoints(float(real(eltype(T))), n; kind=kind)) # eltype to handle point
98-
bary(v::AbstractVector{Float64}, d::IntervalOrSegmentDomain, x::Float64) = bary(v,tocanonical(d,x))
97+
fromcanonical.(Ref(d), chebyshevpoints(float(real(eltype(T))), n; kind=kind)) # eltype to handle point
98+
bary(v::AbstractVector{Float64},d::IntervalOrSegmentDomain,x::Float64) = bary(v,tocanonical(d,x))
99+
100+
include("bary.jl")
99101

100-
function FastTransforms.chebyshevtransform!(X::AbstractMatrix{T};kind::Integer=1) where T<:fftwNumber
101-
if kind == 1
102-
if size(X) == (1,1)
103-
X
104-
else
105-
X=r2r!(X,REDFT10)
106-
X[:,1]/=2;X[1,:]/=2;
107-
lmul!(1/(size(X,1)*size(X,2)),X)
108-
end
109-
elseif kind == 2
110-
if size(X) == (1,1)
111-
X
112-
else
113-
X=r2r!(X,REDFT00)
114-
lmul!(1/((size(X,1)-1)*(size(X,2)-1)),X)
115-
X[:,1]/=2;X[:,end]/=2
116-
X[1,:]/=2;X[end,:]/=2
117-
X
118-
end
119-
end
120-
end
121-
122-
function FastTransforms.ichebyshevtransform!(X::AbstractMatrix{T};kind::Integer=1) where T<:fftwNumber
123-
if kind == 1
124-
if size(X) == (1,1)
125-
X
126-
else
127-
X[1,:]*=2;X[:,1]*=2
128-
X = r2r(X,REDFT01)
129-
lmul!(1/4,X)
130-
end
131-
elseif kind == 2
132-
if size(X) == (1,1)
133-
X
134-
else
135-
X[1,:]*=2;X[end,:]*=2;X[:,1]*=2;X[:,end]*=2
136-
X=chebyshevtransform!(X;kind=kind)
137-
X[1,:]*=2;X[end,:]*=2;X[:,1]*=2;X[:,end]*=2
138-
lmul!((size(X,1)-1)*(size(X,2)-1)/4,X)
139-
end
140-
end
141-
end
142102

143103
include("ultraspherical.jl")
144104
include("Domains/Domains.jl")

src/Spaces/Jacobi/jacobitransform.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ JacobiTransformPlan(chebplan::CPLAN, cjtplan::CJT) where {CPLAN,CJT} =
1010
JacobiTransformPlan{eltype(chebplan),CPLAN,CJT}(chebplan, cjtplan)
1111

1212
plan_transform(S::Jacobi, v::AbstractVector) =
13-
JacobiTransformPlan(plan_transform(Chebyshev(), v), plan_icjt(v, S.a, S.b))
13+
JacobiTransformPlan(plan_transform(Chebyshev(), v), plan_cheb2jac(v, S.a, S.b))
1414
*(P::JacobiTransformPlan, vals::AbstractVector) = P.cjtplan*(P.chebplan*vals)
1515

1616

@@ -25,29 +25,29 @@ JacobiITransformPlan(chebplan::CPLAN, cjtplan::CJT) where {CPLAN,CJT} =
2525

2626

2727
plan_itransform(S::Jacobi, v::AbstractVector) =
28-
JacobiITransformPlan(plan_itransform(Chebyshev(), v), plan_cjt(v, S.a, S.b))
28+
JacobiITransformPlan(plan_itransform(Chebyshev(), v), plan_jac2cheb(v, S.a, S.b))
2929
*(P::JacobiITransformPlan, cfs::AbstractVector) = P.ichebplan*(P.icjtplan*cfs)
3030

3131

32-
function coefficients(f::AbstractVector,a::Jacobi,b::Chebyshev)
32+
function coefficients(f::AbstractVector{T}, a::Jacobi, b::Chebyshev) where T
3333
if domain(a) == domain(b) && (!isapproxinteger(a.a-0.5) || !isapproxinteger(a.b-0.5))
34-
cjt(f,a.a,a.b)
34+
jac2cheb(f, convert(T,a.a), convert(T,a.b))
3535
else
3636
defaultcoefficients(f,a,b)
3737
end
3838
end
39-
function coefficients(f::AbstractVector,a::Chebyshev,b::Jacobi)
39+
function coefficients(f::AbstractVector{T}, a::Chebyshev, b::Jacobi) where T
4040
isempty(f) && return f
4141
if domain(a) == domain(b) && (!isapproxinteger(b.a-0.5) || !isapproxinteger(b.b-0.5))
42-
icjt(f,b.a,b.b)
42+
cheb2jac(f, convert(T,b.a), convert(T,b.b))
4343
else
4444
defaultcoefficients(f,a,b)
4545
end
4646
end
4747

4848
function coefficients(f::AbstractVector,a::Jacobi,b::Jacobi)
4949
if domain(a) == domain(b) && (!isapproxinteger(a.a-b.a) || !isapproxinteger(a.b-b.b))
50-
jjt(f,a.a,a.b,b.a,b.b)
50+
jac2jac(f,a.a,a.b,b.a,b.b)
5151
else
5252
defaultcoefficients(f,a,b)
5353
end

src/Spaces/Ultraspherical/Ultraspherical.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ end
5858
function UltrasphericalPlan::Number,vals)
5959
if λ == 0.5
6060
cp = plan_transform(Chebyshev(),vals)
61-
c2lp = FastTransforms.th_cheb2legplan(eltype(vals),length(vals))
61+
c2lp = plan_cheb2leg(eltype(vals),length(vals))
6262
UltrasphericalPlan{typeof(cp),typeof(c2lp)}(cp,c2lp)
6363
else
6464
error("Not implemented")
@@ -68,7 +68,7 @@ end
6868
function UltrasphericalIPlan::Number,cfs)
6969
if λ == 0.5
7070
cp=plan_itransform(Chebyshev(),cfs)
71-
c2lp=FastTransforms.th_leg2chebplan(eltype(cfs),length(cfs))
71+
c2lp=plan_leg2cheb(eltype(cfs),length(cfs))
7272
UltrasphericalIPlan{typeof(cp),typeof(c2lp)}(cp,c2lp)
7373
else
7474
error("Not implemented")

src/bary.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Barycentric formula
2+
3+
export bary,barysum
4+
5+
function bary(v::AbstractVector{Float64},pts::AbstractVector{Float64},x::Float64)
6+
n=length(v)
7+
@assert n == length(pts)
8+
9+
10+
retd = 1/(2*(x-pts[1]))
11+
retn = v[1]*retd
12+
13+
for i = 2:2:n-1
14+
@inbounds cd = 1/(x-pts[i])
15+
retd -= cd
16+
@inbounds retn -= v[i]*cd
17+
end
18+
19+
for i = 3:2:n-1
20+
@inbounds cd = 1/(x-pts[i])
21+
retd += cd
22+
@inbounds retn += v[i]*cd
23+
end
24+
25+
cd = .5*(-1.)^(n-1)/(x-pts[n])
26+
retd += cd
27+
retn += v[n]*cd
28+
29+
retn/retd
30+
end
31+
32+
33+
bary(v::AbstractVector{Float64},x::Float64)=bary(v,chebyshevpoints(length(v);kind=2),x)
34+
35+
function randomadaptivebary(f::Function)
36+
r=rand()
37+
fr=f(r)
38+
err=1.
39+
logn=1
40+
41+
tol=200eps()
42+
43+
vals=Float64[]
44+
45+
while err > tol
46+
n=2^logn + 1
47+
pts=chebyshevpoints(n;kind=2)
48+
vals=f(pts)
49+
err=abs(bary(vals,pts,r)-fr)/n
50+
logn+=1
51+
end
52+
53+
vals
54+
end

test/JacobiTest.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using ApproxFunOrthogonalPolynomials, ApproxFunBase, Test, SpecialFunctions, LinearAlgebra
2-
import ApproxFunBase: testbandedbelowoperator, testbandedoperator, testspace, testtransforms, Vec,
3-
maxspace, NoSpace, hasconversion, testfunctional,
4-
reverseorientation, ReverseOrientation
5-
import ApproxFunOrthogonalPolynomials: jacobip
2+
import ApproxFunBase: testbandedbelowoperator, testbandedoperator, testspace, testtransforms, Vec,
3+
maxspace, NoSpace, hasconversion, testfunctional,
4+
reverseorientation, ReverseOrientation
5+
import ApproxFunOrthogonalPolynomials: jacobip
66

77
@testset "Jacobi" begin
88
@testset "Basic" begin

test/MultivariateTest.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using ApproxFunBase, ApproxFunOrthogonalPolynomials, LinearAlgebra, SpecialFunct
22
import ApproxFunBase: testbandedblockbandedoperator, testraggedbelowoperator, factor, Block, cfstype,
33
blocklengths, block, tensorizer, Vec, ArraySpace, ∞,
44
testblockbandedoperator
5-
import ApproxFunOrthogonalPolynomials: chebyshevtransform
5+
import ApproxFunOrthogonalPolynomials: chebyshevtransform
66

77
@testset "Multivariate" begin
88
@testset "Square" begin

0 commit comments

Comments
 (0)