Skip to content

Commit c7fb0ad

Browse files
committed
Tests pass!!!
1 parent e408b88 commit c7fb0ad

File tree

9 files changed

+180
-106
lines changed

9 files changed

+180
-106
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ os:
66
julia:
77
- 0.6
88
- nightly
9-
matrix:
10-
allow_failures:
11-
- julia: nightly
129
notifications:
1310
email: false
1411
after_success:

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
julia 0.6
1+
julia 0.7-
22
ToeplitzMatrices 0.2
33
HierarchicalMatrices 0.1.1
44
LowRankApprox 0.1.1

appveyor.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ environment:
55
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
66
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
77

8-
matrix:
9-
allow_failures:
10-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
11-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
12-
138
branches:
149
only:
1510
- master

src/SphericalHarmonics/SphericalHarmonics.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ function *(P::SphericalHarmonicPlan, X::AbstractMatrix)
44
mul!(zero(X), P, X)
55
end
66

7-
function \(P::SphericalHarmonicPlan, X::AbstractMatrix)
8-
mul!(zero(X), transpose(P), X)
7+
if VERSION < v"0.7-"
8+
function \(P::SphericalHarmonicPlan, X::AbstractMatrix)
9+
At_mul_B!(zero(X), P, X)
10+
end
11+
else
12+
function \(P::SphericalHarmonicPlan, X::AbstractMatrix)
13+
mul!(zero(X), transpose(P), X)
14+
end
915
end
1016

1117
include("sphfunctions.jl")

src/fftBigFloat.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434
rfft(v::Vector{T}) where T<:BigFloats = fft(v)[1:div(length(v),2)+1]
3535
function irfft(v::Vector{T},n::Integer) where T<:BigFloats
3636
@assert n==2length(v)-1
37-
r = Vector{Complex{BigFloat}}(n)
37+
r = Vector{Complex{BigFloat}}(undef, n)
3838
r[1:length(v)]=v
3939
r[length(v)+1:end]=reverse(conj(v[2:end]))
4040
real(ifft(r))
@@ -163,8 +163,8 @@ for (Plan,ff,ff!) in ((:DummyFFTPlan,:fft,:fft!),
163163
@eval begin
164164
*(p::$Plan{T,true}, x::StridedArray{T,N}) where {T,N} = $ff!(x)
165165
*(p::$Plan{T,false}, x::StridedArray{T,N}) where {T,N} = $ff(x)
166-
function mul!(C::StridedVector,p::$Plan,x::StridedVector)
167-
C[:]=$ff(x)
166+
function LAmul!(C::StridedVector, p::$Plan, x::StridedVector)
167+
C[:] = $ff(x)
168168
C
169169
end
170170
end

test/sphericalharmonics/apitests.jl

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,33 @@ using Compat.Test
44
import FastTransforms: normalizecolumns!, maxcolnorm
55

66
@testset "Spherical harmonic API" begin
7-
n = 512
8-
A = sphrandn(Float64, n, n);
9-
normalizecolumns!(A);
7+
let n = 512
8+
A = sphrandn(Float64, n, n);
9+
normalizecolumns!(A);
1010

11-
B = sph2fourier(A)
12-
C = fourier2sph(B)
13-
println("The backward difference between slow plan and original: ", maxcolnorm(A-C))
11+
B = sph2fourier(A)
12+
C = fourier2sph(B)
13+
println("The backward difference between slow plan and original: ", maxcolnorm(A-C))
1414

15-
P = plan_sph2fourier(A)
16-
B = P*A
17-
C = P\B
15+
P = plan_sph2fourier(A)
16+
B = P*A
17+
C = P\B
1818

19-
println("The backward difference between slow plan and original: ", maxcolnorm(A-C))
19+
println("The backward difference between slow plan and original: ", maxcolnorm(A-C))
2020

2121

22-
n = 1024
23-
A = sphrandn(Float64, n, n);
24-
normalizecolumns!(A);
22+
n = 1024
23+
A = sphrandn(Float64, n, n);
24+
normalizecolumns!(A);
2525

26-
B = sph2fourier(A; sketch = :none)
27-
C = fourier2sph(B; sketch = :none)
28-
println("The backward difference between thin plan and original: ", maxcolnorm(A-C))
26+
B = sph2fourier(A; sketch = :none)
27+
C = fourier2sph(B; sketch = :none)
28+
println("The backward difference between thin plan and original: ", maxcolnorm(A-C))
2929

30-
P = plan_sph2fourier(A; sketch = :none)
31-
B = P*A
32-
C = P\B
30+
P = plan_sph2fourier(A; sketch = :none)
31+
B = P*A
32+
C = P\B
3333

34-
println("The backward difference between thin plan and original: ", maxcolnorm(A-C))
34+
println("The backward difference between thin plan and original: ", maxcolnorm(A-C))
35+
end
3536
end

test/sphericalharmonics/synthesisanalysistests.jl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,29 @@ end
110110
end
111111
end
112112

113-
# This test confirms numerically that [P_4(z⋅y) - P_4(x⋅y)]/(z⋅y - x⋅y) is actually a degree-3 polynomial on 𝕊²
114-
x = [0,0,1]
115-
y = normalize!([.123,.456,.789])
113+
@testset "Degree-3 polynomial" begin
114+
# This test confirms numerically that [P_4(z⋅y) - P_4(x⋅y)]/(z⋅y - x⋅y) is actually a degree-3 polynomial on 𝕊²
115+
x = [0,0,1]
116+
y = normalize!([.123,.456,.789])
116117

117-
z = (θ,φ) -> [sinpi(θ)*cospi(φ), sinpi(θ)*sinpi(φ), cospi(θ)]
118+
z = (θ,φ) -> [sinpi(θ)*cospi(φ), sinpi(θ)*sinpi(φ), cospi(θ)]
118119

119-
P4 = x -> (35*x^4-30*x^2+3)/8
120+
P4 = x -> (35*x^4-30*x^2+3)/8
120121

121-
n = 5
122-
θ = (0.5:n-0.5)/n
123-
φ = (0:2n-2)*2/(2n-1)
124-
F = [(P4(z(θ,φ)y) - P4(xy))/(z(θ,φ)y - xy) for θ in θ, φ in φ]
125-
V = zero(F)
126-
mul!(V, FastTransforms.plan_analysis(F), F)
127-
U3 = fourier2sph(V)
122+
n = 5
123+
θ = (0.5:n-0.5)/n
124+
φ = (0:2n-2)*2/(2n-1)
125+
F = [(P4(z(θ,φ)y) - P4(xy))/(z(θ,φ)y - xy) for θ in θ, φ in φ]
126+
V = zero(F)
127+
mul!(V, FastTransforms.plan_analysis(F), F)
128+
U3 = fourier2sph(V)
128129

129-
# U3 is degree-3
130+
# U3 is degree-3
130131

131-
F = [P4(z(θ,φ)y) for θ in θ, φ in φ]
132-
V = zero(F)
133-
mul!(V, FastTransforms.plan_analysis(F), F)
134-
U4 = fourier2sph(V)
132+
F = [P4(z(θ,φ)y) for θ in θ, φ in φ]
133+
V = zero(F)
134+
mul!(V, FastTransforms.plan_analysis(F), F)
135+
U4 = fourier2sph(V)
135136

136-
# U4 is degree-4
137+
# U4 is degree-4
138+
end
Lines changed: 110 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,87 @@
11
using FastTransforms, Compat
22
using Compat.Test
33

4-
@testset "Test vector field transforms" begin
5-
# f = (θ,φ) -> cospi(θ) + sinpi(θ)*(1+cospi(2θ))*sinpi(φ) + sinpi(θ)^5*(cospi(5φ)-sinpi(5φ))
6-
∇θf = (θ,φ) -> -sinpi(θ) + (cospi(θ)*(1+cospi(2θ)) - 2*sinpi(θ)*sinpi(2θ))*sinpi(φ) + 5*sinpi(θ)^4*cospi(θ)*(cospi(5φ)-sinpi(5φ))
7-
∇φf = (θ,φ) -> (1+cospi(2θ))*cospi(φ) - 5*sinpi(θ)^4*(sinpi(5φ)+cospi(5φ))
4+
if VERSION < v"0.7-"
5+
@testset "Test vector field transforms" begin
6+
# f = (θ,φ) -> cospi(θ) + sinpi(θ)*(1+cospi(2θ))*sinpi(φ) + sinpi(θ)^5*(cospi(5φ)-sinpi(5φ))
7+
∇θf = (θ,φ) -> -sinpi(θ) + (cospi(θ)*(1+cospi(2θ)) - 2*sinpi(θ)*sinpi(2θ))*sinpi(φ) + 5*sinpi(θ)^4*cospi(θ)*(cospi(5φ)-sinpi(5φ))
8+
∇φf = (θ,φ) -> (1+cospi(2θ))*cospi(φ) - 5*sinpi(θ)^4*(sinpi(5φ)+cospi(5φ))
89

9-
n = 6
10-
θ = (0.5:n-0.5)/n
11-
φ = (0:2n-2)*2/(2n-1)
12-
∇θF = [∇θf(θ,φ) for θ in θ, φ in φ]
13-
∇φF = [∇φf(θ,φ) for θ in θ, φ in φ]
14-
V1 = zero(∇θF)
15-
V2 = zero(∇φF)
16-
Pa = FastTransforms.plan_analysis(∇θF)
17-
mul!(V1, V2, Pa, ∇θF, ∇φF)
18-
P = SlowSphericalHarmonicPlan(V1)
19-
20-
U1 = zero(V1)
21-
U2 = zero(V2)
22-
FastTransforms.At_mul_B!(U1, U2, P, V1, V2)
23-
24-
W1 = zero(U1)
25-
W2 = zero(U2)
10+
n = 6
11+
θ = (0.5:n-0.5)/n
12+
φ = (0:2n-2)*2/(2n-1)
13+
∇θF = [∇θf(θ,φ) for θ in θ, φ in φ]
14+
∇φF = [∇φf(θ,φ) for θ in θ, φ in φ]
15+
V1 = zero(∇θF)
16+
V2 = zero(∇φF)
17+
Pa = FastTransforms.plan_analysis(∇θF)
18+
mul!(V1, V2, Pa, ∇θF, ∇φF)
19+
P = SlowSphericalHarmonicPlan(V1)
2620

27-
mul!(W1, W2, P, U1, U2)
21+
U1 = zero(V1)
22+
U2 = zero(V2)
23+
At_mul_B!(U1, U2, P, V1, V2)
2824

29-
Ps = FastTransforms.plan_synthesis(W1)
25+
W1 = zero(U1)
26+
W2 = zero(U2)
3027

31-
G1 = zero(∇θF)
32-
G2 = zero(∇φF)
28+
mul!(W1, W2, P, U1, U2)
3329

34-
mul!(G1, G2, Ps, W1, W2)
30+
Ps = FastTransforms.plan_synthesis(W1)
3531

36-
@test vecnorm(∇θF - G1)/vecnorm(∇θF) < n*eps()
37-
@test vecnorm(∇φF - G2)/vecnorm(∇φF) < n*eps()
32+
G1 = zero(∇θF)
33+
G2 = zero(∇φF)
3834

39-
y = (1.0, 2.0, 3.0)
40-
for k in (10, 20, 40)
41-
∇θf = (θ,φ) -> -2k*sin(k*((sinpi(θ)*cospi(φ) - y[1])^2 + (sinpi(θ)*sinpi(φ) - y[2])^2 + (cospi(θ) - y[3])^2))*( (sinpi(θ)*cospi(φ) - y[1])*(cospi(θ)*cospi(φ)) + (sinpi(θ)*sinpi(φ) - y[2])*(cospi(θ)*sinpi(φ)) - (cospi(θ) - y[3])*sinpi(θ) )
42-
∇φf = (θ,φ) -> -2k*sin(k*((sinpi(θ)*cospi(φ) - y[1])^2 + (sinpi(θ)*sinpi(φ) - y[2])^2 + (cospi(θ) - y[3])^2))*( (sinpi(θ)*cospi(φ) - y[1])*(-sinpi(φ)) + (sinpi(θ)*sinpi(φ) - y[2])*(cospi(φ)) )
43-
n = 12k
35+
mul!(G1, G2, Ps, W1, W2)
4436

37+
@test vecnorm(∇θF - G1)/vecnorm(∇θF) < n*eps()
38+
@test vecnorm(∇φF - G2)/vecnorm(∇φF) < n*eps()
39+
40+
y = (1.0, 2.0, 3.0)
41+
for k in (10, 20, 40)
42+
∇θf = (θ,φ) -> -2k*sin(k*((sinpi(θ)*cospi(φ) - y[1])^2 + (sinpi(θ)*sinpi(φ) - y[2])^2 + (cospi(θ) - y[3])^2))*( (sinpi(θ)*cospi(φ) - y[1])*(cospi(θ)*cospi(φ)) + (sinpi(θ)*sinpi(φ) - y[2])*(cospi(θ)*sinpi(φ)) - (cospi(θ) - y[3])*sinpi(θ) )
43+
∇φf = (θ,φ) -> -2k*sin(k*((sinpi(θ)*cospi(φ) - y[1])^2 + (sinpi(θ)*sinpi(φ) - y[2])^2 + (cospi(θ) - y[3])^2))*( (sinpi(θ)*cospi(φ) - y[1])*(-sinpi(φ)) + (sinpi(θ)*sinpi(φ) - y[2])*(cospi(φ)) )
44+
n = 12k
45+
46+
θ = (0.5:n-0.5)/n
47+
φ = (0:2n-2)*2/(2n-1)
48+
∇θF = [∇θf(θ,φ) for θ in θ, φ in φ]
49+
∇φF = [∇φf(θ,φ) for θ in θ, φ in φ]
50+
V1 = zero(∇θF)
51+
V2 = zero(∇φF)
52+
Pa = FastTransforms.plan_analysis(∇θF)
53+
mul!(V1, V2, Pa, ∇θF, ∇φF)
54+
P = SlowSphericalHarmonicPlan(V1)
55+
56+
U1 = zero(V1)
57+
U2 = zero(V2)
58+
At_mul_B!(U1, U2, P, V1, V2)
59+
60+
W1 = zero(U1)
61+
W2 = zero(U2)
62+
63+
mul!(W1, W2, P, U1, U2)
64+
65+
Ps = FastTransforms.plan_synthesis(W1)
66+
67+
G1 = zero(∇θF)
68+
G2 = zero(∇φF)
69+
70+
mul!(G1, G2, Ps, W1, W2)
71+
72+
@test vecnorm(∇θF - G1)/vecnorm(∇θF) < n*eps()
73+
@test vecnorm(∇φF - G2)/vecnorm(∇φF) < n*eps()
74+
end
75+
end
76+
else
77+
@testset "Test vector field transforms" begin
78+
# f = (θ,φ) -> cospi(θ) + sinpi(θ)*(1+cospi(2θ))*sinpi(φ) + sinpi(θ)^5*(cospi(5φ)-sinpi(5φ))
79+
n = 6
4580
θ = (0.5:n-0.5)/n
4681
φ = (0:2n-2)*2/(2n-1)
82+
∇θf = (θ,φ) -> -sinpi(θ) + (cospi(θ)*(1+cospi(2θ)) - 2*sinpi(θ)*sinpi(2θ))*sinpi(φ) + 5*sinpi(θ)^4*cospi(θ)*(cospi(5φ)-sinpi(5φ))
83+
∇φf = (θ,φ) -> (1+cospi(2θ))*cospi(φ) - 5*sinpi(θ)^4*(sinpi(5φ)+cospi(5φ))
84+
4785
∇θF = [∇θf(θ,φ) for θ in θ, φ in φ]
4886
∇φF = [∇φf(θ,φ) for θ in θ, φ in φ]
4987
V1 = zero(∇θF)
@@ -54,7 +92,7 @@ using Compat.Test
5492

5593
U1 = zero(V1)
5694
U2 = zero(V2)
57-
FastTransforms.At_mul_B!(U1, U2, P, V1, V2)
95+
mul!(U1, transpose(U2), P, V1, V2)
5896

5997
W1 = zero(U1)
6098
W2 = zero(U2)
@@ -68,7 +106,43 @@ using Compat.Test
68106

69107
mul!(G1, G2, Ps, W1, W2)
70108

71-
@test vecnorm(∇θF - G1)/vecnorm(∇θF) < n*eps()
72-
@test vecnorm(∇φF - G2)/vecnorm(∇φF) < n*eps()
109+
@test norm(∇θF - G1)/norm(∇θF) < n*eps()
110+
@test norm(∇φF - G2)/norm(∇φF) < n*eps()
111+
112+
for k in (10, 20, 40)
113+
y = (1.0, 2.0, 3.0)
114+
n = 12k
115+
θ = (0.5:n-0.5)/n
116+
φ = (0:2n-2)*2/(2n-1)
117+
∇θf = (θ,φ) -> -2k*sin(k*((sinpi(θ)*cospi(φ) - y[1])^2 + (sinpi(θ)*sinpi(φ) - y[2])^2 + (cospi(θ) - y[3])^2))*( (sinpi(θ)*cospi(φ) - y[1])*(cospi(θ)*cospi(φ)) + (sinpi(θ)*sinpi(φ) - y[2])*(cospi(θ)*sinpi(φ)) - (cospi(θ) - y[3])*sinpi(θ) )
118+
∇φf = (θ,φ) -> -2k*sin(k*((sinpi(θ)*cospi(φ) - y[1])^2 + (sinpi(θ)*sinpi(φ) - y[2])^2 + (cospi(θ) - y[3])^2))*( (sinpi(θ)*cospi(φ) - y[1])*(-sinpi(φ)) + (sinpi(θ)*sinpi(φ) - y[2])*(cospi(φ)) )
119+
120+
∇θF = [∇θf(θ,φ) for θ in θ, φ in φ]
121+
∇φF = [∇φf(θ,φ) for θ in θ, φ in φ]
122+
V1 = zero(∇θF)
123+
V2 = zero(∇φF)
124+
Pa = FastTransforms.plan_analysis(∇θF)
125+
mul!(V1, V2, Pa, ∇θF, ∇φF)
126+
P = SlowSphericalHarmonicPlan(V1)
127+
128+
U1 = zero(V1)
129+
U2 = zero(V2)
130+
FastTransforms.mul!(U1, transpose(U2), P, V1, V2)
131+
132+
W1 = zero(U1)
133+
W2 = zero(U2)
134+
135+
mul!(W1, W2, P, U1, U2)
136+
137+
Ps = FastTransforms.plan_synthesis(W1)
138+
139+
G1 = zero(∇θF)
140+
G2 = zero(∇φF)
141+
142+
mul!(G1, G2, Ps, W1, W2)
143+
144+
@test norm(∇θF - G1)/norm(∇θF) < n*eps()
145+
@test norm(∇φF - G2)/norm(∇φF) < n*eps()
146+
end
73147
end
74148
end

test/toeplitztests.jl

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
using FastTransforms
1+
using FastTransforms, ToeplitzMatrices
22

3-
@testset "BigFloat" begin
3+
@testset "BigFloat TOeplitz" begin
44
T = Toeplitz(BigFloat[1,2,3,4,5], BigFloat[1,6,7,8,0])
55
@test T*ones(BigFloat,5) [22,24,19,16,15]
66

7-
n = 512
8-
r = map(BigFloat,rand(n))
9-
T = Toeplitz(r,[r[1];map(BigFloat,rand(n-1))])
10-
@test T*ones(BigFloat,n) Matrix(T)*ones(BigFloat,n)
7+
let n = 512
8+
r = map(BigFloat,rand(n))
9+
T = Toeplitz(r,[r[1];map(BigFloat,rand(n-1))])
10+
@test T*ones(BigFloat,n) Matrix(T)*ones(BigFloat,n)
1111

12-
T = TriangularToeplitz(BigFloat[1,2,3,4,5],:L)
13-
@test T*ones(BigFloat,5) Matrix(T)*ones(BigFloat,5)
12+
T = TriangularToeplitz(BigFloat[1,2,3,4,5],:L)
13+
@test T*ones(BigFloat,5) Matrix(T)*ones(BigFloat,5)
1414

15-
n = 512
16-
r = map(BigFloat,rand(n))
17-
T = TriangularToeplitz(r,:L)
18-
@test T*ones(BigFloat,n) Matrix(T)*ones(BigFloat,n)
15+
r = map(BigFloat,rand(n))
16+
T = TriangularToeplitz(r,:L)
17+
@test T*ones(BigFloat,n) Matrix(T)*ones(BigFloat,n)
1918

20-
T = TriangularToeplitz(BigFloat[1,2,3,4,5],:U)
21-
@test T*ones(BigFloat,5) Matrix(T)*ones(BigFloat,5)
19+
T = TriangularToeplitz(BigFloat[1,2,3,4,5],:U)
20+
@test T*ones(BigFloat,5) Matrix(T)*ones(BigFloat,5)
2221

23-
n = 512
24-
r = map(BigFloat,rand(n))
25-
T = TriangularToeplitz(r,:U)
26-
@test T*ones(BigFloat,n) Matrix(T)*ones(BigFloat,n)
22+
r = map(BigFloat,rand(n))
23+
T = TriangularToeplitz(r,:U)
24+
@test T*ones(BigFloat,n) Matrix(T)*ones(BigFloat,n)
25+
end
2726
end

0 commit comments

Comments
 (0)