Skip to content

Commit 03ef58b

Browse files
authored
Merge pull request #72 from gaurav-arya/scaled
Immutable ScaledPlan
2 parents 600b24a + 10e12af commit 03ef58b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/definitions.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ plan_rfft(x::AbstractArray, region; kws...) = plan_rfft(realfloat(x), region; kw
234234
_pinv_type(p::Plan) = typeof([plan_inv(x) for x in typeof(p)[]])
235235
pinv_type(p::Plan) = eltype(_pinv_type(p))
236236

237+
function plan_inv end
238+
237239
inv(p::Plan) =
238240
isdefined(p, :pinv) ? p.pinv::pinv_type(p) : (p.pinv = plan_inv(p))
239241
\(p::Plan, x::AbstractArray) = inv(p) * x
@@ -243,10 +245,9 @@ LinearAlgebra.ldiv!(y::AbstractArray, p::Plan, x::AbstractArray) = LinearAlgebra
243245
# implementations only need to provide the unnormalized backwards FFT,
244246
# similar to FFTW, and we do the scaling generically to get the ifft:
245247

246-
mutable struct ScaledPlan{T,P,N} <: Plan{T}
248+
struct ScaledPlan{T,P,N} <: Plan{T}
247249
p::P
248250
scale::N # not T, to avoid unnecessary promotion to Complex
249-
pinv::Plan
250251
ScaledPlan{T,P,N}(p, scale) where {T,P,N} = new(p, scale)
251252
end
252253
ScaledPlan{T}(p::P, scale::N) where {T,P,N} = ScaledPlan{T,P,N}(p, scale)
@@ -278,7 +279,7 @@ plan_ifft(x::AbstractArray, region; kws...) =
278279
plan_ifft!(x::AbstractArray, region; kws...) =
279280
ScaledPlan(plan_bfft!(x, region; kws...), normalization(x, region))
280281

281-
plan_inv(p::ScaledPlan) = ScaledPlan(inv(p.p), inv(p.scale))
282+
inv(p::ScaledPlan) = ScaledPlan(inv(p.p), inv(p.scale))
282283

283284
LinearAlgebra.mul!(y::AbstractArray, p::ScaledPlan, x::AbstractArray) =
284285
LinearAlgebra.lmul!(p.scale, LinearAlgebra.mul!(y, p.p, x))

0 commit comments

Comments
 (0)