pub struct DiffFftPlan<T: Float> { /* private fields */ }Expand description
Differentiable FFT plan for automatic differentiation.
Wraps a standard FFT plan and provides differentiation capabilities.
Implementations§
Source§impl<T: Float> DiffFftPlan<T>
impl<T: Float> DiffFftPlan<T>
Sourcepub fn inverse(&self, input: &[Complex<T>], output: &mut [Complex<T>])
pub fn inverse(&self, input: &[Complex<T>], output: &mut [Complex<T>])
Execute inverse FFT (normalized).
Sourcepub fn forward_dual(
&self,
input: &[DualComplex<T>],
) -> (Vec<Complex<T>>, Vec<Complex<T>>)
pub fn forward_dual( &self, input: &[DualComplex<T>], ) -> (Vec<Complex<T>>, Vec<Complex<T>>)
Compute forward FFT with its Jacobian-vector product (forward mode AD).
Given input x and tangent dx, computes:
- y = FFT(x)
- dy = FFT(dx) (the directional derivative)
Sourcepub fn backward(&self, grad_output: &[Complex<T>]) -> Vec<Complex<T>>
pub fn backward(&self, grad_output: &[Complex<T>]) -> Vec<Complex<T>>
Compute gradient of a scalar loss with respect to FFT input (backward mode AD).
Given the gradient of loss w.r.t. FFT output (grad_output), computes the gradient w.r.t. FFT input.
For FFT: y = F·x where F is the DFT matrix F[k,n] = exp(-2πi·k·n/N)
The adjoint F^H satisfies: <v, F·x> = <F^H·v, x>
F^H = conj(F^T) = IFFT_unnormalized = N · IFFT
Gradient: ∂L/∂x = F^H · ∂L/∂y = conj(FFT(conj(∂L/∂y)))
Sourcepub fn backward_inverse(&self, grad_output: &[Complex<T>]) -> Vec<Complex<T>>
pub fn backward_inverse(&self, grad_output: &[Complex<T>]) -> Vec<Complex<T>>
Compute gradient of a scalar loss with respect to IFFT input.
For normalized IFFT: y = (1/N)·Fᴴ·x The adjoint of (1/N)·Fᴴ is (1/N)·F Gradient: ∂L/∂x = (1/N)·F · ∂L/∂y = (1/N)·FFT(∂L/∂y)
Auto Trait Implementations§
impl<T> Freeze for DiffFftPlan<T>
impl<T> RefUnwindSafe for DiffFftPlan<T>where
T: RefUnwindSafe,
impl<T> Send for DiffFftPlan<T>
impl<T> Sync for DiffFftPlan<T>
impl<T> Unpin for DiffFftPlan<T>
impl<T> UnwindSafe for DiffFftPlan<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more