*G7* offers basic matrix operations on matrices, one or two at a time, but not yet long expressions involving many terms. For other vector operations, see the *vc*, *vmake*, and related commands.

The available commands are

mcopy: | Copy one matrix to another; the two do not need to be in the same VAM file. The routine also can copy vectors. |
---|---|

madd: | Add or subtract two matrices in the default Vam file. |

mmult: | Multiply two matrices in the standard matrix algebra way, perform element-by-element multiplication or division, multiply two matrices after transposing the first, select the greater or lesser elements of the two matrices, or multiply or divide matrix elements by a constant. |

minv: | Invert the matrix. |

linv: | Form the Leontief inverse of a matrix. |

mtrans: | Form the transpose of a matrix. |

The operations can be limited to a single year or can operate over the range specified by *fdates*. Here are the details of the commands.

**mcopy [bank letter.]<destination> [bank letter.]<source> [year]**

Examples:

```
mcopy AM = FM 2000
```

Copies the FM matrix for the year 2000 from the default VAM file into the AM matrix in the same file.

```
mcopy AM = FM
```

Same as above, except that the copy is done for all the years in the *fdates* range.

```
mcopy AM = c.FM
```

Copies the FM matrix in the VAM file assigned as bank c to the AM matrix in the default VAM file for all years in the *fdates* range.

```
mcopy d.AM = c.FM 1995
```

Copies the FM matrix from the VAM file assigned as bank c to the AM matrix in the VAM file assigned as bank d. The copy is performed for 1995 only.

If AM and FM in these examples do not have the same dimensions, the copy is done the smaller number of rows and the smaller number of columns. If the optional year is not provided, then the operation is performed over the range specified by the *fdates*.

All of the other matrix commands operate only on matrices in the default VAM file.

Matrix addition or subtration of matrices, all in the default VAM file. If the optional year specification is absent, the operation is done over the *fdates* range.

Matrix algebra multiplication of matrices ‘B’ and ‘C’. Matrices must be conformable and dimensions of ‘A’ appropriate for the product. Alternatively, B or C may be a constant.

Matrix ‘B’ is transposed before matrix multiplication.

Element-by-element multiplication of matrix ‘B’ by matrix ‘C’. Alternatively, B or C may be a constant.

Element-by-element division of matrix ‘B’ by matrix ‘C’. Alternatively, B or C may be a constant.

Assign elements of A to the lesser or greater values of elements in ‘B’ and ‘C’.

Place the transpose of ‘B’ into ‘A’.

Replace ‘A’ with its inverse.

Subtract the ‘A’ matrix from the identity matrix, invert the result, and replace ‘A’ with the result.