Add two vectors of scalars
(a: &[F], b: &[F])
| 35 | |
| 36 | /// Add two vectors of scalars |
| 37 | pub fn add_vecs<F: Field>(a: &[F], b: &[F]) -> Vec<F> { |
| 38 | let (a_len, b_len) = (a.len(), b.len()); |
| 39 | let res_len = ark_std::cmp::max(a_len, b_len); |
| 40 | cfg_into_iter!(0..res_len) |
| 41 | .map(|i| { |
| 42 | let a_i = a.get(i).cloned().unwrap_or(F::zero()); |
| 43 | let b_i = b.get(i).cloned().unwrap_or(F::zero()); |
| 44 | a_i + b_i |
| 45 | }) |
| 46 | .collect() |
| 47 | } |
| 48 | |
| 49 | /// Weighted inner product of 2 vectors `a` and `b` with weight `w`. Calculated as `\sum_{i=0}(a_i * b_i * w^{i+1})` |
| 50 | pub fn weighted_inner_product<F: Field>(a: &[F], b: &[F], w: &F) -> F { |
no test coverage detected