SVD.OMS
Script File:
# Description:
# Computes the singular value decomposition (SVD) of a matrix.
#
clear
#
# matrix that we are factoring
x = {[2., 1.], [1., 2.]}
# values returned by svd
u = novalue
v = novalue
# compute the factorization
s = svd(x, u, v)
# diagonal matrix of singular values
D = diag(s)
# demonstrate factorization properties
print "x"
print x
print "u * D * v'"
print u * D * v'
print "u * u'"
print u * u'
print "v * v'"
print v * v'
Output:
x
{
[ 2 , 1 ]
[ 1 , 2 ]
}
u * D * v'
{
[ 2 , 1 ]
[ 1 , 2 ]
}
u * u'
{
[ 1 , 0 ]
[ 0 , 1 ]
}
v * v'
{
[ 1 , 0 ]
[ 0 , 1 ]
}