use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method polyAdd_S.
@Test
public void polyAdd_S() {
GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
// Create an arbitrary polynomial: 0x12*x^2 + 0x54*x + 0xFF
GrowQueue_I8 inputA = new GrowQueue_I8(3);
inputA.resize(3);
inputA.set(2, 0x12);
inputA.set(1, 0x54);
inputA.set(0, 0xFF);
// Create an arbitrary polynomial: 0xA0*x^3 + 0x45
GrowQueue_I8 inputB = new GrowQueue_I8(4);
inputB.resize(4);
inputB.set(3, 0xA0);
inputB.set(0, 0x45);
// make sure the order doesn't matter
GrowQueue_I8 output0 = new GrowQueue_I8();
alg.polyAdd_S(inputA, inputB, output0);
GrowQueue_I8 output1 = new GrowQueue_I8();
alg.polyAdd_S(inputB, inputA, output1);
assertEquals(4, output0.size);
assertEqualsG_S(output0, output1);
// compare to hand computed solution
assertEquals(0xA0, output0.data[3] & 0xFF);
assertEquals(0x12, output0.data[2] & 0xFF);
assertEquals(0x54, output0.data[1] & 0xFF);
assertEquals(0xFF ^ 0x45, output0.data[0] & 0xFF);
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method polyMult_S.
@Test
public void polyMult_S() {
GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
// Create an arbitrary polynomial: 0x12*x^2 + 0x54*x + 0xFF
GrowQueue_I8 inputA = new GrowQueue_I8();
inputA.resize(3);
inputA.set(2, 0x12);
inputA.set(1, 0x54);
inputA.set(0, 0xFF);
GrowQueue_I8 inputB = new GrowQueue_I8();
inputB.resize(2);
inputB.set(0, 0x03);
// make sure the order doesn't matter
GrowQueue_I8 output0 = new GrowQueue_I8();
alg.polyMult_S(inputA, inputB, output0);
GrowQueue_I8 output1 = new GrowQueue_I8();
alg.polyMult_S(inputB, inputA, output1);
assertEquals(4, output0.size);
assertEqualsG_S(output0, output1);
// check the value against a manual solution
GrowQueue_I8 expected = new GrowQueue_I8();
expected.resize(4);
expected.set(2, alg.multiply(0x12, 0x03));
expected.set(1, alg.multiply(0x54, 0x03));
expected.set(0, alg.multiply(0xFF, 0x03));
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method polyEval_random.
@Test
public void polyEval_random() {
GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
GrowQueue_I8 inputA = new GrowQueue_I8();
for (int i = 0; i < 1000; i++) {
randomPoly(inputA, 30);
int value = rand.nextInt(256);
int found = alg.polyEval(inputA, value);
assertTrue(found >= 0 && found < 256);
}
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method polyMult.
@Test
public void polyMult() {
GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
// Create an arbitrary polynomial: 0x12*x^2 + 0x54*x + 0xFF
GrowQueue_I8 inputA = new GrowQueue_I8();
inputA.resize(3);
inputA.set(0, 0x12);
inputA.set(1, 0x54);
inputA.set(2, 0xFF);
GrowQueue_I8 inputB = new GrowQueue_I8();
inputB.resize(2);
inputB.set(1, 0x03);
// make sure the order doesn't matter
GrowQueue_I8 output0 = new GrowQueue_I8();
alg.polyMult(inputA, inputB, output0);
GrowQueue_I8 output1 = new GrowQueue_I8();
alg.polyMult(inputB, inputA, output1);
assertEquals(4, output0.size);
assertEqualsG(output0, output1);
// check the value against a manual solution
GrowQueue_I8 expected = new GrowQueue_I8();
expected.resize(4);
expected.set(1, alg.multiply(0x12, 0x03));
expected.set(2, alg.multiply(0x54, 0x03));
expected.set(3, alg.multiply(0xFF, 0x03));
}
use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.
the class TestGaliosFieldTableOps method polyEvalContinue.
@Test
public void polyEvalContinue() {
GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
GrowQueue_I8 polyA = new GrowQueue_I8();
randomPoly(polyA, 30);
int x = 0x09;
int expected = alg.polyEval(polyA, x);
GrowQueue_I8 polyB = new GrowQueue_I8(10);
polyB.resize(10);
System.arraycopy(polyA.data, 20, polyB.data, 0, 10);
polyA.size = 20;
int found = alg.polyEval(polyA, x);
found = alg.polyEvalContinue(found, polyB, x);
assertEquals(expected, found);
}
Aggregations