在 MathLink 中设置 ComplexType
我还有一个。我尝试在 C# 中使用 ml.ComplexType = System.Type.GetType("Complex");
与 Mathematica MathLink,但是当我尝试使用 GetComplexArray 读取数字时,它抛出一个异常,指出我必须使用方法 IMathLink.SetComplexType()
,该方法似乎不存在。
有没有办法在不解析字符串的情况下做到这一点,因为我一生都无法正确地做到这一点?
I have another one. I tried to use ml.ComplexType = System.Type.GetType("Complex");
in C# with the Mathematica MathLink, but when I tried to read the numbers with GetComplexArray, it threw an exception stating that I must use the method IMathLink.SetComplexType()
, which does not appear to exist.
Is there any way to do this without parsing strings, since I can't for the life of me do that correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SetComplexType 的文档位于:http://reference.wolfram.com/mathematica/ NETLink/ref/SetComplexType.html。您还可以通过将“NETLink/ref/SetComplexType”粘贴到 Mathematica 文档中心来找到它。这两个来源都表明您必须在 Mathematica 中使用之前执行
Needs["NETLink
]"。The documentation for SetComplexType is here: http://reference.wolfram.com/mathematica/NETLink/ref/SetComplexType.html. You can also find this by pasting "NETLink/ref/SetComplexType" into the Mathematica documentation center. Both these sources indicate that you must execute
Needs["NETLink
]" prior to use in Mathematica.为了供其他人参考,我自己找到了这个问题的答案。
您要做的就是创建具有必要属性/方法(例如 System.Numerics.Complex)的任何类的虚拟实例,此处名为 myVar。现在假设
ml
是IKernelLink
的实例,调用然后您可以使用
ml.GetComplex()
或ml.GetComplexArray()< /代码>。
For anyone else's reference, I discovered the answer to this one on my own.
What you do is create a dummy instance of any class that has the necessary properties/methods (such as
System.Numerics.Complex
), here namedmyVar
. Now assumingml
is an instance ofIKernelLink
, callYou can then use
ml.GetComplex()
orml.GetComplexArray()
.