# MATC

Jump to: navigation, search

Elmer uses MATC to evaluate mathematical expressions in the Solver Input Files. Also ElmerPost includes MATC.

MATC was written by Juha Ruokolainen.

You can find the official manual at http://www.nic.funet.fi/pub/sci/physics/elmer/doc/MATCManual.pdf

## Using MATC

### Embedding in sif files

There are two options for embedding MATC in Solver Input Files. Variables can be defined as

```gravity = Real \$ 0 0 -1 *9.81 ! evaluation at program start
```

Which would be evaluated once at program start. or by

```gravity = Real MATC 0 0 -1 * 9.81 ! evaluation at every use
```

which is evaluated every time the gravity variable is used.

### Calling MATC from the command line

MATC can be called from the command line by calling \$ELMER_HOME/bin/matc. Under Unix/Linux this should be part of your \$PATH and calling matc should suffice.

To quit using command line MATC type quit .

## Operator Precedence

The mathematical operations are evaluated from high to low precedence and within each level from left to right (everything as usual).

The most important operators ordered from high to low precedence:

```() (parentheses)
' ' (SPACE as a separator for vector components)
^ (power)
*/
+-
```

A full list can be found in the MATC Manual.

### Scalars and Vectors

Vectors in MATC are written by separating their entries with spaces. Since the space forming vectors has a higher precedence than the algebraic operations

```min(3*4 2) = min(12 6) = 6
```

while

```min((3*4) 2) = min(12 2) = 2
```

this can lead to strange behavior of boundary conditions if the parentheses are forgotten.