public Generic derivative(int n) { int c[] = new int[derivations.length]; for (int i = 0; i < c.length; i++) { if (i == n) c[i] = derivations[i] + 1; else c[i] = derivations[i]; } return new ImplicitFunction(name, parameters, c, subscripts).selfExpand(); }
public Generic selfElementary() { return expressionValue(); }
public static int[] algebra(Generic generic) { if (generic.signum() == 0) return null; Variable v = generic.variableValue(); if (v instanceof ImplicitFunction) { Generic g[] = ((ImplicitFunction) v).getParameters(); int p = g[0].integerValue().intValue(); int q = g[1].integerValue().intValue(); if (v.compareTo(new ImplicitFunction("cl", new Generic[]{JsclInteger.valueOf(p), JsclInteger.valueOf(q)}, new int[]{0, 0}, new Generic[]{})) == 0) return new int[]{p, q}; } throw new ArithmeticException(); }
nameToMathML(element); } else { MathML e1 = element.element("msup"); nameToMathML(e1); derivationToMathML(e1, n); element.appendChild(e1); if (n == 0) { MathML e1 = element.element("msub"); nameToMathML(e1); MathML e2 = element.element("mrow"); for (Generic subscript : subscripts) { } else { MathML e1 = element.element("msubsup"); nameToMathML(e1); MathML e2 = element.element("mrow"); for (Generic subscript : subscripts) { derivationToMathML(e1, n); element.appendChild(e1);
@Nonnull public Variable newInstance() { return new ImplicitFunction(name, new Generic[parameters.length], derivations, subscripts); } }
public int compareTo(Variable that) { if (this == that) return 0; int c = comparator.compare(this, that); if (c < 0) return -1; else if (c > 0) return 1; else { ImplicitFunction v = (ImplicitFunction) that; c = name.compareTo(v.name); if (c < 0) return -1; else if (c > 0) return 1; else { c = ArrayComparator.comparator.compare(subscripts, v.subscripts); if (c < 0) return -1; else if (c > 0) return 1; else { c = compareDerivation(derivations, v.derivations); if (c < 0) return -1; else if (c > 0) return 1; else return ArrayComparator.comparator.compare(parameters, v.parameters); } } } }
public String toString() { final StringBuilder result = new StringBuilder(); int n = 0; for (int derivation : derivations) { n += derivation; } result.append(name); for (Generic aSubscript : subscripts) { result.append("[").append(aSubscript).append("]"); } if (n == 0) { // do nothing } else if (parameters.length == 1 && n <= Constant.PRIME_CHARS) { result.append(Constant.primeChars(n)); } else { result.append(derivationToString()); } result.append("("); for (int i = 0; i < parameters.length; i++) { result.append(parameters[i]).append(i < parameters.length - 1 ? ", " : ""); } result.append(")"); return result.toString(); }
public String toJava() { final StringBuilder result = new StringBuilder(); int n = 0; for (int derivation : derivations) { n += derivation; } result.append(name); if (n == 0) { // do nothing } else if (parameters.length == 1 && n <= Constant.PRIME_CHARS) { result.append(Constant.underscores(n)); } else { result.append(derivationToJava()); } result.append("("); for (int i = 0; i < parameters.length; i++) { result.append(parameters[i].toJava()).append(i < parameters.length - 1 ? ", " : ""); } result.append(")"); for (Generic subscript : subscripts) { result.append("[").append(subscript.integerValue().intValue()).append("]"); } return result.toString(); }
public void toMathML(MathML element, Object data) { MathML e1; int exponent = data instanceof Integer ? (Integer) data : 1; if (exponent == 1) bodyToMathML(element); else { e1 = element.element("msup"); bodyToMathML(e1); MathML e2 = element.element("mn"); e2.appendChild(element.text(String.valueOf(exponent))); e1.appendChild(e2); element.appendChild(e1); } e1 = element.element("mfenced"); for (Generic parameter : parameters) { parameter.toMathML(e1, null); } element.appendChild(e1); }
static Ordering ordering(Generic generic) { Variable v = generic.variableValue(); if (v.compareTo(new Constant("lex")) == 0) return Monomial.lexicographic; else if (v.compareTo(new Constant("tdl")) == 0) return Monomial.totalDegreeLexicographic; else if (v.compareTo(new Constant("drl")) == 0) return Monomial.degreeReverseLexicographic; else if (v instanceof ImplicitFunction) { Generic g[] = ((ImplicitFunction) v).getParameters(); int k = g[0].integerValue().intValue(); if (v.compareTo(new ImplicitFunction("elim", new Generic[]{JsclInteger.valueOf(k)}, new int[]{0}, new Generic[]{})) == 0) return Monomial.kthElimination(k); } throw new ArithmeticException(); }
return new ImplicitFunction(name, a, derivations, ArrayUtils.toArray(subscripts, new Generic[subscripts.size()]));
public Generic antiDerivative(int n) throws NotIntegrableException { int c[] = new int[derivations.length]; for (int i = 0; i < c.length; i++) { if (i == n) { if (derivations[i] > 0) c[i] = derivations[i] - 1; else throw new NotIntegrableException(this); } else c[i] = derivations[i]; } return new ImplicitFunction(name, parameters, c, subscripts).selfExpand(); }
public Generic selfExpand() { return expressionValue(); }
public Generic selfSimplify() { return expressionValue(); }