Skip to content

Commit 2ee6063

Browse files
committed
Drop support for a range of Julia 0.7.0-DEV versions and deal with A_mul_B! to mul! rename
1 parent 17edca2 commit 2ee6063

File tree

7 files changed

+39
-38
lines changed

7 files changed

+39
-38
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ To define a new FFT implementation in your own module, you should
2525
* Define a new method `AbstractFFTs.plan_fft(x, region; kws...)` that returns a `MyPlan` for at least some types of
2626
`x` and some set of dimensions `region`.
2727

28-
* Define a method of `A_mul_B!(y, p::MyPlan, x)` that computes the transform `p` of `x` and stores the result in `y`.
28+
* Define a method of `LinearAlgebra.mul!(y, p::MyPlan, x)` (or `A_mul_B!(y, p::MyPlan, x)` on Julia prior to
29+
0.7.0-DEV.3204) that computes the transform `p` of `x` and stores the result in `y`.
2930

30-
* Define a method of `*(p::MyPlan, x)`, which can simply call your `A_mul_B!` method.
31+
* Define a method of `*(p::MyPlan, x)`, which can simply call your `mul!` (or `A_mul_B!`) method.
3132
This is not defined generically in this package due to subtleties that arise for in-place and real-input FFTs.
3233

3334
* If the inverse transform is implemented, you should also define `plan_inv(p::MyPlan)`, which should construct the

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6
2-
Compat 0.48
1+
julia 0.6 0.7.0-DEV.602 0.7.0-DEV.3449

docs/src/implementations.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ The following packages extend the functionality provided by AbstractFFTs:
99

1010
## Defining a new implementation
1111

12-
Implementations should implement `Base.A_mul_B!(Y, plan, X)` so as to support
12+
Implementations should implement `LinearAlgebra.mul!(Y, plan, X)` (or
13+
`A_mul_B!(y, p::MyPlan, x)` on Julia prior to 0.7.0-DEV.3204) so as to support
1314
pre-allocated output arrays.
14-
We don't define `*` in terms of `A_mul_B!` generically here, however, because
15+
We don't define `*` in terms of `mul!` generically here, however, because
1516
of subtleties for in-place and real FFT plans.
1617

17-
To support `inv`, `\`, and `A_ldiv_B!(y, plan, x)`, we require `Plan` subtypes
18+
To support `inv`, `\`, and `ldiv!(y, plan, x)`, we require `Plan` subtypes
1819
to have a `pinv::Plan` field, which caches the inverse plan, and which should be
1920
initially undefined.
2021
They should also implement `plan_inv(p)` to construct the inverse of a plan `p`.

src/AbstractFFTs.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@ module AbstractFFTs
33

44
# After this version, the bindings can overwrite deprecated bindings in Base safely, but
55
# prior to it we want to extend/reexport the Base definitions
6-
if VERSION < v"0.7.0-DEV.986"
6+
if VERSION < v"0.7.0-DEV.602"
77
import Base: fft, ifft, bfft, fft!, ifft!, bfft!,
88
plan_fft, plan_ifft, plan_bfft, plan_fft!, plan_ifft!, plan_bfft!,
99
rfft, irfft, brfft, plan_rfft, plan_irfft, plan_brfft,
1010
fftshift, ifftshift
11-
if VERSION < v"0.7.0-DEV.602"
12-
import Base.DFT: Plan, ScaledPlan, plan_inv, pinv_type, normalization,
13-
rfft_output_size, brfft_output_size, realfloat, complexfloat
14-
end
11+
import Base.DFT: Plan, ScaledPlan, plan_inv, pinv_type, normalization,
12+
rfft_output_size, brfft_output_size, realfloat, complexfloat
1513
end
1614
# Reexport the Base bindings unchanged for versions before FFTW was removed, or export the
1715
# new definitions after overwritable deprecation bindings were introduced
18-
if VERSION < v"0.7.0-DEV.602" || VERSION >= v"0.7.0-DEV.986"
19-
export fft, ifft, bfft, fft!, ifft!, bfft!,
20-
plan_fft, plan_ifft, plan_bfft, plan_fft!, plan_ifft!, plan_bfft!,
21-
rfft, irfft, brfft, plan_rfft, plan_irfft, plan_brfft,
22-
fftshift, ifftshift
23-
end
16+
export fft, ifft, bfft, fft!, ifft!, bfft!,
17+
plan_fft, plan_ifft, plan_bfft, plan_fft!, plan_ifft!, plan_bfft!,
18+
rfft, irfft, brfft, plan_rfft, plan_irfft, plan_brfft,
19+
fftshift, ifftshift
2420

2521
# Only define things if we aren't using the existing Base bindings
2622
VERSION >= v"0.7.0-DEV.602" && include("definitions.jl")

src/definitions.jl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# This file was formerly a part of Julia. License is MIT: https://julialang.org/license
22

3-
using Compat
4-
using Compat.LinearAlgebra
5-
using Compat.LinearAlgebra: BlasReal
6-
import Compat.LinearAlgebra: A_mul_B!, A_ldiv_B!
3+
using LinearAlgebra
4+
using LinearAlgebra: BlasReal
75
import Base: show, summary, size, ndims, length, eltype,
86
*, inv, \
97

@@ -36,11 +34,11 @@ realfloat(x::AbstractArray{T}) where {T<:Real} = copy1(typeof(fftfloat(zero(T)))
3634

3735
# copy to a 1-based array, using circular permutation
3836
function copy1(::Type{T}, x) where T
39-
y = Array{T}(uninitialized, map(length, Compat.axes(x)))
37+
y = Array{T}(uninitialized, map(length, axes(x)))
4038
Base.circcopy!(y, x)
4139
end
4240

43-
to1(x::AbstractArray) = _to1(Compat.axes(x), x)
41+
to1(x::AbstractArray) = _to1(axes(x), x)
4442
_to1(::Tuple{Base.OneTo,Vararg{Base.OneTo}}, x) = x
4543
_to1(::Tuple, x) = copy1(eltype(x), x)
4644

@@ -96,11 +94,11 @@ contains all of the information needed to compute `fft(A, dims)` quickly.
9694
To apply `P` to an array `A`, use `P * A`; in general, the syntax for applying plans is much
9795
like that of matrices. (A plan can only be applied to arrays of the same size as the `A`
9896
for which the plan was created.) You can also apply a plan with a preallocated output array `Â`
99-
by calling `A_mul_B!(Â, plan, A)`. (For `A_mul_B!`, however, the input array `A` must
97+
by calling `mul!(Â, plan, A)`. (For `mul!`, however, the input array `A` must
10098
be a complex floating-point array like the output `Â`.) You can compute the inverse-transform plan by `inv(P)`
10199
and apply the inverse plan with `P \\ Â` (the inverse plan is cached and reused for
102100
subsequent calls to `inv` or `\\`), and apply the inverse plan to a pre-allocated output
103-
array `A` with `A_ldiv_B!(A, P, Â)`.
101+
array `A` with `ldiv!(A, P, Â)`.
104102
105103
The `flags` argument is a bitwise-or of FFTW planner flags, defaulting to `FFTW.ESTIMATE`.
106104
e.g. passing `FFTW.MEASURE` or `FFTW.PATIENT` will instead spend several seconds (or more)
@@ -209,12 +207,12 @@ plan_rfft(x::AbstractArray, region; kws...) = plan_rfft(realfloat(x), region; kw
209207
# only require implementation to provide *(::Plan{T}, ::Array{T})
210208
*(p::Plan{T}, x::AbstractArray) where {T} = p * copy1(T, x)
211209

212-
# Implementations should also implement A_mul_B!(Y, plan, X) so as to support
213-
# pre-allocated output arrays. We don't define * in terms of A_mul_B!
210+
# Implementations should also implement mul!(Y, plan, X) so as to support
211+
# pre-allocated output arrays. We don't define * in terms of mul!
214212
# generically here, however, because of subtleties for in-place and rfft plans.
215213

216214
##############################################################################
217-
# To support inv, \, and A_ldiv_B!(y, p, x), we require Plan subtypes
215+
# To support inv, \, and ldiv!(y, p, x), we require Plan subtypes
218216
# to have a pinv::Plan field, which caches the inverse plan, and which
219217
# should be initially undefined. They should also implement
220218
# plan_inv(p) to construct the inverse of a plan p.
@@ -227,7 +225,7 @@ pinv_type(p::Plan) = eltype(_pinv_type(p))
227225
inv(p::Plan) =
228226
isdefined(p, :pinv) ? p.pinv::pinv_type(p) : (p.pinv = plan_inv(p))
229227
\(p::Plan, x::AbstractArray) = inv(p) * x
230-
A_ldiv_B!(y::AbstractArray, p::Plan, x::AbstractArray) = A_mul_B!(y, inv(p), x)
228+
LinearAlgebra.ldiv!(y::AbstractArray, p::Plan, x::AbstractArray) = LinearAlgebra.mul!(y, inv(p), x)
231229

232230
##############################################################################
233231
# implementations only need to provide the unnormalized backwards FFT,
@@ -268,8 +266,8 @@ plan_ifft!(x::AbstractArray, region; kws...) =
268266

269267
plan_inv(p::ScaledPlan) = ScaledPlan(plan_inv(p.p), inv(p.scale))
270268

271-
A_mul_B!(y::AbstractArray, p::ScaledPlan, x::AbstractArray) =
272-
scale!(p.scale, A_mul_B!(y, p.p, x))
269+
LinearAlgebra.mul!(y::AbstractArray, p::ScaledPlan, x::AbstractArray) =
270+
scale!(p.scale, LinearAlgebra.mul!(y, p.p, x))
273271

274272
##############################################################################
275273
# Real-input DFTs are annoying because the output has a different size

test/REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Compat 0.48

test/runtests.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# This file contains code that was formerly part of Julia. License is MIT: https://julialang.org/license
22

33
using AbstractFFTs
4+
using AbstractFFTs: Plan
5+
using Compat.LinearAlgebra
46
using Compat.Test
57

6-
import AbstractFFTs: Plan, plan_fft, plan_inv, plan_bfft
7-
import Base: A_mul_B!, *
8+
if VERSION < v"0.7.0-DEV.3204"
9+
const mul! = Base.A_mul_B!
10+
else
11+
const mul! = LinearAlgebra.mul!
12+
end
813

914
mutable struct TestPlan{T} <: Plan{T}
1015
region
@@ -34,11 +39,11 @@ function dft!(y::Vector, x::Vector, sign::Int)
3439
return y
3540
end
3641

37-
Base.A_mul_B!(y::Vector, p::TestPlan, x::Vector) = dft!(y, x, -1)
38-
Base.A_mul_B!(y::Vector, p::InverseTestPlan, x::Vector) = dft!(y, x, 1)
42+
mul!(y::Vector, p::TestPlan, x::Vector) = dft!(y, x, -1)
43+
mul!(y::Vector, p::InverseTestPlan, x::Vector) = dft!(y, x, 1)
3944

40-
Base.:*(p::TestPlan, x::Vector) = A_mul_B!(copy(x), p, x)
41-
Base.:*(p::InverseTestPlan, x::Vector) = A_mul_B!(copy(x), p, x)
45+
Base.:*(p::TestPlan, x::Vector) = mul!(copy(x), p, x)
46+
Base.:*(p::InverseTestPlan, x::Vector) = mul!(copy(x), p, x)
4247

4348
@testset "Custom Plan" begin
4449
x = AbstractFFTs.fft(collect(1:8))

0 commit comments

Comments
 (0)