/** * Returns the fieldpolynomial as a new Bitstring. * * @return a copy of the fieldpolynomial as a new Bitstring */ public final GF2Polynomial getFieldPolynomial() { if (fieldPolynomial == null) { computeFieldPolynomial(); } return new GF2Polynomial(fieldPolynomial); }
/** * Performs a basis transformation of this element to the given GF2nField * <tt>basis</tt>. * * @param basis the GF2nField representation to transform this element to * @return this element in the representation of <tt>basis</tt> */ public final GF2nElement convert(GF2nField basis) { return mField.convert(this, basis); }
/** * Compute <tt>this + addend</tt> (overwrite <tt>this</tt>). * * @param addend the addend */ public void addToThis(GFElement addend) throws RuntimeException { if (!(addend instanceof GF2nONBElement)) { throw new RuntimeException(); } if (!mField.equals(((GF2nONBElement)addend).mField)) { throw new RuntimeException(); } for (int i = 0; i < mLength; i++) { mPol[i] ^= ((GF2nONBElement)addend).mPol[i]; } }
/** * Creates a new GF2nPolynomialElement using the given field and Bitstring. * * @param f the GF2nPolynomialField to use * @param bs the desired value as Bitstring */ public GF2nPolynomialElement(GF2nPolynomialField f, GF2Polynomial bs) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(bs); polynomial.expandN(mDegree); }
/** * Compare this element with another object. * * @param other the other object * @return <tt>true</tt> if the two objects are equal, <tt>false</tt> * otherwise */ public boolean equals(Object other) { if (other == null || !(other instanceof GF2nPolynomialElement)) { return false; } GF2nPolynomialElement otherElem = (GF2nPolynomialElement)other; if (mField != otherElem.mField) { if (!mField.getFieldPolynomial().equals( otherElem.mField.getFieldPolynomial())) { return false; } } return polynomial.equals(otherElem.polynomial); }
B1.computeCOBMatrix(this); return; u = B1.getRandomRoot(fieldPolynomial);
/** * @return the hash code of this element */ public int hashCode() { return mField.hashCode() + polynomial.hashCode(); }
u = B1.getRandomRoot(fieldPolynomial);
if (i == -1) computeCOBMatrix(basis); i = fields.indexOf(basis);
/** * Create a new random GF2nPolynomialElement using the given field and * source of randomness. * * @param f the GF2nField to use * @param rand the source of randomness */ public GF2nPolynomialElement(GF2nPolynomialField f, Random rand) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree); randomize(rand); }
/** * Compare this element with another object. * * @param other the other object * @return <tt>true</tt> if the two objects are equal, <tt>false</tt> * otherwise */ public boolean equals(Object other) { if (other == null || !(other instanceof GF2nPolynomialElement)) { return false; } GF2nPolynomialElement otherElem = (GF2nPolynomialElement)other; if (mField != otherElem.mField) { if (!mField.getFieldPolynomial().equals( otherElem.mField.getFieldPolynomial())) { return false; } } return polynomial.equals(otherElem.polynomial); }
B1.computeCOBMatrix(this); return; u = B1.getRandomRoot(fieldPolynomial);
/** * @return the hash code of this element */ public int hashCode() { return mField.hashCode() + polynomial.hashCode(); }
u = B1.getRandomRoot(fieldPolynomial);
if (i == -1) computeCOBMatrix(basis); i = fields.indexOf(basis);
/** * Creates a new GF2nPolynomialElement using the given field and Bitstring. * * @param f the GF2nPolynomialField to use * @param bs the desired value as Bitstring */ public GF2nPolynomialElement(GF2nPolynomialField f, GF2Polynomial bs) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(bs); polynomial.expandN(mDegree); }
/** * Compute <tt>this + addend</tt> (overwrite <tt>this</tt>). * * @param addend the addend * @throws DifferentFieldsException if the elements are of different fields. */ public void addToThis(GFElement addend) throws RuntimeException { if (!(addend instanceof GF2nONBElement)) { throw new RuntimeException(); } if (!mField.equals(((GF2nONBElement)addend).mField)) { throw new RuntimeException(); } for (int i = 0; i < mLength; i++) { mPol[i] ^= ((GF2nONBElement)addend).mPol[i]; } }
GF2Polynomial c = new GF2Polynomial(mDegree); GF2Polynomial u = getGF2Polynomial(); GF2Polynomial v = mField.getFieldPolynomial(); GF2Polynomial h; while (true) b.addToThis(mField.getFieldPolynomial()); b.shiftRightThis();
/** * Returns the fieldpolynomial as a new Bitstring. * * @return a copy of the fieldpolynomial as a new Bitstring */ public final GF2Polynomial getFieldPolynomial() { if (fieldPolynomial == null) { computeFieldPolynomial(); } return new GF2Polynomial(fieldPolynomial); }
/** * Performs a basis transformation of this element to the given GF2nField * <tt>basis</tt>. * * @param basis the GF2nField representation to transform this element to * @return this element in the representation of <tt>basis</tt> * @throws DifferentFieldsException if <tt>this</tt> cannot be converted according to * <tt>basis</tt>. */ public final GF2nElement convert(GF2nField basis) throws RuntimeException { return mField.convert(this, basis); }