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());
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations