pub enum ConvolveRealFft {}Implementations§
Source§impl ConvolveRealFft
impl ConvolveRealFft
Sourcepub fn middle_product_f64(
a: impl ExactSizeIterator<Item = f64>,
b: impl ExactSizeIterator<Item = f64>,
) -> Vec<f64>
pub fn middle_product_f64( a: impl ExactSizeIterator<Item = f64>, b: impl ExactSizeIterator<Item = f64>, ) -> Vec<f64>
Returns coefficients b.len() - 1..a.len() of the convolution of a and b.
Panics unless 0 < b.len() <= a.len().
Examples found in repository?
crates/competitive/src/string/wildcard_pattern_matching.rs (lines 19-22)
7fn wildcard_pattern_matching_with_rng(p: &[u8], s: &[u8], rng: &mut Xorshift) -> Vec<bool> {
8 assert!(!p.is_empty());
9 assert!(p.len() <= s.len());
10 let mut direct = [0.0; 256];
11 let mut inverse = [0.0; 256];
12 for i in 0..256 {
13 let x = 1.25 + 0.75 * rng.randf();
14 direct[i] = x;
15 inverse[i] = 1.0 / x;
16 }
17 direct[b'?' as usize] = 0.0;
18 inverse[b'?' as usize] = 0.0;
19 ConvolveRealFft::middle_product_f64(
20 s.iter().map(|&c| direct[c as usize]),
21 p.iter().rev().map(|&c| inverse[c as usize]),
22 )
23 .into_iter()
24 .map(|x| (x - x.round()).abs() < 1e-8)
25 .collect()
26}Trait Implementations§
Source§impl ConvolveSteps for ConvolveRealFft
impl ConvolveSteps for ConvolveRealFft
type T = Vec<i64>
type F = Vec<Complex<f64>>
fn length(t: &Self::T) -> usize
fn transform(t: Self::T, len: usize) -> Self::F
fn inverse_transform(f: Self::F, len: usize) -> Self::T
fn convolve(a: Self::T, b: Self::T) -> Self::T
fn multiply(f: &mut Self::F, g: &Self::F)
Source§const CYCLIC: bool = false
const CYCLIC: bool = false
Whether transform multiplication computes modulo x^n - 1 in the coefficient ring.
fn square(t: Self::T, len: usize) -> Self::T
Auto Trait Implementations§
impl Freeze for ConvolveRealFft
impl RefUnwindSafe for ConvolveRealFft
impl Send for ConvolveRealFft
impl Sync for ConvolveRealFft
impl Unpin for ConvolveRealFft
impl UnsafeUnpin for ConvolveRealFft
impl UnwindSafe for ConvolveRealFft
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