Skip to content

Instantly share code, notes, and snippets.

@olologin
Created November 16, 2014 19:10
Show Gist options
  • Save olologin/1a4d472ac7badededae4 to your computer and use it in GitHub Desktop.
Save olologin/1a4d472ac7badededae4 to your computer and use it in GitHub Desktop.
>>> Us,ss,Vhs = linalg.svds(csc_matrix(matrix,dtype='d'),2,which='LM')
>>> Vhs[:2,:].T
array([[ 0.00489193, 0.42631592],
[-0.02222114, 0.04556005],
[-0.65336888, 0.006326 ],
[ 0.00627651, 0.53522851],
[-0.58519582, 0.0048177 ],
[ 0.00189393, 0.37190156],
[-0.08852632, 0.01125631],
[ 0.00740663, 0.62545491],
[-0.47138359, 0.00386173]])
>>> Us,ss,Vhs = linalg.svds(csc_matrix(matrix,dtype='d'),2,which='LM')
>>> Vhs[:2,:].T
array([[ 0.00489193, -0.42631592],
[-0.02222114, -0.04556005],
[-0.65336888, -0.006326 ],
[ 0.00627651, -0.53522851],
[-0.58519582, -0.0048177 ],
[ 0.00189393, -0.37190156],
[-0.08852632, -0.01125631],
[ 0.00740663, -0.62545491],
[-0.47138359, -0.00386173]])
>>> matrix
array([[1, 0, 0, 1, 0, 1, 0, 1, 0],
[0, 0, 0, 1, 0, 0, 0, 1, 0],
[0, 0, 0, 1, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 1],
[0, 0, 1, 0, 1, 0, 0, 0, 1],
[1, 0, 0, 1, 0, 1, 0, 1, 0],
[1, 0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 1],
[0, 1, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 0, 1, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 0]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment