MathGroup Archive 2011

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

Search the Archive

Re: outputting C code

  • To: mathgroup at
  • Subject: [mg116744] Re: outputting C code
  • From: Oliver Ruebenkoenig <ruebenko at>
  • Date: Fri, 25 Feb 2011 06:38:41 -0500 (EST)


On Thu, 24 Feb 2011, HonestMath wrote:

> Thank you for your reply, I studied the examples you presented.
> It looks like I am able to create some code for external use.
> However, I wonder if enough code is generated or if some is in byte
> code for that platform.  Let me elaborate.  I want to know if it is
> possible to create a function that calls built-in Mathematica
> functions, and use this in an external software package.

Yes and no; for example Sin[] is a build in function and you can compile 
that, however, NDSolve[] is also a build in function and you can not 
compile that one. If you can compile the functions in question then you 
can generate C code. To check if the compiled code needs a call back to 
the M- evaluator, I usually use CompilePrint and see if there is a call to 

> For example,  if I have an application meant for use on an Android
> device, is it possible for Mathematica to give me all I need to
> generate a Java library, or C source code that can be compiled for a
> Java device?  As compilation is device dependent, it seems it might be
> limited to the device on which Mathematica is running.  If you have
> Mathematica for Windows, it generates Windows code, if on a Mac, it
> generates Mac code.  Is this correct, or is there a way to get all I
> need to run on an Android, Palm, or iphone?
> Cheers!

Oh, this is definitely out of my turf... Here are some notes on how to 
build for a different target system

And the section on setting the compiler.


> On Feb 23, 3:23 am, Oliver Ruebenkoenig <ruebe... at> wrote:
>> On Wed, 23 Feb 2011, HonestMath wrote:
>>> Hello all,
>>> I know that Mathematica 8 contains the ability to export your
>>> functions to C code. I am wondering what the extent of that might be.
>>> If my function were to contain references to built in Mathematica
>>> functions, are those too output?
>>> Is it possible to use built-in functions for use in an external
>>> library?
>>> Cheers,
>>> Matt
>> Hallo Matt,
>> you might want to consult the documentation for this
>> see for example:
>> CCodeGenerator/tutorial/Examples#659427467
>> ref/LiftingFilterData#258228157
>> those should get your started
>> hth,
>> Oliver

  • Prev by Date: Re: FinancialData Function Not Working for Property "Members"
  • Next by Date: Re: Mathematica Weirdness
  • Previous by thread: Re: outputting C code
  • Next by thread: Re: outputting C code