/** * Convert the symbolName to lowercase (if <code>Config.PARSER_USE_LOWERCASE_SYMBOLS</code> is set) and insert a new * Symbol in the <code>PREDEFINED_SYMBOLS_MAP</code>. The symbol is created using the given upper case string to use * it as associated class name in package org.matheclipse.core.reflection.system. * * @param symbolName * the predefined symbol name in upper-case form * @return */ public static ISymbol initFinalHiddenSymbol(final String symbolName) { ISymbol temp = new Symbol(symbolName, org.matheclipse.core.expression.Context.DUMMY); HIDDEN_SYMBOLS_MAP.put(symbolName, temp); return temp; }
/** {@inheritDoc} */ public void clearAll(EvalEngine engine) { clear(engine); fAttributes = NOATTRIBUTE; }
/** * Compares this expression with the specified expression for order. Returns a * negative integer, zero, or a positive integer as this expression is * canonical less than, equal to, or greater than the specified expression. */ @Override public int compareTo(final IExpr obj) { if (obj instanceof MethodSymbol) { return fMethod.toString().compareTo(((MethodSymbol) obj).fMethod.toString()); } return super.compareTo(obj); }
/** {@inheritDoc} */ @Override public IExpr evaluate(EvalEngine engine) { if (hasLocalVariableStack()) { return ExprUtil.ofNullable(get()); } IExpr result; if ((result = evalDownRule(engine, this)).isPresent()) { return result; } return F.NIL; }
/** {@inheritDoc} */ @Override public IExpr evaluate(EvalEngine engine) { if (hasLocalVariableStack()) { return get(); } IExpr result; if ((result = evalDownRule(engine, this)) != null) { return result; } final IEvaluator module = getEvaluator(); if (module instanceof ISymbolEvaluator) { if (engine.isNumericMode()) { return ((ISymbolEvaluator) module).numericEval(this); } return ((ISymbolEvaluator) module).evaluate(this); } return null; }
/** * {@inheritDoc} */ @Override public boolean hasAssignedSymbolValue() { if (hasLocalVariableStack()) { return get() != null; } else { if (fRulesData != null) { PatternMatcherEquals pme = fRulesData.getEqualDownRules().get(this); if (pme != null) { return pme.getRHS() != null; } } } return false; }
IExpr[] result = new IExpr[2]; IExpr symbolValue; if (hasLocalVariableStack()) { symbolValue = get(); result[0] = symbolValue; IExpr calculatedResult = function.apply(symbolValue); if (calculatedResult.isPresent()) { set(calculatedResult); result[1] = calculatedResult; return result; engine.printMessage(toString() + " is not a variable with a value, so its value cannot be changed."); return null;
/** {@inheritDoc} */ @Override public final INumber evalNumber() { if (isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } else if (hasLocalVariableStack()) { IExpr temp = get(); if (temp != null && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } } else { IExpr temp = evalDownRule(EvalEngine.get(), this); if (temp.isPresent() && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isNumber()) { return (INumber) result; } } } return null; }
@Override public boolean isNumericFunction() { if (isConstant()) { return true; } if (hasLocalVariableStack()) { IExpr temp = get(); if (temp != null && temp != this && temp.isNumericFunction()) { return true; } } else { IExpr temp = evalDownRule(EvalEngine.get(), this); if (temp.isPresent() && temp.isNumericFunction()) { return true; } } return false; }
IExpr[] result = new IExpr[2]; IExpr symbolValue; if (hasLocalVariableStack()) { symbolValue = get(); result[0] = symbolValue; IExpr calculatedResult = function.apply(symbolValue); if (calculatedResult != null) { set(calculatedResult); result[1] = calculatedResult; return result;
/** {@inheritDoc} */ @Override public String definitionToString() throws IOException { StringWriter buf = new StringWriter(); IAST attributesList = AttributeFunctions.attributesList(this); OutputFormFactory off = OutputFormFactory.get(EvalEngine.get().isRelaxedSyntax()); off.setIgnoreNewLine(true); IAST list = definition(); buf.append("Attributes("); buf.append(this.toString()); buf.append(")="); buf.append(attributesList.toString()); buf.append("\n"); for (int i = 1; i < list.size(); i++) { off.convert(buf, list.get(i)); if (i < list.size() - 1) { buf.append("\n"); off.setColumnCounter(0); } } return buf.toString(); }
/** {@inheritDoc} */ public String definitionToString() throws IOException { // dummy call to ensure, that the associated rules are loaded: getEvaluator(); StringBufferWriter buf = new StringBufferWriter(); buf.setIgnoreNewLine(true); List<IAST> list = definition(); buf.append("{"); for (int i = 0; i < list.size(); i++) { OutputFormFactory.get().convert(buf, list.get(i)); if (i < list.size() - 1) { buf.append(",\n "); } } buf.append("}\n"); return buf.toString(); }
/** {@inheritDoc} */ @Override public boolean isValue() { return evaluate(EvalEngine.get()) != null; }
/** {@inheritDoc} */ public void pushLocalVariable() { pushLocalVariable(null); }
if (lst.get(i).isSymbol()) { variables.add(lst.get(i)); ((Symbol) lst.get(i)).pushLocalVariable(); } else { if (lst.get(i).isAST(F.Set, 3)) { if (setFun.get(1).isSymbol()) { variables.add(setFun.get(1)); ((Symbol) setFun.get(1)).pushLocalVariable(engine.evaluate(setFun.get(2))); ((Symbol) variables.get(i)).popLocalVariable();
final IExpr lastTimesHeader = ((IAST) lastTimes).head(); if ((lastTimesHeader == F.Power) && (((IAST) lastTimes).size() == 3)) { final int cp = compareTo(((IAST) lastTimes).get(1)); if (cp != 0) { return cp; final int cp = compareTo(lastTimes); if (cp != 0) { return cp; return (hierarchy() - (obj).hierarchy());
/** {@inheritDoc} */ @Override public boolean isPolynomialOfMaxDegree(ISymbol variable, long maxDegree) { if (maxDegree == 0L) { if (this.equals(variable)) { return false; } } return true; }
IExpr[] result = new IExpr[2]; IExpr symbolValue; if (hasLocalVariableStack()) { symbolValue = get(); result[0] = symbolValue; set(calculatedResult); result[1] = calculatedResult; return result; throw new WrongArgumentType(this, functionSymbol.toString() + " - Symbol: " + toString() + " has no value! Reassignment with a new value is not possible");
/** {@inheritDoc} */ @Override public final ISignedNumber evalReal() { if (isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } else if (hasLocalVariableStack()) { IExpr temp = get(); if (temp != null && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } } else { IExpr temp = evalDownRule(EvalEngine.get(), this); if (temp.isPresent() && temp.isNumericFunction()) { IExpr result = F.evaln(this); if (result.isReal()) { return (ISignedNumber) result; } } } return null; }
/** * {@inheritDoc} */ @Override public IExpr getAssignedValue() { if (hasLocalVariableStack()) { return get(); } else { if (fRulesData != null) { PatternMatcherEquals pme = fRulesData.getEqualDownRules().get(this); if (pme != null) { return pme.getRHS(); } } } return null; }