Skip to main content

Section 3.1 The row vectors, column vectors and submatrix

After finishing this section, you will learn the following.
  1. How to get a row (column) vector from a matrix.
  2. How to get a submatrix from a matrix.
  3. How to from a big matrix from two matrices.
Here is my code for Gauss-Jordan Elimination.
def GaussJordan(A): #目标:求得矩阵的阶梯型
    a = A.dimensions() #得到行数和列数
    k = a[1] #取列数
    s=0 # 行数的计数
    for i in range(k): #开始循环, 从第0列开始
        for j in range(s,A.nrows()): # 开始检验第j列中第s个数开始至最后一行数中非零的entry
        #问题:若矩阵A第一列的entries全为0, s为何值?
            if A[j,i] != 0: 
                A[[s,j]] = A[[j,s]]# that is the way to exchange two rows in python 换到第s行
                A[s] /= A[s,i] # leading entry变为1
                for t in range(s,A.nrows()): # 开始将leading entry 下都变为0.
                    if t != s:
                        A[t]-=A[s]*A[t,i]
                s+=1 # it is very important to have s here 
    print(A)

Subsection 3.1.1 row and column vectors

Some row and column of a matrix can be recorded by row(i) and column(j)
Example: Let
\begin{equation*} A = \begin{pmatrix} 0 \amp 2 \amp -8 \amp 8 \\ 1 \amp -2 \amp 1 \amp 0 \\ 5 \amp 0 \amp -5 \amp 10 \end{pmatrix} \end{equation*}
Exercise:
1. Input
\begin{equation*} B = \begin{pmatrix} 1 \amp 2 \amp -8 \amp 8 \\ 1 \amp -2 \amp 1 \amp 0 \\ 5 \amp 0 \amp -5 \amp 10 \end{pmatrix}. \end{equation*}
Hint: Look for the difference of matrices \(A\) and \(B\text{.}\)
2. Get the second column of \(B\) as a column vector.

Subsection 3.1.2 How to get a submatrix

Exercise: For the matrix \(U\) below, get the submatrix \(X\) which from the columns 1,2,5; and get the submatrix \(Y\) which from the columns 1,2 and rows 3, 4.
In this course, deleting one row and one column is important. For your information, it will be used in Chapter 3 to compute the Determinant of a square matrix.
Exercise: Delete the column 3 to form a new matrix \(F\text{.}\)

Subsection 3.1.3 Constructing Matrix from vectors

Sometimes, we construct a matrix from vectors. For this moment, I only know how to construct a matrix from row vector.