@Nonnull @Override public Constant getConstant() { if (constant == null) { constant = new Constant(this.name); } return constant; }
@Nonnull @Override public String getName() { return this.constant.getName(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ExtendedConstant)) return false; ExtendedConstant that = (ExtendedConstant) o; if (!constant.equals(that.constant)) return false; return true; }
public Generic substitute(Variable variable, Generic generic) { Constant v = (Constant) newInstance(); for (int i = 0; i < subscripts.length; i++) { v.subscripts[i] = subscripts[i].substitute(variable, generic); } if (v.isIdentity(variable)) { return generic; } else { return v.expressionValue(); } }
public Generic expand() { Constant v = (Constant) newInstance(); for (int i = 0; i < subscripts.length; i++) { v.subscripts[i] = subscripts[i].expand(); } return v.expressionValue(); }
protected void operator(MathML element, String name) { Variable variable[] = toVariables((JsclVector) GenericVariable.content(parameters[1])); MathML e1 = element.element("msub"); new Constant(name).toMathML(e1, null); MathML e2 = element.element("mrow"); for (int i = 0; i < variable.length; i++) variable[i].expressionValue().toMathML(e2, null); e1.appendChild(e2); element.appendChild(e1); } }
public String toJava() { final IConstant constantFromRegistry = JsclMathEngine.getInstance().getConstantsRegistry().get(getName()); if (constantFromRegistry != null) { return constantFromRegistry.toJava(); } final StringBuilder result = new StringBuilder(); result.append(name); if (prime != 0) { if (prime <= PRIME_CHARS) result.append(underscores(prime)); else result.append("_").append(prime); } for (Generic subscript : subscripts) { result.append("[").append(subscript.integerValue().intValue()).append("]"); } return result.toString(); }
return Constants.INF.getName(); } else { return Constants.INF.expressionValue().negate().toString(); final IConstant piInv = this.getConstantsRegistry().get(Constants.PI_INV.getName()); if (piInv != null && value.equals(piInv.getDoubleValue())) { constant = piInv;
@Override public int hashCode() { return constant.hashCode(); }
@Override public boolean isIdDefined() { return constant.isIdDefined(); }
@Nonnull @Override public Integer getId() { return constant.getId(); }
@Override public int compareTo(ExtendedConstant o) { return this.constant.compareTo(o.getConstant()); } }
@Override public void copy(@Nonnull MathEntity that) { this.constant.copy(that); if (that instanceof IConstant) { this.description = ((IConstant) that).getDescription(); this.value = ((IConstant) that).getValue(); } if (that instanceof ExtendedConstant) { this.javaString = ((ExtendedConstant) that).javaString; } }
public void toMathML(MathML element, Object data) { int exponent = data instanceof Integer ? (Integer) data : 1; if (exponent == 1) bodyToMathML(element); else { MathML e1 = element.element("msup"); bodyToMathML(e1); MathML e2 = element.element("mn"); e2.appendChild(element.text(String.valueOf(exponent))); e1.appendChild(e2); element.appendChild(e1); } }
protected void operator(MathML element, String name) { Variable variable[] = toVariables(GenericVariable.content(parameters[1])); MathML e1 = element.element("msubsup"); new Constant(name).toMathML(e1, null); MathML e2 = element.element("mrow"); for (int i = 0; i < variable.length; i++) variable[i].expressionValue().toMathML(e2, null); e1.appendChild(e2); e2 = element.element("mo"); e2.appendChild(element.text("T")); e1.appendChild(e2); element.appendChild(e1); }
public Generic factorize() { Constant v = (Constant) newInstance(); for (int i = 0; i < subscripts.length; i++) { v.subscripts[i] = subscripts[i].factorize(); } return v.expressionValue(); }
@Override @Nonnull public String toJava() { if (javaString != null) { return javaString; } else if (value != null) { return String.valueOf(value); } else { return constant.getName(); } }
@Nonnull public Variable newInstance() { return new Constant(name, prime, new Generic[subscripts.length]); }
public Generic elementary() { Constant v = (Constant) newInstance(); for (int i = 0; i < subscripts.length; i++) { v.subscripts[i] = subscripts[i].elementary(); } return v.expressionValue(); }
@Override protected String getSubstituteFromJscl(@Nonnull String match) { return Constants.INF_2.getName().equals(match) ? MathType.INFINITY : super.getSubstituteFromJscl(match); } },