Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: a mathlink question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89648] Re: a mathlink question
  • From: dh <dh at metrohm.ch>
  • Date: Mon, 16 Jun 2008 06:40:30 -0400 (EDT)
  • References: <g32q5m$c2t$1@smc.vnet.net>


Hi,

obviously you would need some memory for the last value of the sum. This 

can conveniently be implemented as a static variable in C. care must be 

taken to initialize it correctly. More cumbersome would be to keep the 

memory in a Mathematica variable and transfere it each time the function is called.

hope this helps, Daniel



GS wrote:

> I would like to call a C-program from Mathematica. All the examples in

> the MathLink tutorials (like AddTwo[i,j]) work like this: they are

> called from Mathematica, are executed, send the result to Mathematica

> and exit.

> 

> I would like a C-program to not exit after the execution, and keep the

> memory of the previous inputs. Say, I want an external C-program, to

> be called as AddToPreviousSum[x]. When it is first called, it returns

> x. When it is called the second time AddToPreviousSum[y], it returns x

> +y. When it is called the third time AddToPreviousSum[z], it returns x

> +y+z, and so on.

> 

> How do I implement this in C using MathLink?

> 

> Thanks.

> GS.

> 





-- 



Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at metrohm.com>

Internet:<http://www.metrohm.com>




  • Prev by Date: Re: DiffMaps package
  • Next by Date: Making nice-looking Legend for Plot
  • Previous by thread: Re: a mathlink question
  • Next by thread: Nested Grids