PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_lapack_dgesvj (f08kj)
Purpose
nag_lapack_dgesvj (f08kj) computes the one-sided Jacobi singular value decomposition (SVD) of a real
by
matrix
,
, with fast scaled rotations and de Rijk’s pivoting, optionally computing the left and/or right singular vectors. For
, the functions
nag_lapack_dgesvd (f08kb) or
nag_lapack_dgesdd (f08kd) may be used.
Syntax
[
a,
sva,
v,
work,
info] = f08kj(
joba,
jobu,
jobv,
a,
mv,
v,
work, 'm',
m, 'n',
n)
[
a,
sva,
v,
work,
info] = nag_lapack_dgesvj(
joba,
jobu,
jobv,
a,
mv,
v,
work, 'm',
m, 'n',
n)
Description
The SVD is written as
where
is an
by
diagonal matrix,
is an
by
orthonormal matrix, and
is an
by
orthogonal matrix. The diagonal elements of
are the singular values of
in descending order of magnitude. The columns of
and
are the left and the right singular vectors of
.
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
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
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
Specifies the structure of matrix
.
- The input matrix is lower triangular.
- The input matrix is upper triangular.
- The input matrix is a general by matrix, .
Constraint:
, or .
- 2:
– string (length ≥ 1)
-
Specifies whether to compute the left singular vectors and if so whether you want to control their numerical orthogonality threshold.
- The left singular vectors corresponding to the nonzero singular values are computed and returned in the leading columns of a. See more details in the description of a. The numerical orthogonality threshold is set to approximately , where is the machine precision and .
- Analogous to , except that you can control the level of numerical orthogonality of the computed left singular vectors. The orthogonality threshold is set to , where is given on input in . The option can be used if is a satisfactory orthogonality of the computed left singular vectors, so could save a few sweeps of Jacobi rotations. See the descriptions of a and .
- The matrix is not computed. However, see the description of a.
Constraint:
, or .
- 3:
– string (length ≥ 1)
-
Specifies whether and how to compute the right singular vectors.
- The matrix is computed and returned in the array v.
- The Jacobi rotations are applied to the leading by part of the array v. In other words, the right singular vector matrix is not computed explicitly, instead it is applied to an by matrix initially stored in the first mv rows of v.
- The matrix is not computed and the array v is not referenced.
Constraint:
, or .
- 4:
– double array
-
The first dimension of the array
a must be at least
.
The second dimension of the array
a must be at least
.
The by matrix .
- 5:
– int64int32nag_int scalar
-
If
, the product of Jacobi rotations is applied to the first
rows of
v.
If
,
mv is ignored. See the description of
jobv.
- 6:
– double array
-
The first dimension,
, of the array
v must satisfy
- if , ;
- if , ;
- otherwise .
The second dimension of the array
v must be at least
if
or
, and at least
otherwise.
If
,
v must contain an
by
matrix to be premultiplied by the matrix
of right singular vectors.
- 7:
– double array
-
lwork, the dimension of the array, must satisfy the constraint
.
If
,
, where
defines the threshold for convergence. The process stops if all columns of
are mutually orthogonal up to
. It is required that
, i.e., it is not possible to force the function to obtain orthogonality below
.
greater than
is meaningless, where
is the
machine precision.
Constraint:
if , .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a.
, the number of rows of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
a.
, the number of columns of the matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
The first dimension of the array
a will be
.
The second dimension of the array
a will be
.
The matrix
containing the left singular vectors of
.
- If or
-
- if
- orthonormal columns of are returned in the leading columns of the array a. Here is the number of computed singular values of that are above the safe range parameter, as returned by nag_machine_real_safe (x02am). The singular vectors corresponding to underflowed or zero singular values are not computed. The value of is returned by rounding to the nearest whole number. Also see the descriptions of sva and work. The computed columns of are mutually numerically orthogonal up to approximately ; or (), where is the machine precision and is supplied on entry in , see the description of jobu.
- If
- nag_lapack_dgesvj (f08kj) did not converge in iterations (sweeps). In this case, the computed columns of may not be orthogonal up to . The output (stored in a), (given by the computed singular values in sva) and is still a decomposition of the input matrix in the sense that the residual is small, where is the value returned in .
- If
-
- if
- Note that the left singular vectors are ‘for free’ in the one-sided Jacobi SVD algorithm. However, if only the singular values are needed, the level of numerical orthogonality of is not an issue and iterations are stopped when the columns of the iterated matrix are numerically orthogonal up to approximately . Thus, on exit, a contains the columns of scaled with the corresponding singular values.
- If
- nag_lapack_dgesvj (f08kj) did not converge in iterations (sweeps).
- 2:
– double array
-
The, possibly scaled, singular values of
.
- If
- The singular values of are
, for , where is the scale factor stored in . Normally , however, if some of the singular values of might underflow or overflow, then and the scale factor needs to be applied to obtain the singular values.
- If
- nag_lapack_dgesvj (f08kj) did not converge in iterations and may not be accurate.
- 3:
– double array
-
The first dimension,
, of the array
v will be
- if , ;
- if , ;
- otherwise .
The second dimension of the array
v will be
if
or
and
otherwise.
The right singular vectors of
.
If
,
v contains the
by
matrix of the right singular vectors.
If
,
v contains the product of the computed right singular vector matrix and the initial matrix in the array
v.
If
,
v is not referenced.
- 4:
– double array
-
.
Contains information about the completed job.
- the scaling factor, , such that
, for are the computed singular values of . (See description of sva.)
- gives the number of the computed nonzero singular values.
- gives the number of the computed singular values that are larger than the underflow threshold.
- gives the number of iterations (sweeps of Jacobi rotations) needed for numerical convergence.
- in the last iteration (sweep). This is useful information in cases when nag_lapack_dgesvj (f08kj) did not converge, as it can be used to estimate whether the output is still useful and for subsequent analysis.
- The largest absolute value over all sines of the Jacobi rotation angles in the last sweep. It can be useful for subsequent analysis.
- 5:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
If , argument had an illegal value. An explanatory message is output, and execution of the program is terminated.
- W
-
nag_lapack_dgesvj (f08kj) did not converge in the allowed number of iterations (), but its output might still be useful.
Accuracy
The computed singular value decomposition is nearly the exact singular value decomposition for a nearby matrix
, where
and
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.
See Section 6 of
Drmac and Veselic (2008a) for a detailed discussion of the accuracy of the computed SVD.
Further Comments
This SVD algorithm is numerically superior to the bidiagonalization based
algorithm implemented by
nag_lapack_dgesvd (f08kb) and the divide and conquer algorithm implemented by
nag_lapack_dgesdd (f08kd) algorithms and is considerably faster than previous implementations of the (equally accurate) Jacobi SVD method. Moreover, this algorithm can compute the SVD faster than
nag_lapack_dgesvd (f08kb) and not much slower than
nag_lapack_dgesdd (f08kd). See Section 3.3 of
Drmac and Veselic (2008b) for the details.
Example
This example finds the singular values and left and right singular vectors of the
by
matrix
together with approximate error bounds for the computed singular values and vectors.
Open in the MATLAB editor:
f08kj_example
function f08kj_example
fprintf('f08kj example results\n\n');
m = int64(6);
n = int64(4);
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];
joba = 'g';
jobu = 'u';
jobv = 'v';
work = zeros(10,1);
v = zeros(4, 4);
mv = int64(0);
[a, sva, v, work, info] = f08kj( ...
joba, jobu, jobv, a, mv, v, work);
eps = x02aj;
serrbd = eps*sva(1);
fprintf('Singular values:\n');
disp(transpose(sva));
if (abs(work(1)-1) > eps)
fprintf('\nValues nned scaling by %13.5e.\n', work(1));
end
[ifail] = x04ca( ...
'Gen', ' ', a, 'Left singular vectors');
fprintf('\n');
[ifail] = x04ca( ...
'Gen', ' ', v, 'Right singular vectors');
[rcondu, info] = f08fl( ...
'Left', m, n, sva);
[rcondv, info] = f08fl( ...
'Right', m, n, sva);
fprintf('\nError estimate for the singular values a\n');
fprintf('%11.1e\n', serrbd);
fprintf('\nError estimates for left singular vectors\n');
fprintf('%11.1e ',serrbd./rcondu);
fprintf('\n\nError estimates for right singular vectors\n');
fprintf('%11.1e ',serrbd./rcondv);
fprintf('\n');
f08kj example results
Singular values:
9.9966 3.6831 1.3569 0.5000
Left singular vectors
1 2 3 4
1 -0.2774 0.6003 -0.1277 0.1323
2 -0.2020 0.0301 0.2805 0.7034
3 -0.2918 -0.3348 0.6453 0.1906
4 0.0938 0.3699 0.6781 -0.5399
5 0.4213 -0.5266 0.0413 -0.0575
6 -0.7816 -0.3353 -0.1645 -0.3957
Right singular vectors
1 2 3 4
1 -0.1921 0.8030 0.0041 -0.5642
2 0.8794 0.3926 -0.0752 0.2587
3 -0.2140 0.2980 0.7827 0.5027
4 0.3795 -0.3351 0.6178 -0.6017
Error estimate for the singular values a
1.1e-15
Error estimates for left singular vectors
1.8e-16 4.8e-16 1.3e-15 2.2e-15
Error estimates for right singular vectors
1.8e-16 4.8e-16 1.3e-15 1.3e-15
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015