Skip to content

Commit 86f1020

Browse files
author
Ahmet Inan
committed
skip reduction with multiplication
1 parent 455bc95 commit 86f1020

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cauchy_prime_field_erasure_coding.hh

+9-6
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@ struct CauchyPrimeFieldErasureCoding
7373
}
7474
void mac(const IO *a, PF b, int len, bool first, bool last)
7575
{
76-
if (first) {
76+
if (first && last) {
7777
for (int i = 0; i < len; i++)
7878
temp[i] = b * PF(a[i]);
79+
} else if (first) {
80+
for (int i = 0; i < len; i++)
81+
temp[i] = mul(b, PF(a[i]));
7982
} else if (last) {
8083
for (int i = 0; i < len; i++)
81-
temp[i] = reduce(add(temp[i], b * PF(a[i])));
84+
temp[i] = reduce(add(temp[i], mul(b, PF(a[i]))));
8285
} else {
8386
for (int i = 0; i < len; i++)
84-
temp[i] = add(temp[i], b * PF(a[i]));
87+
temp[i] = add(temp[i], mul(b, PF(a[i])));
8588
}
8689
}
8790
void mac_sub(IO *c, const IO *a, PF b, IO s, int len, bool first, bool last)
@@ -92,13 +95,13 @@ struct CauchyPrimeFieldErasureCoding
9295
c[i] = (b * PF(a[i] == s ? v : a[i]))();
9396
} else if (first) {
9497
for (int i = 0; i < len; i++)
95-
temp[i] = b * PF(a[i] == s ? v : a[i]);
98+
temp[i] = mul(b, PF(a[i] == s ? v : a[i]));
9699
} else if (last) {
97100
for (int i = 0; i < len; i++)
98-
c[i] = reduce(add(temp[i], b * PF(a[i] == s ? v : a[i])))();
101+
c[i] = reduce(add(temp[i], mul(b, PF(a[i] == s ? v : a[i]))))();
99102
} else {
100103
for (int i = 0; i < len; i++)
101-
temp[i] = add(temp[i], b * PF(a[i] == s ? v : a[i]));
104+
temp[i] = add(temp[i], mul(b, PF(a[i] == s ? v : a[i])));
102105
}
103106
}
104107
int find_unused(int block_len)

0 commit comments

Comments
 (0)