如何将选项放入 MathLink 中的函数中
这与我之前的问题有点相关,但有所不同。我无法弄清楚如何在不使用 Evaluate() 等的情况下提供 MathLink 函数选项。例如,我有以下 C# 代码:
ml.PutFunction("Abs",1);
ml.PutFunction("Fourier",2);
ml.Put(data); //data = double[]
ml.Put("FourierParameters->{-1,1}");
它不起作用。它将 FourierParameters 部分作为文字字符串,而不是选项。我尝试用该字符串创建一个 Expr 并将其放入,但也失败了。这甚至可以在 .NETLink 中做到吗?
This is sort of related to my earlier question, but different. I can't figure out how to give MathLink function options without using Evaluate(), etc. For example, I have the following C# code:
ml.PutFunction("Abs",1);
ml.PutFunction("Fourier",2);
ml.Put(data); //data = double[]
ml.Put("FourierParameters->{-1,1}");
It doesn't work. It puts the FourierParameters part as a literal string, and not an option. I tried creating an Expr with that string and putting that, but that failed too. Is this even possible to do in .NETLink?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遵循此示例页面,似乎该选项必须用PutSymbol输入,并且需要添加一个“Rule”PutFunction。
导致类似的结果(未测试):
Following this example page, seems the option must be entered with PutSymbol, and you need to add a "Rule" PutFunction.
Resulting in something like (not tested):
我会使用高级包装器来做到这一点。例如,可以使用 Mathematica 的所有便利功能编写一个名为 MyFunction 的 Mathematica 函数,该函数调用多个低级 mathlink 函数(例如 myFunction1、myFunction2 等)之一。要调用哪个 mathlink 函数将基于标准选项处理技术数学。
I would do this using high level wrappers. For example, one could write a Mathematica function called MyFunction, using all the conveniences of Mathematica, that calls one of several low level, mathlink functions say myFunction1, myFunction2, etc. Which mathlink function to call would be based on standard option handling techniques within Mathematica.