Math Processor provides several functions for creating, manipulating and obtaining information about matrices. A matrix is created using the matrix function. Its use is demonstrated in the following MP code snippet:

{

a = array (1,2,3) :

b = array (4,5,6) :

matrix_1 = matrix (a, b) :

matrix_2 = matrix (array(4,5,6), array(5,7,8)) :

matrix_3 = matrix (1,2,3,4) :

matrix_3 = matrix (array(1,2,3,4)) :

matrix_3 = matrix (a, array(5,4,3), b) :

}

For full details on MP's matrix support visit the Matrix Operations section.

**Note:** MP provides a GUI tool called Matrix Easy Kit for convenient manipulation of matrices in a GUI environment. However, the command line functions provide more power in certain cases.

It is important to understand the behavior of ordinary operators on matrices. The operators **+, -, *, /, % **and **^** can be used with matrices. Their usage and meaning depends upon the context. Following sections will describe how the supported operations are performed.

Unary + and - can be applied to matrices like other numeric variables. Unary + will have no effect. Unary - will perform member-wise negation. Unary operators performed in series will act like in ordinary arithmetic.

It is possible to perform addition between matrices of same order as well as between a matrix and a scalar (i.e. a single value). An array with just one item or a matrix of order 1 x 1 are also treated as single values for addition and subtraction. The addition is commutative (i.e. order of the operands is not important) while subtraction is not.

It is possible to multiply two matrices in accordance with normal matrix rules. Division is not defined between two matrices. However, multiplication, division and remainder operation between a matrix and a scalar (i.e. a single numeric value) create a matrix by performing member-wise multiplication, division or remainder operation respectively. An array of just one item or a matrix of order 1 x 1 are also treated as a single value for these operations. Multiplication is commutative (i.e. order of the operands is not important) while division and remainder are not.

Be very careful while using the power operator (^) with matrices. Operator ^ is used for member-wise power operation. This is different from multiplying a square matrix with itself **n** number of times.

For example **matrix_a ^ 4** will produce a new matrix having the same order as matrix_a by raising each member of the matrix_a to the power 4. Conversely, **4 ^ matrix_a** will create a matrix by raising 4 to member-wise times of the matrix_a.

If you want to multiply a square matrix **n** number of times with itself, use the multiplication operator instead.

1AvM287k9ocUbqp6SPhGLzyGqFx3JZFcSA

Your donations will help keep this free service running.