Search in sources :

Example 6 with GrowQueue_I8

use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.

the class TestReidSolomonCodes method findErrorEvaluator.

private void findErrorEvaluator(GrowQueue_I8 syndromes, GrowQueue_I8 errorLocator, GrowQueue_I8 expected) {
    GrowQueue_I8 found = new GrowQueue_I8();
    ReidSolomonCodes alg = new ReidSolomonCodes(8, primitive8);
    alg.findErrorEvaluator(syndromes, errorLocator, found);
    assertEquals(found.size, expected.size);
    for (int j = 0; j < found.size; j++) {
        assertEquals(found.get(j), expected.get(j));
    }
}
Also used : GrowQueue_I8(org.ddogleg.struct.GrowQueue_I8)

Example 7 with GrowQueue_I8

use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.

the class TestGaliosFieldTableOps method polyScale.

@Test
public void polyScale() {
    GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
    // Create an arbitrary polynomial: 0x12*x^2 + 0x54*x + 0xFF
    GrowQueue_I8 input = new GrowQueue_I8(3);
    input.set(0, 0x12);
    input.set(1, 0x54);
    input.set(2, 0xFF);
    int scale = 0x45;
    GrowQueue_I8 output = new GrowQueue_I8();
    alg.polyScale(input.copy(), scale, output);
    assertEquals(input.size, output.size);
    for (int i = 0; i < input.size; i++) {
        int expected = alg.multiply(input.data[i] & 0xFF, scale);
        assertEquals(expected, output.data[i] & 0xFF);
    }
}
Also used : GrowQueue_I8(org.ddogleg.struct.GrowQueue_I8) Test(org.junit.Test)

Example 8 with GrowQueue_I8

use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.

the class TestGaliosFieldTableOps method polyAddScaleB.

@Test
public void polyAddScaleB() {
    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(0, 0x12);
    inputA.set(1, 0x54);
    inputA.set(2, 0xFF);
    // Create an arbitrary polynomial: 0xA0*x^3 + 0x45
    GrowQueue_I8 inputB = new GrowQueue_I8(4);
    inputB.resize(4);
    inputB.set(0, 0xA0);
    inputB.set(3, 0x45);
    int scale = 0x62;
    GrowQueue_I8 scaleB = new GrowQueue_I8();
    alg.polyScale(inputB, scale, scaleB);
    GrowQueue_I8 expected = new GrowQueue_I8();
    alg.polyAdd(inputA, scaleB, expected);
    GrowQueue_I8 found = new GrowQueue_I8();
    alg.polyAddScaleB(inputA, inputB, scale, found);
    assertEqualsG(expected, found);
}
Also used : GrowQueue_I8(org.ddogleg.struct.GrowQueue_I8) Test(org.junit.Test)

Example 9 with GrowQueue_I8

use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.

the class TestGaliosFieldTableOps method polyEval_S.

@Test
public void polyEval_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);
    int input = 0x09;
    int found = alg.polyEval_S(inputA, input);
    int expected = 0xFF ^ alg.multiply(0x54, input);
    expected ^= alg.multiply(0x12, alg.multiply(input, input));
    assertEquals(expected, found);
}
Also used : GrowQueue_I8(org.ddogleg.struct.GrowQueue_I8) Test(org.junit.Test)

Example 10 with GrowQueue_I8

use of org.ddogleg.struct.GrowQueue_I8 in project BoofCV by lessthanoptimal.

the class TestGaliosFieldTableOps method polyDivide.

@Test
public void polyDivide() {
    GaliosFieldTableOps alg = new GaliosFieldTableOps(8, primitive8);
    // Create an arbitrary polynomial: 0BB*x^4 + 0x12*x^3 + 0x54*x^2 + 0*x + 0xFF
    GrowQueue_I8 inputA = new GrowQueue_I8();
    inputA.resize(5);
    inputA.set(0, 0xBB);
    inputA.set(1, 0x12);
    inputA.set(2, 0x54);
    inputA.set(4, 0xFF);
    GrowQueue_I8 inputB = new GrowQueue_I8();
    inputB.resize(2);
    inputB.set(0, 0xF0);
    inputB.set(1, 0x0A);
    GrowQueue_I8 quotient = new GrowQueue_I8();
    GrowQueue_I8 remainder = new GrowQueue_I8();
    alg.polyDivide(inputA, inputB, quotient, remainder);
    assertEquals(4, quotient.size);
    assertEquals(1, remainder.size);
    // see if division was done correct and reconstruct the original equation
    checkDivision(alg, inputA, inputB, quotient, remainder);
    // have the divisor be larger than the dividend
    alg.polyDivide(inputB, inputA, quotient, remainder);
    assertEquals(0, quotient.size);
    assertEquals(2, remainder.size);
    checkDivision(alg, inputB, inputA, quotient, remainder);
}
Also used : GrowQueue_I8(org.ddogleg.struct.GrowQueue_I8) Test(org.junit.Test)

Aggregations

GrowQueue_I8 (org.ddogleg.struct.GrowQueue_I8)30 Test (org.junit.Test)22 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)3 GrayU16 (boofcv.struct.image.GrayU16)1 File (java.io.File)1 Buffer (java.nio.Buffer)1 ByteBuffer (java.nio.ByteBuffer)1