/** * Compute <tt>this + addend</tt> (overwrite <tt>this</tt>). * * @param addend the addend */ public void addToThis(GFElement addend) throws RuntimeException { if (!(addend instanceof GF2nPolynomialElement)) { throw new RuntimeException(); } if (!mField.equals(((GF2nPolynomialElement)addend).mField)) { throw new RuntimeException(); } polynomial.addToThis(((GF2nPolynomialElement)addend).polynomial); }
/** * 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 GF2nPolynomialElement)) { throw new RuntimeException(); } if (!mField.equals(((GF2nPolynomialElement)addend).mField)) { throw new RuntimeException(); } polynomial.addToThis(((GF2nPolynomialElement)addend).polynomial); }
/** * Shifts left b and adds the result to Its a fast version of * <tt>this = add(b.shl(k));</tt> * * @param b GF2Polynomial to shift and add to this * @param k the amount to shift * @see GF2nPolynomialElement#invertEEA */ public void shiftLeftAddThis(GF2Polynomial b, int k) { if (k == 0) { addToThis(b); return; } int i; expandN(b.len + k); int d = k >>> 5; for (i = b.blocks - 1; i >= 0; i--) { if ((i + d + 1 < blocks) && ((k & 0x1f) != 0)) { value[i + d + 1] ^= b.value[i] >>> (32 - (k & 0x1f)); } value[i + d] ^= b.value[i] << (k & 0x1f); } }
/** * Shifts left b and adds the result to Its a fast version of * <tt>this = add(b.shl(k));</tt> * * @param b GF2Polynomial to shift and add to this * @param k the amount to shift * @see GF2nPolynomialElement#invertEEA */ public void shiftLeftAddThis(GF2Polynomial b, int k) { if (k == 0) { addToThis(b); return; } int i; expandN(b.len + k); int d = k >>> 5; for (i = b.blocks - 1; i >= 0; i--) { if ((i + d + 1 < blocks) && ((k & 0x1f) != 0)) { value[i + d + 1] ^= b.value[i] >>> (32 - (k & 0x1f)); } value[i + d] ^= b.value[i] << (k & 0x1f); } }