nag_complex_svd (f02xec) (PDF version)
f02 Chapter Contents
f02 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_complex_svd (f02xec)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_complex_svd (f02xec) returns all, or part, of the singular value decomposition of a general complex matrix.

2  Specification

#include <nag.h>
#include <nagf02.h>
void  nag_complex_svd (Integer m, Integer n, Complex a[], Integer tda, Integer ncolb, Complex b[], Integer tdb, Nag_Boolean wantq, Complex q[], Integer tdq, double sv[], Nag_Boolean wantp, Complex ph[], Integer tdph, Integer *iter, double e[], Integer *failinfo, NagError *fail)

3  Description

The m  by n  matrix A  is factorized as
A = QDP H
where
D = S 0 m > n D = S , m = n D = S 0 m < n
Q  is an m  by m  unitary matrix, P  is an n  by n  unitary matrix and S  is a minm,n  by minm,n  diagonal matrix with real non-negative diagonal elements, sv 1 , sv 2 , , sv min m,n , ordered such that
sv 1 sv 2 sv min m,n 0 .
The first minm,n  columns of Q  are the left-hand singular vectors of A , the diagonal elements of S  are the singular values of A  and the first minm,n  columns of P  are the right-hand singular vectors of A .
Either or both of the left-hand and right-hand singular vectors of A  may be requested and the matrix C  given by
C = Q H B
where B  is an m  by ncolb  given matrix, may also be requested.
The function obtains the singular value decomposition by first reducing A  to upper triangular form by means of Householder transformations, from the left when mn  and from the right when m < n .  The upper triangular form is then reduced to bidiagonal form by Givens plane rotations and finally the QR  algorithm is used 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 this function is not based on the LINPACK routine CSVDC.
Note that if K  is any unitary diagonal matrix such that
KK H = I
then
A = Q K D P K 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:     mIntegerInput
On entry: the number of rows, m , of the matrix A .
Constraint: m0 .
When m=0  then an immediate return is effected.
2:     nIntegerInput
On entry: the number of columns, n , of the matrix A .
Constraint: n0 .
When n=0  then an immediate return is effected.
3:     a[m×tda]ComplexInput/Output
Note: the i,jth element of the matrix A is stored in a[i-1×tda+j-1].
On entry: the leading m  by n  part of the array a must contain the matrix A  whose singular value decomposition is required.
On exit: if mn  and wantq=Nag_TRUE , then the leading m  by n  part of a will contain the first n  columns of the unitary matrix Q .
If m<n  and wantp=Nag_TRUE , then the leading m  by n  part of a will contain the first m  rows of the unitary matrix P H .
If mn  and wantq=Nag_FALSE  and wantp=Nag_TRUE , then the leading n  by n  part of a will contain the first n  rows of the unitary matrix P H .
Otherwise the contents of the leading m  by n  part of a are indeterminate.
4:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: tdan .
5:     ncolbIntegerInput
On entry: ncolb , the number of columns of the matrix B . When ncolb=0  the array b is not referenced and may be NULL.
Constraint: ncolb0 .
6:     b[m×tdb]ComplexInput/Output
Note: the i,jth element of the matrix B is stored in b[i-1×tdb+j-1].
On entry: if ncolb>0 , the leading m  by ncolb  part of the array b must contain the matrix to be transformed.
If ncolb=0  the array b is not referenced and may be NULL.
On exit: b is overwritten by the m  by ncolb  matrix Q H B .
7:     tdbIntegerInput
On entry: the stride separating matrix column elements in the array b.
Constraint: if ncolb>0  then tdbncolb .
8:     wantqNag_BooleanInput
On entry: wantq must be Nag_TRUE if the left-hand singular vectors are required. If wantq=Nag_FALSE  then the array q is not referenced and may be NULL.
9:     q[m×tdq]ComplexOutput
Note: the i,jth element of the matrix Q is stored in q[i-1×tdq+j-1].
On exit: if m<n  and wantq=Nag_TRUE , the leading m  by m  part of the array q will contain the unitary matrix Q . Otherwise the array q is not referenced and may be NULL.
10:   tdqIntegerInput
On entry: the stride separating matrix column elements in the array q.
Constraint: if m<n  and wantq=Nag_TRUE , tdqm
11:   sv[minm,n]doubleOutput
On exit: the minm,n  diagonal elements of the matrix S .
12:   wantpNag_BooleanInput
On entry: wantp must be Nag_TRUE if the right-hand singular vectors are required. If wantp = Nag_FALSE then the array ph is not referenced and may be NULL.
13:   ph[n×tdph]ComplexOutput
Note: the i,jth element of the matrix is stored in ph[i-1×tdph+j-1].
On exit: if mn  and wantq and wantp are Nag_TRUE, the leading n  by n  part of the array ph will contain the unitary matrix P H . Otherwise the array ph is not referenced and may be NULL.
14:   tdphIntegerInput
On entry: the stride separating matrix column elements in the array ph.
Constraint: if mn  and wantq=Nag_TRUE  and wantp=Nag_TRUE , tdphn
15:   iterInteger *Output
On exit: the total number of iterations taken by the QR  algorithm.
16:   e[minm,n]doubleOutput
On exit: if the error NE_QR_NOT_CONV occurs the array e contains the super-diagonal elements of matrix E  in the factorization of A  according to A = QEP H . See Section 6 for further details.
17:   failinfoInteger *Output
On exit: if the error NE_QR_NOT_CONV occurs failinfo contains the number of singular values which may not have been found correctly. See Section 6 for details.
18:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, tda=value  while n=value . These arguments must satisfy tdan .
On entry, tdb=value  while ncolb=value . These arguments must satisfy tdbncolb .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_INT_ARG_LT
On entry, m=value.
Constraint: m0.
On entry, n=value.
Constraint: n0.
On entry, ncolb=value.
Constraint: ncolb0.
NE_QR_NOT_CONV
The QR algorithm has failed to converge in value iterations. Singular values 1 , 2 , , failinfo  may not have been found correctly and the remaining singular values may not be the smallest. The matrix A  will nevertheless have been factorized as A = QEPT , where the leading minm,n  by minm,n  part of E  is a bidiagonal matrix with sv[0] , sv[1] , , sv[ minm,n-1 ]  as the diagonal elements and e[0] , e[1] , , e[ minm'n-2 ]  as the super-diagonal elements. This failure is not likely to occur.
NE_TDP_LT_N
On entry, tdph=value  while n=value . When wantq and wantp are Nag_TRUE and mn  then relationship tdphn  must be satisfied.
NE_TDQ_LT_M
On entry, tdq=value  while m=value . When wantq is Nag_TRUE and m<n  then relationship tdqm  must be satisfied.

7  Accuracy

The computed factors Q , D  and P  satisfy the relation
QDP H = A + E
where E c ε A , ε  being the machine precision, c  is a modest function of m  and n  and .  denotes the spectral (two) norm. Note that A = sv 1 .

8  Parallelism and Performance

Not applicable.

9  Further Comments

None.

10  Example

For this function two examples are presented. There is a single example program for nag_complex_svd (f02xec), with a main program and the code to solve the two example problems is given in the functions ex1 and ex2.
Example 1 (ex1)
To find the singular value decomposition of the 5 by 3 matrix
A = 0.5 i -0.5 + 1.5 i -1.0 + 1.0 i 0.4 + 0.3 i - 0.9 + 1.3 i - 0.2 + 1.4 i 0.4 +0.3 i -0.4 + 0.4 i - 1.8 +0.3 i 0.3 - 0.4 i - 0.1 + 0.7 i - 0.0 +0.3 i -0.3 i - 0.3 + 0.3 i 2.4 i
together with the vector Q H b  for the vector
b = -0.55 + 1.05 i 0.49 + 0.93 i 0.56 - 0.16 i 0.39 + 0.23 i 1.13 + 0.83 i .
Example 2 (ex2)
To find the singular value decomposition of the 3 by 5 matrix
A = 0.5 i 0.4 - 0.3 i - 0.4 -0.4 i 0.3 + 0.4 i 0.3 i -0.5 - 1.5 i 0.9 - 1.3 i -0.4 - 0.4 i 0.1 - 0.7 i 0.3 - 0.3 i -1.0 - 1.0 i 0.2 - 1.4 i - 1.8 -0.4 i - 0.0 -0.4 i -2.4 i .

10.1  Program Text

Program Text (f02xece.c)

10.2  Program Data

Program Data (f02xece.d)

10.3  Program Results

Program Results (f02xece.r)


nag_complex_svd (f02xec) (PDF version)
f02 Chapter Contents
f02 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014