From 86f1020d54ac0901142d1ed7a0006e329e71cbca Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Thu, 28 Mar 2024 16:28:04 +0100 Subject: [PATCH] skip reduction with multiplication --- cauchy_prime_field_erasure_coding.hh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cauchy_prime_field_erasure_coding.hh b/cauchy_prime_field_erasure_coding.hh index e481102..cd23a0f 100644 --- a/cauchy_prime_field_erasure_coding.hh +++ b/cauchy_prime_field_erasure_coding.hh @@ -73,15 +73,18 @@ struct CauchyPrimeFieldErasureCoding } void mac(const IO *a, PF b, int len, bool first, bool last) { - if (first) { + if (first && last) { for (int i = 0; i < len; i++) temp[i] = b * PF(a[i]); + } else if (first) { + for (int i = 0; i < len; i++) + temp[i] = mul(b, PF(a[i])); } else if (last) { for (int i = 0; i < len; i++) - temp[i] = reduce(add(temp[i], b * PF(a[i]))); + temp[i] = reduce(add(temp[i], mul(b, PF(a[i])))); } else { for (int i = 0; i < len; i++) - temp[i] = add(temp[i], b * PF(a[i])); + temp[i] = add(temp[i], mul(b, PF(a[i]))); } } void mac_sub(IO *c, const IO *a, PF b, IO s, int len, bool first, bool last) @@ -92,13 +95,13 @@ struct CauchyPrimeFieldErasureCoding c[i] = (b * PF(a[i] == s ? v : a[i]))(); } else if (first) { for (int i = 0; i < len; i++) - temp[i] = b * PF(a[i] == s ? v : a[i]); + temp[i] = mul(b, PF(a[i] == s ? v : a[i])); } else if (last) { for (int i = 0; i < len; i++) - c[i] = reduce(add(temp[i], b * PF(a[i] == s ? v : a[i])))(); + c[i] = reduce(add(temp[i], mul(b, PF(a[i] == s ? v : a[i]))))(); } else { for (int i = 0; i < len; i++) - temp[i] = add(temp[i], b * PF(a[i] == s ? v : a[i])); + temp[i] = add(temp[i], mul(b, PF(a[i] == s ? v : a[i]))); } } int find_unused(int block_len)