Your source code has a problem for ramdom data correction as below and returns correctionSucceeded is true.
It was succeeded from the original c-source.
public static void main(String[] args) {
java.util.Random random = new java.util.Random();
for(int count = 0; count < 10; count++) {
int[] data = new int[255];
for(int i = 0; i < data.length; i++) {
data[i] = random.nextInt() & 0xff;
}
ReedSolomon rs = new ReedSolomon(data, 17);
rs.correct();
System.out.println(rs.correctionSucceeded);
}
}
Random data problem patch (2007-10-12 01:24 by m-miyzaki #32732)
*** orig\ReedSolomon.java Fri Oct 12 01:15:41 2007
--- ReedSolomon.java Fri Oct 12 01:04:07 2007
***************
*** 161,167 ****
}
/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */
! void Modified_Berlekamp_Massey() {
int L2, d;
int[] psi = new int[MAXDEG];
int[] psi2 = new int[MAXDEG];
--- 161,167 ----
}
/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */
! boolean Modified_Berlekamp_Massey() {
int L2, d;
int[] psi = new int[MAXDEG];
int[] psi2 = new int[MAXDEG];
***************
*** 196,201 ****
--- 196,203 ----
/* D = scale_poly(ginv(d), psi); */
for (int i = 0; i < MAXDEG; i++) D[i] = gmult(psi[i], ginv(d));
L = L2;
+ if(L > NPAR / 2)
+ return false;
}
/* given Psi (called Lambda in Modified_Berlekamp_Massey) and synBytes,
***************
*** 328,334 ****
NErasures = nerasures;
for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];
! Modified_Berlekamp_Massey();
Find_Roots();
if (NErrors == 0) return true;
--- 331,338 ----
NErasures = nerasures;
for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];
/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */
! void Modified_Berlekamp_Massey() {
int L2, d;
int[] psi = new int[MAXDEG];
int[] psi2 = new int[MAXDEG];
--- 160,166 ----
}
/* From Cain, Clark, "Error-Correction Coding For Digital Communications", pp. 216. */
! int Modified_Berlekamp_Massey() {
int L2, d;
int[] psi = new int[MAXDEG];
int[] psi2 = new int[MAXDEG];
***************
*** 207,212 ****
--- 207,213 ----
for(int i = 0; i < MAXDEG; i++) Lambda[i] = psi[i];
//printArray(Lambda);
compute_modified_omega();
+ return L;
}
/* given Psi (called Lambda in Modified_Berlekamp_Massey) and synBytes,
***************
*** 327,334 ****
NErasures = nerasures;
for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];
! Modified_Berlekamp_Massey();
Find_Roots();
if (NErrors == 0) return true;
if (NErrors <= NPAR) {
--- 328,337 ----
NErasures = nerasures;
for (int i = 0; i < NErasures; i++) ErasureLocs[i] = erasures[i];
I don't understand what you mean. If you find a bug in my code, please let me know. Or if you have a specific test tthat can fail my code, let me know also.
Brief description (2007-10-16 18:34 by m-miyzaki #32799)
The degree of Lambda must be equal to NErrors to correct RS-CODE correctly. It is necessary to notify the correction failure, if it is not so.
However, the original source code and yours lack this check.