📄 sbdsdc.c
字号:
#include "blaswrap.h"
/* -- translated by f2c (version 19990503).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/
#include "f2c.h"
/* Common Block Declarations */
struct {
real ops, itcnt;
} latime_;
#define latime_1 latime_
/* Table of constant values */
static integer c__9 = 9;
static integer c__0 = 0;
static real c_b15 = 1.f;
static integer c__1 = 1;
static real c_b29 = 0.f;
/* Subroutine */ int sbdsdc_(char *uplo, char *compq, integer *n, real *d__,
real *e, real *u, integer *ldu, real *vt, integer *ldvt, real *q,
integer *iq, real *work, integer *iwork, integer *info)
{
/* System generated locals */
integer u_dim1, u_offset, vt_dim1, vt_offset, i__1, i__2;
real r__1;
/* Builtin functions */
double r_sign(real *, real *), log(doublereal);
/* Local variables */
static integer difl, difr, ierr, perm, mlvl, sqre, i__, j, k;
static real p, r__;
static integer z__;
extern logical lsame_(char *, char *);
static integer poles;
extern /* Subroutine */ int slasr_(char *, char *, char *, integer *,
integer *, real *, real *, real *, integer *);
static integer iuplo, nsize, start;
extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *,
integer *), sswap_(integer *, real *, integer *, real *, integer *
), slasd0_(integer *, integer *, real *, real *, real *, integer *
, real *, integer *, integer *, integer *, real *, integer *);
static integer ic, ii, kk;
static real cs;
static integer is, iu;
static real sn;
extern doublereal slamch_(char *);
extern /* Subroutine */ int slasda_(integer *, integer *, integer *,
integer *, real *, real *, real *, integer *, real *, integer *,
real *, real *, real *, real *, integer *, integer *, integer *,
integer *, real *, real *, real *, real *, integer *, integer *),
xerbla_(char *, integer *);
extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
integer *, integer *, ftnlen, ftnlen);
extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *,
real *, integer *, integer *, real *, integer *, integer *);
static integer givcol;
extern /* Subroutine */ int slasdq_(char *, integer *, integer *, integer
*, integer *, integer *, real *, real *, real *, integer *, real *
, integer *, real *, integer *, real *, integer *);
static integer icompq;
extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *,
real *, real *, integer *), slartg_(real *, real *, real *
, real *, real *);
static real orgnrm;
static integer givnum;
extern doublereal slanst_(char *, integer *, real *, real *);
static integer givptr, nm1, qstart, smlsiz, wstart, smlszp;
static real eps;
static integer ivt;
#define u_ref(a_1,a_2) u[(a_2)*u_dim1 + a_1]
#define vt_ref(a_1,a_2) vt[(a_2)*vt_dim1 + a_1]
/* -- LAPACK routine (instrumented to count ops, version 3.0) --
Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
Courant Institute, Argonne National Lab, and Rice University
October 31, 1999
Purpose
=======
SBDSDC computes the singular value decomposition (SVD) of a real
N-by-N (upper or lower) bidiagonal matrix B: B = U * S * VT,
using a divide and conquer method, where S is a diagonal matrix
with non-negative diagonal elements (the singular values of B), and
U and VT are orthogonal matrices of left and right singular vectors,
respectively. SBDSDC can be used to compute all singular values,
and optionally, singular vectors or singular vectors in compact form.
This code makes very mild assumptions about floating point
arithmetic. It will work on machines with a guard digit in
add/subtract, or on those binary machines without guard digits
which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2.
It could conceivably fail on hexadecimal or decimal machines
without guard digits, but we know of none. See SLASD3 for details.
The code currently call SLASDQ if singular values only are desired.
However, it can be slightly modified to compute singular values
using the divide and conquer method.
Arguments
=========
UPLO (input) CHARACTER*1
= 'U': B is upper bidiagonal.
= 'L': B is lower bidiagonal.
COMPQ (input) CHARACTER*1
Specifies whether singular vectors are to be computed
as follows:
= 'N': Compute singular values only;
= 'P': Compute singular values and compute singular
vectors in compact form;
= 'I': Compute singular values and singular vectors.
N (input) INTEGER
The order of the matrix B. N >= 0.
D (input/output) REAL array, dimension (N)
On entry, the n diagonal elements of the bidiagonal matrix B.
On exit, if INFO=0, the singular values of B.
E (input/output) REAL array, dimension (N)
On entry, the elements of E contain the offdiagonal
elements of the bidiagonal matrix whose SVD is desired.
On exit, E has been destroyed.
U (output) REAL array, dimension (LDU,N)
If COMPQ = 'I', then:
On exit, if INFO = 0, U contains the left singular vectors
of the bidiagonal matrix.
For other values of COMPQ, U is not referenced.
LDU (input) INTEGER
The leading dimension of the array U. LDU >= 1.
If singular vectors are desired, then LDU >= max( 1, N ).
VT (output) REAL array, dimension (LDVT,N)
If COMPQ = 'I', then:
On exit, if INFO = 0, VT' contains the right singular
vectors of the bidiagonal matrix.
For other values of COMPQ, VT is not referenced.
LDVT (input) INTEGER
The leading dimension of the array VT. LDVT >= 1.
If singular vectors are desired, then LDVT >= max( 1, N ).
Q (output) REAL array, dimension (LDQ)
If COMPQ = 'P', then:
On exit, if INFO = 0, Q and IQ contain the left
and right singular vectors in a compact form,
requiring O(N log N) space instead of 2*N**2.
In particular, Q contains all the REAL data in
LDQ >= N*(11 + 2*SMLSIZ + 8*INT(LOG_2(N/(SMLSIZ+1))))
words of memory, where SMLSIZ is returned by ILAENV and
is equal to the maximum size of the subproblems at the
bottom of the computation tree (usually about 25).
For other values of COMPQ, Q is not referenced.
IQ (output) INTEGER array, dimension (LDIQ)
If COMPQ = 'P', then:
On exit, if INFO = 0, Q and IQ contain the left
and right singular vectors in a compact form,
requiring O(N log N) space instead of 2*N**2.
In particular, IQ contains all INTEGER data in
LDIQ >= N*(3 + 3*INT(LOG_2(N/(SMLSIZ+1))))
words of memory, where SMLSIZ is returned by ILAENV and
is equal to the maximum size of the subproblems at the
bottom of the computation tree (usually about 25).
For other values of COMPQ, IQ is not referenced.
WORK (workspace) REAL array, dimension (LWORK)
If COMPQ = 'N' then LWORK >= (4 * N).
If COMPQ = 'P' then LWORK >= (6 * N).
If COMPQ = 'I' then LWORK >= (3 * N**2 + 4 * N).
IWORK (workspace) INTEGER array, dimension (7*N)
INFO (output) INTEGER
= 0: successful exit.
< 0: if INFO = -i, the i-th argument had an illegal value.
> 0: The algorithm failed to compute an singular value.
The update process of divide and conquer failed.
Further Details
===============
Based on contributions by
Ming Gu and Huan Ren, Computer Science Division, University of
California at Berkeley, USA
=====================================================================
Test the input parameters.
Parameter adjustments */
--d__;
--e;
u_dim1 = *ldu;
u_offset = 1 + u_dim1 * 1;
u -= u_offset;
vt_dim1 = *ldvt;
vt_offset = 1 + vt_dim1 * 1;
vt -= vt_offset;
--q;
--iq;
--work;
--iwork;
/* Function Body */
*info = 0;
iuplo = 0;
if (lsame_(uplo, "U")) {
iuplo = 1;
}
if (lsame_(uplo, "L")) {
iuplo = 2;
}
if (lsame_(compq, "N")) {
icompq = 0;
} else if (lsame_(compq, "P")) {
icompq = 1;
} else if (lsame_(compq, "I")) {
icompq = 2;
} else {
icompq = -1;
}
if (iuplo == 0) {
*info = -1;
} else if (icompq < 0) {
*info = -2;
} else if (*n < 0) {
*info = -3;
} else if (*ldu < 1 || icompq == 2 && *ldu < *n) {
*info = -7;
} else if (*ldvt < 1 || icompq == 2 && *ldvt < *n) {
*info = -9;
}
if (*info != 0) {
i__1 = -(*info);
xerbla_("SBDSDC", &i__1);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -