Example usage for org.apache.commons.math3.exception MathRuntimeException printStackTrace

List of usage examples for org.apache.commons.math3.exception MathRuntimeException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception MathRuntimeException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.matheclipse.commons.parser.util.Console.java

/**
 * Evaluates the given string-expression and returns the result in string
 * form.//from  w  w w.j a va 2 s .co  m
 * 
 * @param strEval
 * @return the result in string for
 */
public String interpreter(final String strEval) {
    try {
        if (fComplexEvaluatorMode) {
            ComplexEvaluator engine = new ComplexEvaluator(true);
            Parser p = new Parser(engine.isRelaxedSyntax());
            ASTNode obj = p.parse(strEval);
            if (obj instanceof FunctionNode) {
                obj = engine.optimizeFunction((FunctionNode) obj);
            }
            Complex c = engine.evaluateNode(obj);
            return ComplexEvaluator.toString(c);
        } else {
            DoubleEvaluator engine = new DoubleEvaluator(true);
            double d = engine.evaluate(strEval);
            return Double.toString(d);
        }
    } catch (MathRuntimeException e) {
        System.err.println();
        System.err.println(e.getMessage());
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
    return "";
}