Engineering Math - Matrix

 

 

 

Rank

 

Rank is an indicator that shows how many of the vectors comprising a matrix are linearly independent to each other. The rank is one number, but it answers several practical questions. It tells you whether a square matrix can be inverted, whether a set of linear equations has a solution, and how many independent streams a MIMO channel can carry.

I'll first define rank with a 3 x 3 example and list the facts worth remembering. Then we'll compute a rank by row reduction and connect it to the determinant and to linear equations. The last section returns to the MIMO example of the summary figure and adds numbers to it.

What does the rank of a matrix count ?

A matrix is a stack of row vectors, or equally a row of column vectors. The rank asks how many of those vectors point in genuinely different directions. A vector that can be built from the others adds no new direction, so it does not raise the rank.

For example, let's suppose we have a matrix as follows.

A general 3 x 3 matrix M with elements a11 to a33

Figure 1. A general 3 x 3 matrix M. The element aij sits in row i and column j.

Let's take each row of the matrix and construct vectors as follows. (These vectors are called 'row vector')

The three rows of M taken out as row vectors v1, v2 and v3

Figure 2. The three rows of M taken out as the row vectors v1, v2 and v3. The rank is the number of these vectors that are linearly independent.

Figure 2 has one typo in the extracted vectors. The vector v2 is the second row, so it should read [a21 a22 a23], not [a21 a22 a33]. The matrix on the left of the figure is correct.

Now the question is how many of these vectors are linearly independent to each other ? The answer to this question is the Rank of the matrix.

    How many of these vectors v1, v2, v3 are linearly independent to each other

The rows are only one way to count. You can also split M into its three column vectors and count how many of those are independent. The answer is always the same number. This is why people speak of the rank of a matrix, and not of a separate row rank and column rank. It also means the rank can never exceed the smaller of the two dimensions. A 3 x 5 matrix has five columns, but they live in a 3-dimensional space, so at most three of them are independent.

The rank of an m x n matrix therefore lies between 0 and min(m, n). Only the zero matrix has rank 0. A matrix that reaches min(m, n) has full rank. A matrix below that value is rank deficient, which means at least one row or column is a combination of the others.

  • Rank counts independent directions : a repeated row, or a row built from other rows, adds nothing to it.
  • Row rank equals column rank : counting rows and counting columns always give the same number.
  • The rank is at most min(m, n) : a 3 x 5 matrix has rank 3 or less.
  • Full rank means no redundancy : no row and no column can be built from the others.

What should you remember about rank ?

The formal definition is short, but it is easy to lose in practice. The summary figure below reduces rank to two statements and one application. Two of those statements need a condition that the figure leaves out, so read the notes under it as well.

Probably this definition itself would sound too dry to you. Just remember followings and try to apply when you need.

Summary of rank, its link to the determinant and a MIMO channel application example

Figure 3. Summary of rank. The rank counts independent vectors, and the MIMO example reads it as the number of independent paths.

  • Top arrow : Rank[M] is the number of vectors in M that are independent of each other.
  • Second arrow : maximum rank means that the determinant of M is not zero. This holds for a square matrix only, because the determinant is defined only for square matrices.
  • Application example : for a MIMO channel matrix, the rank tells how many paths are independent of each other.

Two statements in the figure need a qualifier. First, the link to the determinant works only for an n x n matrix. There, full rank and a nonzero determinant are the same condition, as a later section shows. Second, full rank in a MIMO channel does not mean that the paths do not influence each other. Every receive antenna still hears every transmit antenna. Full rank means that the receiver can separate the streams, because no path is a combination of the others. The MIMO section below adds numbers to this.

For more intuitive explanation, I want to introduce a good video linked here.

  • Square matrices only : rank n and a nonzero determinant are the same condition only for an n x n matrix.
  • Full rank is about separability : the paths still mix, but the mixing can be undone.

How do you find the rank by row reduction ?

Counting independent vectors by eye works only for small textbook cases. For real numbers you need a procedure, and the standard one is row reduction. Row operations change the rows, but they never change the rank. So you reduce the matrix to a simple form and count what is left.

Let's take A = [1, 2, 3; 2, 4, 6; 1, 0, 1], written row by row with semicolons between the rows. Subtract 2 times row 1 from row 2, and subtract row 1 from row 3. Row 2 becomes [0, 0, 0], and row 3 becomes [0, -2, -2]. The two remaining rows, [1, 2, 3] and [0, -2, -2], are clearly independent. So the rank of A is 2.

The zero row tells you why. Row 2 was exactly 2 times row 1, so it carried no new direction. The column view agrees. Column 3 equals column 1 plus column 2, because 3 = 1 + 2, 6 = 2 + 4 and 1 = 1 + 0. So A sends the vector (-1, -1, 1) to zero.

Three row operations are allowed, and none of them changes the rank. You may swap two rows. You may multiply a row by a nonzero number. You may add a multiple of one row to another row. After enough of these steps, the matrix reaches a staircase shape called row echelon form, and the rank is the number of nonzero rows.

In practice you let software do it. Matlab and Octave have rank(A), and Python has numpy.linalg.matrix_rank(A). Both compute the singular values of A and count the ones above a small tolerance, because rounding errors rarely give an exact zero. For A above, both return 2.

  • Row operations keep the rank : swapping, scaling by a nonzero number, and adding multiples of rows are all safe.
  • Count the nonzero rows : after reduction, each nonzero row is one independent direction.
  • A zero row points to a dependency : here it shows that row 2 = 2 x row 1.
  • Software uses singular values : a tolerance decides which tiny values count as zero.

How is rank related to the determinant and to linear equations ?

Rank becomes useful when you connect it to the two questions you ask most often about a matrix. Can you invert it ? And does Ax = b have a solution ? Both answers come from the rank, and the determinant is a special case of the first one.

For a square n x n matrix, four statements are the same condition. The rank is n. The determinant is not zero. The matrix has an inverse. And Ax = 0 has only the solution x = 0. The matrix A of the previous section has rank 2, which is less than 3. So its determinant is 0, and A has no inverse. For a non-square matrix, the determinant is not defined, and the rank is what describes it.

The rank also counts the solutions of Ax = 0. For an m x n matrix, these solutions form a space of dimension n minus the rank. For A, this is 3 - 2 = 1, so the solutions are all the multiples of (-1, -1, 1). This result is known as the rank-nullity theorem.

For Ax = b, compare the rank of A with the rank of the augmented matrix [A | b], which is A with b added as an extra column. If the two ranks are equal, a solution exists. If adding b raises the rank, b points in a direction that A cannot reach, and there is no solution. With b = (1, 2, 0), the rank stays 2, and the system is solvable. With b = (1, 3, 0), the rank rises to 3, and there is no solution. The reason is that the second equation now contradicts 2 times the first one. The table below collects these conditions.

 

Question

Condition on the rank

Is the n x n matrix A invertible ?

rank A = n, which is the same as det A not equal to 0

How many solutions does Ax = 0 have ?

a space of dimension n - rank A

Does Ax = b have a solution ?

rank A = rank [A | b]

Is that solution unique ?

also rank A = n, the number of unknowns

 

  • The determinant is a yes or no test : the rank gives the full count, and it works for any shape.
  • Rank deficiency means free directions : each missing rank adds one direction to the solutions of Ax = 0.
  • Solvability is a rank comparison : b must not raise the rank of A.

What does rank mean for a MIMO channel ?

The summary figure ends with a MIMO example, and this is the reason rank matters in wireless communication. The channel between Nt transmit antennas and Nr receive antennas is an Nr x Nt matrix H. Its rank limits how many independent data streams, or layers, the link can carry at the same time.

Let's compare two 2 x 2 channels. In H = [1, 1; 1, 1], both receive antennas see exactly the same combination of the two transmit antennas. The second row adds nothing, the rank is 1, and only one stream can be separated. A strong line-of-sight path with closely spaced antennas tends to produce a channel like this. In H = [1, 0; 0, 1], each receive antenna hears a different transmit antenna. The rank is 2, and two streams can be sent.

Rank alone is not the whole story. H = [1, 0.99; 0.99, 1] has rank 2 on paper. Its singular values, however, are 1.99 and 0.01, so the second stream arrives with about 1/199 of the amplitude gain of the first. With noise, such a channel behaves almost like a rank 1 channel. That is why a receiver looks at the singular values, or at the condition number 1.99/0.01 = 199, and not only at the rank. In LTE and NR, the UE reports this judgement to the network as the Rank Indicator, RI, which is the number of layers it recommends.

  • The rank of H is at most min(Nr, Nt) : a 4 x 2 channel carries at most 2 layers.
  • Correlated paths lower the useful rank : identical rows in H mean identical views of the transmitter.
  • Singular values show the quality of each layer : a tiny singular value is a layer that noise will destroy.
  • RI is the practical rank : it is the number of layers the UE can actually decode, not the mathematical rank of H.