Developer Reference for Intel® oneAPI Math Kernel Library for C
?gesdd
Computes the singular value decomposition of a general rectangular matrix using a divide and conquer method.
Syntax
lapack_int LAPACKE_sgesdd ( intmatrix_layout , charjobz , lapack_intm , lapack_intn , float*a , lapack_intlda , float*s , float*u , lapack_intldu , float*vt , lapack_intldvt );
lapack_int LAPACKE_dgesdd ( intmatrix_layout , charjobz , lapack_intm , lapack_intn , double*a , lapack_intlda , double*s , double*u , lapack_intldu , double*vt , lapack_intldvt );
lapack_int LAPACKE_cgesdd ( intmatrix_layout , charjobz , lapack_intm , lapack_intn , lapack_complex_float*a , lapack_intlda , float*s , lapack_complex_float*u , lapack_intldu , lapack_complex_float*vt , lapack_intldvt );
lapack_int LAPACKE_zgesdd ( intmatrix_layout , charjobz , lapack_intm , lapack_intn , lapack_complex_double*a , lapack_intlda , double*s , lapack_complex_double*u , lapack_intldu , lapack_complex_double*vt , lapack_intldvt );
Include Files
mkl.h
Description
sgesdd dgesdd cgesdd zgesdd gesdd
The routine computes the singular value decomposition (SVD) of a real/complex m -by- n matrix A , optionally computing the left and/or right singular vectors.
If singular vectors are desired, it uses a divide-and-conquer algorithm. The SVD is written
A = U*Σ*V^{T} for real routines,
A = U*Σ*V^{H} for complex routines,
where Σ is an m -by- n matrix which is zero except for its min( m , n ) diagonal elements, U is an m -by- m orthogonal/unitary matrix, and V is an n -by- n orthogonal/unitary matrix. The diagonal elements of Σ are the singular values of A ; they are real and non-negative, and are returned in descending order. The first min( m , n ) columns of U and V are the left and right singular vectors of A .
Note that the routine returns vt = VT (for real flavors) or vt = VH (for complex flavors), not V .
Input Parameters
- matrix_layout
-
Specifies whether matrix storage layout is row major ( LAPACK_ROW_MAJOR ) or column major ( LAPACK_COL_MAJOR ).
jobz
Must be ‘A’ , ‘S’ , ‘O’ , or ‘N’ .
Specifies options for computing all or part of the matrices U and V . If jobz = 'A' , all m columns of U and all n rows of VT or VH are returned in the arrays u and vt ; if jobz = 'S' , the first min( m , n ) columns of U and the first min( m , n ) rows of VT or VH are returned in the arrays u and vt ; if jobz = 'O' , then if m ≥ n , the first n columns of U are overwritten in the array a and all rows of VT or VH are returned in the array vt ; if m < n , all columns of U are returned in the array u and the first m rows of VT or VH are overwritten in the array a ; if jobz = 'N' , no columns of U or rows of VT or VH are computed.
m
The number of rows of the matrix A ( m≥ 0 ).
n
The number of columns in A ( n ≥ 0).
- a , work
-
REAL for sgesdd DOUBLE PRECISION for dgesdd COMPLEX for cgesdd DOUBLE COMPLEX for zgesdd . Arrays:
a (size max(1, lda * n ) for column major layout and max(1, lda * m ) for row major layout) is an array containing the m -by- n matrix A .
The second dimension of a must be at least max(1, n ). work is a workspace array, its dimension max(1, lwork) .
lda
The leading dimension of the array a . Must be at least max(1, m ) for column major layout and at least max(1, n ) for row major layout .
ldu , ldvt
The leading dimensions of the output arrays u and vt , respectively.
Constraints: ldu≥ 1 ; ldvt≥ 1 . If jobz = 'S' or ‘A’ , or jobz = 'O' and m < n , then ldu≥m ; If jobz = 'A' or jobz = 'O' and m≥ n , then ldvt≥n ; If jobz = 'S' , ldvt≥ min(m, n) . The minimum size of ldu is jobzm ≥ nm < n ‘N’ 1 1 ‘A’ mm ‘S’ m for column major layout; n for row major layout m ‘O’ 1 m The minimum size of ldvt is jobzm ≥ nm < n ‘N’ 1 1 ‘A’ nn ‘S’ nm for column major layout; n for row major layout ‘O’ n 1
lwork
The dimension of the array work ; lwork≥ 1 . If lwork = -1 , then a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the work(1) , and no error message related to lwork is issued by xerbla . See Application Notes for the theoretical minimum value of lwork when a workspace query is not performed.
- rwork
-
REAL for cgesdd DOUBLE PRECISION for zgesdd Workspace array, size at least max(1, 7*min(m,n)) if jobz = 'N' . Otherwise, the dimension of rwork must be at least max(1,min(m,n)*max(5*min(m,n)+7,2*max(m,n)+2*min(m,n)+1)) . This array is used in complex flavors only.
iwork
Workspace array, size at least max(1, 8 *min(m, n)) .
Output Parameters
- a
-
On exit: If jobz = 'O' , then if m ≥ n , a is overwritten with the first n columns of U (the left singular vectors, stored columnwise). If m < n , a is overwritten with the first m rows of V:code:`T` (the right singular vectors, stored rowwise); If jobz ≠ ‘O’ , the contents of a are destroyed.
- s
-
REAL for single precision flavors DOUBLE PRECISION for double precision flavors. Array, size at least max(1, min( m , n )). Contains the singular values of A sorted so that s(i) ≥ s(i+1) .
- u , vt
-
REAL for sgesdd DOUBLE PRECISION for dgesdd COMPLEX for cgesdd DOUBLE COMPLEX for zgesdd . Arrays: u ( ldu ,*); the second dimension of u must be at least max(1, m ) if jobz = 'A' or jobz = 'O' and m < n . Array u is of size: jobzm ≥ nm < n ‘N’ 1 1 ‘A’ max(1, ldu * m ) max(1, ldu * m ) ‘S’ max(1, ldu * n ) for column major layout; max(1, ldu * m ) for row major layout max(1, ldu * m ) ‘O’ 1 max(1, ldu * m ) If jobz = 'S' , the second dimension of u must be at least max(1, min( m , n )). If jobz = 'A' or jobz = 'O' and m < n , u contains the m -by- m orthogonal/unitary matrix U . If jobz = 'S' , u contains the first min( m , n ) columns of U (the left singular vectors, stored columnwise). If jobz = 'O' and m ≥ n , or jobz = 'N' , u is not referenced. vt ( ldvt ,*); the second dimension of vt must be at least max(1, n ). Array vt is of size: jobzm ≥ nm < n ‘N’ 1 1 ‘A’ max(1, ldvt * n ) max(1, ldvt * n ) ‘S’ max(1, ldvt * n ) max(1, ldvt * n ) for column major layout; max(1, ldvt * m ) for row major layout; ‘O’ max(1, ldvt * n ) 1 If jobz = 'A' or jobz = 'O' and m ≥ n , vt contains the n -by- n orthogonal/unitary matrix V:code:`T` . If jobz = 'S' , vt contains the first min( m , n ) rows of V:code:`T` (the right singular vectors, stored rowwise). If jobz = 'O' and m < n , or jobz = 'N' , vt is not referenced.
- work(1)
-
On exit, if info = 0 , then work(1) returns the optimal size of lwork .
Return Values
This function returns a value info .
If info=0 , the execution is successful.
If info = -i , the i -th parameter had an illegal value.
If info = -4 , A had a NAN entry.
If info = i , then ?bdsdc did not converge, updating process failed.
LAPACK 95 Interface Notes
There exist FORTRAN 77 and FORTRAN 95 interfaces for this routine. See the Intel® oneMKL Fortran Developer Reference for details.
Application Notes
The theoretical minimum value for lwork depends on the flavor of the routine.
For real flavors :
If jobz = 'N' , lwork= 3*min(m, n) + max (max(m,n), 6*min(m, n)) ;
If jobz = 'O' , \(lwork= 3 (min(m, n))^{2} + max (max(m, n), 5 (min(m, n))^{2} + 4 min(m, n))\) ;
If jobz = 'S' or ‘A’ , lwork= min(m, n)*(6 + 4*min(m, n)) + max(m, n) ;
For complex flavors :
If jobz = 'N' , lwork= 2*min(m, n) + max(m, n) ;
If jobz = 'O' , \(lwork= 2 (min(m, n))^{2} + max(m, n) + 2 min(m, n)\) ;
If jobz = 'S' or ‘A’ , \(lwork= (min(m, n))^{2} + max(m, n) + 2 min(m, n)\) ;
The optimal value of lwork returned by a workspace query generally provides better performance than the theoretical minimum value.The value of lwork returned by a workspace query is generally larger than the theoretical minimum value, but for very small matrices it can be smaller. The absolute minimum value of lwork is the minimum of the workspace query result and the theoretical minimum.
If you set lwork to a value less than the absolute minimum value and not equal to -1, the routine returns immediately with an error exit and does not provide information on the recommended workspace size.