1
1
# This file was formerly a part of Julia. License is MIT: https://julialang.org/license
2
2
3
- using Base. LinAlg: BlasReal
3
+ using LinearAlgebra
4
+ using LinearAlgebra: BlasReal
4
5
import Base: show, summary, size, ndims, length, eltype,
5
- * , A_mul_B!, inv, \ , A_ldiv_B!
6
+ * , inv, \
6
7
7
8
# DFT plan where the inputs are an array of eltype T
8
9
abstract type Plan{T} end
@@ -33,11 +34,11 @@ realfloat(x::AbstractArray{T}) where {T<:Real} = copy1(typeof(fftfloat(zero(T)))
33
34
34
35
# copy to a 1-based array, using circular permutation
35
36
function copy1 (:: Type{T} , x) where T
36
- y = Array {T} (map (length, indices (x)))
37
+ y = Array {T} (uninitialized, map (length, axes (x)))
37
38
Base. circcopy! (y, x)
38
39
end
39
40
40
- to1 (x:: AbstractArray ) = _to1 (indices (x), x)
41
+ to1 (x:: AbstractArray ) = _to1 (axes (x), x)
41
42
_to1 (:: Tuple{Base.OneTo,Vararg{Base.OneTo}} , x) = x
42
43
_to1 (:: Tuple , x) = copy1 (eltype (x), x)
43
44
@@ -93,11 +94,11 @@ contains all of the information needed to compute `fft(A, dims)` quickly.
93
94
To apply `P` to an array `A`, use `P * A`; in general, the syntax for applying plans is much
94
95
like that of matrices. (A plan can only be applied to arrays of the same size as the `A`
95
96
for which the plan was created.) You can also apply a plan with a preallocated output array `Â`
96
- 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
97
98
be a complex floating-point array like the output `Â`.) You can compute the inverse-transform plan by `inv(P)`
98
99
and apply the inverse plan with `P \\ Â` (the inverse plan is cached and reused for
99
100
subsequent calls to `inv` or `\\ `), and apply the inverse plan to a pre-allocated output
100
- array `A` with `A_ldiv_B !(A, P, Â)`.
101
+ array `A` with `ldiv !(A, P, Â)`.
101
102
102
103
The `flags` argument is a bitwise-or of FFTW planner flags, defaulting to `FFTW.ESTIMATE`.
103
104
e.g. passing `FFTW.MEASURE` or `FFTW.PATIENT` will instead spend several seconds (or more)
@@ -206,12 +207,12 @@ plan_rfft(x::AbstractArray, region; kws...) = plan_rfft(realfloat(x), region; kw
206
207
# only require implementation to provide *(::Plan{T}, ::Array{T})
207
208
* (p:: Plan{T} , x:: AbstractArray ) where {T} = p * copy1 (T, x)
208
209
209
- # Implementations should also implement A_mul_B !(Y, plan, X) so as to support
210
- # 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 !
211
212
# generically here, however, because of subtleties for in-place and rfft plans.
212
213
213
214
# #############################################################################
214
- # 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
215
216
# to have a pinv::Plan field, which caches the inverse plan, and which
216
217
# should be initially undefined. They should also implement
217
218
# plan_inv(p) to construct the inverse of a plan p.
@@ -224,7 +225,7 @@ pinv_type(p::Plan) = eltype(_pinv_type(p))
224
225
inv (p:: Plan ) =
225
226
isdefined (p, :pinv ) ? p. pinv:: pinv_type (p) : (p. pinv = plan_inv (p))
226
227
\ (p:: Plan , x:: AbstractArray ) = inv (p) * x
227
- 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)
228
229
229
230
# #############################################################################
230
231
# implementations only need to provide the unnormalized backwards FFT,
@@ -245,7 +246,13 @@ size(p::ScaledPlan) = size(p.p)
245
246
show (io:: IO , p:: ScaledPlan ) = print (io, p. scale, " * " , p. p)
246
247
summary (p:: ScaledPlan ) = string (p. scale, " * " , summary (p. p))
247
248
248
- * (p:: ScaledPlan , x:: AbstractArray ) = scale! (p. p * x, p. scale)
249
+ if VERSION >= v " 0.7.0-DEV.3665"
250
+ * (p:: ScaledPlan , x:: AbstractArray ) = LinearAlgebra. rmul! (p. p * x, p. scale)
251
+ elseif VERSION >= v " 0.7.0-DEV.3563"
252
+ * (p:: ScaledPlan , x:: AbstractArray ) = LinearAlgebra. mul1! (p. p * x, p. scale)
253
+ else
254
+ * (p:: ScaledPlan , x:: AbstractArray ) = scale! (p. p * x, p. scale)
255
+ end
249
256
250
257
* (α:: Number , p:: Plan ) = ScaledPlan (p, α)
251
258
* (p:: Plan , α:: Number ) = ScaledPlan (p, α)
@@ -265,8 +272,16 @@ plan_ifft!(x::AbstractArray, region; kws...) =
265
272
266
273
plan_inv (p:: ScaledPlan ) = ScaledPlan (plan_inv (p. p), inv (p. scale))
267
274
268
- A_mul_B! (y:: AbstractArray , p:: ScaledPlan , x:: AbstractArray ) =
269
- scale! (p. scale, A_mul_B! (y, p. p, x))
275
+ if VERSION >= v " 0.7.0-DEV.3665"
276
+ LinearAlgebra. mul! (y:: AbstractArray , p:: ScaledPlan , x:: AbstractArray ) =
277
+ LinearAlgebra. lmul! (p. scale, LinearAlgebra. mul! (y, p. p, x))
278
+ elseif VERSION >= v " 0.7.0-DEV.3563"
279
+ LinearAlgebra. mul! (y:: AbstractArray , p:: ScaledPlan , x:: AbstractArray ) =
280
+ LinearAlgebra. mul2! (p. scale, LinearAlgebra. mul! (y, p. p, x))
281
+ else
282
+ LinearAlgebra. mul! (y:: AbstractArray , p:: ScaledPlan , x:: AbstractArray ) =
283
+ scale! (p. scale, LinearAlgebra. mul! (y, p. p, x))
284
+ end
270
285
271
286
# #############################################################################
272
287
# Real-input DFTs are annoying because the output has a different size
0 commit comments