Menu

[r2807]: / trunk / course / examples / scipy / example10.3.2  Maximize  Restore  History

Download this file

23 lines (21 with data), 532 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
>>> A = mat('[1 3 2; 1 2 3]')
>>> M,N = A.shape
>>> U,s,Vh = linalg.svd(A)
>>> Sig = mat(diagsvd(s,M,N))
>>> U, Vh = mat(U), mat(Vh)
>>> print U
Matrix([[-0.7071, -0.7071],
[-0.7071, 0.7071]])
>>> print Sig
Matrix([[ 5.1962, 0. , 0. ],
[ 0. , 1. , 0. ]])
>>> print Vh
Matrix([[-0.2722, -0.6804, -0.6804],
[-0. , -0.7071, 0.7071],
[-0.9623, 0.1925, 0.1925]])
>>> print A
Matrix([[1, 3, 2],
[1, 2, 3]])
>>> print U*Sig*Vh
Matrix([[ 1., 3., 2.],
[ 1., 2., 3.]])
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.