Search in sources :

Example 11 with DoubleEvaluator

use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.

the class EvalDoubleTestCase method check.

public void check(String in, String compareWith) {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        double d = engine.evaluate(in);
        assertEquals(Double.valueOf(d).toString(), compareWith);
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : DoubleEvaluator(org.matheclipse.parser.client.eval.DoubleEvaluator) MathException(org.matheclipse.parser.client.math.MathException)

Example 12 with DoubleEvaluator

use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.

the class EvalDoubleCallbackTestCase method testMissingFunction009.

public void testMissingFunction009() {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        double d = engine.evaluate("aTest[1.0]");
        assertEquals(Double.toString(d), "");
    } catch (MathException e) {
        assertEquals("EvalDouble#evaluateFunction(FunctionNode) not possible for: aTest(1.0)", e.getMessage());
    }
}
Also used : DoubleEvaluator(org.matheclipse.parser.client.eval.DoubleEvaluator) MathException(org.matheclipse.parser.client.math.MathException)

Example 13 with DoubleEvaluator

use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.

the class EvalDoubleCallbackTestCase method check.

public void check(String in, String compareWith) {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        double d = engine.evaluate(in);
        assertEquals(Double.valueOf(d).toString(), compareWith);
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals(e.getMessage(), compareWith);
    }
}
Also used : DoubleEvaluator(org.matheclipse.parser.client.eval.DoubleEvaluator) MathException(org.matheclipse.parser.client.math.MathException)

Example 14 with DoubleEvaluator

use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.

the class EvalDoubleCallbackTestCase method testEval005.

public void testEval005() {
    try {
        IDoubleValue vd = new DoubleVariable(3.0);
        DoubleEvaluator engine = new DoubleEvaluator();
        engine.defineVariable("x", vd);
        double d = engine.evaluate("x^2*x^2-1");
        assertEquals(Double.valueOf(d).toString(), "80.0");
        vd.setValue(4);
        d = engine.evaluate();
        assertEquals(Double.valueOf(d).toString(), "255.0");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : DoubleEvaluator(org.matheclipse.parser.client.eval.DoubleEvaluator) IDoubleValue(org.matheclipse.parser.client.eval.IDoubleValue) DoubleVariable(org.matheclipse.parser.client.eval.DoubleVariable) MathException(org.matheclipse.parser.client.math.MathException)

Example 15 with DoubleEvaluator

use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.

the class EvalDoubleCallbackTestCase method testEval009.

public void testEval009() {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        BooleanVariable vb = new BooleanVariable(true);
        engine.defineVariable("$1", vb);
        double d = engine.evaluate("If[$1, 1, 0]");
        Assert.assertEquals(d, 1d, DoubleEvaluator.EPSILON);
        vb.setValue(false);
        d = engine.evaluate();
        Assert.assertEquals(d, 0d, DoubleEvaluator.EPSILON);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.assertEquals("", e.getMessage());
    }
}
Also used : DoubleEvaluator(org.matheclipse.parser.client.eval.DoubleEvaluator) BooleanVariable(org.matheclipse.parser.client.eval.BooleanVariable) MathException(org.matheclipse.parser.client.math.MathException)

Aggregations

DoubleEvaluator (org.matheclipse.parser.client.eval.DoubleEvaluator)19 MathException (org.matheclipse.parser.client.math.MathException)19 DoubleVariable (org.matheclipse.parser.client.eval.DoubleVariable)8 IDoubleValue (org.matheclipse.parser.client.eval.IDoubleValue)6 BooleanVariable (org.matheclipse.parser.client.eval.BooleanVariable)4