enum RotateCache {}Implementations§
Source§impl RotateCache
impl RotateCache
Sourcefn ensure(n: usize)
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§
Auto Trait Implementations§
impl Freeze for RotateCache
impl RefUnwindSafe for RotateCache
impl Send for RotateCache
impl Sync for RotateCache
impl Unpin for RotateCache
impl UnwindSafe for RotateCache
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
Mutably borrows from an owned value. Read more