Search in sources :

Example 1 with DoubleVariable

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

the class EvalDoubleTestCase method testEval004.

public void testEval004() {
    try {
        IDoubleValue vd = new DoubleVariable(3.0);
        DoubleEvaluator engine = new DoubleEvaluator();
        engine.defineVariable("x", vd);
        double d = engine.evaluate("x^2+3");
        assertEquals(Double.valueOf(d).toString(), "12.0");
        vd.setValue(4);
        d = engine.evaluate();
        assertEquals(Double.valueOf(d).toString(), "19.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 2 with DoubleVariable

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

the class EvalDoubleTestCase method testInterpolatingFunction.

public void testInterpolatingFunction() {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        engine.setCallbackFunction(CoreCallbackFunction.CONST);
        engine.defineVariable("x", new DoubleVariable(3.0));
        double d = engine.evaluate("InterpolatingFunction[{{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}][x]");
        assertEquals(Double.toString(d), "4.0");
    } catch (MathException e) {
        e.printStackTrace();
        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) DoubleVariable(org.matheclipse.parser.client.eval.DoubleVariable)

Example 3 with DoubleVariable

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

the class EvalDoubleTestCase 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 4 with DoubleVariable

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

the class EvalDoubleCallbackTestCase method testInterpolatingFunction.

public void testInterpolatingFunction() {
    try {
        DoubleEvaluator engine = new DoubleEvaluator();
        engine.setCallbackFunction(CoreCallbackFunction.CONST);
        engine.defineVariable("x", new DoubleVariable(3.0));
        double d = engine.evaluate("Interpolation[{{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}][x]");
        assertEquals(Double.toString(d), "4.0");
    } catch (MathException e) {
        e.printStackTrace();
        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) DoubleVariable(org.matheclipse.parser.client.eval.DoubleVariable)

Example 5 with DoubleVariable

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

the class EvalDoubleCallbackTestCase method testEval004.

public void testEval004() {
    try {
        IDoubleValue vd = new DoubleVariable(3.0);
        DoubleEvaluator engine = new DoubleEvaluator();
        engine.defineVariable("x", vd);
        double d = engine.evaluate("x^2+3");
        assertEquals(Double.valueOf(d).toString(), "12.0");
        vd.setValue(4);
        d = engine.evaluate();
        assertEquals(Double.valueOf(d).toString(), "19.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)

Aggregations

DoubleVariable (org.matheclipse.parser.client.eval.DoubleVariable)9 MathException (org.matheclipse.parser.client.math.MathException)9 DoubleEvaluator (org.matheclipse.parser.client.eval.DoubleEvaluator)8 IDoubleValue (org.matheclipse.parser.client.eval.IDoubleValue)6 SymjaMathException (org.matheclipse.core.eval.exception.SymjaMathException)1