RotateCache

Enum RotateCache 

Source
enum RotateCache {}

Implementations§

Source§

impl RotateCache

Source

fn ensure(n: usize)

Examples found in repository?
crates/competitive/src/math/fast_fourier_transform.rs (line 132)
130pub fn fft(a: &mut [Complex<f64>]) {
131    let n = a.len();
132    RotateCache::ensure(n / 2);
133    RotateCache::with(|cache| {
134        let mut v = n / 2;
135        while v > 0 {
136            for (a, wj) in a.chunks_exact_mut(v << 1).zip(cache) {
137                let (l, r) = a.split_at_mut(v);
138                for (x, y) in l.iter_mut().zip(r) {
139                    let ajv = wj * *y;
140                    *y = *x - ajv;
141                    *x += ajv;
142                }
143            }
144            v >>= 1;
145        }
146    });
147}
148
149pub fn ifft(a: &mut [Complex<f64>]) {
150    let n = a.len();
151    RotateCache::ensure(n / 2);
152    RotateCache::with(|cache| {
153        let mut v = 1;
154        while v < n {
155            for (a, wj) in a
156                .chunks_exact_mut(v << 1)
157                .zip(cache.iter().map(|wj| wj.conjugate()))
158            {
159                let (l, r) = a.split_at_mut(v);
160                for (x, y) in l.iter_mut().zip(r) {
161                    let ajv = *x - *y;
162                    *x += *y;
163                    *y = wj * ajv;
164                }
165            }
166            v <<= 1;
167        }
168    });
169}

Trait Implementations§

Source§

impl AssociatedValue for RotateCache

Source§

type T = Vec<Complex<f64>>

Type of value.
Source§

unsafe fn __local_key() -> &'static LocalKey<Cell<Self::T>>

Source§

fn get() -> Self::T

Source§

fn set(x: Self::T)

Source§

fn replace(x: Self::T) -> Self::T

Source§

fn with<F, R>(f: F) -> R
where F: FnOnce(&Self::T) -> R,

Source§

fn modify<F, R>(f: F) -> R
where F: FnOnce(&mut Self::T) -> R,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.