zgeev.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 421 行 · 第 1/3 页
HTML
421 行
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> LOGICAL <a name="LSAME.125"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
INTEGER IDAMAX, <a name="ILAENV.126"></a><a href="hfy-index.html#ILAENV">ILAENV</a>
DOUBLE PRECISION <a name="DLAMCH.127"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, DZNRM2, <a name="ZLANGE.127"></a><a href="zlange.f.html#ZLANGE.1">ZLANGE</a>
EXTERNAL <a name="LSAME.128"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, IDAMAX, <a name="ILAENV.128"></a><a href="hfy-index.html#ILAENV">ILAENV</a>, <a name="DLAMCH.128"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, DZNRM2, <a name="ZLANGE.128"></a><a href="zlange.f.html#ZLANGE.1">ZLANGE</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC DBLE, DCMPLX, DCONJG, DIMAG, 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 arguments
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
LQUERY = ( LWORK.EQ.-1 )
WANTVL = <a name="LSAME.139"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVL, <span class="string">'V'</span> )
WANTVR = <a name="LSAME.140"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVR, <span class="string">'V'</span> )
IF( ( .NOT.WANTVL ) .AND. ( .NOT.<a name="LSAME.141"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVL, <span class="string">'N'</span> ) ) ) THEN
INFO = -1
ELSE IF( ( .NOT.WANTVR ) .AND. ( .NOT.<a name="LSAME.143"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVR, <span class="string">'N'</span> ) ) ) THEN
INFO = -2
ELSE IF( N.LT.0 ) THEN
INFO = -3
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -5
ELSE IF( LDVL.LT.1 .OR. ( WANTVL .AND. LDVL.LT.N ) ) THEN
INFO = -8
ELSE IF( LDVR.LT.1 .OR. ( WANTVR .AND. LDVR.LT.N ) ) THEN
INFO = -10
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute workspace
</span><span class="comment">*</span><span class="comment"> (Note: Comments in the code beginning "Workspace:" describe the
</span><span class="comment">*</span><span class="comment"> minimal amount of workspace needed at that point in the code,
</span><span class="comment">*</span><span class="comment"> as well as the preferred amount for good performance.
</span><span class="comment">*</span><span class="comment"> CWorkspace refers to complex workspace, and RWorkspace to real
</span><span class="comment">*</span><span class="comment"> workspace. NB refers to the optimal block size for the
</span><span class="comment">*</span><span class="comment"> immediately following subroutine, as returned by <a name="ILAENV.161"></a><a href="hfy-index.html#ILAENV">ILAENV</a>.
</span><span class="comment">*</span><span class="comment"> HSWORK refers to the workspace preferred by <a name="ZHSEQR.162"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>, as
</span><span class="comment">*</span><span class="comment"> calculated below. HSWORK is computed assuming ILO=1 and IHI=N,
</span><span class="comment">*</span><span class="comment"> the worst case.)
</span><span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 ) THEN
IF( N.EQ.0 ) THEN
MINWRK = 1
MAXWRK = 1
ELSE
MAXWRK = N + N*<a name="ILAENV.171"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="ZGEHRD.171"></a><a href="zgehrd.f.html#ZGEHRD.1">ZGEHRD</a>'</span>, <span class="string">' '</span>, N, 1, N, 0 )
MINWRK = 2*N
IF( WANTVL ) THEN
MAXWRK = MAX( MAXWRK, N + ( N - 1 )*<a name="ILAENV.174"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="ZUNGHR.174"></a><a href="zunghr.f.html#ZUNGHR.1">ZUNGHR</a>'</span>,
$ <span class="string">' '</span>, N, 1, N, -1 ) )
CALL <a name="ZHSEQR.176"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>( <span class="string">'S'</span>, <span class="string">'V'</span>, N, 1, N, A, LDA, W, VL, LDVL,
$ WORK, -1, INFO )
ELSE IF( WANTVR ) THEN
MAXWRK = MAX( MAXWRK, N + ( N - 1 )*<a name="ILAENV.179"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="ZUNGHR.179"></a><a href="zunghr.f.html#ZUNGHR.1">ZUNGHR</a>'</span>,
$ <span class="string">' '</span>, N, 1, N, -1 ) )
CALL <a name="ZHSEQR.181"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>( <span class="string">'S'</span>, <span class="string">'V'</span>, N, 1, N, A, LDA, W, VR, LDVR,
$ WORK, -1, INFO )
ELSE
CALL <a name="ZHSEQR.184"></a><a href="zhseqr.f.html#ZHSEQR.1">ZHSEQR</a>( <span class="string">'E'</span>, <span class="string">'N'</span>, N, 1, N, A, LDA, W, VR, LDVR,
$ WORK, -1, INFO )
END IF
HSWORK = WORK( 1 )
MAXWRK = MAX( MAXWRK, HSWORK, MINWRK )
END IF
WORK( 1 ) = MAXWRK
<span class="comment">*</span><span class="comment">
</span> IF( LWORK.LT.MINWRK .AND. .NOT.LQUERY ) THEN
INFO = -12
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.198"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="ZGEEV.198"></a><a href="zgeev.f.html#ZGEEV.1">ZGEEV</a> '</span>, -INFO )
RETURN
ELSE IF( LQUERY ) THEN
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 )
$ RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Get machine constants
</span><span class="comment">*</span><span class="comment">
</span> EPS = <a name="DLAMCH.211"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'P'</span> )
SMLNUM = <a name="DLAMCH.212"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'S'</span> )
BIGNUM = ONE / SMLNUM
CALL <a name="DLABAD.214"></a><a href="dlabad.f.html#DLABAD.1">DLABAD</a>( SMLNUM, BIGNUM )
SMLNUM = SQRT( SMLNUM ) / EPS
BIGNUM = ONE / SMLNUM
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale A if max element outside range [SMLNUM,BIGNUM]
</span><span class="comment">*</span><span class="comment">
</span> ANRM = <a name="ZLANGE.220"></a><a href="zlange.f.html#ZLANGE.1">ZLANGE</a>( <span class="string">'M'</span>, N, N, A, LDA, DUM )
SCALEA = .FALSE.
IF( ANRM.GT.ZERO .AND. ANRM.LT.SMLNUM ) THEN
SCALEA = .TRUE.
CSCALE = SMLNUM
ELSE IF( ANRM.GT.BIGNUM ) THEN
SCALEA = .TRUE.
CSCALE = BIGNUM
END IF
IF( SCALEA )
$ CALL <a name="ZLASCL.230"></a><a href="zlascl.f.html#ZLASCL.1">ZLASCL</a>( <span class="string">'G'</span>, 0, 0, ANRM, CSCALE, N, N, A, LDA, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Balance the matrix
</span><span class="comment">*</span><span class="comment"> (CWorkspace: none)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: need N)
</span><span class="comment">*</span><span class="comment">
</span> IBAL = 1
CALL <a name="ZGEBAL.237"></a><a href="zgebal.f.html#ZGEBAL.1">ZGEBAL</a>( <span class="string">'B'</span>, N, A, LDA, ILO, IHI, RWORK( IBAL ), IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Reduce to upper Hessenberg form
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 2*N, prefer N+N*NB)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> ITAU = 1
IWRK = ITAU + N
CALL <a name="ZGEHRD.245"></a><a href="zgehrd.f.html#ZGEHRD.1">ZGEHRD</a>( N, ILO, IHI, A, LDA, WORK( ITAU ), WORK( IWRK ),
$ LWORK-IWRK+1, IERR )
<span class="comment">*</span><span class="comment">
</span> IF( WANTVL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Want left eigenvectors
</span><span class="comment">*</span><span class="comment"> Copy Householder vectors to VL
</span><span class="comment">*</span><span class="comment">
</span> SIDE = <span class="string">'L'</span>
CALL <a name="ZLACPY.254"></a><a href="zlacpy.f.html#ZLACPY.1">ZLACPY</a>( <span class="string">'L'</span>, N, N, A, LDA, VL, LDVL )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Generate unitary matrix in VL
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 2*N-1, prefer N+(N-1)*NB)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="ZUNGHR.260"></a><a href="zunghr.f.html#ZUNGHR.1">ZUNGHR</a>( N, ILO, IHI, VL, LDVL, WORK( ITAU ), WORK( IWRK ),
$ LWORK-IWRK+1, IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Perform QR iteration, accumulating Schur vectors in VL
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?