MCPcopy Create free account
hub / github.com/docknetwork/crypto / inner_product_poly

Function inner_product_poly

utils/src/poly.rs:46–56  ·  view source on GitHub ↗

Given a vector of polynomials `polys` and scalars `coeffs`, return their inner product `polys[0] * coeffs[0] + polys[1] * coeffs[1] + ...`

(
    polys: &[DensePolynomial<F>],
    coeffs: Vec<F>,
)

Source from the content-addressed store, hash-verified

44
45/// Given a vector of polynomials `polys` and scalars `coeffs`, return their inner product `polys[0] * coeffs[0] + polys[1] * coeffs[1] + ...`
46pub fn inner_product_poly<F: Field>(
47 polys: &[DensePolynomial<F>],
48 coeffs: Vec<F>,
49) -> DensePolynomial<F> {
50 let product = cfg_into_iter!(coeffs)
51 .zip(cfg_into_iter!(polys))
52 .map(|(f, p)| p * f);
53
54 let zero = DensePolynomial::zero;
55 cfg_iter_sum!(product, zero)
56}
57
58/// Create a polynomial from given `roots` as `(x-roots[0])*(x-roots[1])*(x-roots[2])*..`
59pub fn poly_from_roots<F: Field>(roots: &[F]) -> DensePolynomial<F> {

Callers 2

generateMethod · 0.85

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected