- Extreme Optimization
- Documentation
- Vector and Matrix Library User's Guide
- Matrix Decompositions
- The LU Decomposition
- The QR Decomposition
- The Cholesky Decomposition
- The Symmetric Indefinite Decomposition
- The Eigenvalue Decomposition
- The Generalized Eigenvalue Decomposition
- The Singular Value Decomposition
- The Generalized Singular Value Decomposition
- Non-Negative Matrix Factorization
- Solving Linear Systems

- The Generalized Singular Value Decomposition

## The Generalized Singular Value Decomposition | Extreme Optimization Numerical Libraries for .NET Professional |

The Generalized Singular Value Decomposition or GSVD of a pair of matrices A and B rewrites each matrix as the product of an orthogonal (or unitary) matrix, a diagonal matrix, and the product of the same triangular and orthogonal matrix. The two matrices must have the same number of rows. The Generalized SVD decomposition is usually written as

A = UΣ_{1}[0 R]Q^{T}
B = VΣ_{2}[0 R]Q^{T},

where U, V, and Q are
square, orthogonal matrices,
Σ_{1}
and
Σ_{2} are diagonal matrices
with the same shape as A, and R
is an upper triangular matrix. Alternatively, the matrices Q
and R may be combined to give:

A = UΣ_{1}X^{-1}
B = VΣ_{2}X^{-1},

When A and B are complex, the transpose should be replaced with the conjugate transpose. The singular values are still real.

The quotients of the diagonal elements of
Σ_{1}
and
Σ_{2} are
called the generalized singular values.

The singular value decomposition of a matrix is represented by the by the
GeneralizedSingularValueDecomposition

var A = Matrix.Create(5, 3, new double[] { 1,2,3,4,5, 6,7,8,9,10, 11,12,13,14,15 }, MatrixElementOrder.ColumnMajor); var B = Matrix.Create(3, 3, new double[] { 8, 3, 4, 1, 5, 9, 6, 7, 2 }, MatrixElementOrder.ColumnMajor); var gsvd = A.GetSingularValueDecomposition(B);

The two remaining overloads let you specify which calculations are to be performed. Because the calculation of the singular vectors U and V as well as the orthogonal factor Q is relatively expensive and not always needed, it is possible to specify that only the singular values should be computed. This is done in one of two ways. The first is by passing a value of type GeneralizedSingularValueDecompositionFactors to the method. Alternatively, you can set the RequestedFactors property to a value of the same type before the decomposition is computed. The possible values for the SingularValueDecompositionFactors enumeration are listed below:

Value | Description |
---|---|

SingularValues | The singular values are required. This is always included. |

PrimarySingularVectors | The left singular vectors of A are required. |

PrimarySingularVectors | The left singular vectors of A are required. |

SecondarySingularVectors | The singular vectors of B are required. |

SecondarySingularVectors | The singular vectors of B are required. |

SharedFactor | The shared factors Q and R are required. |

Thin | The singular values as well as the left and right singular vectors are required, but only the columns that contribute to the products are returned. |

All | The singular values as well as the left and right singular vectors are required. |

A common option is Thin, which is often used for matrices that have more rows than columns. In this case, only a few of the left singular vectors correspond to singular values. The remaining singular vectors correspond to zero rows in the matrix of singular values, and are rarely used.

The Decompose method performs the actual decomposition. This method copies the matrix if necessary. It then calls the appropriate routine to perform the actual decomposition. This method is called by other methods as needed. You will rarely need to call it explicitly.

The GeneralizedSingularValues
property returns a vector containing the generalized singular values.
The PrimarySingularValues
property returns a vector containing the singular values of the primary matrix.
The PrimarySingularValueMatrix
returns the matrix
Σ_{1}
in the decomposition: a diagonal matrix of the same shape
as A with the singular values on the diagonal.

The SecondarySingularValues
property returns a vector containing the singular values of the secondary matrix.
The SecondarySingularValueMatrix
returns the matrix
Σ_{2}
in the decomposition: a diagonal matrix of the same shape
as B with the singular values on the diagonal.

The PrimarySingularVectors and SecondarySingularVectors return the matrices U and V, respectively. The singular vectors are stored in the columns of these matrices. When a thin SVD is requested, the meaning is slightly different. For a matrix with more rows than columns, the singular matrix contains only n columns, where n is the number of columns in the matrix. The columns of these reduced matrices are still orthogonal.

The SharedTriangularFactor and SharedOrthogonalFactor return the matrices [0 R] and Q, respectively. To get just the triangular part, R or just those columns of Q that are multiplied with non-zero columns of [0 R], use the TrimmedSharedTriangularFactor. To get the matrix X from the decomposition, use SharedFactor.

var S = gsvd.GeneralizedSingularValues; var S1 = gsvd.PrimarySingularValues; var S2 = gsvd.SecondarySingularValues; var U = gsvd.PrimarySingularVectors; var V = gsvd.SecondarySingularVectors; var Q = gsvd.SharedOrthogonalFactor; var R = gsvd.TrimmedSharedTriangularFactor; var X = gsvd.SharedFactor;

The implementation of the singular value decomposition is based on the LAPACK routine DGGSVD3.

Copyright © 2004-2021,
Extreme Optimization. All rights reserved.

*Extreme Optimization,* *Complexity made simple*, *M#*, and *M
Sharp* are trademarks of ExoAnalytics Inc.

*Microsoft*, *Visual C#, Visual Basic, Visual Studio*, *Visual
Studio.NET*, and the *Optimized for Visual Studio* logo

are
registered trademarks of Microsoft Corporation.