Message Boards Message Boards

GROUPS:

c/c++ code generation

Posted 7 months ago
1239 Views
|
1 Reply
|
2 Total Likes
|

Hello, can I use Mathematica to generate c/c++ code that I can Include in an external program that can run independently of Mathematica, for example after developing a control algorithm or a machine learning model using wolfram Mathematica can I generate c/c++ code/ library that I can include in a project?

POSTED BY: Joseph Mbayi

Hi Joseph, yes, the Wolfram Language can do those, but not in an holistic way. For the C/C++ code generation you have to create a compiled function (look up the Wolfram Compiler on Google). From there you've got two paths: 1. Generate C code using the CCodeGenerator or 2. directly leverage the Compiler to get extremely fast and optimized compiled code, that you can then call from your stand-alone programs or run that at a very high speed within your Notebook. For the Neural Network exporting, it's extremely simple: You can just use Export to save your model in the MXNet format or the ONNX one (adviced).

Last thing that I wanted to add, is that you can use the Wolfram Language without the Mathematica front-end, exactly like you do with your Python or Perl programs, and if you want to integrate your Wolfram code with other programs, there are other ways, that are way easier than having to deal with code compilation (not the totality of the Wolfram Language can be compiled, for obvious reasons).

POSTED BY: Nicolò Monti
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract