📄 slarrv.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 real c_b6 = 0.f;
static integer c__1 = 1;
/* Subroutine */ int slarrv_(integer *n, real *d__, real *l, integer *isplit,
integer *m, real *w, integer *iblock, real *gersch, real *tol, real *
z__, integer *ldz, integer *isuppz, real *work, integer *iwork,
integer *info)
{
/* System generated locals */
integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5, i__6;
real r__1, r__2;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
static integer iend, jblk, iter, temp[1];
extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
static integer ktot, itmp1, itmp2;
extern doublereal snrm2_(integer *, real *, integer *);
static integer i__, j, k, p, q, indld;
static real sigma;
static integer ndone, iinfo, iindr;
static real resid;
extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
static integer nclus;
extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *,
integer *), saxpy_(integer *, real *, real *, integer *, real *,
integer *);
static integer iindc1, iindc2;
extern /* Subroutine */ int slar1v_(integer *, integer *, integer *, real
*, real *, real *, real *, real *, real *, real *, real *, real *,
integer *, integer *, real *);
static real lambda;
static integer im, in, ibegin, indgap, indlld;
extern doublereal slamch_(char *);
static real mingma;
static integer oldien, oldncl;
static real relgap;
static integer oldcls, ndepth, inderr, iindwk;
extern /* Subroutine */ int slarrb_(integer *, real *, real *, real *,
real *, integer *, integer *, real *, real *, real *, real *,
real *, real *, integer *, integer *);
static logical mgscls;
static integer lsbdpt;
extern /* Subroutine */ int slarrf_(integer *, real *, real *, real *,
real *, integer *, integer *, real *, real *, real *, real *,
integer *, integer *);
static integer newcls, oldfst;
static real minrgp;
static integer indwrk;
extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *,
real *, real *, integer *);
static integer oldlst;
static real reltol;
static integer maxitr, newfrs, newftt;
static real mgstol;
static integer nsplit;
static real nrminv;
static integer newlst;
static real rqcorr;
static integer newsiz;
extern /* Subroutine */ int sstein_(integer *, real *, real *, integer *,
real *, integer *, integer *, real *, integer *, real *, integer *
, integer *, integer *);
static real gap, eps, ztz, tmp1;
#define z___ref(a_1,a_2) z__[(a_2)*z_dim1 + a_1]
/* -- LAPACK auxiliary routine (instru to count ops, version 3.0) --
Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
Courant Institute, Argonne National Lab, and Rice University
June 30, 1999
Common block to return operation count
Purpose
=======
SLARRV computes the eigenvectors of the tridiagonal matrix
T = L D L^T given L, D and the eigenvalues of L D L^T.
The input eigenvalues should have high relative accuracy with
respect to the entries of L and D. The desired accuracy of the
output can be specified by the input parameter TOL.
Arguments
=========
N (input) INTEGER
The order of the matrix. N >= 0.
D (input/output) REAL array, dimension (N)
On entry, the n diagonal elements of the diagonal matrix D.
On exit, D may be overwritten.
L (input/output) REAL array, dimension (N-1)
On entry, the (n-1) subdiagonal elements of the unit
bidiagonal matrix L in elements 1 to N-1 of L. L(N) need
not be set. On exit, L is overwritten.
ISPLIT (input) INTEGER array, dimension (N)
The splitting points, at which T breaks up into submatrices.
The first submatrix consists of rows/columns 1 to
ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1
through ISPLIT( 2 ), etc.
TOL (input) REAL
The absolute error tolerance for the
eigenvalues/eigenvectors.
Errors in the input eigenvalues must be bounded by TOL.
The eigenvectors output have residual norms
bounded by TOL, and the dot products between different
eigenvectors are bounded by TOL. TOL must be at least
N*EPS*|T|, where EPS is the machine precision and |T| is
the 1-norm of the tridiagonal matrix.
M (input) INTEGER
The total number of eigenvalues found. 0 <= M <= N.
If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
W (input) REAL array, dimension (N)
The first M elements of W contain the eigenvalues for
which eigenvectors are to be computed. The eigenvalues
should be grouped by split-off block and ordered from
smallest to largest within the block ( The output array
W from SLARRE is expected here ).
Errors in W must be bounded by TOL (see above).
IBLOCK (input) INTEGER array, dimension (N)
The submatrix indices associated with the corresponding
eigenvalues in W; IBLOCK(i)=1 if eigenvalue W(i) belongs to
the first submatrix from the top, =2 if W(i) belongs to
the second submatrix, etc.
Z (output) REAL array, dimension (LDZ, max(1,M) )
If JOBZ = 'V', then if INFO = 0, the first M columns of Z
contain the orthonormal eigenvectors of the matrix T
corresponding to the selected eigenvalues, with the i-th
column of Z holding the eigenvector associated with W(i).
If JOBZ = 'N', then Z is not referenced.
Note: the user must ensure that at least max(1,M) columns are
supplied in the array Z; if RANGE = 'V', the exact value of M
is not known in advance and an upper bound must be used.
LDZ (input) INTEGER
The leading dimension of the array Z. LDZ >= 1, and if
JOBZ = 'V', LDZ >= max(1,N).
ISUPPZ (output) INTEGER ARRAY, dimension ( 2*max(1,M) )
The support of the eigenvectors in Z, i.e., the indices
indicating the nonzero elements in Z. The i-th eigenvector
is nonzero only in elements ISUPPZ( 2*i-1 ) through
ISUPPZ( 2*i ).
WORK (workspace) REAL array, dimension (13*N)
IWORK (workspace) INTEGER array, dimension (6*N)
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = 1, internal error in SLARRB
if INFO = 2, internal error in SSTEIN
Further Details
===============
Based on contributions by
Inderjit Dhillon, IBM Almaden, USA
Osni Marques, LBNL/NERSC, USA
Ken Stanley, Computer Science Division, University of
California at Berkeley, USA
=====================================================================
Test the input parameters.
Parameter adjustments */
--d__;
--l;
--isplit;
--w;
--iblock;
--gersch;
z_dim1 = *ldz;
z_offset = 1 + z_dim1 * 1;
z__ -= z_offset;
--isuppz;
--work;
--iwork;
/* Function Body */
inderr = *n + 1;
indld = *n << 1;
indlld = *n * 3;
indgap = *n << 2;
indwrk = *n * 5 + 1;
iindr = *n;
iindc1 = *n << 1;
iindc2 = *n * 3;
iindwk = (*n << 2) + 1;
eps = slamch_("Precision");
i__1 = *n << 1;
for (i__ = 1; i__ <= i__1; ++i__) {
iwork[i__] = 0;
/* L10: */
}
latime_1.ops += (real) (*m + 1);
i__1 = *m;
for (i__ = 1; i__ <= i__1; ++i__) {
work[inderr + i__ - 1] = eps * (r__1 = w[i__], dabs(r__1));
/* L20: */
}
slaset_("Full", n, n, &c_b6, &c_b6, &z__[z_offset], ldz);
mgstol = eps * 5.f;
nsplit = iblock[*m];
ibegin = 1;
i__1 = nsplit;
for (jblk = 1; jblk <= i__1; ++jblk) {
iend = isplit[jblk];
/* Find the eigenvectors of the submatrix indexed IBEGIN
through IEND. */
if (ibegin == iend) {
z___ref(ibegin, ibegin) = 1.f;
isuppz[(ibegin << 1) - 1] = ibegin;
isuppz[ibegin * 2] = ibegin;
ibegin = iend + 1;
goto L170;
}
oldien = ibegin - 1;
in = iend - oldien;
latime_1.ops += 1.f;
/* Computing MIN */
r__1 = .01f, r__2 = 1.f / (real) in;
reltol = dmin(r__1,r__2);
im = in;
scopy_(&im, &w[ibegin], &c__1, &work[1], &c__1);
latime_1.ops += (real) (in - 1);
i__2 = in - 1;
for (i__ = 1; i__ <= i__2; ++i__) {
work[indgap + i__] = work[i__ + 1] - work[i__];
/* L30: */
}
/* Computing MAX */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -