polyadd function
Returns a new polynomial r
which is the component-wise sum of polynomials a
and b
.
This function iterates over all coefficients in the polynomials a
and b
,
adding corresponding coefficients together using modular addition.
The result is a new polynomial r
where each coefficient r[i]
is computed as:
r[i] = a[i] + b[i] mod q
.
- Parameters:
- a: The first input polynomial.
- b: The second input polynomial.
- Returns: A new polynomial with coefficients that are the sum of the corresponding
coefficients in
a
andb
, reduced moduloq
.
Implementation
Poly polyadd(Poly a, Poly b) {
Poly r = Poly();
for (int i = 0; i < KYBER_N; i++) {
r.coeffs[i] = fqadd(a.coeffs[i], b.coeffs[i]);
}
return r;
}