updating week 35
This commit is contained in:
@@ -1322,7 +1322,7 @@ As an example, the above defective matrix can be decomposed as
|
||||
|
||||
!bt
|
||||
\[
|
||||
\bm{X} = \frac{1}{\sqrt{2}}\begin{bmatrix} 1& 1 \\ 1& -1\\ \end{bmatrix} \begin{bmatrix} 4& 0 \\ 0& 0\\ \end{bmatrix} \frac{1}{\sqrt{2}}\begin{bmatrix} 1& -1 \\ 1& 1\\ \end{bmatrix}=\bm{U}\bm{\Sigma}\bm{V}^T,
|
||||
\bm{X} = \frac{1}{\sqrt{2}}\begin{bmatrix} 1& 1 \\ 1& -1\\ \end{bmatrix} \begin{bmatrix} 2& 0 \\ 0& 0\\ \end{bmatrix} \frac{1}{\sqrt{2}}\begin{bmatrix} 1& -1 \\ 1& 1\\ \end{bmatrix}=\bm{U}\bm{\Sigma}\bm{V}^T,
|
||||
\]
|
||||
!et
|
||||
|
||||
@@ -1378,7 +1378,7 @@ def SVDinv(A):
|
||||
SVD is numerically more stable than the inversion algorithms provided by
|
||||
numpy and scipy.linalg at the cost of being slower.
|
||||
'''
|
||||
U, S, VT = np.linalg.svd(A)
|
||||
U, S, VT = np.linalg.svd(A,full_matrices=True)
|
||||
print('test U')
|
||||
print( (np.transpose(U) @ U - U @np.transpose(U)))
|
||||
print('test VT')
|
||||
@@ -1394,12 +1394,12 @@ def SVDinv(A):
|
||||
|
||||
|
||||
X = np.array([ [1.0,-1.0], [1.0,-1.0]])
|
||||
#X = np.array([[1, 2], [3, 4], [5, 6]])
|
||||
|
||||
print(X)
|
||||
A = np.transpose(X) @ X
|
||||
print(A)
|
||||
C = SVDinv(A)
|
||||
C = SVDinv(X)
|
||||
# Print the difference between the original matrix and the SVD one
|
||||
print(C-A)
|
||||
print(C-X)
|
||||
!ec
|
||||
|
||||
The matrix $\bm{X}$ has columns that are linearly dependent. The first
|
||||
|
||||
Reference in New Issue
Block a user