Matrices
A matrix is a two-dimensional data structure consisting of numbers arranged in rows and columns.
Definition
A matrix with m rows and n columns is called an m × n
matrix or m-by-n
matrix, while m
and n
are called its dimensions.
For example, the following is a 2 × 3
matrix (2
rows and 3
columns):
1 2 3
4 5 6
Operations on Matrices
- Matrix Addition and Subtraction: Matrices of the same dimensions can be added or subtracted element by element.
- Scalar Multiplication: A matrix can be multiplied by a scalar by multiplying each element of the matrix by the scalar.
- Matrix Multiplication: Two matrices can be multiplied if the number of columns in the first matrix is equal to the number of rows in the second matrix. The result is a new matrix whose elements are computed as dot products of the rows of the first matrix with the columns of the second.
- Determinant: The determinant is a special number that can be calculated from a square matrix.
- Transpose: The transpose of a matrix is found by interchanging its rows into columns or columns into rows.
- Inverse: The inverse of a matrix
A
is a matrix denoted byA^-1
such that whenA
is multiplied byA^-1
the result is the identity matrix. The inverse of a matrix only exists for square, non-singular matrices.
Applications
Matrices are used widely in fields like physics for describing systems of linear equations, in computer graphics for transforming 3D models, in computer vision for camera calibration, in machine learning for representing datasets and much more.