fn eval_polynomial(
    order: usize,
    negative_angle: bool,
    coefs: &[Complex64],
    offset: usize,
    stride: usize,
) -> Vec<Complex64> {
    if order == 0 {
        panic!("Illegal state: coefs.len() < stride")
    } else if order == 1 {
        // If it's off the end, then implicitly zero-pad
        match coefs.get(offset) {
            Some(c) => vec![*c],
            None => vec![Complex64::zero()],
        }
    } else {
        let even_result = eval_polynomial(order / 2, negative_angle, coefs, offset, stride * 2);
        let odd_result = eval_polynomial(
            order / 2,
            negative_angle,
            coefs,
            offset + stride,
            stride * 2,
        );
        let angle =
            (if negative_angle { -1.0 } else { 1.0 }) * 2.0 * std::f64::consts::PI / (order as f64);
        let half_order = order / 2;
        let mut computed = vec![Complex64::new(0.0, 0.0); order];
        for (k, (even_part, odd_part)) in
            Iterator::zip(even_result.iter(), odd_result.iter()).enumerate()
        {
            let root = Complex64::from_polar(&(1.0), &(angle * k as f64));
            let twiddled = root * odd_part;
            computed[k] = even_part + twiddled;
            computed[k + half_order] = even_part - twiddled;
        }
        computed
    }
}
/// Evaluate the polynomial given by a_j = coefs[offset + j * stride] at all the roots
/// of unity of order coefs.len() / stride
/// Assumes order is a power of 2 (WILL DO UNEXPECTED THINGS IF IT ISN'T)
Evaluate the polynomial given by a_j = coefs[offset + j * stride] at all the roots
of unity of order coefs.len() / stride
Assumes order is a power of 2 (WILL DO UNEXPECTED THINGS IF IT ISN'T)
Evaluate the polynomial given by a_j = coefs [ offset + j * stride ] at all the roots of unity of order coefs . len () / stride Assumes order is a power of 2 ( WILL DO UNEXPECTED THINGS IF IT ISN ' T )
fn eval_polynomial(
    order: usize,
    negative_angle: bool,
    coefs: &[Complex64],
    offset: usize,
    stride: usize,
) -> Vec<Complex64> {
    if order == 0 {
        panic!("Illegal state: coefs.len() < stride")
    } else if order == 1 {
        // If it's off the end, then implicitly zero-pad
        match coefs.get(offset) {
            Some(c) => vec![*c],
            None => vec![Complex64::zero()],
        }
    } else {
        let even_result = eval_polynomial(order / 2, negative_angle, coefs, offset, stride * 2);
        let odd_result = eval_polynomial(
            order / 2,
            negative_angle,
            coefs,
            offset + stride,
            stride * 2,
        );
        let angle =
            (if negative_angle { -1.0 } else { 1.0 }) * 2.0 * std::f64::consts::PI / (order as f64);
        let half_order = order / 2;
        let mut computed = vec![Complex64::new(0.0, 0.0); order];
        for (k, (even_part, odd_part)) in
            Iterator::zip(even_result.iter(), odd_result.iter()).enumerate()
        {
            let root = Complex64::from_polar(&(1.0), &(angle * k as f64));
            let twiddled = root * odd_part;
            computed[k] = even_part + twiddled;
            computed[k + half_order] = even_part - twiddled;
        }
        computed
    }
}
fn eval_polynomial ( order : usize , negative_angle : bool , coefs : & [ Complex64 ] , offset : usize , stride : usize , ) -> Vec < Complex64 > { if order == 0 { panic ! ( " " ) } else if order == 1 { // If it's off the end, then implicitly zero-pad match coefs . get ( offset ) { Some ( c ) => vec ! [ c ] , None => vec ! [ Complex64 zero ( ) ] , } } else { let even_result = eval_polynomial ( order / 2 , negative_angle , coefs , offset , stride * 2 ) ; let odd_result = eval_polynomial ( order / 2 , negative_angle , coefs , offset + stride , stride * 2 , ) ; let angle = ( if negative_angle { - 1.0 } else { 1.0 } ) * 2.0 * std :: f64 :: consts :: PI / ( order as f64 ) ; let half_order = order / 2 ; let mut computed = vec ! [ Complex64 new ( 0.0 0.0 ) order ] ; for ( k , ( even_part , odd_part ) ) in Iterator :: zip ( even_result . iter ( ) , odd_result . iter ( ) ) . enumerate ( ) { let root = Complex64 :: from_polar ( & ( 1.0 ) , & ( angle * k as f64 ) ) ; let twiddled = root * odd_part ; computed [ k ] = even_part + twiddled ; computed [ k + half_order ] = even_part - twiddled ; } computed } }
Evaluate the polynomial given by a_j = coefs[offset + j * stride] at all the roots
of unity of order coefs.len() / stride
Assumes order is a power of 2 (WILL DO UNEXPECTED THINGS IF IT ISN'T)
Evaluate the polynomial given by a_j = coefs [ offset + j * stride ] at all the roots of unity of order coefs . len () / stride Assumes order is a power of 2 ( WILL DO UNEXPECTED THINGS IF IT ISN ' T )
order
usize
negative_angle
bool
coefs
&[Complex64]
offset
usize
stride
usize