-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReedSolomon decoding issue #76
Comments
Hi, @JessicaMulein . Reed-Solomon encoding has been well tested by reading QRs generated using the library with a physical QR code reader. getGx(field: FiniteField<F>, nth: number, aDegree: number = 0) The second parameter An example of its usage is shown below: red-agate/packages/red-agate-barcode/src/barcode/Qr.ts Lines 493 to 511 in b62921d
red-agate/packages/red-agate-math/src/_spec/ReedSolomon.spec.ts Lines 33 to 55 in b62921d
|
My encode/decode looked like this
and my test looked like this
The second test fails to return within any reasonable timeframe. |
sorry for the flip flop. when I reconstructed my proof of concept, I thought it was working but realized I was passing in an undegraded input. It definitely still fails to return in the same way. Can you see anything wrong in what I'm doing? |
Why don’t you try it once with a small number of errors? The following test is working: import * as ff from "../index";
describe("ReedSolomon", function() {
it("ReedSolomon", function() {
const gf2 = new ff.Gf2e8Field();
let rsol = new ff.ReedSolomon(gf2, []);
const specRegxs = [193, 157, 113, 95, 94, 199, 111, 159, 194, 216, 1];
const rsgxs = ff.ReedSolomon.listGx(gf2, void 0, 10, 0);
expect(rsgxs[rsgxs.length - 1].length).toEqual(specRegxs.length);
for (let i = 0; i < specRegxs.length; i++) {
expect(rsgxs[rsgxs.length - 1][i]).toEqual(specRegxs[i]);
}
let rsgxs2 = ff.ReedSolomon.listGx(gf2, void 0, 5, 0);
expect(rsgxs2.length).toEqual(5);
rsgxs2 = ff.ReedSolomon.listGx(gf2, rsgxs2, 10, 0);
expect(rsgxs2.length).toEqual(10);
expect(rsgxs2[rsgxs2.length - 1].length).toEqual(specRegxs.length);
for (let i = 0; i < specRegxs.length; i++) {
expect(rsgxs2[rsgxs2.length - 1][i]).toEqual(specRegxs[i]);
}
const rsgx3 = ff.ReedSolomon.getGx(gf2, 10, 0);
expect(rsgx3.length).toEqual(specRegxs.length);
for (let i = 0; i < specRegxs.length; i++) {
expect(rsgx3[i]).toEqual(specRegxs[i]);
}
rsol = new ff.ReedSolomon(gf2, rsgxs[rsgxs.length - 1]);
rsol.gx = ff.ReedSolomon.getGx(gf2, 10, 0);
const ax = [
16, 32, 12, 86, 97, 128, 236, 17,
237, 18, 239, 19, 240, 20, 241, 21].reverse();
const poly = new ff.ArrayPolynomialRing(rsol.field);
const rsec = rsol.encode(ax);
// console.log(poly.add(poly.mul(poly.divmod(ax, rsol.gx, rsol.gx.length - 1).q, rsol.gx), rsec));
const rsrecv = rsec.concat(ax);
const wwww1 = poly.field.div(0, 242);
const q1111 = poly.divmod(rsrecv, rsol.gx);
// console.log(q1111.q);
// console.log(q1111.r);
// console.log(q1111.divisible);
console.log("rs send=" + rsrecv);
//rsrecv[3] ^= 51;
rsrecv[11] ^= 211;
rsrecv[12] ^= 73;
rsrecv[17] ^= 103;
rsrecv[21] ^= 99;
rsrecv[23] ^= 97;
//rsrecv[25] ^= 53;
const rscorr = rsol.decode(rsrecv);
console.log("rs corr=" + rscorr);
expect(rscorr.length).toEqual(ax.length);
for (let i = 0; i < ax.length; i++) {
expect(rscorr[i]).toEqual(ax[i]);
}
});
});
|
I was trying to do some very basic reed solomon encoding and decoding and I was able to generate FEC for an input array filled with the numbers 0 to 127, and then decode the input + fec data (given as FEC first, then data, figured out by trial and error). But while it works when there are no errors, introducing even one bit error seems to cause the decode never to complete (or at least not in any reasonable timeframe).
Have you done much testing on your reed solomon module of your red-agate-math library?
I had set up a GF2e8 with a gx from getgx using nth 127. I was doing an encode on 128 bytes (filled with numbers 0 to 127) and then trying to decode([...fec, ...input]).
The text was updated successfully, but these errors were encountered: