Open vpuri3 opened 1 year ago
Cosigning this, having AdjointStyle
and adjoint_mul
for r2r
plans would be great. I'm working out the one-dimensional case, but haven't quite wrapped my head around multidimensional FFTW yet
Here's an extremely rudimentary implementation of adjoint_mul
for the 1d REDFT10, in case anyone finds it helpful as a starting point
using AbstractFFTs
using FFTW
struct R2RFFTAdjointStyle <: AbstractFFTs.AdjointStyle end
AbstractFFTs.AdjointStyle(::FFTW.r2rFFTWPlan) = R2RFFTAdjointStyle()
function AbstractFFTs.adjoint_mul(
p::FFTW.r2rFFTWPlan{T}, x::AbstractVector{T}, ::R2RFFTAdjointStyle
) where {T}
(length(p.kinds) == 1) || throw(ArgumentError("Multidimensional r2r transforms not yet supported"))
(only(p.kinds) == 5) || throw(ArgumentError("r2r kinds other than REDFT10 not yet supported"))
pinv = inv(p)
unscaled_pinv = (pinv isa AbstractFFTs.ScaledPlan) ? pinv.p : pinv
y = unscaled_pinv * x
# REDFT10 is unitary except for the first row, so the unscaled inverse is its adjoint
# except for the first column. To obtain the true adjoint, add more DC.
y .+= first(x)
return y
end
how is the gradient computed for
plan_dct
, if there's notrrule
dordct
??error message: