Skip to content

Commit 1695c7e

Browse files
committed
Add plan_mul to capture partial interface implementation
1 parent 4977633 commit 1695c7e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ext/AbstractFFTsForwardDiffExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import AbstractFFTs: Plan
77

88
for P in (:Plan, :ScaledPlan) # need ScaledPlan to avoid ambiguities
99
@eval begin
10-
Base.:*(p::AbstractFFTs.$P, x::AbstractArray{DT}) where DT<:Dual = array2dual(DT, p * dual2array(x))
11-
Base.:*(p::AbstractFFTs.$P, x::AbstractArray{Complex{DT}}) where DT<:Dual = array2dual(DT, p * dual2array(x))
10+
AbstractFFTs.plan_mul(p::AbstractFFTs.$P, x::AbstractArray{DT}) where DT<:Dual = array2dual(DT, p * dual2array(x))
11+
AbstractFFTs.plan_mul(p::AbstractFFTs.$P, x::AbstractArray{Complex{DT}}) where DT<:Dual = array2dual(DT, p * dual2array(x))
1212
end
1313
end
1414

src/definitions.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ rfft(x::AbstractArray{<:Union{Integer,Rational}}, region=1:ndims(x)) = rfft(real
221221
plan_rfft(x::AbstractArray, region; kws...) = plan_rfft(realfloat(x), region; kws...)
222222

223223
# only require implementation to provide *(::Plan{T}, ::Array{T})
224-
*(p::Plan{T}, x::AbstractArray) where {T} = p * copy1(T, x)
224+
plan_mul(p::Plan{T}, x::AbstractArray) where {T} = p * copy1(T, x)
225+
plan_mul(p::Plan{T}, x::AbstractArray{T}) where {T} = error("The plan interface requires overloading *(::MyPlan{T}, ::AbstractArray{T}) where T")
226+
*(p::Plan, x::AbstractArray) = plan_mul(p, x)
225227

226228
# Implementations should also implement mul!(Y, plan, X) so as to support
227229
# pre-allocated output arrays. We don't define * in terms of mul!

0 commit comments

Comments
 (0)