slarrj.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 303 行 · 第 1/2 页
HTML
303 行
RIGHT = W( II ) + WERR( II )
WIDTH = RIGHT - MID
TMP = MAX( ABS( LEFT ), ABS( RIGHT ) )
<span class="comment">*</span><span class="comment"> The following test prevents the test of converged intervals
</span> IF( WIDTH.LT.RTOL*TMP ) THEN
<span class="comment">*</span><span class="comment"> This interval has already converged and does not need refinement.
</span><span class="comment">*</span><span class="comment"> (Note that the gaps might change through refining the
</span><span class="comment">*</span><span class="comment"> eigenvalues, however, they can only get bigger.)
</span><span class="comment">*</span><span class="comment"> Remove it from the list.
</span> IWORK( K-1 ) = -1
<span class="comment">*</span><span class="comment"> Make sure that I1 always points to the first unconverged interval
</span> IF((I.EQ.I1).AND.(I.LT.I2)) I1 = I + 1
IF((PREV.GE.I1).AND.(I.LE.I2)) IWORK( 2*PREV-1 ) = I + 1
ELSE
<span class="comment">*</span><span class="comment"> unconverged interval found
</span> PREV = I
<span class="comment">*</span><span class="comment"> Make sure that [LEFT,RIGHT] contains the desired eigenvalue
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Do while( CNT(LEFT).GT.I-1 )
</span><span class="comment">*</span><span class="comment">
</span> FAC = ONE
20 CONTINUE
CNT = 0
S = LEFT
DPLUS = D( 1 ) - S
IF( DPLUS.LT.ZERO ) CNT = CNT + 1
DO 30 J = 2, N
DPLUS = D( J ) - S - E2( J-1 )/DPLUS
IF( DPLUS.LT.ZERO ) CNT = CNT + 1
30 CONTINUE
IF( CNT.GT.I-1 ) THEN
LEFT = LEFT - WERR( II )*FAC
FAC = TWO*FAC
GO TO 20
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Do while( CNT(RIGHT).LT.I )
</span><span class="comment">*</span><span class="comment">
</span> FAC = ONE
50 CONTINUE
CNT = 0
S = RIGHT
DPLUS = D( 1 ) - S
IF( DPLUS.LT.ZERO ) CNT = CNT + 1
DO 60 J = 2, N
DPLUS = D( J ) - S - E2( J-1 )/DPLUS
IF( DPLUS.LT.ZERO ) CNT = CNT + 1
60 CONTINUE
IF( CNT.LT.I ) THEN
RIGHT = RIGHT + WERR( II )*FAC
FAC = TWO*FAC
GO TO 50
END IF
NINT = NINT + 1
IWORK( K-1 ) = I + 1
IWORK( K ) = CNT
END IF
WORK( K-1 ) = LEFT
WORK( K ) = RIGHT
75 CONTINUE
SAVI1 = I1
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Do while( NINT.GT.0 ), i.e. there are still unconverged intervals
</span><span class="comment">*</span><span class="comment"> and while (ITER.LT.MAXITR)
</span><span class="comment">*</span><span class="comment">
</span> ITER = 0
80 CONTINUE
PREV = I1 - 1
I = I1
OLNINT = NINT
DO 100 P = 1, OLNINT
K = 2*I
II = I - OFFSET
NEXT = IWORK( K-1 )
LEFT = WORK( K-1 )
RIGHT = WORK( K )
MID = HALF*( LEFT + RIGHT )
<span class="comment">*</span><span class="comment"> semiwidth of interval
</span> WIDTH = RIGHT - MID
TMP = MAX( ABS( LEFT ), ABS( RIGHT ) )
IF( ( WIDTH.LT.RTOL*TMP ) .OR.
$ (ITER.EQ.MAXITR) )THEN
<span class="comment">*</span><span class="comment"> reduce number of unconverged intervals
</span> NINT = NINT - 1
<span class="comment">*</span><span class="comment"> Mark interval as converged.
</span> IWORK( K-1 ) = 0
IF( I1.EQ.I ) THEN
I1 = NEXT
ELSE
<span class="comment">*</span><span class="comment"> Prev holds the last unconverged interval previously examined
</span> IF(PREV.GE.I1) IWORK( 2*PREV-1 ) = NEXT
END IF
I = NEXT
GO TO 100
END IF
PREV = I
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Perform one bisection step
</span><span class="comment">*</span><span class="comment">
</span> CNT = 0
S = MID
DPLUS = D( 1 ) - S
IF( DPLUS.LT.ZERO ) CNT = CNT + 1
DO 90 J = 2, N
DPLUS = D( J ) - S - E2( J-1 )/DPLUS
IF( DPLUS.LT.ZERO ) CNT = CNT + 1
90 CONTINUE
IF( CNT.LE.I-1 ) THEN
WORK( K-1 ) = MID
ELSE
WORK( K ) = MID
END IF
I = NEXT
100 CONTINUE
ITER = ITER + 1
<span class="comment">*</span><span class="comment"> do another loop if there are still unconverged intervals
</span><span class="comment">*</span><span class="comment"> However, in the last iteration, all intervals are accepted
</span><span class="comment">*</span><span class="comment"> since this is the best we can do.
</span> IF( ( NINT.GT.0 ).AND.(ITER.LE.MAXITR) ) GO TO 80
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> At this point, all the intervals have converged
</span> DO 110 I = SAVI1, ILAST
K = 2*I
II = I - OFFSET
<span class="comment">*</span><span class="comment"> All intervals marked by '0' have been refined.
</span> IF( IWORK( K-1 ).EQ.0 ) THEN
W( II ) = HALF*( WORK( K-1 )+WORK( K ) )
WERR( II ) = WORK( K ) - W( II )
END IF
110 CONTINUE
<span class="comment">*</span><span class="comment">
</span>
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="SLARRJ.278"></a><a href="slarrj.f.html#SLARRJ.1">SLARRJ</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?