gpt4 book ai didi

java - symja 数学解析器无法识别 Abs[x]

转载 作者:行者123 更新时间:2023-11-30 07:41:01 25 4
gpt4 key购买 nike

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

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

向我抛出一个错误:org.matheclipse.parser.client.math.ArithmeticMathException:EvalDouble#evaluateFunction(FunctionNode) 不可能用于:Abs(x)和

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]");

}

}

最佳答案

(感谢堆栈跟踪和下载地址)

此问题已在几个小时前得到修复,最新版本应该可以解决该问题:

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

关于java - symja 数学解析器无法识别 Abs[x],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34698277/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com