Using the mathemagix interpreter

This tutorial describes how to use the mathemagix interpreter.

1.Using the interpreter

The mathemagix interpreter starts with the command:

If you use the interpreter in a textual context, several shortcuts can be very useful such as

Different modes are available:

Information about an object or a function can obtained with the command help:

Mmx] 

help infix +

+ : (Vector (Generic), Vector (Generic)) -> Vector (Generic)
(Native)

+ : (Generic, Vector (Generic)) -> Vector (Generic)
(Native)
+ : (Vector (Generic), Generic) -> Vector (Generic)
(Native)
+ : (Double, Double) -> Double
(Native)
+ : (Int, Int) -> Int
(Native)

+ : (Syntactic, Syntactic) -> Syntactic
(Native)

Mmx] 

2.Loading mathemagix files

A quick description of the syntax of the language is available here.

A classical way to develop mathemagix code is to edit files and load them from the interpreter. As an example, we give below the content of a file step1.mmx (in mmxtools/mmx):

It can be used from the interpreter as follows:

Mmx] 

include "mmxlight/step1.mmx"

Mmx] 

f 57

Mmx] 

3.Using mathemagix files as scripts

The interpreter can be used directly with a file:

Mathemagix files can also be used as scripts, as shown in this example:

If this code is put in a file, say mean, it can be used as follows:

provided that the command mmx-light is available.

4.Loading a package

The command to load and use the types and functions exported by an external library is use:


      

Here the dynamic library libmmxpackage.so will be searched in the loading path (see variable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH).

5.The environment files

The first time the shell is launched it creates a .mathemagix in the home directory. A warning is printed.

The file .mathemagix/etc/boot.mmx is automatically loaded at startup. This is the right place to customize the shell and to load the packages you frequently use. In order to load packages you can proceed as follows:

Prior to user's boot file a global boot file (usually /usr/local/etc/mathemagix/boot.mmx) is loaded. In case you wish to disable both boot files use the option –noboot within the mmx-light command.

Within an interactive session, ending a line with a ';' actually means finishing with a null instruction. As a consequence this extra ';' prevents from printing the output of the previous instruction.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License. If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.