zhptrs.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 426 行 · 第 1/2 页
HTML
426 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>zhptrs.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="ZHPTRS.1"></a><a href="zhptrs.f.html#ZHPTRS.1">ZHPTRS</a>( UPLO, N, NRHS, AP, IPIV, B, LDB, 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> CHARACTER UPLO
INTEGER INFO, LDB, N, NRHS
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> INTEGER IPIV( * )
COMPLEX*16 AP( * ), B( LDB, * )
<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="ZHPTRS.19"></a><a href="zhptrs.f.html#ZHPTRS.1">ZHPTRS</a> solves a system of linear equations A*X = B with a complex
</span><span class="comment">*</span><span class="comment"> Hermitian matrix A stored in packed format using the factorization
</span><span class="comment">*</span><span class="comment"> A = U*D*U**H or A = L*D*L**H computed by <a name="ZHPTRF.21"></a><a href="zhptrf.f.html#ZHPTRF.1">ZHPTRF</a>.
</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"> UPLO (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment"> Specifies whether the details of the factorization are stored
</span><span class="comment">*</span><span class="comment"> as an upper or lower triangular matrix.
</span><span class="comment">*</span><span class="comment"> = 'U': Upper triangular, form is A = U*D*U**H;
</span><span class="comment">*</span><span class="comment"> = 'L': Lower triangular, form is A = L*D*L**H.
</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 A. N >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> NRHS (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The number of right hand sides, i.e., the number of columns
</span><span class="comment">*</span><span class="comment"> of the matrix B. NRHS >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> AP (input) COMPLEX*16 array, dimension (N*(N+1)/2)
</span><span class="comment">*</span><span class="comment"> The block diagonal matrix D and the multipliers used to
</span><span class="comment">*</span><span class="comment"> obtain the factor U or L as computed by <a name="ZHPTRF.41"></a><a href="zhptrf.f.html#ZHPTRF.1">ZHPTRF</a>, stored as a
</span><span class="comment">*</span><span class="comment"> packed triangular matrix.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> IPIV (input) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment"> Details of the interchanges and the block structure of D
</span><span class="comment">*</span><span class="comment"> as determined by <a name="ZHPTRF.46"></a><a href="zhptrf.f.html#ZHPTRF.1">ZHPTRF</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> B (input/output) COMPLEX*16 array, dimension (LDB,NRHS)
</span><span class="comment">*</span><span class="comment"> On entry, the right hand side matrix B.
</span><span class="comment">*</span><span class="comment"> On exit, the solution matrix X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDB (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array B. LDB >= max(1,N).
</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">
</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> COMPLEX*16 ONE
PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL UPPER
INTEGER J, K, KC, KP
DOUBLE PRECISION S
COMPLEX*16 AK, AKM1, AKM1K, BK, BKM1, DENOM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.72"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
EXTERNAL <a name="LSAME.73"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL <a name="XERBLA.76"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>, ZDSCAL, ZGEMV, ZGERU, <a name="ZLACGV.76"></a><a href="zlacgv.f.html#ZLACGV.1">ZLACGV</a>, ZSWAP
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC DBLE, DCONJG, MAX
<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> INFO = 0
UPPER = <a name="LSAME.84"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'U'</span> )
IF( .NOT.UPPER .AND. .NOT.<a name="LSAME.85"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( UPLO, <span class="string">'L'</span> ) ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( NRHS.LT.0 ) THEN
INFO = -3
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -7
END IF
IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.95"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="ZHPTRS.95"></a><a href="zhptrs.f.html#ZHPTRS.1">ZHPTRS</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. NRHS.EQ.0 )
$ RETURN
<span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Solve A*X = B, where A = U*D*U'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> First solve U*D*X = B, overwriting B with X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> K is the main loop index, decreasing from N to 1 in steps of
</span><span class="comment">*</span><span class="comment"> 1 or 2, depending on the size of the diagonal blocks.
</span><span class="comment">*</span><span class="comment">
</span> K = N
KC = N*( N+1 ) / 2 + 1
10 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If K < 1, exit from loop.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.LT.1 )
$ GO TO 30
<span class="comment">*</span><span class="comment">
</span> KC = KC - K
IF( IPIV( K ).GT.0 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 1 x 1 diagonal block
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Interchange rows K and IPIV(K).
</span><span class="comment">*</span><span class="comment">
</span> KP = IPIV( K )
IF( KP.NE.K )
$ CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Multiply by inv(U(K)), where U(K) is the transformation
</span><span class="comment">*</span><span class="comment"> stored in column K of A.
</span><span class="comment">*</span><span class="comment">
</span> CALL ZGERU( K-1, NRHS, -ONE, AP( KC ), 1, B( K, 1 ), LDB,
$ B( 1, 1 ), LDB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Multiply by the inverse of the diagonal block.
</span><span class="comment">*</span><span class="comment">
</span> S = DBLE( ONE ) / DBLE( AP( KC+K-1 ) )
CALL ZDSCAL( NRHS, S, B( K, 1 ), LDB )
K = K - 1
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 2 x 2 diagonal block
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Interchange rows K-1 and -IPIV(K).
</span><span class="comment">*</span><span class="comment">
</span> KP = -IPIV( K )
IF( KP.NE.K-1 )
$ CALL ZSWAP( NRHS, B( K-1, 1 ), LDB, B( KP, 1 ), LDB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Multiply by inv(U(K)), where U(K) is the transformation
</span><span class="comment">*</span><span class="comment"> stored in columns K-1 and K of A.
</span><span class="comment">*</span><span class="comment">
</span> CALL ZGERU( K-2, NRHS, -ONE, AP( KC ), 1, B( K, 1 ), LDB,
$ B( 1, 1 ), LDB )
CALL ZGERU( K-2, NRHS, -ONE, AP( KC-( K-1 ) ), 1,
$ B( K-1, 1 ), LDB, B( 1, 1 ), LDB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Multiply by the inverse of the diagonal block.
</span><span class="comment">*</span><span class="comment">
</span> AKM1K = AP( KC+K-2 )
AKM1 = AP( KC-1 ) / AKM1K
AK = AP( KC+K-1 ) / DCONJG( AKM1K )
DENOM = AKM1*AK - ONE
DO 20 J = 1, NRHS
BKM1 = B( K-1, J ) / AKM1K
BK = B( K, J ) / DCONJG( AKM1K )
B( K-1, J ) = ( AK*BKM1-BK ) / DENOM
B( K, J ) = ( AKM1*BK-BKM1 ) / DENOM
20 CONTINUE
KC = KC - K + 1
K = K - 2
END IF
<span class="comment">*</span><span class="comment">
</span> GO TO 10
30 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Next solve U'*X = B, overwriting B with X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> K is the main loop index, increasing from 1 to N in steps of
</span><span class="comment">*</span><span class="comment"> 1 or 2, depending on the size of the diagonal blocks.
</span><span class="comment">*</span><span class="comment">
</span> K = 1
KC = 1
40 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If K > N, exit from loop.
</span><span class="comment">*</span><span class="comment">
</span> IF( K.GT.N )
$ GO TO 50
<span class="comment">*</span><span class="comment">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?