I am writing a routine in C++ where I will end up having to perform a very difficult integral which I believe will be difficult/inefficient to approximate numerically.
My desire is to spawn a child process using fork() and have that process launch a Mathematica kernel to evaluate the integral. (The script will be pre-written with the variable definitions as command line arguments).
As of right now, the only thing I know to do is to have Mathematica write the final value of the integral to a file and have the parent process spin (looking for the file to be written) and then read the value of the file once it is done.
Is there a more efficient way to do this? I know there is a lot of overhead with the writing to a file and spinning until the file is complete, but I don't know how to send/receive signals with Mathematica. Is there any way to open up a piece of shared memory between Mathematica and my program so that the value can be written to memory instead of having two processes read/write a file?
Any other ideas I haven't thought of, or way to speed up this technique, would be greatly appreciated.
You can use MathLink to talk to a copy of mathematica. Or you can embed mathematica libraries into your application to do the calculations.
The options are covered here, with specific references to mathlink here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With