The Problem.
I have a C++ class that does some computations, and returns a C++ vector object (the length of which can possibly vary with each run).
I want to store each of these vectors as a list in Mathematica, so, for instance, if three iterations returns the vectors (0, 1)
, (0.02, 0.9)
and (0.04, 0.73)
, I want this output to be written into a Mathematica list of the form {{0,1},{0.02, 0.9},{0.04, 0.73}}
.
My limitations.
This is the first time I am trying to mess with MathLink. Having spent all of today trying to get this to work, I'm feeling pretty lost. The documentation that has shipped with my Mathematica distribution, is helpful only in that I know what to do to write most of the template file. But I can't quite understand how to finish it, and what to do next.
Operating System and other information
I am on a Mac running Snow Leopard 10.6.8. Mathematica is installed in the usual place: /Applications/Mathematica.app
Code
First, what I believe are the relevant portions of the C++ code that I already have
#include<iostream>
#include<vector>
#include<deque>
#include<cmath>
// and a bunch of other files
class mp{
// stuff that defines the class
public:
// some functions
vector <long double> viewCurrent(); // returns the (t, x) vector for the current state of the
// system; note that x can be a vector itself
};
What I would like is to store the output of mp::viewCurrent()
into Mathematica lists. How do I do this?
double
instead oflong double
. $\endgroup$ – Szabolcs Jul 23 '12 at 6:41