use of org.matheclipse.core.interfaces.IExpr in project symja_android_library by axkr.
the class ASCIIPrintTest method testTen.
public void testTen() {
IExpr expr = F.C10;
String s1 = " ";
String s2 = "10";
String s3 = " ";
check(expr, s1, s2, s3);
}
use of org.matheclipse.core.interfaces.IExpr in project symja_android_library by axkr.
the class ASCIIPrintTest method testOne.
public void testOne() {
IExpr expr = F.C1;
String s1 = " ";
String s2 = "1";
String s3 = " ";
check(expr, s1, s2, s3);
}
use of org.matheclipse.core.interfaces.IExpr in project symja_android_library by axkr.
the class ASCIIPrintTest method testMinusOne.
public void testMinusOne() {
IExpr expr = F.CN1;
String s1 = " ";
String s2 = "-1";
String s3 = " ";
check(expr, s1, s2, s3);
}
use of org.matheclipse.core.interfaces.IExpr in project symja_android_library by axkr.
the class EvalComplex method evalSymbol.
public static double[] evalSymbol(final ISymbol symbol) {
if (symbol.hasLocalVariableStack()) {
final IExpr expr = symbol.get();
if (expr instanceof ISignedNumber) {
final double[] result = new double[2];
result[0] = ((ISignedNumber) expr).doubleValue();
result[1] = 0.0;
return result;
}
if (expr instanceof ComplexNum) {
final double[] result = new double[2];
result[0] = ((ComplexNum) expr).getRealPart();
result[1] = ((ComplexNum) expr).getImaginaryPart();
return result;
}
}
if (symbol.isSignedNumberConstant()) {
// fast evaluation path
final double[] result = new double[2];
result[0] = ((ISignedNumberConstant) ((IBuiltInSymbol) symbol).getEvaluator()).evalReal();
result[1] = 0.0;
return result;
}
if (symbol.isBuiltInSymbol()) {
final IEvaluator module = ((IBuiltInSymbol) symbol).getEvaluator();
if (module instanceof INumericComplexConstant) {
// fast evaluation path
return ((INumericComplexConstant) module).evalComplex();
}
}
// slow evaluation path
final IExpr result = F.evaln(symbol);
if (result instanceof ComplexNum) {
final double[] res = new double[2];
res[0] = ((ComplexNum) result).getRealPart();
res[1] = ((ComplexNum) result).getImaginaryPart();
return res;
}
if (result instanceof Num) {
final double[] res = new double[2];
res[0] = ((Num) result).doubleValue();
res[1] = 0.0;
return res;
}
throw new UnsupportedOperationException();
}
use of org.matheclipse.core.interfaces.IExpr in project symja_android_library by axkr.
the class EvalComplex method evalAST.
public static double[] evalAST(final DoubleStack stack, final int top, final IAST ast) {
final int newTop = top;
final ISymbol symbol = (ISymbol) ast.get(0);
if (symbol.isBuiltInSymbol()) {
final IEvaluator module = ((IBuiltInSymbol) symbol).getEvaluator();
if (module instanceof INumericComplex) {
// fast evaluation path
stack.ensureCapacity(top + ast.size() * 2);
for (int i = 1; i < ast.size(); i++) {
final double[] result = eval(stack, newTop, ast.get(i));
stack.push(result[0]);
stack.push(result[1]);
}
return ((INumericComplex) module).evalComplex(stack, ast.size() - 1);
}
}
// slow evaluation path
final IExpr result = F.evaln(ast);
if (result instanceof ComplexNum) {
final double[] res = new double[2];
res[0] = ((ComplexNum) result).getRealPart();
res[1] = ((ComplexNum) result).getImaginaryPart();
return res;
}
if (result instanceof Num) {
final double[] res = new double[2];
res[0] = ((Num) result).doubleValue();
res[1] = 0.0;
return res;
}
throw new UnsupportedOperationException();
}
Aggregations