1

我已经导入了 .jar 文件,但是

DoubleEvaluator engine = new DoubleEvaluator();
engine.defineVariable("x", -1);
engine.evaluate("Abs[x]");

给我一个错误:org.matheclipse.parser.client.math.ArithmeticMathException: EvalDouble#evaluateFunction(FunctionNode) not possible for: Abs(x) and

engine.evaluate("Sin[x]");

才不是。这可能是什么原因?

Exception in thread "main" org.matheclipse.parser.client.math.ArithmeticMathException: EvalDouble#evaluateFunction(FunctionNode) not possible for: Abs(x)
at org.matheclipse.parser.client.eval.DoubleEvaluator.evaluateFunction(DoubleEvaluator.java:563)
at org.matheclipse.parser.client.eval.DoubleEvaluator.evaluateNode(DoubleEvaluator.java:493)
at org.matheclipse.parser.client.eval.DoubleEvaluator.evaluate(DoubleEvaluator.java:460)
at javaapplication14.JavaApplication14.main(JavaApplication14.java:24)
Java Result: 1

并且示例运行

import org.matheclipse.parser.client.eval.DoubleEvaluator;

public class application {

public static void main(String[] args) {

    DoubleEvaluator engine = new DoubleEvaluator();

    engine.defineVariable("x",-1);
    engine.evaluate("Abs[x]");

}

}

4

1 回答 1

1

(感谢stacktrace和下载地址)

这个问题已经在几个小时前修复了,最新版本应该可以解决这个问题:

https://bitbucket.org/axelclk/symja_android_library/downloads/symjaMMA2016-01-09.zip

添加了缺失的函数 Abs:

FUNCTION_DOUBLE_MAP.put("Abs", new IDouble1Function() {
   public double evaluate(double arg1) {
      return Math.abs(arg1);
   }
 });

查看差异: https ://bitbucket.org/axelclk/symja_android_library/diff/symja_android_library/matheclipse-parser/src/main/java/org/matheclipse/parser/client/eval/DoubleEvaluator.java?diff2=c84fa1c92f83&at=master

于 2016-01-09T20:10:14.167 回答