void CReedSolomon::Modified_Berlekamp_Massey (void) { int L, L2, k, d; int psi [MAX_LENGTH], psi2 [MAX_LENGTH], D [MAX_LENGTH]; int gamma [MAX_LENGTH]; int iMaxLength = m_iCorrectCodeSize * 2; /* initialize Gamma, the erasure locator polynomial */ init_gamma (gamma); /* initialize to z */ copy_poly (D, gamma); mul_z_poly (D); copy_poly (psi, gamma); k = -1; L = m_NErasures; for (int n = m_NErasures; n < m_iCorrectCodeSize; n ++) { d = compute_discrepancy (psi, m_synBytes, L, n); if (d != 0) { /* psi2 = psi - d*D */ for (int i = 0; i < iMaxLength; i++) { psi2 [i] = psi [i] ^ gmult (d, D [i]); } if (L < (n - k)) { L2 = n - k; k = n - L; /* D = scale_poly(ginv(d), psi); */ for (int i = 0; i < iMaxLength; i ++) { D [i] = gmult (psi [i], ginv (d)); } L = L2; } /* psi = psi2 */ for (int i = 0; i < iMaxLength; i ++) { psi [i] = psi2 [i]; } } mul_z_poly (D); } for (int i = 0; i < MAX_LENGTH; i ++) { m_Lambda [i] = psi [i]; } compute_modified_omega (); }
/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */ void Modified_Berlekamp_Massey (void) { int n, L, L2, k, d, i; int psi[MAXDEG], psi2[MAXDEG], D[MAXDEG]; int gamma[MAXDEG]; /* initialize Gamma, the erasure locator polynomial */ init_gamma(gamma); /* initialize to z */ copy_poly(D, gamma); mul_z_poly(D); copy_poly(psi, gamma); k = -1; L = NErasures; for (n = NErasures; n < NPAR; n++) { d = compute_discrepancy(psi, synBytes, L, n); if (d != 0) { /* psi2 = psi - d*D */ for (i = 0; i < MAXDEG; i++) psi2[i] = psi[i] ^ gmult(d, D[i]); if (L < (n-k)) { L2 = n-k; k = n-L; /* D = scale_poly(ginv(d), psi); */ for (i = 0; i < MAXDEG; i++) D[i] = gmult(psi[i], ginv(d)); L = L2; } /* psi = psi2 */ for (i = 0; i < MAXDEG; i++) psi[i] = psi2[i]; } mul_z_poly(D); } for(i = 0; i < MAXDEG; i++) Lambda[i] = psi[i]; compute_modified_omega(); }