How MathLink Is Used
MathLink provides a mechanism through which programs can interact with Mathematica.
| • Calling functions in an external program from within Mathematica. |
| • Calling Mathematica from within an external program. |
| • Setting up alternative front ends to Mathematica. |
| • Exchanging data between Mathematica and external programs. |
| • Exchanging data between concurrent Mathematica processes. |
Some typical uses of MathLink.
MathLink provides a general interface for external programs to communicate with Mathematica. Many standard software systems now have MathLink compatibility either built in or available in add-on modules.
In addition, the MathLink Developer Kit bundled with most versions of Mathematica provides the tools you need to create your own MathLink-compatible programs.
Once you have a MathLink-compatible program, you can transparently establish a link between it and Mathematica.
The link can either be on a single computer, or it can be over a network, potentially with a different type of computer at each end.
| • Implementing inner loops in a low-level language. |
| • Handling large volumes of data external to Mathematica. |
| • Sending Mathematica graphics or other data for special processing. |
| • Connecting to a system with an existing user interface. |
A few uses of MathLink-compatible programs.
MathLink-compatible programs range from very simple to very complex. A minimal MathLink-compatible program is just a few lines long. But it is also possible to build very large and sophisticated MathLink-compatible programs. Indeed, the Mathematica notebook front end is one example of a sophisticated MathLink-compatible program.
Much of the power of MathLink comes from its use of Mathematica expressions. The basic idea is that MathLink provides a way to exchange Mathematica expressions between programs, and such expressions can represent absolutely any kind of data.
| • An array of numbers. |
| • A collection of geometrical objects. |
| • A sequence of commands. |
| • A stream of text. |
| • Records in a database. |
| • The cells of a Mathematica notebook. |
A few examples of data represented by Mathematica expressions in MathLink.
The MathLink library consists of a collection of routines that allow external programs to send and receive Mathematica expressions using the fundamental C data types.
The MathLink Developer Kit provides utilities for incorporating these routines into external programs. Utilities are included for a variety of languages, although here we discuss mainly the case of C.
An important feature of the MathLink library is that it is completely platform independent: it can transparently use any interprogram communication mechanism that exists on your computer system.
