Section3.1The row vectors, column vectors and submatrix
After finishing this section, you will learn the following.
How to get a row (column) vector from a matrix.
How to get a submatrix from a matrix.
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)
Subsection3.1.1row and column vectors
Some row and column of a matrix can be recorded by row(i) and column(j)
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{.}\)
Subsection3.1.3Constructing Matrix from vectors
Sometimes, we construct a matrix from vectors. For this moment, I only know how to construct a matrix from row vector.