@Test public void testGcd() throws Exception { }
@Nonnull public Literal gcd(@Nonnull Literal that) { Literal result = newInstance(Math.min(this.size, that.size)); int i = 0; int thisI = 0; int thatI = 0; Variable thisVariable = thisI < this.size ? this.variables[thisI] : null; Variable thatVariable = thatI < that.size ? that.variables[thatI] : null; while (thisVariable != null || thatVariable != null) { int c; if (thisVariable == null) { c = 1; } else if (thatVariable == null) { c = -1; } else { c = thisVariable.compareTo(thatVariable); } if (c < 0) { thisI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; } else if (c > 0) { thatI++; thatVariable = thatI < that.size ? that.variables[thatI] : null; } else { int minPower = Math.min(this.powers[thisI], that.powers[thatI]); result.variables[i] = thisVariable; result.powers[i] = minPower; result.degree += minPower; i++; thisI++; thatI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; thatVariable = thatI < that.size ? that.variables[thatI] : null; } } result.resize(i); return result; }
Literal implements Comparable { @Nonnull public Literal gcd(@Nonnull Literal that) { Literal result = newInstance(Math.min(this.size, that.size)); int i = 0; int thisI = 0; int thatI = 0; Variable thisVariable = thisI < this.size ? this.variables[thisI] : null; Variable thatVariable = thatI < that.size ? that.variables[thatI] : null; while (thisVariable != null || thatVariable != null) { int c; if (thisVariable == null) { c = 1; } else if (thatVariable == null) { c = -1; } else { c = thisVariable.compareTo(thatVariable); } if (c < 0) { thisI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; } else if (c > 0) { thatI++; thatVariable = thatI < that.size ? that.variables[thatI] : null; } else { int minPower = Math.min(this.powers[thisI], that.powers[thatI]); result.variables[i] = thisVariable; result.powers[i] = minPower; result.degree += minPower; i++; thisI++; thatI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; thatVariable = thatI < that.size ? that.variables[thatI] : null; } } result.resize(i); return result; } }
Literal implements Comparable { @Nonnull public Literal gcd(@Nonnull Literal that) { Literal result = newInstance(Math.min(this.size, that.size)); int i = 0; int thisI = 0; int thatI = 0; Variable thisVariable = thisI < this.size ? this.variables[thisI] : null; Variable thatVariable = thatI < that.size ? that.variables[thatI] : null; while (thisVariable != null || thatVariable != null) { int c; if (thisVariable == null) { c = 1; } else if (thatVariable == null) { c = -1; } else { c = thisVariable.compareTo(thatVariable); } if (c < 0) { thisI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; } else if (c > 0) { thatI++; thatVariable = thatI < that.size ? that.variables[thatI] : null; } else { int minPower = Math.min(this.powers[thisI], that.powers[thatI]); result.variables[i] = thisVariable; result.powers[i] = minPower; result.degree += minPower; i++; thisI++; thatI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; thatVariable = thatI < that.size ? that.variables[thatI] : null; } } result.resize(i); return result; } Literal();   Literal(int size); }
Literal implements Comparable { @Nonnull public Literal gcd(@Nonnull Literal that) { Literal result = newInstance(Math.min(this.size, that.size)); int i = 0; int thisI = 0; int thatI = 0; Variable thisVariable = thisI < this.size ? this.variables[thisI] : null; Variable thatVariable = thatI < that.size ? that.variables[thatI] : null; while (thisVariable != null || thatVariable != null) { int c; if (thisVariable == null) { c = 1; } else if (thatVariable == null) { c = -1; } else { c = thisVariable.compareTo(thatVariable); } if (c < 0) { thisI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; } else if (c > 0) { thatI++; thatVariable = thatI < that.size ? that.variables[thatI] : null; } else { int minPower = Math.min(this.powers[thisI], that.powers[thatI]); result.variables[i] = thisVariable; result.powers[i] = minPower; result.degree += minPower; i++; thisI++; thatI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; thatVariable = thatI < that.size ? that.variables[thatI] : null; } } result.resize(i); return result; } Literal();   Literal(int size); static Literal newInstance(); static Literal valueOf(Variable variable); static Literal valueOf(Variable variable, int power); static Literal valueOf(Monomial monomial); int size(); @Nonnull Variable getVariable(int i); int getPower(int i); Literal multiply(@Nonnull Literal that); Literal divide(Literal literal); @Nonnull Literal gcd(@Nonnull Literal that); Literal scm(@Nonnull Literal that); Generic[] productValue(); Power powerValue(); Variable variableValue(); Variable[] variables(); int degree(); int compareTo(@Nonnull Literal that); int compareTo(Object o); String toString(); String toJava(); void toMathML(MathML element, @Nullable Object data); }
Literal implements Comparable { @Nonnull public Literal gcd(@Nonnull Literal that) { Literal result = newInstance(Math.min(this.size, that.size)); int i = 0; int thisI = 0; int thatI = 0; Variable thisVariable = thisI < this.size ? this.variables[thisI] : null; Variable thatVariable = thatI < that.size ? that.variables[thatI] : null; while (thisVariable != null || thatVariable != null) { int c; if (thisVariable == null) { c = 1; } else if (thatVariable == null) { c = -1; } else { c = thisVariable.compareTo(thatVariable); } if (c < 0) { thisI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; } else if (c > 0) { thatI++; thatVariable = thatI < that.size ? that.variables[thatI] : null; } else { int minPower = Math.min(this.powers[thisI], that.powers[thatI]); result.variables[i] = thisVariable; result.powers[i] = minPower; result.degree += minPower; i++; thisI++; thatI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; thatVariable = thatI < that.size ? that.variables[thatI] : null; } } result.resize(i); return result; } Literal();   Literal(int size); static Literal newInstance(); static Literal valueOf(Variable variable); static Literal valueOf(Variable variable, int power); static Literal valueOf(Monomial monomial); int size(); @Nonnull Variable getVariable(int i); int getPower(int i); Literal multiply(@Nonnull Literal that); Literal divide(Literal literal); @Nonnull Literal gcd(@Nonnull Literal that); Literal scm(@Nonnull Literal that); Generic[] productValue(); Power powerValue(); Variable variableValue(); Variable[] variables(); int degree(); int compareTo(@Nonnull Literal that); int compareTo(Object o); String toString(); String toJava(); void toMathML(MathML element, @Nullable Object data);  }