cgeev.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 422 行 · 第 1/3 页
HTML
422 行
</span><span class="comment">*</span><span class="comment"> Perform QR iteration, accumulating Schur vectors in VL
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 1, prefer HSWORK (see comments) )
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> IWRK = ITAU
CALL <a name="CHSEQR.269"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>( <span class="string">'S'</span>, <span class="string">'V'</span>, N, ILO, IHI, A, LDA, W, VL, LDVL,
$ WORK( IWRK ), LWORK-IWRK+1, INFO )
<span class="comment">*</span><span class="comment">
</span> IF( WANTVR ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Want left and right eigenvectors
</span><span class="comment">*</span><span class="comment"> Copy Schur vectors to VR
</span><span class="comment">*</span><span class="comment">
</span> SIDE = <span class="string">'B'</span>
CALL <a name="CLACPY.278"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'F'</span>, N, N, VL, LDVL, VR, LDVR )
END IF
<span class="comment">*</span><span class="comment">
</span> ELSE IF( WANTVR ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Want right eigenvectors
</span><span class="comment">*</span><span class="comment"> Copy Householder vectors to VR
</span><span class="comment">*</span><span class="comment">
</span> SIDE = <span class="string">'R'</span>
CALL <a name="CLACPY.287"></a><a href="clacpy.f.html#CLACPY.1">CLACPY</a>( <span class="string">'L'</span>, N, N, A, LDA, VR, LDVR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Generate unitary matrix in VR
</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="CUNGHR.293"></a><a href="cunghr.f.html#CUNGHR.1">CUNGHR</a>( N, ILO, IHI, VR, LDVR, 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 VR
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 1, prefer HSWORK (see comments) )
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> IWRK = ITAU
CALL <a name="CHSEQR.301"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>( <span class="string">'S'</span>, <span class="string">'V'</span>, N, ILO, IHI, A, LDA, W, VR, LDVR,
$ WORK( IWRK ), LWORK-IWRK+1, INFO )
<span class="comment">*</span><span class="comment">
</span> ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute eigenvalues only
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 1, prefer HSWORK (see comments) )
</span><span class="comment">*</span><span class="comment"> (RWorkspace: none)
</span><span class="comment">*</span><span class="comment">
</span> IWRK = ITAU
CALL <a name="CHSEQR.311"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>( <span class="string">'E'</span>, <span class="string">'N'</span>, N, ILO, IHI, A, LDA, W, VR, LDVR,
$ WORK( IWRK ), LWORK-IWRK+1, INFO )
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If INFO > 0 from <a name="CHSEQR.315"></a><a href="chseqr.f.html#CHSEQR.1">CHSEQR</a>, then quit
</span><span class="comment">*</span><span class="comment">
</span> IF( INFO.GT.0 )
$ GO TO 50
<span class="comment">*</span><span class="comment">
</span> IF( WANTVL .OR. WANTVR ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute left and/or right eigenvectors
</span><span class="comment">*</span><span class="comment"> (CWorkspace: need 2*N)
</span><span class="comment">*</span><span class="comment"> (RWorkspace: need 2*N)
</span><span class="comment">*</span><span class="comment">
</span> IRWORK = IBAL + N
CALL <a name="CTREVC.327"></a><a href="ctrevc.f.html#CTREVC.1">CTREVC</a>( SIDE, <span class="string">'B'</span>, SELECT, N, A, LDA, VL, LDVL, VR, LDVR,
$ N, NOUT, WORK( IWRK ), RWORK( IRWORK ), IERR )
END IF
<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"> Undo balancing of left eigenvectors
</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> CALL <a name="CGEBAK.337"></a><a href="cgebak.f.html#CGEBAK.1">CGEBAK</a>( <span class="string">'B'</span>, <span class="string">'L'</span>, N, ILO, IHI, RWORK( IBAL ), N, VL, LDVL,
$ IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Normalize left eigenvectors and make largest component real
</span><span class="comment">*</span><span class="comment">
</span> DO 20 I = 1, N
SCL = ONE / SCNRM2( N, VL( 1, I ), 1 )
CALL CSSCAL( N, SCL, VL( 1, I ), 1 )
DO 10 K = 1, N
RWORK( IRWORK+K-1 ) = REAL( VL( K, I ) )**2 +
$ AIMAG( VL( K, I ) )**2
10 CONTINUE
K = ISAMAX( N, RWORK( IRWORK ), 1 )
TMP = CONJG( VL( K, I ) ) / SQRT( RWORK( IRWORK+K-1 ) )
CALL CSCAL( N, TMP, VL( 1, I ), 1 )
VL( K, I ) = CMPLX( REAL( VL( K, I ) ), ZERO )
20 CONTINUE
END IF
<span class="comment">*</span><span class="comment">
</span> IF( WANTVR ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Undo balancing of right eigenvectors
</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> CALL <a name="CGEBAK.362"></a><a href="cgebak.f.html#CGEBAK.1">CGEBAK</a>( <span class="string">'B'</span>, <span class="string">'R'</span>, N, ILO, IHI, RWORK( IBAL ), N, VR, LDVR,
$ IERR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Normalize right eigenvectors and make largest component real
</span><span class="comment">*</span><span class="comment">
</span> DO 40 I = 1, N
SCL = ONE / SCNRM2( N, VR( 1, I ), 1 )
CALL CSSCAL( N, SCL, VR( 1, I ), 1 )
DO 30 K = 1, N
RWORK( IRWORK+K-1 ) = REAL( VR( K, I ) )**2 +
$ AIMAG( VR( K, I ) )**2
30 CONTINUE
K = ISAMAX( N, RWORK( IRWORK ), 1 )
TMP = CONJG( VR( K, I ) ) / SQRT( RWORK( IRWORK+K-1 ) )
CALL CSCAL( N, TMP, VR( 1, I ), 1 )
VR( K, I ) = CMPLX( REAL( VR( K, I ) ), ZERO )
40 CONTINUE
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Undo scaling if necessary
</span><span class="comment">*</span><span class="comment">
</span> 50 CONTINUE
IF( SCALEA ) THEN
CALL <a name="CLASCL.385"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>( <span class="string">'G'</span>, 0, 0, CSCALE, ANRM, N-INFO, 1, W( INFO+1 ),
$ MAX( N-INFO, 1 ), IERR )
IF( INFO.GT.0 ) THEN
CALL <a name="CLASCL.388"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>( <span class="string">'G'</span>, 0, 0, CSCALE, ANRM, ILO-1, 1, W, N, IERR )
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> WORK( 1 ) = MAXWRK
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="CGEEV.395"></a><a href="cgeev.f.html#CGEEV.1">CGEEV</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?