F08KHF (DGEJSV) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08KHF (DGEJSV)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F08KHF (DGEJSV) computes the singular value decomposition (SVD) of a real $m$ by $n$ matrix $A$ where $m\ge n$, and optionally computes the left and/or right singular vectors. F08KHF (DGEJSV) implements the preconditioned Jacobi SVD of Drmac and Veselic. This is the expert driver routine that calls F08KJF (DGESVJ) after certain preconditioning. In most cases F08KBF (DGESVD) or F08KDF (DGESDD) is sufficient to obtain the SVD of a real matrix. These are much simpler to use and also handle the case $m.

## 2  Specification

 SUBROUTINE F08KHF ( JOBA, JOBU, JOBV, JOBR, JOBT, JOBP, M, N, A, LDA, SVA, U, LDU, V, LDV, WORK, LWORK, IWORK, INFO)
 INTEGER M, N, LDA, LDU, LDV, LWORK, IWORK(M+3*N), INFO REAL (KIND=nag_wp) A(LDA,*), SVA(N), U(LDU,*), V(LDV,*), WORK(LWORK) CHARACTER(1) JOBA, JOBU, JOBV, JOBR, JOBT, JOBP
The routine may be called by its LAPACK name dgejsv.

## 3  Description

The SVD is written as
 $A = UΣVT ,$
where $\Sigma$ is an $m$ by $n$ matrix which is zero except for its $n$ diagonal elements, $U$ is an $m$ by $m$ orthogonal matrix, and $V$ is an $n$ by $n$ orthogonal matrix. The diagonal elements of $\Sigma$ are the singular values of $A$ in descending order of magnitude. The columns of $U$ and $V$ are the left and the right singular vectors of $A$. The diagonal of $\Sigma$ is computed and stored in the array SVA.
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
Drmac Z and Veselic K (2008a) New fast and accurate Jacobi SVD algorithm I SIAM J. Matrix Anal. Appl. 29 4
Drmac Z and Veselic K (2008b) New fast and accurate Jacobi SVD algorithm II SIAM J. Matrix Anal. Appl. 29 4
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Parameters

1:     JOBA – CHARACTER(1)Input
On entry: specifies the form of pivoting for the $QR$ factorization stage; whether an estimate of the condition number of the scaled matrix is required; and the form of rank reduction that is performed.
${\mathbf{JOBA}}=\text{'C'}$
The initial $QR$ factorization of the input matrix is performed with column pivoting; no estimate of condition number is computed; and, the rank is reduced by only the underflowed part of the triangular factor $R$. This option works well (high relative accuracy) if $A=BD$, with well-conditioned $B$ and arbitrary diagonal matrix $D$. The accuracy cannot be spoiled by column scaling. The accuracy of the computed output depends on the condition of $B$, and the procedure aims at the best theoretical accuracy.
${\mathbf{JOBA}}=\text{'E'}$
Computation as with ${\mathbf{JOBA}}=\text{'C'}$ with an additional estimate of the condition number of $B$. It provides a realistic error bound.
${\mathbf{JOBA}}=\text{'F'}$
The initial $QR$ factorization of the input matrix is performed with full row and column pivoting; no estimate of condition number is computed; and, the rank is reduced by only the underflowed part of the triangular factor $R$. If $A={D}_{1}×C×{D}_{2}$ with ill-conditioned diagonal scalings ${D}_{1}$, ${D}_{2}$, and well-conditioned matrix $C$, this option gives higher accuracy than the ${\mathbf{JOBA}}=\text{'C'}$ option. If the structure of the input matrix is not known, and relative accuracy is desirable, then this option is advisable.
${\mathbf{JOBA}}=\text{'G'}$
Computation as with ${\mathbf{JOBA}}=\text{'F'}$ with an additional estimate of the condition number of $B$, where $A=DB$ (i.e., $B=C×{D}_{2}$). If $A$ has heavily weighted rows, then using this condition number gives too pessimistic an error bound.
${\mathbf{JOBA}}=\text{'A'}$
Computation as with ${\mathbf{JOBA}}=\text{'C'}$ except in the treatment of rank reduction. In this case, small singular values are to be considered as noise and, if found, the matrix is treated as numerically rank deficient. The computed SVD $A=U\Sigma {V}^{\mathrm{T}}$ restores $A$ up to $f\left(m,n\right)×\epsilon ×‖A‖$, where $\epsilon$ is machine precision. This gives the procedure licence to discard (set to zero) all singular values below ${\mathbf{N}}×\epsilon ×‖A‖$.
${\mathbf{JOBA}}=\text{'R'}$
Similar to ${\mathbf{JOBA}}=\text{'A'}$. The rank revealing property of the initial $QR$ factorization is used to reveal (using the upper triangular factor) a gap ${\sigma }_{r+1}<\epsilon {\sigma }_{r}$ in which case the numerical rank is declared to be $r$. The SVD is computed with absolute error bounds, but more accurately than with ${\mathbf{JOBA}}=\text{'A'}$.
Constraint: ${\mathbf{JOBA}}=\text{'C'}$, $\text{'E'}$, $\text{'F'}$, $\text{'G'}$, $\text{'A'}$ or $\text{'R'}$.
2:     JOBU – CHARACTER(1)Input
On entry: specifies options for computing the left singular vectors $U$.
${\mathbf{JOBU}}=\text{'U'}$
The first $n$ left singular vectors (columns of $U$) are computed and returned in the array U.
${\mathbf{JOBU}}=\text{'F'}$
All $m$ left singular vectors are computed and returned in the array U.
${\mathbf{JOBU}}=\text{'W'}$
No left singular vectors are computed, but the array U (with ${\mathbf{LDU}}\ge {\mathbf{M}}$ and second dimension at least N) is available as workspace for computing right singular values. See the description of U.
${\mathbf{JOBU}}=\text{'N'}$
No left singular vectors are computed. ${\mathbf{U}}$ is not referenced.
Constraint: ${\mathbf{JOBU}}=\text{'U'}$, $\text{'F'}$, $\text{'W'}$ or $\text{'N'}$.
3:     JOBV – CHARACTER(1)Input
On entry: specifies options for computing the right singular vectors $V$.
${\mathbf{JOBV}}=\text{'V'}$
the $n$ right singular vectors (columns of $V$) are computed and returned in the array V; Jacobi rotations are not explicitly accumulated.
${\mathbf{JOBV}}=\text{'J'}$
the $n$ right singular vectors (columns of $V$) are computed and returned in the array V, but they are computed as the product of Jacobi rotations. This option is allowed only if ${\mathbf{JOBU}}=\text{'U'}$ or $\text{'F'}$, i.e., in computing the full SVD.
${\mathbf{JOBV}}=\text{'W'}$
No right singular values are computed, but the array V (with ${\mathbf{LDV}}\ge {\mathbf{N}}$ and second dimension at least N) is available as workspace for computing left singular values. See the description of V.
${\mathbf{JOBV}}=\text{'N'}$
No right singular vectors are computed. ${\mathbf{V}}$ is not referenced.
Constraints:
• ${\mathbf{JOBV}}=\text{'V'}$, $\text{'J'}$, $\text{'W'}$ or $\text{'N'}$;
• if ${\mathbf{JOBU}}=\text{'W'}$ or $\text{'N'}$, ${\mathbf{JOBV}}\ne \text{'J'}$.
4:     JOBR – CHARACTER(1)Input
On entry: specifies the conditions under which columns of $A$ are to be set to zero. This effectively specifies a lower limit on the range of singular values; any singular values below this limit are (through column zeroing) set to zero. If $A\ne 0$ is scaled so that the largest column (in the Euclidean norm) of $cA$ is equal to the square root of the overflow threshold, then JOBR allows the routine to kill columns of $A$ whose norm in $cA$ is less than $\sqrt{\mathit{sfmin}}$ (for ${\mathbf{JOBR}}=\text{'R'}$), or less than $\mathit{sfmin}/\epsilon$ (otherwise). $\mathit{sfmin}$ is the safe range parameter, as returned by routine X02AMF.
${\mathbf{JOBR}}=\text{'N'}$
Only set to zero those columns of $A$ for which the norm of corresponding column of $cA<\mathit{sfmin}/\epsilon$, that is, those columns that are effectively zero (to machine precision) anyway. If the condition number of $A$ is greater than the overflow threshold $\lambda$, where $\lambda$ is the value returned by X02ALF, you are recommended to use routine F08KJF (DGESVJ).
${\mathbf{JOBR}}=\text{'R'}$
Set to zero those columns of $A$ for which the norm of the corresponding column of $cA<\sqrt{\mathit{sfmin}}$. This approximately represents a restricted range for $\sigma \left(cA\right)$ of $\left[\sqrt{\mathit{sfmin}},\sqrt{\lambda }\right]$.
For computing the singular values in the full range from the safe minimum up to the overflow threshold use F08KJF (DGESVJ).
Suggested value: ${\mathbf{JOBR}}=\text{'R'}$
Constraint: ${\mathbf{JOBR}}=\text{'N'}$ or $\text{'R'}$.
5:     JOBT – CHARACTER(1)Input
On entry: specifies, in the case $n=m$, whether the routine is permitted to use the transpose of $A$ for improved efficiency. If the matrix is square then the procedure may use transposed $A$ if ${A}^{\mathrm{T}}$ seems to be better with respect to convergence. If the matrix is not square, JOBT is ignored. The decision is based on two values of entropy over the adjoint orbit of ${A}^{\mathrm{T}}A$. See the descriptions of ${\mathbf{WORK}}\left(6\right)$ and ${\mathbf{WORK}}\left(7\right)$.
${\mathbf{JOBT}}=\text{'T'}$
If $n=m$, perform an entropy test and then transpose if the test indicates possibly faster convergence of the Jacobi process if ${A}^{\mathrm{T}}$ is taken as input. If $A$ is replaced with ${A}^{\mathrm{T}}$, then the row pivoting is included automatically.
${\mathbf{JOBT}}=\text{'N'}$
No entropy test and no transposition is performed.
The option ${\mathbf{JOBT}}=\text{'T'}$ can be used to compute only the singular values, or the full SVD ($U$, $\Sigma$ and $V$). In the case where only one set of singular vectors ($U$ or $V$) is required, the caller must still provide both U and V, as one of the matrices is used as workspace if the matrix $A$ is transposed. See the descriptions of U and V.
Constraint: ${\mathbf{JOBT}}=\text{'T'}$ or $\text{'N'}$.
6:     JOBP – CHARACTER(1)Input
On entry: specifies whether the routine should be allowed to introduce structured perturbations to drown denormalized numbers. For details see Drmac and Veselic (2008a) and Drmac and Veselic (2008b). For the sake of simplicity, these perturbations are included only when the full SVD or only the singular values are requested.
${\mathbf{JOBP}}=\text{'P'}$
Introduce perturbation if $A$ is found to be very badly scaled (introducing denormalized numbers).
${\mathbf{JOBP}}=\text{'N'}$
Do not perturb.
Constraint: ${\mathbf{JOBP}}=\text{'P'}$ or $\text{'N'}$.
7:     M – INTEGERInput
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{M}}\ge 0$.
8:     N – INTEGERInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{M}}\ge {\mathbf{N}}\ge 0$.
9:     A(LDA,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $m$ by $n$ matrix $A$.
On exit: the contents of A are overwritten.
10:   LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08KHF (DGEJSV) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$.
11:   SVA(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the, possibly scaled, singular values of $A$.
The singular values of $A$ are ${\sigma }_{\mathit{i}}=\alpha {\mathbf{SVA}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,n$, where $\alpha ={\mathbf{WORK}}\left(1\right)/{\mathbf{WORK}}\left(2\right)$. Normally $\alpha =1$ and no scaling is required to obtain the singular values. However, if the largest singular value of $A$ overflows or if small singular values have been saved from underflow by scaling the input matrix $A$, then $\alpha \ne 1$.
If ${\mathbf{JOBR}}=\text{'R'}$ then some of the singular values may be returned as exact zeros because they are below the numerical rank threshold or are denormalized numbers.
12:   U(LDU,$*$) – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array U must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$ if ${\mathbf{JOBU}}=\text{'F'}$, $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{JOBU}}=\text{'U'}$ or $\text{'W'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{JOBU}}=\text{'U'}$, U contains the $m$ by $n$ matrix of the left singular vectors.
If ${\mathbf{JOBU}}=\text{'F'}$, U contains the $m$ by $m$ matrix of the left singular vectors, including an orthonormal basis of the orthogonal complement of Range($A$).
If ${\mathbf{JOBU}}=\text{'W'}$ and (${\mathbf{JOBV}}=\text{'V'}$ and ${\mathbf{JOBT}}=\text{'T'}$ and ${\mathbf{M}}={\mathbf{N}}$), then U is used as workspace if the procedure replaces $A$ with ${A}^{\mathrm{T}}$. In that case, $V$ is computed in U as left singular vectors of ${A}^{\mathrm{T}}$ and then copied back to the array V.
If ${\mathbf{JOBU}}=\text{'N'}$, U is not referenced.
13:   LDU – INTEGERInput
On entry: the first dimension of the array U as declared in the (sub)program from which F08KHF (DGEJSV) is called.
Constraints:
• if ${\mathbf{JOBU}}=\text{'F'}$, $\text{'U'}$ or $\text{'W'}$, ${\mathbf{LDU}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$;
• otherwise ${\mathbf{LDU}}\ge 1$.
14:   V(LDV,$*$) – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array V must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{JOBV}}=\text{'V'}$, $\text{'J'}$ or $\text{'W'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{JOBV}}=\text{'V'}$ or $\text{'J'}$, V contains the $n$ by $n$ matrix of the right singular vectors.
If ${\mathbf{JOBV}}=\text{'W'}$ and (${\mathbf{JOBU}}=\text{'U'}$ and ${\mathbf{JOBT}}=\text{'T'}$ and ${\mathbf{M}}={\mathbf{N}}$), then V is used as workspace if the procedure replaces $A$ with ${A}^{\mathrm{T}}$. In that case, $U$ is computed in V as right singular vectors of ${A}^{\mathrm{T}}$ and then copied back to the array U.
If ${\mathbf{JOBV}}=\text{'N'}$, V is not referenced.
15:   LDV – INTEGERInput
On entry: the first dimension of the array V as declared in the (sub)program from which F08KHF (DGEJSV) is called.
Constraints:
• if ${\mathbf{JOBV}}=\text{'V'}$, $\text{'J'}$ or $\text{'W'}$, ${\mathbf{LDV}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDV}}\ge 1$.
16:   WORK(LWORK) – REAL (KIND=nag_wp) arrayWorkspace
On exit: contains information about the completed job.
${\mathbf{WORK}}\left(1\right)$
$\alpha ={\mathbf{WORK}}\left(1\right)/{\mathbf{WORK}}\left(2\right)$ is the scaling factor such that ${\sigma }_{\mathit{i}}=\alpha {\mathbf{SVA}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,n$ are the computed singular values of $A$. (See the description of ${\mathbf{SVA}}$.)
${\mathbf{WORK}}\left(2\right)$
See the description of ${\mathbf{WORK}}\left(1\right)$.
${\mathbf{WORK}}\left(3\right)$
sconda, an estimate for the condition number of column equilibrated $A$ (if ${\mathbf{JOBA}}=\text{'E'}$ or $\text{'G'}$). sconda is an estimate of $\sqrt{\left({‖{\left({R}^{\mathrm{T}}R\right)}^{-1}‖}_{1}\right)}$. It is computed using F07FGF (DPOCON). It satisfies ${n}^{-\frac{1}{4}}×\mathit{sconda}\le {‖{R}^{-1}‖}_{2}\le {n}^{\frac{1}{4}}×\mathit{sconda}$ where $R$ is the triangular factor from the $QR$ factorization of $A$. However, if $R$ is truncated and the numerical rank is determined to be strictly smaller than $n$, sconda is returned as $-1$, thus indicating that the smallest singular values might be lost.
If full SVD is needed, and you are familiar with the details of the method, the following two condition numbers are useful for the analysis of the algorithm.
${\mathbf{WORK}}\left(4\right)$
An estimate of the scaled condition number of the triangular factor in the first $QR$ factorization.
${\mathbf{WORK}}\left(5\right)$
An estimate of the scaled condition number of the triangular factor in the second $QR$ factorization.
The following two parameters are computed if ${\mathbf{JOBT}}=\text{'T'}$.
${\mathbf{WORK}}\left(6\right)$
The entropy of ${A}^{\mathrm{T}}A$: this is the Shannon entropy of $\mathrm{diag}{A}^{\mathrm{T}}A/\mathrm{trace}{A}^{\mathrm{T}}A$ taken as a point in the probability simplex.
${\mathbf{WORK}}\left(7\right)$
The entropy of $A{A}^{\mathrm{T}}$.
17:   LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08KHF (DGEJSV) is called.
If ${\mathbf{JOBU}}=\text{'N'}$ and ${\mathbf{JOBV}}=\text{'N'}$
if ${\mathbf{JOBA}}\ne \text{'E'}$ or $\text{'G'}$
The minimal requirement is ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2{\mathbf{M}}+{\mathbf{N}},4{\mathbf{N}}+1,7\right)$.
For optimal performance the requirement is ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2{\mathbf{M}}+{\mathbf{N}},3{\mathbf{N}}+\left({\mathbf{N}}+1\right)\mathit{nb},7\right)$, where $\mathit{nb}$ is the block size used by F08AEF (DGEQRF) and F08BFF (DGEQP3). Assuming a value of $\mathit{nb}=128$ is wise, but choosing a smaller value (e.g., $\mathit{nb}=64$) should still lead to acceptable performance.
if ${\mathbf{JOBA}}=\text{'E'}$ or $\text{'G'}$
In this case, LWORK is the maximum of the above and ${\mathbf{N}}×{\mathbf{N}}+4{\mathbf{N}}$, i.e., ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2{\mathbf{M}}+{\mathbf{N}},3{\mathbf{N}}+\left({\mathbf{N}}+1\right)\mathit{nb},{\mathbf{N}}×{\mathbf{N}}+4{\mathbf{N}},7\right)$.
If ${\mathbf{JOBU}}\ne \text{'U'}$ or $\text{'F'}$ and ${\mathbf{JOBV}}=\text{'V'}$ or $\text{'J'}$
The minimal requirement is ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2{\mathbf{N}}+{\mathbf{M}},7\right)$.
For optimal performance, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2{\mathbf{N}}+{\mathbf{M}},2{\mathbf{N}}+{\mathbf{N}}×\mathit{nb},7\right)$, where $\mathit{nb}$ is described above.
If ${\mathbf{JOBU}}=\text{'U'}$ or $\text{'F'}$ and ${\mathbf{JOBV}}\ne \text{'V'}$ or $\text{'J'}$
The minimal requirement is ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2{\mathbf{N}}+{\mathbf{M}},7\right)$.
For optimal performance, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2{\mathbf{N}}+{\mathbf{M}},2{\mathbf{N}}+{\mathbf{N}}×\mathit{nb},7\right)$, where $\mathit{nb}$ is described above.
If ${\mathbf{JOBU}}=\text{'U'}$ or $\text{'F'}$ and ${\mathbf{JOBV}}=\text{'V'}$
${\mathbf{LWORK}}\ge 6{\mathbf{N}}+2{\mathbf{N}}×{\mathbf{N}}$.
If ${\mathbf{JOBU}}=\text{'U'}$ or $\text{'F'}$ and ${\mathbf{JOBV}}=\text{'J'}$
The minimal requirement is ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{M}}+3{\mathbf{N}}+{\mathbf{N}}×{\mathbf{N}},7\right)$.
For better performance ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(3{\mathbf{N}}+{\mathbf{N}}×{\mathbf{N}}+{\mathbf{M}},3{\mathbf{N}}+{\mathbf{N}}×{\mathbf{N}}+{\mathbf{N}}×\mathit{nb},7\right)$, where $\mathit{nb}$ is described above.
18:   IWORK(${\mathbf{M}}+3×{\mathbf{N}}$) – INTEGER arrayOutput
On exit: contains information about the completed job.
${\mathbf{IWORK}}\left(1\right)$
The numerical rank of $A$ determined after the initial $QR$ factorization with pivoting. See the descriptions of JOBA and JOBR.
${\mathbf{IWORK}}\left(2\right)$
The number of computed nonzero singular values.
${\mathbf{IWORK}}\left(3\right)$
If nonzero, a warning message: If ${\mathbf{IWORK}}\left(3\right)=1$ then some of the column norms of $A$ were denormalized (tiny) numbers. The requested high accuracy is not warranted by the data.
19:   INFO – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{INFO}}>0$
F08KHF (DGEJSV) did not converge in the maximal number of sweeps. The computed values might be inaccurate.

## 7  Accuracy

The computed singular value decomposition is nearly the exact singular value decomposition for a nearby matrix $\left(A+E\right)$, where
 $E2 = Oε A2 ,$
and $\epsilon$ is the machine precision. In addition, the computed singular vectors are nearly orthogonal to working precision. See Section 4.9 of Anderson et al. (1999) for further details.

## 8  Further Comments

F08KHF (DGEJSV) implements a preconditioned Jacobi SVD algorithm. It uses F08AEF (DGEQRF), F08AHF (DGELQF) and F08BFF (DGEQP3) as preprocessors and preconditioners. Optionally, an additional row pivoting can be used as a preprocessor, which in some cases results in much higher accuracy. An example is matrix $A$ with the structure $A={D}_{1}C{D}_{2}$, where ${D}_{1}$, ${D}_{2}$ are arbitrarily ill-conditioned diagonal matrices and $C$ is a well-conditioned matrix. In that case, complete pivoting in the first $QR$ factorizations provides accuracy dependent on the condition number of $C$, and independent of ${D}_{1}$, ${D}_{2}$. Such higher accuracy is not completely understood theoretically, but it works well in practice. Further, if $A$ can be written as $A=BD$, with well-conditioned $B$ and some diagonal $D$, then the high accuracy is guaranteed, both theoretically and in software, independent of $D$.

## 9  Example

This example finds the singular values and left and right singular vectors of the $6$ by $4$ matrix
 $A = 2.27 -1.54 1.15 -1.94 0.28 -1.67 0.94 -0.78 -0.48 -3.09 0.99 -0.21 1.07 1.22 0.79 0.63 -2.35 2.93 -1.45 2.30 0.62 -7.39 1.03 -2.57 ,$
together with the condition number of $A$ and approximate error bounds for the computed singular values and vectors.

### 9.1  Program Text

Program Text (f08khfe.f90)

### 9.2  Program Data

Program Data (f08khfe.d)

### 9.3  Program Results

Program Results (f08khfe.r)

F08KHF (DGEJSV) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual