Skip to content

Commit aa1dcf1

Browse files
swap files
1 parent ad21867 commit aa1dcf1

File tree

2 files changed

+79
-55
lines changed

2 files changed

+79
-55
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
function sphrand{T}(::Type{T}, m, n)
2+
A = zeros(T, m, 2n-1)
3+
for i = 1:m
4+
A[i,1] = rand(T)
5+
end
6+
for j = 1:n
7+
for i = 1:m-j
8+
A[i,2j] = rand(T)
9+
A[i,2j+1] = rand(T)
10+
end
11+
end
12+
A
13+
end
14+
15+
function sphrandn{T}(::Type{T}, m, n)
16+
A = zeros(T, m, 2n-1)
17+
for i = 1:m
18+
A[i,1] = randn(T)
19+
end
20+
for j = 1:n
21+
for i = 1:m-j
22+
A[i,2j] = randn(T)
23+
A[i,2j+1] = randn(T)
24+
end
25+
end
26+
A
27+
end
28+
29+
function normalizecolumns!(A::AbstractMatrix)
30+
m, n = size(A)
31+
@inbounds for j = 1:n
32+
nrm = zero(eltype(A))
33+
for i = 1:m
34+
nrm += abs2(A[i,j])
35+
end
36+
nrm = sqrt(nrm)
37+
for i = 1:m
38+
A[i,j] /= nrm
39+
end
40+
end
41+
A
42+
end
43+
44+
function maxcolnorm(A::AbstractMatrix)
45+
m, n = size(A)
46+
nrm = zeros(n)
47+
@inbounds for j = 1:n
48+
nrm[j] = 0
49+
for i = 1:m
50+
nrm[j] += abs2(A[i,j])
51+
end
52+
nrm[j] = sqrt(nrm[j])
53+
end
54+
norm(nrm, Inf)
55+
end
56+
57+
function sphevaluatepi::Number,L::Integer,M::Integer)
58+
ret = one(θ)/sqrt(two(θ))
59+
if M < 0 M = -M end
60+
c, s = cospi(θ), sinpi(θ)
61+
for m = 1:M
62+
ret *= sqrt((m+half(θ))/m)*s
63+
end
64+
tc = two(c)*c
65+
66+
if L == M
67+
return ret
68+
elseif L == M+1
69+
return sqrt(two(θ)*M+3)*c*ret
70+
else
71+
temp = ret
72+
ret *= sqrt(two(θ)*M+3)*c
73+
for l = M+1:L-1
74+
ret, temp = (sqrt(l+half(θ))*tc*ret - sqrt((l-M)*(l+M)/(l-half(θ)))*temp)/sqrt((l-M+1)*(l+M+1)/(l+3half(θ))), ret
75+
end
76+
return ret
77+
end
78+
end

test/sphericalharmonictests.jl

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,6 @@
11
using FastTransforms, Base.Test
22

3-
function sphrand{T}(::Type{T}, m, n)
4-
A = zeros(T, m, 2n-1)
5-
for i = 1:m
6-
A[i,1] = rand(T)
7-
end
8-
for j = 1:n
9-
for i = 1:m-j
10-
A[i,2j] = rand(T)
11-
A[i,2j+1] = rand(T)
12-
end
13-
end
14-
A
15-
end
16-
17-
function sphrandn{T}(::Type{T}, m, n)
18-
A = zeros(T, m, 2n-1)
19-
for i = 1:m
20-
A[i,1] = randn(T)
21-
end
22-
for j = 1:n
23-
for i = 1:m-j
24-
A[i,2j] = randn(T)
25-
A[i,2j+1] = randn(T)
26-
end
27-
end
28-
A
29-
end
30-
31-
function normalizecolumns!(A::AbstractMatrix)
32-
m, n = size(A)
33-
@inbounds for j = 1:n
34-
nrm = zero(eltype(A))
35-
for i = 1:m
36-
nrm += abs2(A[i,j])
37-
end
38-
nrm = sqrt(nrm)
39-
for i = 1:m
40-
A[i,j] /= nrm
41-
end
42-
end
43-
A
44-
end
45-
46-
function maxcolnorm(A::AbstractMatrix)
47-
m, n = size(A)
48-
nrm = zeros(n)
49-
@inbounds for j = 1:n
50-
nrm[j] = 0
51-
for i = 1:m
52-
nrm[j] += abs2(A[i,j])
53-
end
54-
nrm[j] = sqrt(nrm[j])
55-
end
56-
norm(nrm, Inf)
57-
end
3+
include("sphericalharmonictestfunctions.jl")
584

595
println("Testing slow plan")
606
include("test_slowplan.jl")

0 commit comments

Comments
 (0)