Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 15, 2019 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robofied/8708543e40c86af51267b466b6b17e9c to your computer and use it in GitHub Desktop.
Save Robofied/8708543e40c86af51267b466b6b17e9c to your computer and use it in GitHub Desktop.
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