gsvd [matrix]
— Loadable Function: s = gsvd (a, b)
— Loadable Function: [u, v, c, s, x [, r]] = gsvd (a, b)

Compute the generalised singular value decomposition of (a, b):

          u' * a * x = [I 0; 0 c] * [0 r]
          v' * b * x = [0 s; 0 0] * [0 r]
          c * c + s * s = eye(columns(a))
          I and 0 are padding matrices of suitable size
          r is upper triangular

The function gsvd normally returns the vector of generalised singular values diag(r)./diag(s). If asked for five return values, it computes U, V, and X. With a sixth output argument, it also returns r, The common upper triangular right term. Other authors, like S. Van Huffel, define this transformation as the simulatenous diagonalisation of the input matrices, this can be achieved by multiplying x by the inverse of [I 0; 0 r].

For example,

          gsvd (hilb (3), [1 2 3; 3 2 1])

returns

          ans =
          
            0.1055705
            0.0031759

and

          [u, v, c, s, x, r] = gsvd (hilb (3),  [1 2 3; 3 2 1])

returns

          u =
          
            -0.965609   0.240893   0.097825
            -0.241402  -0.690927  -0.681429
            -0.096561  -0.681609   0.725317
          
          v =
          
            -0.41974   0.90765
            -0.90765  -0.41974
          
          c =
          
             0.10499   0.00000
             0.00000   0.00318
          
          s =
             0.99447   0.00000
             0.00000   0.99999
          x =
          
             0.408248   0.902199   0.139179
            -0.816497   0.429063  -0.386314
             0.408248  -0.044073  -0.911806
          
          r =
            -0.14093  -1.24345   0.43737
             0.00000  -3.90043   2.57818
             0.00000   0.00000  -2.52599
          

The code is a wrapper to the corresponding Lapack dggsvd and zggsvd routines.