fn divide_at_point(p: &P, point: &P::Point) -> Vec<P>
    where
        P::Point: Index<usize, Output = E::Fr>,
    {
        let num_vars = p.num_vars();
        if p.is_zero() {
            return vec![P::zero(); num_vars];
        }
        let mut quotients = Vec::with_capacity(num_vars);
        // `cur` represents the current dividend
        let mut cur = p.clone();
        // Divide `cur` by `X_i - z_i`
        for i in 0..num_vars {
            let mut quotient_terms = Vec::new();
            let mut remainder_terms = Vec::new();
            for (mut coeff, term) in cur.terms() {
                // Since the final remainder is guaranteed to be 0, all the constant terms
                // cancel out so we don't need to keep track of them
                if term.is_constant() {
                    continue;
                }
                // If the current term contains `X_i` then divide appropiately,
                // otherwise add it to the remainder
                let mut term_vec = (&*term).to_vec();
                match term_vec.binary_search_by(|(var, _)| var.cmp(&i)) {
                    Ok(idx) => {
                        // Repeatedly divide the term by `X_i - z_i` until the remainder
                        // doesn't contain any `X_i`s
                        while term_vec[idx].1 > 1 {
                            // First divide by `X_i` and add the term to the quotient
                            term_vec[idx] = (i, term_vec[idx].1 - 1);
                            quotient_terms.push((coeff, P::Term::new(term_vec.clone())));
                            // Then compute the remainder term in-place
                            coeff *= &point[i];
                        }
                        // Since `X_i` is power 1, we can remove it entirely
                        term_vec.remove(idx);
                        quotient_terms.push((coeff, P::Term::new(term_vec.clone())));
                        remainder_terms.push((point[i] * &coeff, P::Term::new(term_vec)));
                    }
                    Err(_) => remainder_terms.push((coeff, term.clone())),
                }
            }
            quotients.push(P::from_coefficients_vec(num_vars, quotient_terms));
            // Set the current dividend to be the remainder of this division
            cur = P::from_coefficients_vec(num_vars, remainder_terms);
        }
        quotients
    }
/// Given some point `z`, compute the quotients `w_i(X)` s.t
///
/// `p(X) - p(z) = (X_1-z_1)*w_1(X) + (X_2-z_2)*w_2(X) + ... + (X_l-z_l)*w_l(X)`
///
/// These quotients can always be found with no remainder.


These quotients can always be found with no remainder.
These quotients can always be found with no remainder .
fn divide_at_point(p: &P, point: &P::Point) -> Vec<P>
    where
        P::Point: Index<usize, Output = E::Fr>,
    {
        let num_vars = p.num_vars();
        if p.is_zero() {
            return vec![P::zero(); num_vars];
        }
        let mut quotients = Vec::with_capacity(num_vars);
        // `cur` represents the current dividend
        let mut cur = p.clone();
        // Divide `cur` by `X_i - z_i`
        for i in 0..num_vars {
            let mut quotient_terms = Vec::new();
            let mut remainder_terms = Vec::new();
            for (mut coeff, term) in cur.terms() {
                // Since the final remainder is guaranteed to be 0, all the constant terms
                // cancel out so we don't need to keep track of them
                if term.is_constant() {
                    continue;
                }
                // If the current term contains `X_i` then divide appropiately,
                // otherwise add it to the remainder
                let mut term_vec = (&*term).to_vec();
                match term_vec.binary_search_by(|(var, _)| var.cmp(&i)) {
                    Ok(idx) => {
                        // Repeatedly divide the term by `X_i - z_i` until the remainder
                        // doesn't contain any `X_i`s
                        while term_vec[idx].1 > 1 {
                            // First divide by `X_i` and add the term to the quotient
                            term_vec[idx] = (i, term_vec[idx].1 - 1);
                            quotient_terms.push((coeff, P::Term::new(term_vec.clone())));
                            // Then compute the remainder term in-place
                            coeff *= &point[i];
                        }
                        // Since `X_i` is power 1, we can remove it entirely
                        term_vec.remove(idx);
                        quotient_terms.push((coeff, P::Term::new(term_vec.clone())));
                        remainder_terms.push((point[i] * &coeff, P::Term::new(term_vec)));
                    }
                    Err(_) => remainder_terms.push((coeff, term.clone())),
                }
            }
            quotients.push(P::from_coefficients_vec(num_vars, quotient_terms));
            // Set the current dividend to be the remainder of this division
            cur = P::from_coefficients_vec(num_vars, remainder_terms);
        }
        quotients
    }
fn divide_at_point ( p : & P , point : & P :: Point ) -> Vec < P > where P :: Point : Index < usize , Output = E :: Fr > , { let num_vars = p . num_vars ( ) ; if p . is_zero ( ) { return vec ! [ P zero ( ) num_vars ] ; } let mut quotients = Vec :: with_capacity ( num_vars ) ; // `cur` represents the current dividend let mut cur = p . clone ( ) ; // Divide `cur` by `X_i - z_i` for i in 0 .. num_vars { let mut quotient_terms = Vec :: new ( ) ; let mut remainder_terms = Vec :: new ( ) ; for ( mut coeff , term ) in cur . terms ( ) { // Since the final remainder is guaranteed to be 0, all the constant terms // cancel out so we don't need to keep track of them if term . is_constant ( ) { continue ; } // If the current term contains `X_i` then divide appropiately, // otherwise add it to the remainder let mut term_vec = ( & * term ) . to_vec ( ) ; match term_vec . binary_search_by ( | ( var , _ ) | var . cmp ( & i ) ) { Ok ( idx ) => { // Repeatedly divide the term by `X_i - z_i` until the remainder // doesn't contain any `X_i`s while term_vec [ idx ] . 1 > 1 { // First divide by `X_i` and add the term to the quotient term_vec [ idx ] = ( i , term_vec [ idx ] . 1 - 1 ) ; quotient_terms . push ( ( coeff , P :: Term :: new ( term_vec . clone ( ) ) ) ) ; // Then compute the remainder term in-place coeff *= & point [ i ] ; } // Since `X_i` is power 1, we can remove it entirely term_vec . remove ( idx ) ; quotient_terms . push ( ( coeff , P :: Term :: new ( term_vec . clone ( ) ) ) ) ; remainder_terms . push ( ( point [ i ] * & coeff , P :: Term :: new ( term_vec ) ) ) ; } Err ( _ ) => remainder_terms . push ( ( coeff , term . clone ( ) ) ) , } } quotients . push ( P :: from_coefficients_vec ( num_vars , quotient_terms ) ) ; // Set the current dividend to be the remainder of this division cur = P :: from_coefficients_vec ( num_vars , remainder_terms ) ; } quotients }
Given some point `z`, compute the quotients `w_i(X)` s.t
`p(X) - p(z) = (X_1-z_1)*w_1(X) + (X_2-z_2)*w_2(X) + ... + (X_l-z_l)*w_l(X)`
Given some point ` z ` compute the quotients ` w_i ( X ) ` s . t ` p ( X ) - p ( z ) = ( X_1 - z_1 ) * w_1 ( X ) + ( X_2 - z_2 ) * w_2 ( X ) + ... + ( X_l - z_l ) * w_l ( X ) `
p
&P
point
&P::Point