Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Numpy
## performing svd using svd() function.
## Returns full matrices by default.
U,V,S = lnp.svd(a = np.random.randn(9, 6))
## Printing the shapes of all matrices.
print(U.shape,V.shape,S.shape)
#[Output]:
#(9, 9) (6,) (6, 6)
## Eigen vectors
##1. eig()
##Compute the eigenvalues and right eigenvectors of a square array.In [11]:
## It is returning eigenvalues and eigenvectors.
w, v = lnp.eig(np.array([[1, -1], [1, 1]]))
## eigenvalues
print(w)
#[Output]:
#array([1.+1.j, 1.-1.j])
## eigenvectors
print(v)
#[Output]:
#array([[0.70710678+0.j , 0.70710678-0.j ],
# [0. -0.70710678j, 0. +0.70710678j]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.