use of org.matheclipse.parser.client.eval.DoubleEvaluator 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());
}
}
use of org.matheclipse.parser.client.eval.DoubleEvaluator 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());
}
}
use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.
the class EvalDoubleTestCase method testEval003.
public void testEval003() {
try {
DoubleEvaluator engine = new DoubleEvaluator();
double d = engine.evaluate("Sin[Pi/2*Cos[Pi]]");
assertEquals(Double.toString(d), "-1.0");
} catch (Exception e) {
e.printStackTrace();
assertEquals("", e.getMessage());
}
}
use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.
the class EvalDoubleTestCase 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());
}
}
use of org.matheclipse.parser.client.eval.DoubleEvaluator in project symja_android_library by axkr.
the class EvalDoubleTestCase method testEval006.
public void testEval006() {
try {
DoubleEvaluator engine = new DoubleEvaluator();
BooleanVariable vb = new BooleanVariable(true);
engine.defineVariable("$1", vb);
BooleanVariable vb2 = new BooleanVariable(true);
engine.defineVariable("$2", vb2);
double d = engine.evaluate("If[$1 && $2, 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());
}
}
Aggregations