A matrix is a 2D array of elements with m rows and n columns. The elements in the 2D array might be real numbers, complex numbers, functions, or operators. The matrix A shown below is an array of m rows and n columns with m × n elements.
Here, ai, j denotes the (i, j)th element located in the ith row and the jth column. In general, such a matrix is a rectangular matrix. When m = n so that the number of rows is equal to the number of columns, the matrix is a square matrix. An m × 1 matrix—m rows and one column—is a column vector. A row vector is a 1 × n matrix—one row and n columns. If all the elements other than the diagonal elements are zero—that is, a i, j = 0, i ≠ j—such a matrix is a diagonal matrix. For example,
is a diagonal matrix. A diagonal matrix with all the diagonal elements equal to one is an identity matrix, also known as unit matrix. If all the elements below the main diagonal are zero, the matrix is an upper triangular matrix. On the other hand, if all the elements above the main diagonal are zero, the matrix is a lower triangular matrix. When all the elements are real numbers, the matrix is a real matrix. On the other hand, when at least one of the elements of the matrix is a complex number, the matrix is a complex matrix.