nag_dbdsdc (f08mdc) (PDF version)
f08 Chapter Contents
f08 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_dbdsdc (f08mdc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_dbdsdc (f08mdc) computes the singular values and, optionally, the left and right singular vectors of a real n by n (upper or lower) bidiagonal matrix B.

2  Specification

#include <nag.h>
#include <nagf08.h>
void  nag_dbdsdc (Nag_OrderType order, Nag_UploType uplo, Nag_ComputeSingularVecsType compq, Integer n, double d[], double e[], double u[], Integer pdu, double vt[], Integer pdvt, double q[], Integer iq[], NagError *fail)

3  Description

nag_dbdsdc (f08mdc) computes the singular value decomposition (SVD) of the (upper or lower) bidiagonal matrix B as
B = USVT ,
where S is a diagonal matrix with non-negative diagonal elements sii=si, such that
s1 s2 sn 0 ,
and U and V are orthogonal matrices. The diagonal elements of S are the singular values of B and the columns of U and V are respectively the corresponding left and right singular vectors of B.
When only singular values are required the function uses the QR algorithm, but when singular vectors are required a divide and conquer method is used. The singular values can optionally be returned in compact form, although currently no function is available to apply U or V when stored in compact form.

4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

5  Arguments

1:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by order=Nag_RowMajor. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     uploNag_UploTypeInput
On entry: indicates whether B is upper or lower bidiagonal.
uplo=Nag_Upper
B is upper bidiagonal.
uplo=Nag_Lower
B is lower bidiagonal.
Constraint: uplo=Nag_Upper or Nag_Lower.
3:     compqNag_ComputeSingularVecsTypeInput
On entry: specifies whether singular vectors are to be computed.
compq=Nag_NotSingularVecs
Compute singular values only.
compq=Nag_PackedSingularVecs
Compute singular values and compute singular vectors in compact form.
compq=Nag_SingularVecs
Compute singular values and singular vectors.
Constraint: compq=Nag_NotSingularVecs, Nag_PackedSingularVecs or Nag_SingularVecs.
4:     nIntegerInput
On entry: n, the order of the matrix B.
Constraint: n0.
5:     d[dim]doubleInput/Output
Note: the dimension, dim, of the array d must be at least max1,n.
On entry: the n diagonal elements of the bidiagonal matrix B.
On exit: if fail.code= NE_NOERROR, the singular values of B.
6:     e[dim]doubleInput/Output
Note: the dimension, dim, of the array e must be at least max1,n-1.
On entry: the n-1 off-diagonal elements of the bidiagonal matrix B.
On exit: the contents of e are destroyed.
7:     u[dim]doubleOutput
Note: the dimension, dim, of the array u must be at least
  • max1,pdu×n when compq=Nag_SingularVecs;
  • 1 otherwise.
The i,jth element of the matrix U is stored in
  • u[j-1×pdu+i-1] when order=Nag_ColMajor;
  • u[i-1×pdu+j-1] when order=Nag_RowMajor.
On exit: if compq=Nag_SingularVecs, then if fail.code= NE_NOERROR, u contains the left singular vectors of the bidiagonal matrix B.
If compqNag_SingularVecs, u is not referenced.
8:     pduIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array u.
Constraints:
  • if compq=Nag_SingularVecs, pdu max1,n ;
  • otherwise pdu1.
9:     vt[dim]doubleOutput
Note: the dimension, dim, of the array vt must be at least
  • max1,pdvt×n when compq=Nag_SingularVecs;
  • 1 otherwise.
The i,jth element of the matrix is stored in
  • vt[j-1×pdvt+i-1] when order=Nag_ColMajor;
  • vt[i-1×pdvt+j-1] when order=Nag_RowMajor.
On exit: if compq=Nag_SingularVecs, then if fail.code= NE_NOERROR, the rows of vt contain the right singular vectors of the bidiagonal matrix B.
If compqNag_SingularVecs, vt is not referenced.
10:   pdvtIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array vt.
Constraints:
  • if compq=Nag_SingularVecs, pdvt max1,n ;
  • otherwise pdvt1.
11:   q[dim]doubleOutput
Note: the dimension, dim, of the array q must be at least max1,n2+5n,ldq.
On exit: if compq=Nag_PackedSingularVecs, then if fail.code= NE_NOERROR, q and iq contain the left and right singular vectors in a compact form, requiring O n log2n  space instead of 2×n2. In particular, q contains all the real data in the first ldq =n× 11+2× smlsiz+8× int log2 n/ smlsiz+1  elements of q, where smlsiz is equal to the maximum size of the subproblems at the bottom of the computation tree (usually about 25).
If compqNag_PackedSingularVecs, q is not referenced.
12:   iq[dim]IntegerOutput
Note: the dimension, dim, of the array iq must be at least max1,ldiq.
On exit: if compq=Nag_PackedSingularVecs, then if fail.code= NE_NOERROR, q and iq contain the left and right singular vectors in a compact form, requiring O n log2n  space instead of 2×n2. In particular, iq contains all integer data in the first ldiq =n× 3+3× int log2 n/ smlsiz+1  elements of iq, where smlsiz is equal to the maximum size of the subproblems at the bottom of the computation tree (usually about 25).
If compqNag_PackedSingularVecs, iq is not referenced.
13:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_ENUM_INT_2
On entry, compq=value, pdu=value and n=value.
Constraint: if compq=Nag_SingularVecs, pdu max1,n ;
otherwise pdu1.
On entry, compq=value, pdvt=value and n=value.
Constraint: if compq=Nag_SingularVecs, pdvt max1,n ;
otherwise pdvt1.
NE_INT
On entry, n=value.
Constraint: n0.
On entry, pdu=value.
Constraint: pdu>0.
On entry, pdvt=value.
Constraint: pdvt>0.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_SINGULAR
The algorithm failed to compute a singular value. The update process of divide-and-conquer failed.

7  Accuracy

Each computed singular value of B is accurate to nearly full relative precision, no matter how tiny the singular value. The ith computed singular value, s^i, satisfies the bound
s^i-si pnεsi
where ε is the machine precision and pn is a modest function of n.
For bounds on the computed singular values, see Section 4.9.1 of Anderson et al. (1999). See also nag_ddisna (f08flc).

8  Parallelism and Performance

nag_dbdsdc (f08mdc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_dbdsdc (f08mdc) 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 Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

If only singular values are required, the total number of floating-point operations is approximately proportional to n2. When singular vectors are required the number of operations is bounded above by approximately the same number of operations as nag_dbdsqr (f08mec), but for large matrices nag_dbdsdc (f08mdc) is usually much faster.
There is no complex analogue of nag_dbdsdc (f08mdc).

10  Example

This example computes the singular value decomposition of the upper bidiagonal matrix
B = 3.62 1.26 0.00 0.00 0.00 -2.41 -1.53 0.00 0.00 0.00 1.92 1.19 0.00 0.00 0.00 -1.43 .

10.1  Program Text

Program Text (f08mdce.c)

10.2  Program Data

Program Data (f08mdce.d)

10.3  Program Results

Program Results (f08mdce.r)


nag_dbdsdc (f08mdc) (PDF version)
f08 Chapter Contents
f08 Chapter Introduction
NAG Library Manual

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