MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Use of mathlink in C++

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55724] Re: Use of mathlink in C++
  • From: Mario Drobics <mario.drobics at scch.at>
  • Date: Tue, 5 Apr 2005 03:20:44 -0400 (EDT)
  • References: <d2qjc5$p1e$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

depending on the type of structure you use, ypu have to do three loops 
to transfer the 3d array. the basic code to transfer an array looks 
something like this (let con be an stl container like std::list<T>, 
where T is either another list or a double):

void putElement(std::list<T> const & con) {
	MLPutFunction(getLink(), "List", con.size());
	for (std::list<T>::const_iterator iter = con.begin(); iter != 
con.end(); iter++)
		putElement(*iter);

}

and for the basic data type:

void putElement(float & elem)
{
	MLPutFloat(getLink(), elem);
}

getLink() should return the current mathlink you are using.

hope that helps,
-mario-

Ryan Tibshirani wrote:
> Hi everyone, I have a question:
> 
> I want to pass a three-dimensional array of real numbers from C++ to 
> Mathematica, and I want to call Mathematica's ContourPlot3D function 
> (from within the C++ program) to graph a contour plot using this array 
> as the input data.  Can someone respond with a bit of sample C++ code on 
> how to do this?
> 
> Thanks very much
> Ryan Tibshirani
> 


  • Prev by Date: Re: Front End Memory usage while exporting many graphics
  • Next by Date: spiral cipher
  • Previous by thread: Re: Use of mathlink in C++
  • Next by thread: Re: Use of mathlink in C++