What I want to do: Check out the singular value decomposition of linear algebra
For the $ m $ row $ n $ matrix $ A $
-$ U $: $ m \ times m $ unitary matrix -$ \ Sigma $: $ m \ times n $ real diagonal matrix (component non-negative) -$ V $: $ n \ times n $ unitary matrix
Exists and the following holds
A=U\Sigma \overline{V^T}
Where the overline is the complex conjugate and $ ^ T $ is the transpose.
A=\left(
\begin{matrix}
1 & 2 \\
3 & 4
\end{matrix}
\right)
> import numpy as np
> A = np.array([[1,2],[3,4]])
> A
array([[1, 2],
[3, 4]])
U, s, V = np.linalg.svd(A, full_matrices=True)
There are three return values.
> U
array([[-0.40455358, -0.9145143 ],
[-0.9145143 , 0.40455358]])
> s
array([ 5.4649857 , 0.36596619])
> V
array([[-0.57604844, -0.81741556],
[ 0.81741556, -0.57604844]])
Somehow, it feels like $ s $ has collapsed, but the entity is only diagonal components, that is,
> np.diag(s)
array([[ 5.4649857 , 0. ],
[ 0. , 0.36596619]])
Is a matrix of entities.
A=U\Sigma \overline{V^T}
I will check.
>np.dot(np.dot(U, np.diag(s)),V)
array([[ 1., 2.],
[ 3., 4.]])
It feels good ♪ ⇒ Here, since the matrix $ V $ is obtained by the execution column, it is not necessary to perform complex conjugate, but it seems that the one that does not take transpose is returned as the return value.
> np.dot(U, U.T)
array([[ 1.00000000e+00, 2.77555756e-16],
[ 2.77555756e-16, 1.00000000e+00]])
It is numerically unavoidable that a value other than $ 0 $ is entered in a place that is not a diagonal component.
> np.dot(V, V.T)
array([[ 1., 0.],
[ 0., 1.]])
Recommended Posts