Main Content

gsvd

Generalized singular value decomposition

Description

example

[U,V,X,C,S] = gsvd(A,B) performs a generalized singular value decomposition of matrices A and B, and returns unitary matrices U and V, a matrix X, and nonnegative diagonal matrices C and S such that

A = U*C*X'
B = V*S*X'
C'*C + S'*S = I 

example

[U,V,X,C,S] = gsvd(A,B,"econ"), where A is m-by-p and B is n-by-p, produces an economy-size decomposition where the resulting U and V matrices have at most p columns, and C and S have at most p rows.

[U,V,X,C,S] = gsvd(A,B,0) is the same as gsvd(A,B,"econ"). The use of this syntax is not recommended. Use the "econ" option instead.

example

sigma = gsvd(A,B) returns the vector of generalized singular values, sqrt(diag(C'*C)./diag(S'*S)). When B is square and nonsingular, the generalized singular values, gsvd(A,B), correspond to the ordinary singular values, svd(A/B), but they are sorted in the opposite order. Their reciprocals are gsvd(B,A).

Examples

collapse all

Perform a generalized singular value decomposition on two matrices and also calculate the generalized singular values.

Create a 5-by-3 matrix A and a 3-by-3 matrix B.

A = reshape(1:15,5,3)
A = 5×3

     1     6    11
     2     7    12
     3     8    13
     4     9    14
     5    10    15

B = magic(3)
B = 3×3

     8     1     6
     3     5     7
     4     9     2

Perform a generalized singular value decomposition on A and B. The outputs include orthogonal U and V, a nonsingular X, and diagonal matrices C and S. Because A is rank deficient, the first diagonal element of C is zero.

[U,V,X,C,S] = gsvd(A,B)
U = 5×5

   -0.2569    0.6457   -0.4279   -0.4417   -0.3727
    0.6384    0.3296   -0.4375    0.0834    0.5344
   -0.6217    0.0135   -0.4470    0.5799    0.2779
    0.3559   -0.3026   -0.4566    0.3567   -0.6679
   -0.1156   -0.6187   -0.4661   -0.5783    0.2284

V = 3×3

   -0.7071   -0.6946    0.1325
    0.0000   -0.1874   -0.9823
    0.7071   -0.6946    0.1325

X = 3×3

   -2.8284   -9.3761   -6.9346
    5.6569   -8.3071  -18.3301
   -2.8284   -7.2381  -29.7256

C = 5×3

    0.0000         0         0
         0    0.3155         0
         0         0    0.9807
         0         0         0
         0         0         0

S = 3×3

    1.0000         0         0
         0    0.9489         0
         0         0    0.1957

Now, perform an economy-size decomposition of A and B. The matrices U and C have different sizes, but the other output matrices are the same.

[U,V,X,C,S] = gsvd(A,B,"econ")
U = 5×3

    0.5371    0.6457    0.4279
   -0.8093    0.3296    0.4375
    0.1673    0.0135    0.4470
   -0.0551   -0.3026    0.4566
    0.1600   -0.6187    0.4661

V = 3×3

    0.7071   -0.6946   -0.1325
   -0.0000   -0.1874    0.9823
   -0.7071   -0.6946   -0.1325

X = 3×3

    2.8284   -9.3761    6.9346
   -5.6569   -8.3071   18.3301
    2.8284   -7.2381   29.7256

C = 3×3

    0.0000         0         0
         0    0.3155         0
         0         0    0.9807

S = 3×3

    1.0000         0         0
         0    0.9489         0
         0         0    0.1957

Calculate the generalized singular values, which in this case are equal to the ratios diag(C)./diag(S). These values are a reordering of the ordinary singular values returned by svd(A/B).

sigma = gsvd(A,B)
sigma = 3×1

    0.0000
    0.3325
    5.0123

svals = svd(A/B)
svals = 3×1

    5.0123
    0.3325
    0.0000

Examine why generalized singular values can sometimes be Inf.

Create a 3-by-5 matrix A and a 5-by-5 matrix B.

A = reshape(1:15,3,5)
A = 3×5

     1     4     7    10    13
     2     5     8    11    14
     3     6     9    12    15

B = magic(5)
B = 5×5

    17    24     1     8    15
    23     5     7    14    16
     4     6    13    20    22
    10    12    19    21     3
    11    18    25     2     9

Perform a generalized singular value decomposition on A and B. The outputs include orthogonal U and V, a nonsingular X, and diagonal matrices C and S. In this situation, the nonzero diagonal of C is diag(C,2).

[U,V,X,C,S] = gsvd(A,B)
U = 3×3

    0.4082    0.7178   -0.5639
   -0.8165    0.0109   -0.5772
    0.4082   -0.6961   -0.5906

V = 5×5

   -0.7596    0.3266    0.3195   -0.4552   -0.0843
    0.4139   -0.3747    0.6218   -0.5408    0.0956
    0.0484   -0.1713   -0.0078   -0.0271   -0.9836
   -0.1717   -0.4817   -0.6610   -0.5408    0.0956
    0.4689    0.7011   -0.2725   -0.4552   -0.0843

X = 5×5

    0.2422   -0.8564   10.0949  -30.7287   -4.6958
   -9.4897   11.7764   -2.1067  -28.5003  -11.6858
   11.2281    3.8525  -14.8016  -26.2720  -18.6758
   -1.9806  -14.7725   -3.3206  -24.0436  -25.6657
         0         0   10.1340  -21.8152  -32.6557

C = 3×5

         0         0    0.0000         0         0
         0         0         0    0.0439         0
         0         0         0         0    0.7432

S = 5×5

    1.0000         0         0         0         0
         0    1.0000         0         0         0
         0         0    1.0000         0         0
         0         0         0    0.9990         0
         0         0         0         0    0.6690

Find the generalized singular values, which include zeros.

sigma = gsvd(A,B)
sigma = 5×1

         0
         0
    0.0000
    0.0439
    1.1109

Reversing the roles of A and B inverts these values, producing Inf values.

sigma2 = gsvd(B,A)
sigma2 = 5×1
1016 ×

    0.0000
    0.0000
    3.8423
       Inf
       Inf

Input Arguments

collapse all

Input matrices. A and B must have the same number of columns but can have different numbers of rows.

Data Types: single | double
Complex Number Support: Yes

Output Arguments

collapse all

Unitary matrix factors, returned as matrices. U and V are matrices with orthogonal columns that provide a basis for the columns of A and B, respectively.

The sizes of U and V depend on whether you specify the "econ" option. If A is m-by-p and B is n-by-p, then:

  • By default, U is m-by-m and V is n-by-n.

  • If you specify the "econ" option, then U is m-by-min(m,p) and V is n-by-min(n,p).

Matrix factor, returned as a matrix. If A is m-by-p and B is n-by-p, then X is p-by-q, where q is the numerical rank of [A; B].

A property of X is that norm([A; B]) == norm(X) because U, V, C, and S represent only an orthogonal basis for the matrix [A; B].

Diagonal matrix factors, returned as matrices. The nonzero elements of S are always on its main diagonal. The nonzero elements of C are on the diagonal diag(C,max(0,size(C,2)-size(C,1))). To retrieve the nonzero values, use the commands sv = max(S,[],1) and cv = max(C,[],1). The generalized singular values of A and B are equal to the ratio cv./sv.

The sizes of C and S depend on whether you specify the "econ" option. If A is m-by-p and B is n-by-p, then:

  • By default, C is m-by-q and S is n-by-q.

  • If you specify the "econ" option, then C is min(m,p)-by-q and V is min(n,p)-by-q.

In both cases, q is the numerical rank of [A; B].

Generalized singular values, returned as a column vector. If sv = max(S,[],1) and cv = max(C,[],1), then the generalized singular values of A and B are equal to the ratio cv./sv.

sigma has length equal to the numerical rank of [A; B] and is in nondecreasing order.

Algorithms

The generalized singular value decomposition performed by the gsvd function uses a C-S decomposition, as well as the built-in svd and qr functions.

Extended Capabilities

Version History

Introduced before R2006a

expand all

See Also

|