Examples of Polynomial


Examples of org.rabinfingerprint.polynomial.Polynomial

    this.popTable = that.popTable;
  }

  private void precomputePopTable() {
    for (int i = 0; i < 256; i++) {
      Polynomial f = Polynomial.createFromLong(i);
      f = f.shiftLeft(BigInteger.valueOf(bytesPerWindow * 8));
      f = f.mod(poly);
      popTable[i] = f.toBigInteger().longValue();
    }
  }
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

    super(poly);
    this.byteShift = BigInteger.valueOf(8);
    this.windowShift = BigInteger.valueOf(bytesPerWindow * 8);
    this.bytesPerWindow = bytesPerWindow;
    this.byteWindow = new CircularByteQueue((int) bytesPerWindow + 1);
    this.fingerprint = new Polynomial();
  }
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

   *
   * If we have passed overflowed our window, we pop a byte
   */
  @Override
  public synchronized void pushByte(byte b) {
    Polynomial f = fingerprint;
    f = f.shiftLeft(byteShift);
    f = f.or(Polynomial.createFromLong(b & 0xFFL));
    f = f.mod(poly);

    fingerprint = f;

    if (bytesPerWindow > 0) {
      byteWindow.add(b);
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

   * Note that despite this massive shift, the fingerprint will still result
   * in a k-bit number at the end of the calculation.
   */
  public synchronized void popByte() {
    byte b = byteWindow.poll();
    Polynomial f = Polynomial.createFromLong(b & 0xFFL);
    f = f.shiftLeft(windowShift);
    f = f.mod(poly);

    fingerprint = fingerprint.xor(f);
  }
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

    fingerprint = fingerprint.xor(f);
  }

  @Override
  public synchronized void reset() {
    this.fingerprint = new Polynomial();
    this.byteWindow.clear();
  }
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

   * be xor'red with the fingerprint in the inner loop of our own
   * {@link #pushByte} and {@link #popByte}
   */
  private void precomputePushTable() {
    for (int i = 0; i < 512; i++) {
      Polynomial f = Polynomial.createFromLong(i);
      f = f.shiftLeft(poly.degree());
      f = f.xor(f.mod(poly));
      pushTable[i] = f.toBigInteger().longValue();
    }
  }
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

import org.rabinfingerprint.handprint.Handprints.HandPrintFactory;
import org.rabinfingerprint.polynomial.Polynomial;

public class HandprintTest extends TestCase {
  public void testChunkingFiles() throws IOException {
    Polynomial p = Polynomial.createIrreducible(53);
   
    List<InputStream> sims = TestDataGenerator.getSimilarRandomBytes(4);
    HandPrintFactory factory = Handprints.newFactory(p);
    Handprint hand1 = factory.newHandprint(sims.get(0));
    Handprint hand2 = factory.newHandprint(sims.get(1));
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

   *
   * The polys used are from here:
   * http://en.wikipedia.org/wiki/Finite_field_arithmetic#Rijndael.27s_finite_field
   */
  public void testPolynomialArithmetic() {
    Polynomial pa = Polynomial.createFromLong(0x53);
    Polynomial pb = Polynomial.createFromLong(0xCA);
    Polynomial pm = Polynomial.createFromLong(0x11B);
    Polynomial px = pa.multiply(pb);
    assertEquals(0x3F7E, px.toBigInteger().longValue());
    Polynomial pabm = px.mod(pm);
    assertEquals(0x1, pabm.toBigInteger().longValue());
  }
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

  public Stats getSpread(int degree, int tests) {
    int i = 0;
    int last_i = 0;
    Stats stats = new Stats();
    while (tests > 0) {
      Polynomial f = Polynomial.createRandom(degree);
      Reducibility r = f.getReducibility();
      if (r == Reducibility.IRREDUCIBLE) {
        int spread = i - last_i;
        stats.add(spread);
        last_i = i;
        tests--;
View Full Code Here

Examples of org.rabinfingerprint.polynomial.Polynomial

    byte[] data = new byte[1024];
    Random random = new Random(System.currentTimeMillis());
    random.nextBytes(data);

    // generate random irreducible polynomial
    Polynomial p = Polynomial.createIrreducible(53);
    final Fingerprint<Polynomial> rabin0 = new RabinFingerprintPolynomial(p);
    final Fingerprint<Polynomial> rabin1 = new RabinFingerprintLong(p);
    rabin0.pushBytes(data);
    rabin1.pushBytes(data);
    assertEquals(0, rabin0.getFingerprint().compareTo(rabin1.getFingerprint()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.