Skip to content

Commit ec29d06

Browse files
remove restriction on same band limit for m as l
issue #16
1 parent 782cf6c commit ec29d06

File tree

7 files changed

+26
-28
lines changed

7 files changed

+26
-28
lines changed

src/SphericalHarmonics/SphericalHarmonics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include("thinplan.jl")
1616

1717
function plan_sph2fourier(A::AbstractMatrix; opts...)
1818
M, N = size(A)
19-
if M 1022
19+
if M 1023
2020
SlowSphericalHarmonicPlan(A)
2121
else
2222
ThinSphericalHarmonicPlan(A; opts...)

src/SphericalHarmonics/fastplan.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ end
1010

1111
function FastSphericalHarmonicPlan{T}(A::Matrix{T}, L::Int; opts...)
1212
M, N = size(A)
13-
@assert N == 2M-1
1413
n = (N+1)÷2
1514
RP = RotationPlan(T, n-1)
1615
p1 = plan_normleg2cheb(A)

src/SphericalHarmonics/sphfunctions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function sphrand{T}(::Type{T}, m::Int, n::Int)
1515
for i = 1:m
1616
A[i,1] = rand(T)
1717
end
18-
for j = 1:n
18+
for j = 1:n-1
1919
for i = 1:m-j
2020
A[i,2j] = rand(T)
2121
A[i,2j+1] = rand(T)
@@ -29,7 +29,7 @@ function sphrandn{T}(::Type{T}, m::Int, n::Int)
2929
for i = 1:m
3030
A[i,1] = randn(T)
3131
end
32-
for j = 1:n
32+
for j = 1:n-1
3333
for i = 1:m-j
3434
A[i,2j] = randn(T)
3535
A[i,2j+1] = randn(T)
@@ -43,7 +43,7 @@ function sphones{T}(::Type{T}, m::Int, n::Int)
4343
for i = 1:m
4444
A[i,1] = one(T)
4545
end
46-
for j = 1:n
46+
for j = 1:n-1
4747
for i = 1:m-j
4848
A[i,2j] = one(T)
4949
A[i,2j+1] = one(T)

src/SphericalHarmonics/thinplan.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ end
1414

1515
function ThinSphericalHarmonicPlan{T}(A::Matrix{T}, L::Int; opts...)
1616
M, N = size(A)
17-
@assert N == 2M-1
1817
n = (N+1)÷2
1918
RP = RotationPlan(T, n-1)
2019
p1 = plan_normleg2cheb(A)

test/sphericalharmonictests.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,31 @@ println()
2626

2727
import FastTransforms: sphevaluatepi, normalizecolumns!, maxcolnorm
2828

29-
n = 255
30-
A = sphrandn(Float64, n+1, n+1);
29+
n = 256
30+
A = sphrandn(Float64, n, n);
3131
normalizecolumns!(A);
3232
B = sph2fourier(A);
3333

3434
for θ in (0.123, 0.456)
35-
S0 = sum(cospi((ℓ-1)*θ)*B[ℓ,1] forin 1:n+1)
36-
SA = sum(sphevaluatepi(θ,ℓ-1,0)*A[ℓ,1] forin 1:n+1)
35+
S0 = sum(cospi((ℓ-1)*θ)*B[ℓ,1] forin 1:n)
36+
SA = sum(sphevaluatepi(θ,ℓ-1,0)*A[ℓ,1] forin 1:n)
3737
@test norm(S0-SA) < 1000eps()
38-
for m in 3:2:n+1
39-
S0 = sum(cospi((ℓ-1)*θ)*B[ℓ,2m-2] forin 1:n+1)
40-
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-2] forin 1:n+1)
38+
for m in 3:2:n
39+
S0 = sum(cospi((ℓ-1)*θ)*B[ℓ,2m-2] forin 1:n)
40+
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-2] forin 1:n)
4141
@test norm(S0-SA) < 1000eps()
42-
S0 = sum(cospi((ℓ-1)*θ)*B[ℓ,2m-1] forin 1:n+1)
43-
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-1] forin 1:n+1)
42+
S0 = sum(cospi((ℓ-1)*θ)*B[ℓ,2m-1] forin 1:n)
43+
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-1] forin 1:n)
4444
@test norm(S0-SA) < 1000eps()
4545
end
4646
end
4747

48-
for θ in (0.123, 0.456), m in 2:2:n+1
49-
S1 = sum(sinpi(ℓ*θ)*B[ℓ,2m-2] forin 1:n+1)
50-
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-2] forin 1:n+1)
48+
for θ in (0.123, 0.456), m in 2:2:n
49+
S1 = sum(sinpi(ℓ*θ)*B[ℓ,2m-2] forin 1:n)
50+
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-2] forin 1:n)
5151
@test norm(S1-SA) < 1000eps()
52-
S1 = sum(sinpi(ℓ*θ)*B[ℓ,2m-1] forin 1:n+1)
53-
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-1] forin 1:n+1)
52+
S1 = sum(sinpi(ℓ*θ)*B[ℓ,2m-1] forin 1:n)
53+
SA = sum(sphevaluatepi(θ,ℓ+m-2,m-1)*A[ℓ,2m-1] forin 1:n)
5454
@test norm(S1-SA) < 1000eps()
5555
end
5656

@@ -60,8 +60,8 @@ println()
6060

6161
import FastTransforms: normalizecolumns!, maxcolnorm
6262

63-
n = VERSION < v"0.6.0-" ? 255 : 511
64-
A = sphrandn(Float64, n+1, n+1);
63+
n = VERSION < v"0.6.0-" ? 256 : 512
64+
A = sphrandn(Float64, n, n);
6565
normalizecolumns!(A);
6666

6767
B = sph2fourier(A)
@@ -75,8 +75,8 @@ C = P\B
7575
println("The backward difference between slow plan and original: ", maxcolnorm(A-C))
7676

7777
if VERSION v"0.6.0-"
78-
n = 1023
79-
A = sphrandn(Float64, n+1, n+1);
78+
n = 1024
79+
A = sphrandn(Float64, n, n);
8080
normalizecolumns!(A);
8181

8282
B = sph2fourier(A; sketch = :none)

test/test_fastplan.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import FastTransforms: allranks, normalizecolumns!, maxcolnorm
22

3-
n = 362
3+
m, n = 362, 300
44

5-
A = sphrandn(Float64, n+1, n+1);
5+
A = sphrandn(Float64, m, n);
66
normalizecolumns!(A);
77
B = zero(A);
88
C = zero(A);

test/test_thinplan.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import FastTransforms: allranks, normalizecolumns!, maxcolnorm
22

3-
n = VERSION < v"0.6.0-" ? 362 : 724
3+
m, n = VERSION < v"0.6.0-" ? (362, 300) : (724, 600)
44

5-
A = sphrandn(Float64, n+1, n+1);
5+
A = sphrandn(Float64, m, n);
66
normalizecolumns!(A);
77
B = zero(A);
88
C = zero(A);

0 commit comments

Comments
 (0)