../../.cargo/katex-header.html

Function winter_math::polynom::interpolate_batch

source ·
pub fn interpolate_batch<E, const N: usize>(
    xs: &[[E; N]],
    ys: &[[E; N]]
) -> Vec<[E; N]>
where E: FieldElement,
Expand description

Returns a vector of polynomials interpolated from the provided X and Y coordinate batches.

Uses Lagrange interpolation to build a vector of polynomial from X and Y coordinate batches (one polynomial per batch).

When the number of batches is larger, this function is significantly faster than using polynom::interpolate() function individually for each batch of coordinates. The speed-up is primarily due to computing all inversions as a single batch inversion across all coordinate batches.

§Panics

Panics if the number of X coordinate batches and Y coordinate batches is not the same.

§Examples

let x_batches: Vec<[BaseElement; 8]> = vec![
    rand_array(),
    rand_array(),
];
let y_batches: Vec<[BaseElement; 8]> = vec![
    rand_array(),
    rand_array(),
];

let polys = interpolate_batch(&x_batches, &y_batches);
for ((p, xs), ys) in polys.iter().zip(x_batches).zip(y_batches) {
    assert_eq!(ys.to_vec(), eval_many(p, &xs));
}