NAG FL Interface
f02xuf (complex_​triang_​svd)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

f02xuf returns all, or part, of the singular value decomposition of a complex upper triangular matrix.

2 Specification

Fortran Interface
Subroutine f02xuf ( n, a, lda, ncolb, b, ldb, wantq, q, ldq, sv, wantp, rwork, cwork, ifail)
Integer, Intent (In) :: n, lda, ncolb, ldb, ldq
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (Inout) :: rwork(*)
Real (Kind=nag_wp), Intent (Out) :: sv(n)
Complex (Kind=nag_wp), Intent (Inout) :: a(lda,*), b(ldb,*), q(ldq,*)
Complex (Kind=nag_wp), Intent (Out) :: cwork(max(1,n-1))
Logical, Intent (In) :: wantq, wantp
C Header Interface
#include <nag.h>
void  f02xuf_ (const Integer *n, Complex a[], const Integer *lda, const Integer *ncolb, Complex b[], const Integer *ldb, const logical *wantq, Complex q[], const Integer *ldq, double sv[], const logical *wantp, double rwork[], Complex cwork[], Integer *ifail)
The routine may be called by the names f02xuf or nagf_eigen_complex_triang_svd.

3 Description

The n×n upper triangular matrix R is factorized as
R=QSPH,  
where Q and P are n×n unitary matrices and S is an n×n diagonal matrix with real non-negative diagonal elements, sv1,sv2,,svn, ordered such that
sv1sv2svn0.  
The columns of Q are the left-hand singular vectors of R, the diagonal elements of S are the singular values of R and the columns of P are the right-hand singular vectors of R.
Either or both of Q and PH may be requested and the matrix C given by
C=QHB,  
where B is an n×ncolb given matrix, may also be requested.
f02xuf obtains the singular value decomposition by first reducing R to bidiagonal form by means of Givens plane rotations and then using the QR algorithm to obtain the singular value decomposition of the bidiagonal form.
Good background descriptions to the singular value decomposition are given in Dongarra et al. (1979), Hammarling (1985) and Wilkinson (1978).
Note that if K is any unitary diagonal matrix so that
KKH=I,  
then
A=(QK)S(PK)H  
is also a singular value decomposition of A.

4 References

Dongarra J J, Moler C B, Bunch J R and Stewart G W (1979) LINPACK Users' Guide SIAM, Philadelphia
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
Wilkinson J H (1978) Singular Value Decomposition – Basic Aspects Numerical Software – Needs and Availability (ed D A H Jacobs) Academic Press

5 Arguments

1: n Integer Input
On entry: n, the order of the matrix R.
If n=0, an immediate return is effected.
Constraint: n0.
2: a(lda,*) Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array a must be at least max(1,n).
On entry: the leading n×n upper triangular part of the array a must contain the upper triangular matrix R.
On exit: if wantp=.TRUE., the n×n part of a will contain the n×n unitary matrix PH, otherwise the n×n upper triangular part of a is used as internal workspace, but the strictly lower triangular part of a is not referenced.
3: lda Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f02xuf is called.
Constraint: ldamax(1,n).
4: ncolb Integer Input
On entry: ncolb, the number of columns of the matrix B.
If ncolb=0, the array b is not referenced.
Constraint: ncolb0.
5: b(ldb,*) Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array b must be at least max(1,ncolb).
On entry: if ncolb>0, the leading n×ncolb part of the array b must contain the matrix to be transformed.
On exit: is overwritten by the n×ncolb matrix QHB.
6: ldb Integer Input
On entry: the first dimension of the array b as declared in the (sub)program from which f02xuf is called.
Constraints:
  • if ncolb>0, ldbmax(1,n);
  • otherwise ldb1.
7: wantq Logical Input
On entry: must be .TRUE. if the matrix Q is required.
If wantq=.FALSE. then the array q is not referenced.
8: q(ldq,*) Complex (Kind=nag_wp) array Output
Note: the second dimension of the array q must be at least max(1,n) if wantq=.TRUE., and at least 1 otherwise.
On exit: if wantq=.TRUE., the leading n×n part of the array q will contain the unitary matrix Q. Otherwise the array q is not referenced.
9: ldq Integer Input
On entry: the first dimension of the array q as declared in the (sub)program from which f02xuf is called.
Constraints:
  • if wantq=.TRUE., ldqmax(1,n);
  • otherwise ldq1.
10: sv(n) Real (Kind=nag_wp) array Output
On exit: the n diagonal elements of the matrix S.
11: wantp Logical Input
On entry: must be .TRUE. if the matrix PH is required, in which case PH is returned in the array a, otherwise wantp must be .FALSE..
12: rwork(*) Real (Kind=nag_wp) array Output
Note: the dimension of the array rwork must be at least max(1,2×(n-1)) if ncolb=0 and wantq=.FALSE. and wantp=.FALSE., max(1,3×(n-1)) if (ncolb=0 and wantq=.FALSE. and wantp=.TRUE.) or (ncolb>0 and wantp=.FALSE.) or (wantq=.TRUE. and wantp=.FALSE.), and at least max(1,5×(n-1)) otherwise.
On exit: rwork(n) contains the total number of iterations taken by the QR algorithm.
The rest of the array is used as workspace.
13: cwork(max(1,n-1)) Complex (Kind=nag_wp) array Workspace
14: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
The QR algorithm has failed to converge. value singular values have not been found.
ifail=-1
On entry, lda=value and n=value.
Constraint: ldan.
On entry, ldb=value, n=value and ncolb=value.
Constraint: if ncolb>0, ldbn.
On entry, ldq=value and n=value.
Constraint: if wantq=.TRUE., ldqn.
On entry, n=value.
Constraint: n0.
On entry, ncolb=value.
Constraint: ncolb0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

The computed factors Q, S and P satisfy the relation
QSPH=A+E,  
where
Ecε A,  
ε is the machine precision, c is a modest function of n and . denotes the spectral (two) norm. Note that A=sv1.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
f02xuf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f02xuf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

For given values of ncolb, wantq and wantp, the number of floating-point operations required is approximately proportional to n3.
Following the use of this routine the rank of R may be estimated by a call f06klf. The statement
irank = f06klf(n,sv,1,tol)
returns the value (k-1) in irank, where k is the smallest integer for which sv(k)<tol×sv(1), where tol is the tolerance supplied in tol, so that irank is an estimate of the rank of S and thus also of R. If tol is supplied as negative then the machine precision is used in place of tol.

10 Example

This example finds the singular value decomposition of the 3×3 upper triangular matrix
A = ( 1 1+i 1+i 0 −2i+ −1-i 0 0i+ −3i+ )  
together with the vector QHb for the vector
b=( 1+1i −1i+0 −1+1i ) .  

10.1 Program Text

Program Text (f02xufe.f90)

10.2 Program Data

Program Data (f02xufe.d)

10.3 Program Results

Program Results (f02xufe.r)