Micro-optimisation
This commit is contained in:
parent
e7b4e9f06d
commit
f25ada5ea9
|
@ -43,13 +43,15 @@
|
||||||
C_KZG_RET do_zero_poly_mul_partial(poly *dst, const uint64_t *indices, uint64_t len_indices, uint64_t stride,
|
C_KZG_RET do_zero_poly_mul_partial(poly *dst, const uint64_t *indices, uint64_t len_indices, uint64_t stride,
|
||||||
const FFTSettings *fs) {
|
const FFTSettings *fs) {
|
||||||
|
|
||||||
|
CHECK(len_indices > 0);
|
||||||
CHECK(dst->length >= len_indices + 1);
|
CHECK(dst->length >= len_indices + 1);
|
||||||
|
|
||||||
for (uint64_t i = 0; i < len_indices; i++) {
|
fr_negate(&dst->coeffs[0], &fs->expanded_roots_of_unity[indices[0] * stride]);
|
||||||
|
|
||||||
|
for (uint64_t i = 1; i < len_indices; i++) {
|
||||||
fr_t neg_di;
|
fr_t neg_di;
|
||||||
fr_negate(&neg_di, &fs->expanded_roots_of_unity[indices[i] * stride]);
|
fr_negate(&neg_di, &fs->expanded_roots_of_unity[indices[i] * stride]);
|
||||||
dst->coeffs[i] = neg_di;
|
dst->coeffs[i] = neg_di;
|
||||||
if (i > 0) {
|
|
||||||
fr_add(&dst->coeffs[i], &dst->coeffs[i], &dst->coeffs[i - 1]);
|
fr_add(&dst->coeffs[i], &dst->coeffs[i], &dst->coeffs[i - 1]);
|
||||||
for (uint64_t j = i - 1; j > 0; j--) {
|
for (uint64_t j = i - 1; j > 0; j--) {
|
||||||
fr_mul(&dst->coeffs[j], &dst->coeffs[j], &neg_di);
|
fr_mul(&dst->coeffs[j], &dst->coeffs[j], &neg_di);
|
||||||
|
@ -57,7 +59,6 @@ C_KZG_RET do_zero_poly_mul_partial(poly *dst, const uint64_t *indices, uint64_t
|
||||||
}
|
}
|
||||||
fr_mul(&dst->coeffs[0], &dst->coeffs[0], &neg_di);
|
fr_mul(&dst->coeffs[0], &dst->coeffs[0], &neg_di);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
dst->coeffs[len_indices] = fr_one;
|
dst->coeffs[len_indices] = fr_one;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue