# Chapter 8: Matrices

A **matrix** is an array of elements that follow certain rules:

We use square brackets to enclose the array.

A matrix has rows and columns, and is said to be of order .

Always mention the *rows* first.
Thus, the above example is

## Examples

is

is

is

is

A matrix is **square** if the `# of rows`

== `# of columns`

.

Some common square matrices:

**zero matrix**is all`0`

s**identity matrix**is all`0`

s except along the main diagonal (top left to bottom right) is`1`

s

In computer graphics, we most commonly use square , , and matrices.

## Operations

Two matrices are equal if

- they have the same
`# of rows and columns`

- their corresponding elements in each position are equal

If , then and .

### Addition and Subtraction

Addition and subtraction of matrices is defined by addition and subtraction of corresponding elements.

*We can only add and subtract matrices of the same order.*