use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class F method initFinalSymbol.
/**
* Insert a new Symbol in the <code>SYSTEM</code> context.
*
* @param symbolName
* the predefined symbol name in upper-case form
* @param evaluator
* defines the evaluation behaviour of the symbol
* @return
*/
public static IBuiltInSymbol initFinalSymbol(final String symbolName, IEvaluator evaluator) {
IBuiltInSymbol temp = new BuiltInSymbol(symbolName, evaluator);
evaluator.setUp(temp);
Context.SYSTEM.put(symbolName, temp);
return temp;
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class F method initFinalSymbol.
/**
* 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 IBuiltInSymbol initFinalSymbol(final String symbolName) {
IBuiltInSymbol temp = new BuiltInSymbol(symbolName);
Context.SYSTEM.put(symbolName, temp);
return temp;
}
use of org.matheclipse.core.interfaces.IBuiltInSymbol in project symja_android_library by axkr.
the class DoubleStackEvaluator method evalAST.
public static double evalAST(double[] stack, final int top, final IAST ast) {
final ISymbol symbol = (ISymbol) ast.get(0);
if (symbol.isBuiltInSymbol()) {
final IEvaluator module = ((IBuiltInSymbol) symbol).getEvaluator();
if (module instanceof INumeric) {
int newTop = top;
// fast evaluation path
if (top + ast.size() >= stack.length) {
stack = new double[ast.size() + 50];
}
for (int i = 1; i < ast.size(); i++) {
++newTop;
stack[newTop] = DoubleStackEvaluator.eval(stack, newTop, ast.get(i));
}
return ((INumeric) module).evalReal(stack, newTop, ast.size() - 1);
}
}
// slow evaluation path
final IExpr result = F.evaln(ast);
if (result instanceof Num) {
return ((Num) result).doubleValue();
}
throw new UnsupportedOperationException("EvalDouble#evalAST(): " + ast);
}
Aggregations