Next: MATC Internal Functions Up: MATC Matrix Language Previous: MATC Operators

# MATC Function Statement

The syntax of the function definition is given below.

    function name(arg1,arg2,...)
    !
    ! Optional function description (seen with help("name"))
    !
    import var1,var2
    export var3,var4
    {
        expr;
         ...
        expr;

        _name = value
    }

Functions have their own list of variables. Global variables are not seen in this function unless imported by import or given as arguments. Local variables can be made global by the export statement.

Functions, if returing matrices, behave in many ways as variables do. So if you have defined function mult as follows

    function mult(a,b)
    {
       _mult = a*b;
    }

you can get element (3,5) of the a times b matrix by the following statement

    mult(x,y)[3,5]

or diagonal values of the same matrix by

    diag(mult(x,y)).