Skip to content

Commit 8e71bff

Browse files
committed
2 parents 33fb8ec + 14c96c8 commit 8e71bff

37 files changed

+471
-845
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.7
87
- 1.0
98
- 1.1
109
- 1.2
10+
- 1.3
1111
- nightly
1212
matrix:
1313
allow_failures:

Project.toml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name = "FastTransforms"
22
uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c"
3-
version = "0.5"
3+
version = "0.6"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
7-
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
87
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
98
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
9+
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
1010
HierarchicalMatrices = "7c893195-952b-5c83-bb6e-be12f22eed51"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
LowRankApprox = "898213cb-b102-5a47-900c-97e73b919f73"
@@ -15,13 +15,21 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1515
ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24"
1616

1717
[compat]
18-
AbstractFFTs = "≥ 0.3.1"
19-
Compat = "≥ 0.17.0"
20-
DSP = "≥ 0.4.0"
21-
FFTW = "≥ 0.0.4"
22-
HierarchicalMatrices = "≥ 0.1.1"
23-
LowRankApprox = "≥ 0.1.1"
24-
ProgressMeter = "≥ 0.3.4"
25-
SpecialFunctions = "≥ 0.3.4"
26-
ToeplitzMatrices = "≥ 0.4.0"
27-
julia = "0.7, 1"
18+
AbstractFFTs = "0.4"
19+
DSP = "0.6"
20+
FFTW = "0.3"
21+
HierarchicalMatrices = "0.2"
22+
LowRankApprox = "0.2.3"
23+
ProgressMeter = "1"
24+
SpecialFunctions = "0.8"
25+
ToeplitzMatrices = "0.6"
26+
FastGaussQuadrature = "0.4"
27+
julia = "1"
28+
29+
[extras]
30+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
31+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
32+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
33+
34+
[targets]
35+
test = ["Test","Random","Statistics"]

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
environment:
22
matrix:
3-
- julia_version: 0.7
43
- julia_version: 1.0
54
- julia_version: 1.1
6-
- julia_version: 1.2
5+
- julia_version: 1.2
6+
- julia_version: 1.3
77
- julia_version: nightly
88

99
platform:

examples/sphere.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ PA = FastTransforms.plan_analysis(F);
5656

5757
# Its spherical harmonic coefficients demonstrate that it is degree-3:
5858
V = zero(F);
59-
A_mul_B!(V, PA, F);
59+
mul!(V, PA, F);
6060
U3 = P\V
6161

6262
# Similarly, on the tensor product grid, the Legendre polynomial P₄(z⋅y) is:
6363
F = [P4(z(θ,φ)y) for θ in θ, φ in φ]
6464

6565
# Its spherical harmonic coefficients demonstrate that it is exact-degree-4:
66-
A_mul_B!(V, PA, F);
66+
mul!(V, PA, F);
6767
U4 = P\V
6868

6969
nrm1 = vecnorm(U4);
@@ -73,7 +73,7 @@ F = [P4(z(θ,φ)⋅x) for θ in θ, φ in φ]
7373

7474
# It only has one nonnegligible spherical harmonic coefficient.
7575
# Can you spot it?
76-
A_mul_B!(V, PA, F);
76+
mul!(V, PA, F);
7777
U4 = P\V
7878

7979
# That nonnegligible coefficient should be approximately √(2π/(4+1/2)),

src/FastTransforms.jl

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,30 @@
1-
__precompile__()
1+
22
module FastTransforms
33

4-
using ToeplitzMatrices, HierarchicalMatrices, LowRankApprox, ProgressMeter, Compat,
5-
AbstractFFTs, SpecialFunctions
6-
7-
if VERSION < v"0.7-"
8-
using Base.FFTW
9-
import Base.FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
10-
import Base.FFTW: libfftw, libfftwf, PlanPtr, r2rFFTWPlan, plan_r2r!,
11-
REDFT00, REDFT01, REDFT10, REDFT11,
12-
RODFT00, RODFT01, RODFT10, RODFT11
13-
const LAmul! = Base.A_mul_B!
14-
import Base: Factorization
15-
rmul!(A::AbstractArray, c::Number) = scale!(A,c)
16-
lmul!(c::Number, A::AbstractArray) = scale!(c,A)
17-
lmul!(A::AbstractArray, B::AbstractArray) = mul!(A,B)
18-
rmul!(A::AbstractArray, B::AbstractArray) = mul!(A,B)
19-
const floatmin = realmin
20-
else
21-
using FFTW, LinearAlgebra, DSP
22-
import FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
23-
import FFTW: libfftw3, libfftw3f, PlanPtr, r2rFFTWPlan, plan_r2r!,
24-
REDFT00, REDFT01, REDFT10, REDFT11,
25-
RODFT00, RODFT01, RODFT10, RODFT11
26-
const LAmul! = LinearAlgebra.mul!
27-
const libfftw = libfftw3
28-
const libfftwf = libfftw3f
29-
import LinearAlgebra: Factorization
30-
flipdim(A,d) = reverse(A; dims=d)
31-
end
4+
using ToeplitzMatrices, HierarchicalMatrices, LowRankApprox, ProgressMeter,
5+
AbstractFFTs, SpecialFunctions, FastGaussQuadrature
6+
7+
using FFTW, LinearAlgebra, DSP
8+
import FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
9+
import FFTW: libfftw3, libfftw3f, PlanPtr, r2rFFTWPlan, plan_r2r!,
10+
REDFT00, REDFT01, REDFT10, REDFT11,
11+
RODFT00, RODFT01, RODFT10, RODFT11
3212

13+
const libfftw = libfftw3
14+
const libfftwf = libfftw3f
15+
import LinearAlgebra: Factorization
16+
flipdim(A,d) = reverse(A; dims=d)
3317

3418
import Base: *, \, inv, size, view
35-
import Base: getindex, setindex!, length
36-
import Compat.LinearAlgebra: BlasFloat, BlasInt
19+
import Base: getindex, setindex!, length, axes
20+
import LinearAlgebra: BlasFloat, BlasInt, transpose, adjoint, lmul!, rmul!
3721
import HierarchicalMatrices: HierarchicalMatrix, unsafe_broadcasttimes!
38-
import HierarchicalMatrices: mul!, At_mul_B!, Ac_mul_B!
22+
import HierarchicalMatrices: mul!
3923
import HierarchicalMatrices: ThreadSafeVector, threadsafezeros
40-
import LowRankApprox: ColPerm
24+
import LowRankApprox: ColPerm, RowPerm
4125
import AbstractFFTs: Plan
42-
import Compat: range, transpose, adjoint, axes
26+
27+
import FastGaussQuadrature: unweightedgausshermite
4328

4429
export cjt, icjt, jjt, plan_cjt, plan_icjt
4530
export leg2cheb, cheb2leg, leg2chebu, ultra2ultra, jac2jac, plan_jac2jac
@@ -64,6 +49,8 @@ export SlowTriangularHarmonicPlan
6449
export tri2cheb, cheb2tri, plan_tri2cheb
6550
export triones, trizeros, trirand, trirandn, trievaluate
6651

52+
export hermitepoints, weightedhermitetransform, iweightedhermitetransform
53+
6754
# Other module methods and constants:
6855
#export ChebyshevJacobiPlan, jac2cheb, cheb2jac
6956
#export sqrtpi, pochhammer, stirlingseries, stirlingremainder, Aratio, Cratio, Anαβ
@@ -73,6 +60,8 @@ export triones, trizeros, trirand, trirandn, trievaluate
7360
#export plan_fejer2, fejernodes2, fejerweights2
7461
#export RecurrencePlan, forward_recurrence!, backward_recurrence
7562

63+
lgamma(x) = logabsgamma(x)[1]
64+
7665
include("stepthreading.jl")
7766
include("fftBigFloat.jl")
7867
include("specialfunctions.jl")
@@ -97,6 +86,7 @@ include("inufft.jl")
9786
include("cjt.jl")
9887

9988
include("toeplitzhankel.jl")
89+
include("hermite.jl")
10090

10191
#leg2cheb(x...)=th_leg2cheb(x...)
10292
#cheb2leg(x...)=th_cheb2leg(x...)

src/SphericalHarmonics/Butterfly.jl

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ function Butterfly(A::AbstractMatrix{T}, L::Int; isorthogonal::Bool = false, opt
110110
Butterfly(columns, factors, permutations, indices, threadsafezeros(T, kk), threadsafezeros(T, kk), threadsafezeros(T, kk), threadsafezeros(T, kk))
111111
end
112112

113-
if VERSION v"0.7-"
114-
LinearAlgebra.adjoint(B::Butterfly) = Adjoint(B)
115-
LinearAlgebra.transpose(B::Butterfly) = Transpose(B)
116-
end
113+
LinearAlgebra.adjoint(B::Butterfly) = Adjoint(B)
114+
LinearAlgebra.transpose(B::Butterfly) = Transpose(B)
115+
117116

118117
function sumkmax(indices::Vector{Vector{Int}})
119118
ret = 0
@@ -173,66 +172,61 @@ function rowperm!(fwd::Bool, y::AbstractVector, x::AbstractVector, p::Vector{Int
173172
end
174173

175174
## ColumnPermutation
176-
mul!(A::ColPerm, B::AbstractVecOrMat, jstart::Int) = rowperm!(false, B, A.p, jstart)
177-
At_mul_B!(A::ColPerm, B::AbstractVecOrMat, jstart::Int) = rowperm!(true, B, A.p, jstart)
178-
Ac_mul_B!(A::ColPerm, B::AbstractVecOrMat, jstart::Int) = At_mul_B!(A, B, jstart)
175+
lmul!(A::ColPerm, B::AbstractVecOrMat, jstart::Int) = rowperm!(false, B, A.p, jstart)
176+
lmul!(At::RowPerm, B::AbstractVecOrMat, jstart::Int) = rowperm!(true, B, transpose(At).p, jstart)
179177

180178
mul!(y::AbstractVector, A::ColPerm, x::AbstractVector, jstart::Int) = rowperm!(false, y, x, A.p, jstart)
181-
At_mul_B!(y::AbstractVector, A::ColPerm, x::AbstractVector, jstart::Int) = rowperm!(true, y, x, A.p, jstart)
182-
Ac_mul_B!(y::AbstractVector, A::ColPerm, x::AbstractVector, jstart::Int) = At_mul_B!(y, x, A, jstart)
179+
mul!(y::AbstractVector, At::RowPerm, x::AbstractVector, jstart::Int) = rowperm!(true, y, x, transpose(At).p, jstart)
183180

184-
# Fast mul!, At_mul_B!, and Ac_mul_B! for an ID. These overwrite the output.
181+
# Fast mul! for an ID. These overwrite the output.
185182

186183

187184
function mul!(y::AbstractVecOrMat{T}, A::IDPackedV{T}, P::ColumnPermutation, x::AbstractVecOrMat{T}, istart::Int, jstart::Int) where {T}
188185
k, n = size(A)
189-
At_mul_B!(P, x, jstart)
186+
lmul!(transpose(P), x, jstart)
190187
copyto!(y, istart, x, jstart, k)
191188
mul!(y, A.T, x, istart, jstart+k)
192-
mul!(P, x, jstart)
189+
lmul!(P, x, jstart)
193190
y
194191
end
195192

196193
function mul!(y::AbstractVector{T}, A::IDPackedV{T}, P::ColumnPermutation, x::AbstractVector{T}, temp::AbstractVector{T}, istart::Int, jstart::Int) where {T}
197194
k, n = size(A)
198-
At_mul_B!(temp, P, x, jstart)
195+
mul!(temp, transpose(P), x, jstart)
199196
copyto!(y, istart, temp, jstart, k)
200197
mul!(y, A.T, temp, istart, jstart+k)
201198
y
202199
end
203200

204-
### mul!, At_mul_B!, and Ac_mul_B! for a Butterfly factorization.
201+
### mul! for a Butterfly factorization.
205202
mul!(u::Vector{T}, B::Butterfly{T}, b::Vector{T}) where T = mul_col_J!(u, B, b, 1)
206203

207-
for f! in (:At_mul_B!, :Ac_mul_B!)
204+
for Trans in (:Transpose, :Adjoint)
208205
@eval begin
209-
function $f!(y::AbstractVecOrMat{T}, A::IDPackedV{T}, P::ColumnPermutation, x::AbstractVecOrMat{T}, istart::Int, jstart::Int) where {T}
206+
function mul!(y::AbstractVecOrMat{T}, Ac::$Trans{T,IDPackedV{T}}, P::ColumnPermutation, x::AbstractVecOrMat{T}, istart::Int, jstart::Int) where {T}
207+
A = parent(Ac)
210208
k, n = size(A)
211209
copyto!(y, istart, x, jstart, k)
212-
$f!(y, A.T, x, istart+k, jstart)
213-
mul!(P, y, istart)
210+
mul!(y, $Trans(A.T), x, istart+k, jstart)
211+
lmul!(P, y, istart)
214212
y
215213
end
216214

217-
function $f!(y::AbstractVector{T}, A::IDPackedV{T}, P::ColumnPermutation, x::AbstractVector{T}, temp::AbstractVector{T}, istart::Int, jstart::Int) where {T}
215+
function mul!(y::AbstractVector{T}, Ac::$Trans{T,IDPackedV{T}}, P::ColumnPermutation, x::AbstractVector{T}, temp::AbstractVector{T}, istart::Int, jstart::Int) where {T}
216+
A = parent(Ac)
218217
k, n = size(A)
219218
copyto!(temp, istart, x, jstart, k)
220-
$f!(temp, A.T, x, istart+k, jstart)
219+
mul!(temp, $Trans(A.T), x, istart+k, jstart)
221220
mul!(y, P, temp, istart)
222221
y
223222
end
224223
end
225224
end
226225

227-
if VERSION < v"0.7-"
228-
Base.A_mul_B!(u::Vector{T}, B::Butterfly{T}, b::Vector{T}) where T = mul_col_J!(u, B, b, 1)
229-
Base.At_mul_B!(u::Vector{T}, B::Butterfly{T}, b::Vector{T}) where T = At_mul_B_col_J!(u, B, b, 1)
230-
Base.Ac_mul_B!(u::Vector{T}, B::Butterfly{T}, b::Vector{T}) where T = Ac_mul_B_col_J!(u, B, b, 1)
231-
else
232-
LinearAlgebra.mul!(u::Vector{T}, B::Butterfly{T}, b::Vector{T}) where T = mul_col_J!(u, B, b, 1)
233-
LinearAlgebra.mul!(u::Vector{T}, Bt::Transpose{T,Butterfly{T}}, b::Vector{T}) where T = At_mul_B_col_J!(u, parent(Bt), b, 1)
234-
LinearAlgebra.mul!(u::Vector{T}, Bc::Adjoint{T,Butterfly{T}}, b::Vector{T}) where T = Ac_mul_B_col_J!(u, parent(Bc), b, 1)
235-
end
226+
LinearAlgebra.mul!(u::Vector{T}, B::Butterfly{T}, b::Vector{T}) where T = mul_col_J!(u, B, b, 1)
227+
LinearAlgebra.mul!(u::Vector{T}, Bt::Transpose{T,Butterfly{T}}, b::Vector{T}) where T = mul_col_J!(u, Bt, b, 1)
228+
LinearAlgebra.mul!(u::Vector{T}, Bc::Adjoint{T,Butterfly{T}}, b::Vector{T}) where T = mul_col_J!(u, Bc, b, 1)
229+
236230

237231

238232
function mul_col_J!(u::VecOrMat{T}, B::Butterfly{T}, b::VecOrMat{T}, J::Int) where T
@@ -290,10 +284,10 @@ function mul_col_J!(u::VecOrMat{T}, B::Butterfly{T}, b::VecOrMat{T}, J::Int) whe
290284
u
291285
end
292286

293-
for f! in (:At_mul_B!,:Ac_mul_B!)
294-
f_col_J! = Meta.parse(string(f!)[1:end-1]*"_col_J!")
287+
for Trans in (:Transpose,:Adjoint)
295288
@eval begin
296-
function $f_col_J!(u::VecOrMat{T}, B::Butterfly{T}, b::VecOrMat{T}, J::Int) where T
289+
function mul_col_J!(u::VecOrMat{T}, Bc::$Trans{T,Butterfly{T}}, b::VecOrMat{T}, J::Int) where T
290+
B = parent(Bc)
297291
L = length(B.factors) - 1
298292
tL = 2^L
299293

@@ -315,7 +309,7 @@ for f! in (:At_mul_B!,:Ac_mul_B!)
315309
for i = 1:tL
316310
ml = mu+1
317311
mu += size(columns[i], 1)
318-
$f!(temp1, columns[i], b, inds[i], ml+COLSHIFT)
312+
mul!(temp1, $Trans(columns[i]), b, inds[i], ml+COLSHIFT)
319313
end
320314

321315
ii, jj = tL, 1
@@ -329,7 +323,7 @@ for f! in (:At_mul_B!,:Ac_mul_B!)
329323
shft = 2jj*div(ctr,2jj)
330324
fill!(temp4, zero(T))
331325
for j = 1:jj
332-
$f!(temp3, factors[j+ctr], permutations[j+ctr], temp1, temp4, indsout[2j+shft-1], indsin[j+ctr])
326+
mul!(temp3, $Trans(factors[j+ctr]), permutations[j+ctr], temp1, temp4, indsout[2j+shft-1], indsin[j+ctr])
333327
addtemp3totemp2!(temp2, temp3, indsout[2j+shft-1], indsout[2j+shft+1]-1)
334328
end
335329
ctr += jj
@@ -346,7 +340,7 @@ for f! in (:At_mul_B!,:Ac_mul_B!)
346340
for j = 1:tL
347341
nl = nu+1
348342
nu += size(factors[j], 2)
349-
$f!(u, factors[j], permutations[j], temp1, nl+COLSHIFT, inds[j])
343+
mul!(u, $Trans(factors[j]), permutations[j], temp1, nl+COLSHIFT, inds[j])
350344
end
351345

352346
u

src/SphericalHarmonics/SphericalHarmonics.jl

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

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
7+
8+
function \(P::SphericalHarmonicPlan, X::AbstractMatrix)
9+
mul!(zero(X), transpose(P), X)
1510
end
1611

1712
include("sphfunctions.jl")

0 commit comments

Comments
 (0)