• Matrices as collections of column vectors

  • Transpose

  • Matrices as collections of row vectors

  • Sparse matrices

Matrices as collections of column vectors

Matrices can be viewed simply as a collection of (column) vectors of same size, that is, as a collection of points in a multi-dimensional space.

Matrices can be described as follows: given n vectors a_1,ldots,a_n in mathbf{R}^m, we can define the m times n matrix A with a_j's as columns:

 A = left(begin{array}{ccc} a_1 & ldots & a_n end{array}right).

Geometrically, A represents n points in a m-dimensional space. The notation mathbf{R}^{m times n} denotes the set of m times n matrices.

With our convention, a column vector in mathbf{R}^{n} is thus a matrix in mathbf{R}^{n times 1}, while a row vector in mathbf{R}^{n} is a matrix in mathbf{R}^{1 times n}.

Transpose

The notation A_{ij} denotes the element of A sitting in row i and column j. The transpose of a matrix A. denoted by A^T, is the matrix with (i,j) element A_{ji}, i=1,ldots,m, j=1,ldots,n.

Matrices as collections of rows

Similarly, we can describe a matrix in row-wise fashion: given m vectors b_1,ldots,b_m in mathbf{R}^n, we can define the m times n matrix B with the transposed vectors b_i^T as rows:

 B = left( begin{array}{c} b_1^T  vdots  b_m^T end{array}right) .

Geometrically, B represents m points in a n-dimensional space.

Matlab syntax
>> A = [1 2 3; 4 5 6]; % a 2x3 matrix
>> B = A'; % this is the transpose of matrix A
>> B = [1 4; 2 5; 3 6]; % B can also be declared that way
>> C = rand(4,5); % a random 4x5 matrix

Examples:

Sparse Matrices

In many applications, one has to deal with very large matrices that are sparse, that is, they have many zeros. It often makes sense to use a sparse storage convention to represent the matrix.

One of the most common formats involves only listing the non-zero elements, and their associated locations (i,j) in the matrix. In Matlab, the function sparse allows to create a sparse matrix based on that information. The user needs also to specify the size of the matrix (it cannot infer it from just the above information).

Matlab syntax
>> S = sparse([3 2 3 4 1],[1 2 2 3 4],[1 2 3 4 5],4,4) % creates a 4x4 matrix
>> S = [0 0 0 5; 0 2 0 0; 1 3 0 0; 0 0 4 0]; % the same matrix with ordinary convention