m4 = np.array([[1,0,0,0,2], [0,0,3,0,0], [0,0,0,0,0], [0,2,0,0,0]])
m4
array([[1, 0, 0, 0, 2],
[0, 0, 3, 0, 0],
[0, 0, 0, 0, 0],
[0, 2, 0, 0, 0]])U, S_diag, V = linalg.svd(m4)
U
array([[ 0., 1., 0., 0.],
[ 1., 0., 0., 0.],
[ 0., 0., 0., -1.],
[ 0., 0., 1., 0.]])S_diag
array([ 3. , 2.23606798, 2. , 0. ])The svd
function just returns the values in the diagonal of Σ, but we want the full Σ matrix, so let's create it:S = np.zeros((4, 5))
S[np.diag_indices(4)] = S_diag
S # Σ