/** * @return the hash code of this polynomial */ public int hashCode() { return getDegree() + coeff.hashCode(); }
/** * @return the hash code of this polynomial */ public int hashCode() { return getDegree() + coeff.hashCode(); }
public final boolean equals(Object other) { if (other == null || !(other instanceof GF2nPolynomial)) { return false; } GF2nPolynomial otherPol = (GF2nPolynomial)other; if (getDegree() != otherPol.getDegree()) { return false; } int i; for (i = 0; i < size; i++) { if (!coeff[i].equals(otherPol.coeff[i])) { return false; } } return true; }
public final boolean equals(Object other) { if (other == null || !(other instanceof GF2nPolynomial)) { return false; } GF2nPolynomial otherPol = (GF2nPolynomial)other; if (getDegree() != otherPol.getDegree()) { return false; } int i; for (i = 0; i < size; i++) { if (!coeff[i].equals(otherPol.coeff[i])) { return false; } } return true; }
GF2nPolynomial shift; GF2nElement factor; int bDegree = b.getDegree(); GF2nElement inv = (GF2nElement)b.coeff[bDegree].invert(); if (a.getDegree() < bDegree) int i = a.getDegree() - bDegree; while (i >= 0) factor = (GF2nElement)a.coeff[a.getDegree()].multiply(inv); shift = b.scalarMultiply(factor); shift.shiftThisLeft(i); a.shrink(); result[0].coeff[i] = (GF2nElement)factor.clone(); i = a.getDegree() - bDegree;
GF2nPolynomial shift; GF2nElement factor; int bDegree = b.getDegree(); GF2nElement inv = (GF2nElement)b.coeff[bDegree].invert(); if (a.getDegree() < bDegree) int i = a.getDegree() - bDegree; while (i >= 0) factor = (GF2nElement)a.coeff[a.getDegree()].multiply(inv); shift = b.scalarMultiply(factor); shift.shiftThisLeft(i); a.shrink(); result[0].coeff[i] = (GF2nElement)factor.clone(); i = a.getDegree() - bDegree;
/** * Computes the greatest common divisor of <i>this</i> and <i>g</i> and * returns the result in a new PolynomialGF2n. * * @param g - * a GF2nPolynomial * @return gcd(<i>this</i>, <i>g</i>) */ public final GF2nPolynomial gcd(GF2nPolynomial g) { GF2nPolynomial a = new GF2nPolynomial(this); GF2nPolynomial b = new GF2nPolynomial(g); a.shrink(); b.shrink(); GF2nPolynomial c; GF2nPolynomial result; GF2nElement alpha; while (!b.isZero()) { c = a.remainder(b); a = b; b = c; } alpha = a.coeff[a.getDegree()]; result = a.scalarMultiply((GF2nElement)alpha.invert()); return result; }
b = c; alpha = a.coeff[a.getDegree()]; result = a.scalarMultiply((GF2nElement)alpha.invert()); return result;