/** * Compute the difference of this element and <tt>minuend</tt>. * * @param minuend the minuend * @return <tt>this - minuend</tt> (newly created) * @throws DifferentFieldsException if the elements are of different fields. */ public final GFElement subtract(GFElement minuend) throws RuntimeException { return add(minuend); }
/** * Compute the difference of this element and <tt>minuend</tt>, * overwriting this element. * * @param minuend the minuend */ public final void subtractFromThis(GFElement minuend) { addToThis(minuend); }
public final void assignZeroToElements() { int i; for (i = 0; i < size; i++) { coeff[i].assignZero(); } }
m = (GF2nElement)n.clone(); for (int j = 1; j <= k; j++) m.squareThis(); n.multiplyThisBy(m); n.squareThis(); n.multiplyThisBy(this); n.squareThis();
GF2nElement factor; int bDegree = b.getDegree(); GF2nElement inv = (GF2nElement)b.coeff[bDegree].invert(); if (a.getDegree() < bDegree) while (i >= 0) factor = (GF2nElement)a.coeff[a.getDegree()].multiply(inv); shift = b.scalarMultiply(factor); shift.shiftThisLeft(i); a = a.add(shift); a.shrink(); result[0].coeff[i] = (GF2nElement)factor.clone(); i = a.getDegree() - bDegree;
return (GF2nElement)elem.clone(); return (GF2nElement)elem.clone(); GF2nElement elemCopy = (GF2nElement)elem.clone(); if (elemCopy instanceof GF2nONBElement) GF2Polynomial bs = new GF2Polynomial(mDegree, elemCopy.toFlexiBigInt()); bs.expandN(mDegree); GF2Polynomial result = new GF2Polynomial(mDegree);
/** * Creates a new PolynomialGF2n by cloning the given PolynomialGF2n <i>a</i>. * * @param a the PolynomialGF2n to clone */ public GF2nPolynomial(GF2nPolynomial a) { int i; coeff = new GF2nElement[a.size]; size = a.size; for (i = 0; i < size; i++) { coeff[i] = (GF2nElement)a.coeff[i].clone(); } }
/** * Returns the degree of this PolynomialGF2n. * * @return the degree of this PolynomialGF2n. */ public final int getDegree() { int i; for (i = size - 1; i >= 0; i--) { if (!coeff[i].isZero()) { return i; } } return -1; }
GF2nElement[] res = new GF2nElement[k]; System.arraycopy(coeff, 0, res, 0, size); GF2nField f = coeff[0].getField(); if (coeff[0] instanceof GF2nPolynomialElement)
/** * Multiplies the scalar <i>s</i> to each coefficient of this * PolynomialGF2n and returns the result in a new PolynomialGF2n. * * @param s the scalar to multiply * @return <i>this</i> x <i>s</i> */ public final GF2nPolynomial scalarMultiply(GF2nElement s) { GF2nPolynomial result = new GF2nPolynomial(size()); int i; for (i = 0; i < size(); i++) { result.coeff[i] = (GF2nElement)coeff[i].multiply(s); // result[i] // = // a[i]*s } return result; }
/** * 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; }
m = (GF2nElement)n.clone(); for (int j = 1; j <= k; j++) m.squareThis(); n.multiplyThisBy(m); n.squareThis(); n.multiplyThisBy(this); n.squareThis();
GF2nElement factor; int bDegree = b.getDegree(); GF2nElement inv = (GF2nElement)b.coeff[bDegree].invert(); if (a.getDegree() < bDegree) while (i >= 0) factor = (GF2nElement)a.coeff[a.getDegree()].multiply(inv); shift = b.scalarMultiply(factor); shift.shiftThisLeft(i); a = a.add(shift); a.shrink(); result[0].coeff[i] = (GF2nElement)factor.clone(); i = a.getDegree() - bDegree;
return (GF2nElement)elem.clone(); return (GF2nElement)elem.clone(); GF2nElement elemCopy = (GF2nElement)elem.clone(); if (elemCopy instanceof GF2nONBElement) GF2Polynomial bs = new GF2Polynomial(mDegree, elemCopy.toFlexiBigInt()); bs.expandN(mDegree); GF2Polynomial result = new GF2Polynomial(mDegree);