Skip to content

Commit d6990af

Browse files
authored
updates for latest FFTW.jl (#34)
1 parent 8f81336 commit d6990af

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Hadamard"
22
uuid = "4a05ff16-5f95-55f4-bb53-bb3f467c689a"
3-
version = "1.6.0"
3+
version = "1.7.0"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -10,7 +10,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1010
[compat]
1111
julia = "1.6"
1212
AbstractFFTs = "0.4,0.5,1"
13-
FFTW = "1.6"
13+
FFTW = "1.9"
1414
LinearAlgebra = "<0.0.1, 1"
1515

1616
[extras]

src/Hadamard.jl

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ module Hadamard
1717
export fwht, ifwht, fwht_natural, ifwht_natural, fwht_natural!, ifwht_natural!, fwht_dyadic, ifwht_dyadic, hadamard, walsh
1818

1919
using FFTW, LinearAlgebra
20-
import FFTW: set_timelimit, dims_howmany, unsafe_execute!, cFFTWPlan, r2rFFTWPlan, PlanPtr, fftwNumber, ESTIMATE, NO_TIMELIMIT, R2HC
21-
import AbstractFFTs: normalization, complexfloat
20+
using FFTW: @exclusive, unsafe_set_timelimit, dims_howmany, unsafe_execute!, cFFTWPlan, r2rFFTWPlan, PlanPtr, fftwNumber, ESTIMATE, NO_TIMELIMIT, R2HC
21+
using AbstractFFTs: normalization, complexfloat
2222

2323
# A power-of-two dimension to be transformed is interpreted as a
2424
# 2x2x2x....x2x2 multidimensional DFT. This function transforms
@@ -62,19 +62,20 @@ const libfftwf = isdefined(FFTW, :libfftwf) ? FFTW.libfftwf : FFTW.libfftw3f
6262

6363
for (Tr,Tc,fftw,lib) in ((:Float64,:ComplexF64,"fftw",libfftw),
6464
(:Float32,:ComplexF32,"fftwf",libfftwf))
65-
@eval function Plan_Hadamard(X::StridedArray{$Tc,N}, Y::StridedArray{$Tc,N},
65+
@eval @exclusive function Plan_Hadamard(X::StridedArray{$Tc,N}, Y::StridedArray{$Tc,N},
6666
region, flags::Unsigned, timelimit::Real,
6767
bitreverse::Bool) where {N}
68-
set_timelimit($Tr, timelimit)
69-
dims, howmany = dims_howmany(X, Y, [size(X)...], region)
68+
unsafe_set_timelimit($Tr, timelimit)
69+
R = isa(region, Tuple) ? region : copy(region)
70+
dims, howmany = dims_howmany(X, Y, size(X), R)
7071
dims = hadamardize(dims, bitreverse)
71-
plan = ccall(($(string(fftw,"_plan_guru64_dft")),$lib[]),
72+
plan = ccall(($(string(fftw,"_plan_guru64_dft")),$lib()),
7273
PlanPtr,
7374
(Int32, Ptr{Int}, Int32, Ptr{Int},
7475
Ptr{$Tc}, Ptr{$Tc}, Int32, UInt32),
7576
size(dims,2), dims, size(howmany,2), howmany,
7677
X, Y, FFTW.FORWARD, flags)
77-
set_timelimit($Tr, NO_TIMELIMIT)
78+
unsafe_set_timelimit($Tr, NO_TIMELIMIT)
7879
if plan == C_NULL
7980
if $(FFTW.fftw_provider == "mkl")
8081
error("MKL is not supported — reconfigure FFTW.jl to use FFTW")
@@ -85,21 +86,22 @@ for (Tr,Tc,fftw,lib) in ((:Float64,:ComplexF64,"fftw",libfftw),
8586
return cFFTWPlan{$Tc,FFTW.FORWARD,X===Y,N}(plan, flags, region, X, Y)
8687
end
8788

88-
@eval function Plan_Hadamard(X::StridedArray{$Tr,N}, Y::StridedArray{$Tr,N},
89+
@eval @exclusive function Plan_Hadamard(X::StridedArray{$Tr,N}, Y::StridedArray{$Tr,N},
8990
region, flags::Unsigned, timelimit::Real,
9091
bitreverse::Bool) where {N}
91-
set_timelimit($Tr, timelimit)
92-
dims, howmany = dims_howmany(X, Y, [size(X)...], region)
92+
unsafe_set_timelimit($Tr, timelimit)
93+
R = isa(region, Tuple) ? region : copy(region)
94+
dims, howmany = dims_howmany(X, Y, size(X), R)
9395
dims = hadamardize(dims, bitreverse)
9496
kind = Array{Int32}(undef, size(dims,2))
9597
kind .= R2HC
96-
plan = ccall(($(string(fftw,"_plan_guru64_r2r")),$lib[]),
98+
plan = ccall(($(string(fftw,"_plan_guru64_r2r")),$lib()),
9799
PlanPtr,
98100
(Int32, Ptr{Int}, Int32, Ptr{Int},
99101
Ptr{$Tr}, Ptr{$Tr}, Ptr{Int32}, UInt32),
100102
size(dims,2), dims, size(howmany,2), howmany,
101103
X, Y, kind, flags)
102-
set_timelimit($Tr, NO_TIMELIMIT)
104+
unsafe_set_timelimit($Tr, NO_TIMELIMIT)
103105
if plan == C_NULL
104106
if $(FFTW.fftw_provider == "mkl")
105107
error("MKL is not supported — reconfigure FFTW.jl to use FFTW")
@@ -371,7 +373,7 @@ end
371373
"""
372374
walsh(n)
373375
374-
Return a Walsh matrix of order `n`, which must be a power of two, in sequency ordering.
376+
Return a Walsh matrix of order `n`, which must be a power of two, in sequency ordering.
375377
This is related to the Hadamard matrix [`hadamard(n)`](@ref) by a bit-reversal permutation
376378
followed by a Gray-code permutation of the rows.
377379
@@ -390,7 +392,7 @@ function walsh(n::Int)
390392
j = b (b >> 1) # binary sequency index
391393
j + 1 # 1-based index
392394
end
393-
for i in 0:n-1 ]
395+
for i in 0:n-1 ]
394396

395397
return hadamard(n)[j, :]
396398
end

0 commit comments

Comments
 (0)