/** * checks if given object is equal to this polynomial. * <p> * The method returns false whenever the given object is not polynomial over * GF(2^m). * * @param other object * @return true or false */ public boolean equals(Object other) { if (other == null || !(other instanceof PolynomialGF2mSmallM)) { return false; } PolynomialGF2mSmallM p = (PolynomialGF2mSmallM)other; if ((field.equals(p.field)) && (degree == p.degree) && (isEqual(coefficients, p.coefficients))) { return true; } return false; }
/** * checks if given object is equal to this polynomial. * <p> * The method returns false whenever the given object is not polynomial over * GF(2^m). * * @param other object * @return true or false */ public boolean equals(Object other) { if (other == null || !(other instanceof PolynomialGF2mSmallM)) { return false; } PolynomialGF2mSmallM p = (PolynomialGF2mSmallM)other; if ((field.equals(p.field)) && (degree == p.degree) && (isEqual(coefficients, p.coefficients))) { return true; } return false; }
/** * Compute the square root of this polynomial modulo the given polynomial. * * @param a the reduction polynomial * @return <tt>this^(1/2) mod a</tt> */ public PolynomialGF2mSmallM modSquareRoot(PolynomialGF2mSmallM a) { int[] resultCoeff = IntUtils.clone(coefficients); int[] help = modMultiply(resultCoeff, resultCoeff, a.coefficients); while (!isEqual(help, coefficients)) { resultCoeff = normalForm(help); help = modMultiply(resultCoeff, resultCoeff, a.coefficients); } return new PolynomialGF2mSmallM(field, resultCoeff); }
/** * Compute the square root of this polynomial modulo the given polynomial. * * @param a the reduction polynomial * @return <tt>this^(1/2) mod a</tt> */ public PolynomialGF2mSmallM modSquareRoot(PolynomialGF2mSmallM a) { int[] resultCoeff = IntUtils.clone(coefficients); int[] help = modMultiply(resultCoeff, resultCoeff, a.coefficients); while (!isEqual(help, coefficients)) { resultCoeff = normalForm(help); help = modMultiply(resultCoeff, resultCoeff, a.coefficients); } return new PolynomialGF2mSmallM(field, resultCoeff); }