use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestReidSolomonCodes method findErrorLocatorPolynomialBM_compareToDirect.
/**
* Compares the results from BM against an error locator polynomial computed directly given the known
* error locations
*/
@Test
public void findErrorLocatorPolynomialBM_compareToDirect() {
GrowQueue_I8 found = new GrowQueue_I8();
GrowQueue_I8 expected = new GrowQueue_I8();
for (int i = 0; i < 30; i++) {
int N = 50;
GrowQueue_I8 message = randomMessage(N);
GrowQueue_I8 ecc = new GrowQueue_I8();
int nsyn = 10;
GrowQueue_I8 syndromes = GrowQueue_I8.zeros(nsyn);
ReidSolomonCodes alg = new ReidSolomonCodes(8, primitive8);
alg.generator(nsyn);
alg.computeECC(message, ecc);
int where = rand.nextInt(N);
message.data[where] ^= 0x12;
alg.computeSyndromes(message, ecc, syndromes);
GrowQueue_I32 whereList = new GrowQueue_I32(1);
whereList.add(where);
alg.findErrorLocatorPolynomialBM(syndromes, found);
alg.findErrorLocatorPolynomial(N + ecc.size, whereList, expected);
assertEquals(found.size, expected.size);
for (int j = 0; j < found.size; j++) {
assertEquals(found.get(j), expected.get(j));
}
}
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestReidSolomonCodes method computeSyndromes.
@Test
public void computeSyndromes() {
GrowQueue_I8 message = randomMessage(50);
GrowQueue_I8 ecc = new GrowQueue_I8();
ReidSolomonCodes alg = new ReidSolomonCodes(8, primitive8);
alg.generator(6);
alg.computeECC(message, ecc);
GrowQueue_I8 syndromes = GrowQueue_I8.zeros(6);
alg.computeSyndromes(message, ecc, syndromes);
// no error. All syndromes values should be zero
for (int i = 0; i < syndromes.size; i++) {
assertEquals(0, syndromes.data[i]);
}
// introduce an error
message.data[6] += 7;
alg.computeSyndromes(message, ecc, syndromes);
int notZero = 0;
for (int i = 0; i < syndromes.size; i++) {
if (syndromes.data[i] != 0)
notZero++;
}
assertTrue(notZero > 1);
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestReidSolomonCodes method correctErrors_hand.
/**
* Compare against a hand computed scenario
*/
@Test
public void correctErrors_hand() {
GrowQueue_I8 message = GrowQueue_I8.parseHex("[ 0x40, 0xd2, 0x75, 0x47, 0x76, 0x17, 0x32, 0x06, 0x27, 0x26, 0x96, 0xc6, 0xc6, 0x96, 0x70, 0xec ]");
GrowQueue_I8 ecc = new GrowQueue_I8();
GrowQueue_I8 syndromes = new GrowQueue_I8();
GrowQueue_I8 errorLocator = new GrowQueue_I8();
int nsyn = 10;
ReidSolomonCodes alg = new ReidSolomonCodes(8, primitive8);
alg.generator(nsyn);
alg.computeECC(message, ecc);
GrowQueue_I8 corrupted = message.copy();
corrupted.data[0] = 0;
corrupted.data[4] = 8;
corrupted.data[5] = 9;
alg.computeSyndromes(corrupted, ecc, syndromes);
alg.findErrorLocatorPolynomialBM(syndromes, errorLocator);
GrowQueue_I32 errorLocations = new GrowQueue_I32(3);
errorLocations.data[0] = 0;
errorLocations.data[1] = 4;
errorLocations.data[2] = 5;
errorLocations.size = 3;
alg.correctErrors(corrupted, message.size + ecc.size, syndromes, errorLocator, errorLocations);
assertEquals(corrupted.size, message.size);
for (int j = 0; j < corrupted.size; j++) {
assertEquals(corrupted.get(j), message.get(j));
}
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method checkDivision.
private void checkDivision(GaliosFieldTableOps alg, GrowQueue_I8 inputA, GrowQueue_I8 inputB, GrowQueue_I8 quotent, GrowQueue_I8 remainder) {
GrowQueue_I8 tmp = new GrowQueue_I8();
GrowQueue_I8 found = new GrowQueue_I8();
alg.polyMult(inputB, quotent, tmp);
alg.polyAdd(tmp, remainder, found);
assertEqualsG(inputA, found);
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method checkDivision_S.
private void checkDivision_S(GaliosFieldTableOps alg, GrowQueue_I8 inputA, GrowQueue_I8 inputB, GrowQueue_I8 quotent, GrowQueue_I8 remainder) {
GrowQueue_I8 tmp = new GrowQueue_I8();
GrowQueue_I8 found = new GrowQueue_I8();
alg.polyMult_S(inputB, quotent, tmp);
alg.polyAdd_S(tmp, remainder, found);
assertEqualsG_S(inputA, found);
}
Aggregations