pub(crate) fn perform_lagrangian_interpolation_at_origin<T>(
    points: &[SignerIndex],
    values: &[T],
) -> Result<T>
where
    T: Sum,
    for<'a> &'a T: Mul<Scalar, Output = T>,
{
    if points.is_empty() || values.is_empty() {
        return Err(CoconutError::Interpolation(
            "Tried to perform lagrangian interpolation for an empty set of coordinates".to_string(),
        ));
    }

    if points.len() != values.len() {
        return Err(CoconutError::Interpolation(
            "Tried to perform lagrangian interpolation for an incomplete set of coordinates"
                .to_string(),
        ));
    }

    let coefficients = generate_lagrangian_coefficients_at_origin(points);

    Ok(coefficients
        .into_iter()
        .zip(values.iter())
        .map(|(coeff, val)| val * coeff)
        .sum())
}
/// Performs a Lagrange interpolation at the origin for a polynomial defined by `points` and `values`.
/// It can be used for Scalars, G1 and G2 points.
Performs a Lagrange interpolation at the origin for a polynomial defined by `points` and `values`.
It can be used for Scalars, G1 and G2 points.
Performs a Lagrange interpolation at the origin for a polynomial defined by ` points ` and ` values ` . It can be used for Scalars G1 and G2 points .
pub(crate) fn perform_lagrangian_interpolation_at_origin<T>(
    points: &[SignerIndex],
    values: &[T],
) -> Result<T>
where
    T: Sum,
    for<'a> &'a T: Mul<Scalar, Output = T>,
{
    if points.is_empty() || values.is_empty() {
        return Err(CoconutError::Interpolation(
            "Tried to perform lagrangian interpolation for an empty set of coordinates".to_string(),
        ));
    }
    if points.len() != values.len() {
        return Err(CoconutError::Interpolation(
            "Tried to perform lagrangian interpolation for an incomplete set of coordinates"
                .to_string(),
        ));
    }
    let coefficients = generate_lagrangian_coefficients_at_origin(points);
    Ok(coefficients
        .into_iter()
        .zip(values.iter())
        .map(|(coeff, val)| val * coeff)
        .sum())
}
pub ( crate ) fn perform_lagrangian_interpolation_at_origin < T > ( points : & [ SignerIndex ] , values : & [ T ] , ) -> Result < T > where T : Sum , for < ' a > & ' a T : Mul < Scalar , Output = T > , { if points . is_empty ( ) || values . is_empty ( ) { return Err ( CoconutError :: Interpolation ( " " . to_string ( ) , ) ) ; } if points . len ( ) != values . len ( ) { return Err ( CoconutError :: Interpolation ( " " . to_string ( ) , ) ) ; } let coefficients = generate_lagrangian_coefficients_at_origin ( points ) ; Ok ( coefficients . into_iter ( ) . zip ( values . iter ( ) ) . map ( | ( coeff , val ) | val * coeff ) . sum ( ) ) }
Performs a Lagrange interpolation at the origin for a polynomial defined by `points` and `values`.
Performs a Lagrange interpolation at the origin for a polynomial defined by ` points ` and ` values ` .
points
&[SignerIndex]
values
&[T]