Abstract
MathCode is a package that translates a subset of Mathematica into a compiled language like Fortran or C++. The chief goal of the design of Math-Code is to add extra performance and portability to the symbolic prototyp-ing capabilities offered by Mathematica. This article discusses several important features of MathCode, such as adding type declarations, examples of functions that can be translated, ways to extend the compilable subset, and generating a stand-alone executable, and presents a few application examples. ‡ Introduction MathCode is a Mathematica add-on that translates a Mathematica program into C++ or Fortran 90. The subset of Mathematica that MathCode is able to translate involves purely numerical operations, and no symbolic operations. In the following sections we provide a variety of examples that show precisely what we mean. The code that is generated can be called and run from within Mathematica, as if you were running a Mathematica function. There are two important purposes that are served by MathCode. Firstly, the C++/ Fortran 90 code runs faster, typically by a factor of about a few hundreds (or about 50 to 100) over interpreted (compiled) Mathematica code, resulting in considerable performance gains, while still requiring hardly any knowledge of C++/Fortran 90 on the part of the user. Secondly, the generated code can also be executed as a stand-alone program outside Mathematica, offering a portability otherwise not possible. You should note, however, that these advantages come at some loss of generality since integer and floating point overflow are not trapped and switched to arbitrary precision as in standard Mathematica code. Here the user is responsible for ensuring an appropriate choice of scaling and input data to matica 6.
Cite
CITATION STYLE
Fritzson, P., Engelson, V., & Sheshadri, K. (2008). MathCode: A System for C++ or Fortran Code Generation from Mathematica. The Mathematica Journal, 10(4). https://doi.org/10.3888/tmj.10.4-7
Register to see more suggestions
Mendeley helps you to discover research relevant for your work.