Search code examples
c#.netwolfram-mathematicamathlink

Getting data from MathLink connections


I'm trying to create a C# library (DLL) that calls Mathematica 8 using the .NET/Link protocol. Specifically, I'm using it for things like FFTs, etc. Right now I'm using EvaluateToOutputForm and parsing the resulting string for doubles. Anytime I try using Evaluate() and GetDoubleArray(), it gives the error message (exception) that I'm trying to read from data of the wrong dimensionality. Even using Evaluate("2+2") and then GetInteger() fails with the error that the waiting data isn't an integer (basically).

The problem with EvaluateToOutputForm() is that the numbers I'm parsing from, say, Abs@Fourier[data] are wrong for non-trivial (e.g. fairly long) inputs. I can't tell what's going wrong. Can anyone here help me?


Solution

  • OutputForm is really only useful for viewing the result. You really want to be using InputForm here, as it maintains the full precision of the numbers in the result. The InputForm syntax is well defined and parseable. InputForm also never results in pseudo-2D formatting like OutputForm.