HyperMath

svd

svd

Previous topic Next topic No expanding text in this topic  

svd

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Singular value decomposition.

Syntax

U, S, V = svd(A)

U, S, V = svd(A, 0)

U, S, V = svd(A, 'econ')

Argument

Name

Description

 

A

A matrix; real or complex.

 

0 or 'econ'

The flag for economy-sized decomposition.

Outputs

Name

Description

 

U

Unitary square matrix (singular vectors).

 

S

Real diagonal matrix (singular values).

 

V

Orthogonal matrix (singular vectors).

Example

Syntax

 

M = [1,2;3,4;5,6];

u,s,v = SVD(M);

print('u = ', u);

print('s = ', s);

print('v = ', v);

A = UnifRnd(0,1,4,2) * UnifRnd(0,1,2,4);

U, S, V = svd(A);

print('U = ', U);

print('S = ', S);

print('V = ', V);

// economy size decomposition

U0, S0, V0 = svd(A, 0);

print('economy size decomposition:');

print('U0 = ', U0);

print('S0 = ', S0);

print('V0 = ', V0);

Comments

U, S, V = svd(A) computes Singular Value Decomposition of the matrix A.  Every matrix has a singular value decomposition.

S is a diagonal matrix of the same dimension as A and with non-negative diagonal elements in decreasing order.

U and V are unitary matrices so that A = U * S * V`.

U, S, V = svd(A, 0) or U, S, V = svd(A, 'econ') computes a compact decomposition of matrix A.

This "economy size" decomposition eliminates the unnecessary rows or columns of U or V.

SVD decompositions are based on the LAPACK routines dgesvd for real matrices and zgesvd for the complex case.

Implemented in HyperMath version 13.0 and later is singular value decomposition based on the BLAS and LAPACK standard libraries.
 
Results can differ (sign convention) from previous versions of HyperMath.
 
Example
 
M = [6,5;4,3;2,1];
 
U, S, V = SVD(M);
 
R = U*S*V`;
 
print('U =', U);
 
print('S =', S);
 
print('V =', V);
 
print('R = ', R);

 
Hypermath 12.0
 
U = [Matrix] 3 x 3
 
0.81964 -0.4019 0.40825
 
0.52474 0.24078 -0.8165
 
0.22985 0.88346 0.40825

 
S = [Matrix] 3 x 2
 
9.5255 0
 
0 0.5143
 
0 0

 

V = [Matrix] 2 x 2
 
0.78489 0.61963
 
0.61963 -0.78489

 
R = [Matrix] 3 x 2
 
6 5
 
4 3
 
2 1

Hypermath 13.0
 
U = [Matrix] 3 x 3
 
-0.81964 0.4019 0.40825
 
-0.52474 -0.24078 -0.8165
 
-0.22985 -0.88346 0.40825

 
S = [Matrix] 3 x 2
 
9.5255 0
 
0 0.5143
 
0 0

 
V = [Matrix] 2 x 2
 
-0.78489 -0.61963
 
-0.61963 0.78489

 
R = [Matrix] 3 x 2
 
6 5
 
4 3
 
2 1

 
R = [Matrix] 3 x 2
 
1 2
 
3 4
 
5 6
 
The two results are valid and verify that: R = U*S*V`.  HyperMath version 13.0 and later are now compliant with the sign convention defined in LAPACK.

See Also:

eig