Question

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?

Was it helpful?

Solution 2

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 named myVar. Now assuming ml is an instance of IKernelLink, call

ml.ComplexType = myVar.GetType();

You can then use ml.GetComplex() or ml.GetComplexArray().

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top