mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
compute constant terms for same row only once
This commit is contained in:
parent
ebb989ce50
commit
6ec9fcba1a
1 changed files with 24 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ struct CauchyReedSolomonErasureCoding
|
|||
typedef typename GF::value_type value_type;
|
||||
typedef typename GF::ValueType ValueType;
|
||||
typedef typename GF::IndexType IndexType;
|
||||
IndexType row_num, row_den;
|
||||
// $a_{ij} = \frac{1}{x_i + y_j}$
|
||||
IndexType cauchy_matrix(int i, int j)
|
||||
{
|
||||
|
|
@ -34,6 +35,7 @@ struct CauchyReedSolomonErasureCoding
|
|||
// $b_{ij} = \frac{\prod_{k=1}^{n}{(x_j + y_k)(x_k + y_i)}}{(x_j + y_i)\prod_{k \ne j}^{n}{(x_j - x_k)}\prod_{k \ne i}^{n}{(y_i - y_k)}}$
|
||||
IndexType inverse_cauchy_matrix(const ValueType *rows, int i, int j, int n)
|
||||
{
|
||||
#if 0
|
||||
ValueType col_i(ValueType::N - i);
|
||||
IndexType prod_xy(0), prod_x(0), prod_y(0);
|
||||
for (int k = 0; k < n; k++) {
|
||||
|
|
@ -45,6 +47,28 @@ struct CauchyReedSolomonErasureCoding
|
|||
prod_y *= index(col_i + col_k);
|
||||
}
|
||||
return prod_xy / (index(rows[j] + col_i) * prod_x * prod_y);
|
||||
#else
|
||||
ValueType col_i(ValueType::N - i);
|
||||
if (j == 0) {
|
||||
IndexType num(0), den(0);
|
||||
for (int k = 0; k < n; k++) {
|
||||
ValueType col_k(ValueType::N - k);
|
||||
num *= index(rows[k] + col_i);
|
||||
if (k != i)
|
||||
den *= index(col_i + col_k);
|
||||
}
|
||||
row_num = num;
|
||||
row_den = den;
|
||||
}
|
||||
IndexType num(row_num), den(row_den);
|
||||
for (int k = 0; k < n; k++) {
|
||||
ValueType col_k(ValueType::N - k);
|
||||
num *= index(rows[j] + col_k);
|
||||
if (k != j)
|
||||
den *= index(rows[j] + rows[k]);
|
||||
}
|
||||
return num / (index(rows[j] + col_i) * den);
|
||||
#endif
|
||||
}
|
||||
#if defined(__ARM_NEON) && !defined(__aarch64__)
|
||||
static inline uint8x16_t vqtbl1q_u8(uint8x16_t lut, uint8x16_t idx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue