pub struct GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase,
H: Homomorphism<R_twiddle, R_main>,
T1: FFTAlgorithm<R_main>,
T2: FFTAlgorithm<R_main>,{ /* private fields */ }
unstable-enable
only.Expand description
A generic variant of the Cooley-Tukey FFT algorithm that can be used to compute the Fourier
transform of an array of length n1 * n2
given Fourier transforms for length n1
resp. n2
.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Implementations§
Source§impl<R, T1, T2> GeneralCooleyTukeyFFT<R::Type, R::Type, Identity<R>, T1, T2>
impl<R, T1, T2> GeneralCooleyTukeyFFT<R::Type, R::Type, Identity<R>, T1, T2>
Sourcepub fn new_with_pows<F>(
ring: R,
root_of_unity_pows: F,
left_table: T1,
right_table: T2,
) -> Self
pub fn new_with_pows<F>( ring: R, root_of_unity_pows: F, left_table: T1, right_table: T2, ) -> Self
Creates a new GeneralCooleyTukeyFFT
over the given ring of length n
, based on FFTs
of length n1
and n2
, where n = n1 * n2
.
The closure root_of_unity_pows
should, on input i
, return z^i
for the primitive n
-th root of
unity z
satisfying z^n1 == right_table.root_of_unity()
and z^n2 - left_table.root_of_unity()
,
where n1
and n2
are the lengths of left_table
and right_table
, respectively.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn new(
ring: R,
root_of_unity: El<R>,
left_table: T1,
right_table: T2,
) -> Self
pub fn new( ring: R, root_of_unity: El<R>, left_table: T1, right_table: T2, ) -> Self
Creates a new GeneralCooleyTukeyFFT
over the given ring of length n
, based on FFTs
of length n1
and n2
, where n = n1 * n2
.
The given root of unity should be the primitive n
-th root of unity satisfying
root_of_unity^n1 == right_table.root_of_unity()
and root_of_unity^n2 - left_table.root_of_unity()
,
where n1
and n2
are the lengths of left_table
and right_table
, respectively.
Do not use this for approximate rings, as computing the powers of root_of_unity
will incur avoidable precision loss.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Source§impl<R_main, R_twiddle, H, A1, A2> GeneralCooleyTukeyFFT<R_main, R_twiddle, H, CooleyTukeyRadix3FFT<R_main, R_twiddle, H, A1>, CooleyTuckeyFFT<R_main, R_twiddle, H, A2>>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase + DivisibilityRing,
H: Homomorphism<R_twiddle, R_main>,
A1: Allocator + Clone,
A2: Allocator + Clone,
impl<R_main, R_twiddle, H, A1, A2> GeneralCooleyTukeyFFT<R_main, R_twiddle, H, CooleyTukeyRadix3FFT<R_main, R_twiddle, H, A1>, CooleyTuckeyFFT<R_main, R_twiddle, H, A2>>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase + DivisibilityRing,
H: Homomorphism<R_twiddle, R_main>,
A1: Allocator + Clone,
A2: Allocator + Clone,
Sourcepub fn change_ring<R_new: ?Sized + RingBase, H_new: Clone + Homomorphism<R_twiddle, R_new>>(
self,
new_hom: H_new,
) -> (GeneralCooleyTukeyFFT<R_new, R_twiddle, H_new, CooleyTukeyRadix3FFT<R_new, R_twiddle, H_new, A1>, CooleyTuckeyFFT<R_new, R_twiddle, H_new, A2>>, H)
pub fn change_ring<R_new: ?Sized + RingBase, H_new: Clone + Homomorphism<R_twiddle, R_new>>( self, new_hom: H_new, ) -> (GeneralCooleyTukeyFFT<R_new, R_twiddle, H_new, CooleyTukeyRadix3FFT<R_new, R_twiddle, H_new, A1>, CooleyTuckeyFFT<R_new, R_twiddle, H_new, A2>>, H)
Replaces the ring that this object can compute FFTs over, assuming that the current twiddle factors can be mapped into the new ring with the given homomorphism.
In particular, this function does not recompute twiddles, but uses a different homomorphism to map the current twiddles into a new ring. Hence, it is extremely cheap.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Source§impl<R_main, R_twiddle, H, T1, T2> GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase,
H: Homomorphism<R_twiddle, R_main>,
T1: FFTAlgorithm<R_main>,
T2: FFTAlgorithm<R_main>,
impl<R_main, R_twiddle, H, T1, T2> GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase,
H: Homomorphism<R_twiddle, R_main>,
T1: FFTAlgorithm<R_main>,
T2: FFTAlgorithm<R_main>,
Sourcepub fn new_with_pows_with_hom<F>(
hom: H,
root_of_unity_pows: F,
left_table: T1,
right_table: T2,
) -> Self
pub fn new_with_pows_with_hom<F>( hom: H, root_of_unity_pows: F, left_table: T1, right_table: T2, ) -> Self
Creates a new GeneralCooleyTukeyFFT
over the given ring of length n
, based on FFTs
of length n1
and n2
, where n = n1 * n2
.
The closure root_of_unity_pows
should, on input i
, return z^i
for the primitive n
-th root of
unity z
satisfying z^n1 == right_table.root_of_unity()
and z^n2 - left_table.root_of_unity()
,
where n1
and n2
are the lengths of left_table
and right_table
, respectively.
Instead of a ring, this function takes a homomorphism R -> S
. Twiddle factors that are
precomputed will be stored as elements of R
, while the main FFT computations will be
performed in S
. This allows both implicit ring conversions, and using patterns like
[zn_64::ZnFastmul
] to precompute some data for better performance.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn create<F>(
hom: H,
root_of_unity_pows: F,
left_table: T1,
right_table: T2,
) -> Self
pub fn create<F>( hom: H, root_of_unity_pows: F, left_table: T1, right_table: T2, ) -> Self
Most general way to create a GeneralCooleyTukeyFFT
. Currently equivalent to GeneralCooleyTukeyFFT::new_with_pows_with_hom()
.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn left_fft_table(&self) -> &T1
pub fn left_fft_table(&self) -> &T1
Returns the length-n1
FFT used by this object to compute length-n
FFTs.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn right_fft_table(&self) -> &T2
pub fn right_fft_table(&self) -> &T2
Returns the length-n2
FFT used by this object to compute length-n
FFTs.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn hom<'a>(&'a self) -> &'a H
pub fn hom<'a>(&'a self) -> &'a H
Returns the homomorphism used to map twiddle factors into the main ring during the computation of FFTs.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn new_with_hom(
hom: H,
root_of_unity: R_twiddle::Element,
left_table: T1,
right_table: T2,
) -> Self
pub fn new_with_hom( hom: H, root_of_unity: R_twiddle::Element, left_table: T1, right_table: T2, ) -> Self
Creates a new GeneralCooleyTukeyFFT
over the given ring of length n
, based on FFTs
of length n1
and n2
, where n = n1 * n2
.
The given root of unity should be the primitive n
-th root of unity satisfying
root_of_unity^n1 == right_table.root_of_unity()
and root_of_unity^n2 - left_table.root_of_unity()
,
where n1
and n2
are the lengths of left_table
and right_table
, respectively.
Instead of a ring, this function takes a homomorphism R -> S
. Twiddle factors that are
precomputed will be stored as elements of R
, while the main FFT computations will be
performed in S
. This allows both implicit ring conversions, and using patterns like
[zn_64::ZnFastmul
] to precompute some data for better performance.
Do not use this for approximate rings, as computing the powers of root_of_unity
will incur avoidable precision loss.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Sourcepub fn ring<'a>(
&'a self,
) -> &'a <H as Homomorphism<R_twiddle, R_main>>::CodomainStore
pub fn ring<'a>( &'a self, ) -> &'a <H as Homomorphism<R_twiddle, R_main>>::CodomainStore
Returns the ring over which this object can compute FFTs.
§Availability
This API is marked as unstable and is only available when the unstable-enable
crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.
Trait Implementations§
Source§impl<R_main, R_twiddle, H, T1, T2> FFTAlgorithm<R_main> for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase,
H: Homomorphism<R_twiddle, R_main>,
T1: FFTAlgorithm<R_main>,
T2: FFTAlgorithm<R_main>,
impl<R_main, R_twiddle, H, T1, T2> FFTAlgorithm<R_main> for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase,
H: Homomorphism<R_twiddle, R_main>,
T1: FFTAlgorithm<R_main>,
T2: FFTAlgorithm<R_main>,
Source§fn root_of_unity<S: RingStore<Type = R_main> + Copy>(
&self,
ring: S,
) -> &R_main::Element
fn root_of_unity<S: RingStore<Type = R_main> + Copy>( &self, ring: S, ) -> &R_main::Element
n
-th roots
of unity can be used equally for computing a Fourier transform, the
concrete one used determines the order of the output values. Read moreSource§fn unordered_fft<V, S>(&self, values: V, ring: S)
fn unordered_fft<V, S>(&self, values: V, ring: S)
FFTAlgorithm::unordered_inv_fft()
). Read moreSource§fn unordered_inv_fft<V, S>(&self, values: V, ring: S)
fn unordered_inv_fft<V, S>(&self, values: V, ring: S)
FFTAlgorithm::unordered_fft()
, with basically the same contract. Read moreSource§fn unordered_fft_permutation(&self, i: usize) -> usize
fn unordered_fft_permutation(&self, i: usize) -> usize
i
, returns j
such that unordered_fft(values)[i]
contains the evaluation
at z^(-j)
of values (note the -
, which is standard convention for Fourier transforms).
Here z
is the value returned by FFTAlgorithm::root_of_unity()
. Read moreSource§fn unordered_fft_permutation_inv(&self, i: usize) -> usize
fn unordered_fft_permutation_inv(&self, i: usize) -> usize
FFTAlgorithm::unordered_fft_permutation()
, i.e. for all i, have
self.unordered_fft_permutation_inv(self.unordered_fft_permutation(i)) == i
.Source§fn fft<V, S>(&self, values: V, ring: S)
fn fft<V, S>(&self, values: V, ring: S)
values
over the specified ring.
The output is in standard order, i.e. the i
-th output element is the evaluation
of the input at self.root_of_unity()^(-i)
(note the -
, which is standard
convention for Fourier transforms). Read moreSource§impl<H, T1, T2> FFTErrorEstimate for GeneralCooleyTukeyFFT<Complex64Base, Complex64Base, H, T1, T2>where
H: Homomorphism<Complex64Base, Complex64Base>,
T1: FFTAlgorithm<Complex64Base> + FFTErrorEstimate,
T2: FFTAlgorithm<Complex64Base> + FFTErrorEstimate,
impl<H, T1, T2> FFTErrorEstimate for GeneralCooleyTukeyFFT<Complex64Base, Complex64Base, H, T1, T2>where
H: Homomorphism<Complex64Base, Complex64Base>,
T1: FFTAlgorithm<Complex64Base> + FFTErrorEstimate,
T2: FFTAlgorithm<Complex64Base> + FFTErrorEstimate,
Source§fn expected_absolute_error(&self, input_bound: f64, input_error: f64) -> f64
fn expected_absolute_error(&self, input_bound: f64, input_error: f64) -> f64
unstable-enable
only.crate::rings::float_complex::Complex64
-specific creator functions.
Note that this is a worst-case estimate and likely to significantly overestimate the error. Read moreSource§impl<R_main, R_twiddle, H, T1, T2> PartialEq for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase,
H: Homomorphism<R_twiddle, R_main>,
T1: FFTAlgorithm<R_main> + PartialEq,
T2: FFTAlgorithm<R_main> + PartialEq,
impl<R_main, R_twiddle, H, T1, T2> PartialEq for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
R_main: ?Sized + RingBase,
R_twiddle: ?Sized + RingBase,
H: Homomorphism<R_twiddle, R_main>,
T1: FFTAlgorithm<R_main> + PartialEq,
T2: FFTAlgorithm<R_main> + PartialEq,
Auto Trait Implementations§
impl<R_main, R_twiddle, H, T1, T2> Freeze for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>
impl<R_main, R_twiddle, H, T1, T2> RefUnwindSafe for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
T1: RefUnwindSafe,
T2: RefUnwindSafe,
<R_main as RingBase>::Element: RefUnwindSafe,
<R_twiddle as RingBase>::Element: RefUnwindSafe,
H: RefUnwindSafe,
R_main: ?Sized,
R_twiddle: ?Sized,
impl<R_main, R_twiddle, H, T1, T2> Send for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>
impl<R_main, R_twiddle, H, T1, T2> Sync for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>
impl<R_main, R_twiddle, H, T1, T2> Unpin for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>
impl<R_main, R_twiddle, H, T1, T2> UnwindSafe for GeneralCooleyTukeyFFT<R_main, R_twiddle, H, T1, T2>where
T1: UnwindSafe,
T2: UnwindSafe,
<R_main as RingBase>::Element: UnwindSafe,
<R_twiddle as RingBase>::Element: UnwindSafe,
H: UnwindSafe,
R_main: ?Sized,
R_twiddle: ?Sized,
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