dstein.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 386 行 · 第 1/2 页
HTML
386 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dstein.f</title>
<meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!--
body { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default a { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
span.string { color: rgb(188, 143, 143); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.string a { color: rgb(188, 143, 143); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
span.comment { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.comment a { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
--></style>
</head>
<body>
<pre>
SUBROUTINE <a name="DSTEIN.1"></a><a href="dstein.f.html#DSTEIN.1">DSTEIN</a>( N, D, E, M, W, IBLOCK, ISPLIT, Z, LDZ, WORK,
$ IWORK, IFAIL, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> -- LAPACK routine (version 3.1) --
</span><span class="comment">*</span><span class="comment"> Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment"> November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Scalar Arguments ..
</span> INTEGER INFO, LDZ, M, N
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> INTEGER IBLOCK( * ), IFAIL( * ), ISPLIT( * ),
$ IWORK( * )
DOUBLE PRECISION D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Purpose
</span><span class="comment">*</span><span class="comment"> =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> <a name="DSTEIN.20"></a><a href="dstein.f.html#DSTEIN.1">DSTEIN</a> computes the eigenvectors of a real symmetric tridiagonal
</span><span class="comment">*</span><span class="comment"> matrix T corresponding to specified eigenvalues, using inverse
</span><span class="comment">*</span><span class="comment"> iteration.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> The maximum number of iterations allowed for each eigenvector is
</span><span class="comment">*</span><span class="comment"> specified by an internal parameter MAXITS (currently set to 5).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Arguments
</span><span class="comment">*</span><span class="comment"> =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> N (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The order of the matrix. N >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> D (input) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment"> The n diagonal elements of the tridiagonal matrix T.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> E (input) DOUBLE PRECISION array, dimension (N-1)
</span><span class="comment">*</span><span class="comment"> The (n-1) subdiagonal elements of the tridiagonal matrix
</span><span class="comment">*</span><span class="comment"> T, in elements 1 to N-1.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> M (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The number of eigenvectors to be found. 0 <= M <= N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> W (input) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment"> The first M elements of W contain the eigenvalues for
</span><span class="comment">*</span><span class="comment"> which eigenvectors are to be computed. The eigenvalues
</span><span class="comment">*</span><span class="comment"> should be grouped by split-off block and ordered from
</span><span class="comment">*</span><span class="comment"> smallest to largest within the block. ( The output array
</span><span class="comment">*</span><span class="comment"> W from <a name="DSTEBZ.48"></a><a href="dstebz.f.html#DSTEBZ.1">DSTEBZ</a> with ORDER = 'B' is expected here. )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> IBLOCK (input) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment"> The submatrix indices associated with the corresponding
</span><span class="comment">*</span><span class="comment"> eigenvalues in W; IBLOCK(i)=1 if eigenvalue W(i) belongs to
</span><span class="comment">*</span><span class="comment"> the first submatrix from the top, =2 if W(i) belongs to
</span><span class="comment">*</span><span class="comment"> the second submatrix, etc. ( The output array IBLOCK
</span><span class="comment">*</span><span class="comment"> from <a name="DSTEBZ.55"></a><a href="dstebz.f.html#DSTEBZ.1">DSTEBZ</a> is expected here. )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> ISPLIT (input) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment"> The splitting points, at which T breaks up into submatrices.
</span><span class="comment">*</span><span class="comment"> The first submatrix consists of rows/columns 1 to
</span><span class="comment">*</span><span class="comment"> ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1
</span><span class="comment">*</span><span class="comment"> through ISPLIT( 2 ), etc.
</span><span class="comment">*</span><span class="comment"> ( The output array ISPLIT from <a name="DSTEBZ.62"></a><a href="dstebz.f.html#DSTEBZ.1">DSTEBZ</a> is expected here. )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Z (output) DOUBLE PRECISION array, dimension (LDZ, M)
</span><span class="comment">*</span><span class="comment"> The computed eigenvectors. The eigenvector associated
</span><span class="comment">*</span><span class="comment"> with the eigenvalue W(i) is stored in the i-th column of
</span><span class="comment">*</span><span class="comment"> Z. Any vector which fails to converge is set to its current
</span><span class="comment">*</span><span class="comment"> iterate after MAXITS iterations.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDZ (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array Z. LDZ >= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> WORK (workspace) DOUBLE PRECISION array, dimension (5*N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> IWORK (workspace) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> IFAIL (output) INTEGER array, dimension (M)
</span><span class="comment">*</span><span class="comment"> On normal exit, all elements of IFAIL are zero.
</span><span class="comment">*</span><span class="comment"> If one or more eigenvectors fail to converge after
</span><span class="comment">*</span><span class="comment"> MAXITS iterations, then their indices are stored in
</span><span class="comment">*</span><span class="comment"> array IFAIL.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> INFO (output) INTEGER
</span><span class="comment">*</span><span class="comment"> = 0: successful exit.
</span><span class="comment">*</span><span class="comment"> < 0: if INFO = -i, the i-th argument had an illegal value
</span><span class="comment">*</span><span class="comment"> > 0: if INFO = i, then i eigenvectors failed to converge
</span><span class="comment">*</span><span class="comment"> in MAXITS iterations. Their indices are stored in
</span><span class="comment">*</span><span class="comment"> array IFAIL.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Internal Parameters
</span><span class="comment">*</span><span class="comment"> ===================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> MAXITS INTEGER, default = 5
</span><span class="comment">*</span><span class="comment"> The maximum number of iterations performed.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> EXTRA INTEGER, default = 2
</span><span class="comment">*</span><span class="comment"> The number of iterations performed after norm growth
</span><span class="comment">*</span><span class="comment"> criterion is satisfied, should be at least 1.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Parameters ..
</span> DOUBLE PRECISION ZERO, ONE, TEN, ODM3, ODM1
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TEN = 1.0D+1,
$ ODM3 = 1.0D-3, ODM1 = 1.0D-1 )
INTEGER MAXITS, EXTRA
PARAMETER ( MAXITS = 5, EXTRA = 2 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> INTEGER B1, BLKSIZ, BN, GPIND, I, IINFO, INDRV1,
$ INDRV2, INDRV3, INDRV4, INDRV5, ITS, J, J1,
$ JBLK, JMAX, NBLK, NRMCHK
DOUBLE PRECISION DTPCRT, EPS, EPS1, NRM, ONENRM, ORTOL, PERTOL,
$ SCL, SEP, TOL, XJ, XJM, ZTR
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Arrays ..
</span> INTEGER ISEED( 4 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> INTEGER IDAMAX
DOUBLE PRECISION DASUM, DDOT, <a name="DLAMCH.121"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, DNRM2
EXTERNAL IDAMAX, DASUM, DDOT, <a name="DLAMCH.122"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, DNRM2
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL DAXPY, DCOPY, <a name="DLAGTF.125"></a><a href="dlagtf.f.html#DLAGTF.1">DLAGTF</a>, <a name="DLAGTS.125"></a><a href="dlagts.f.html#DLAGTS.1">DLAGTS</a>, <a name="DLARNV.125"></a><a href="dlarnv.f.html#DLARNV.1">DLARNV</a>, DSCAL,
$ <a name="XERBLA.126"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC ABS, MAX, SQRT
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Test the input parameters.
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
DO 10 I = 1, M
IFAIL( I ) = 0
10 CONTINUE
<span class="comment">*</span><span class="comment">
</span> IF( N.LT.0 ) THEN
INFO = -1
ELSE IF( M.LT.0 .OR. M.GT.N ) THEN
INFO = -4
ELSE IF( LDZ.LT.MAX( 1, N ) ) THEN
INFO = -9
ELSE
DO 20 J = 2, M
IF( IBLOCK( J ).LT.IBLOCK( J-1 ) ) THEN
INFO = -6
GO TO 30
END IF
IF( IBLOCK( J ).EQ.IBLOCK( J-1 ) .AND. W( J ).LT.W( J-1 ) )
$ THEN
INFO = -5
GO TO 30
END IF
20 CONTINUE
30 CONTINUE
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.162"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="DSTEIN.162"></a><a href="dstein.f.html#DSTEIN.1">DSTEIN</a>'</span>, -INFO )
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span> IF( N.EQ.0 .OR. M.EQ.0 ) THEN
RETURN
ELSE IF( N.EQ.1 ) THEN
Z( 1, 1 ) = ONE
RETURN
END IF
<span class="comment">*</span><span class="comment">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?