dlatbs.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 748 行 · 第 1/4 页
HTML
748 行
</span> ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute the growth in A' * x = b.
</span><span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
JFIRST = 1
JLAST = N
JINC = 1
MAIND = KD + 1
ELSE
JFIRST = N
JLAST = 1
JINC = -1
MAIND = 1
END IF
<span class="comment">*</span><span class="comment">
</span> IF( TSCAL.NE.ONE ) THEN
GROW = ZERO
GO TO 80
END IF
<span class="comment">*</span><span class="comment">
</span> IF( NOUNIT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A is non-unit triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute GROW = 1/G(j) and XBND = 1/M(j).
</span><span class="comment">*</span><span class="comment"> Initially, M(0) = max{x(i), i=1,...,n}.
</span><span class="comment">*</span><span class="comment">
</span> GROW = ONE / MAX( XBND, SMLNUM )
XBND = GROW
DO 60 J = JFIRST, JLAST, JINC
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Exit the loop if the growth factor is too small.
</span><span class="comment">*</span><span class="comment">
</span> IF( GROW.LE.SMLNUM )
$ GO TO 80
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> G(j) = max( G(j-1), M(j-1)*( 1 + CNORM(j) ) )
</span><span class="comment">*</span><span class="comment">
</span> XJ = ONE + CNORM( J )
GROW = MIN( GROW, XBND / XJ )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j))
</span><span class="comment">*</span><span class="comment">
</span> TJJ = ABS( AB( MAIND, J ) )
IF( XJ.GT.TJJ )
$ XBND = XBND*( TJJ / XJ )
60 CONTINUE
GROW = MIN( GROW, XBND )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A is unit triangular.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}.
</span><span class="comment">*</span><span class="comment">
</span> GROW = MIN( ONE, ONE / MAX( XBND, SMLNUM ) )
DO 70 J = JFIRST, JLAST, JINC
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Exit the loop if the growth factor is too small.
</span><span class="comment">*</span><span class="comment">
</span> IF( GROW.LE.SMLNUM )
$ GO TO 80
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> G(j) = ( 1 + CNORM(j) )*G(j-1)
</span><span class="comment">*</span><span class="comment">
</span> XJ = ONE + CNORM( J )
GROW = GROW / XJ
70 CONTINUE
END IF
80 CONTINUE
END IF
<span class="comment">*</span><span class="comment">
</span> IF( ( GROW*TSCAL ).GT.SMLNUM ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Use the Level 2 BLAS solve if the reciprocal of the bound on
</span><span class="comment">*</span><span class="comment"> elements of X is not too small.
</span><span class="comment">*</span><span class="comment">
</span> CALL DTBSV( UPLO, TRANS, DIAG, N, KD, AB, LDAB, X, 1 )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Use a Level 1 BLAS solve, scaling intermediate results.
</span><span class="comment">*</span><span class="comment">
</span> IF( XMAX.GT.BIGNUM ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale X so that its components are less than or equal to
</span><span class="comment">*</span><span class="comment"> BIGNUM in absolute value.
</span><span class="comment">*</span><span class="comment">
</span> SCALE = BIGNUM / XMAX
CALL DSCAL( N, SCALE, X, 1 )
XMAX = BIGNUM
END IF
<span class="comment">*</span><span class="comment">
</span> IF( NOTRAN ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Solve A * x = b
</span><span class="comment">*</span><span class="comment">
</span> DO 110 J = JFIRST, JLAST, JINC
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute x(j) = b(j) / A(j,j), scaling x if necessary.
</span><span class="comment">*</span><span class="comment">
</span> XJ = ABS( X( J ) )
IF( NOUNIT ) THEN
TJJS = AB( MAIND, J )*TSCAL
ELSE
TJJS = TSCAL
IF( TSCAL.EQ.ONE )
$ GO TO 100
END IF
TJJ = ABS( TJJS )
IF( TJJ.GT.SMLNUM ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> abs(A(j,j)) > SMLNUM:
</span><span class="comment">*</span><span class="comment">
</span> IF( TJJ.LT.ONE ) THEN
IF( XJ.GT.TJJ*BIGNUM ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale x by 1/b(j).
</span><span class="comment">*</span><span class="comment">
</span> REC = ONE / XJ
CALL DSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
END IF
X( J ) = X( J ) / TJJS
XJ = ABS( X( J ) )
ELSE IF( TJJ.GT.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 0 < abs(A(j,j)) <= SMLNUM:
</span><span class="comment">*</span><span class="comment">
</span> IF( XJ.GT.TJJ*BIGNUM ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM
</span><span class="comment">*</span><span class="comment"> to avoid overflow when dividing by A(j,j).
</span><span class="comment">*</span><span class="comment">
</span> REC = ( TJJ*BIGNUM ) / XJ
IF( CNORM( J ).GT.ONE ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale by 1/CNORM(j) to avoid overflow when
</span><span class="comment">*</span><span class="comment"> multiplying x(j) times column j.
</span><span class="comment">*</span><span class="comment">
</span> REC = REC / CNORM( J )
END IF
CALL DSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
XMAX = XMAX*REC
END IF
X( J ) = X( J ) / TJJS
XJ = ABS( X( J ) )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and
</span><span class="comment">*</span><span class="comment"> scale = 0, and compute a solution to A*x = 0.
</span><span class="comment">*</span><span class="comment">
</span> DO 90 I = 1, N
X( I ) = ZERO
90 CONTINUE
X( J ) = ONE
XJ = ONE
SCALE = ZERO
XMAX = ZERO
END IF
100 CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale x if necessary to avoid overflow when adding a
</span><span class="comment">*</span><span class="comment"> multiple of column j of A.
</span><span class="comment">*</span><span class="comment">
</span> IF( XJ.GT.ONE ) THEN
REC = ONE / XJ
IF( CNORM( J ).GT.( BIGNUM-XMAX )*REC ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale x by 1/(2*abs(x(j))).
</span><span class="comment">*</span><span class="comment">
</span> REC = REC*HALF
CALL DSCAL( N, REC, X, 1 )
SCALE = SCALE*REC
END IF
ELSE IF( XJ*CNORM( J ).GT.( BIGNUM-XMAX ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Scale x by 1/2.
</span><span class="comment">*</span><span class="comment">
</span> CALL DSCAL( N, HALF, X, 1 )
SCALE = SCALE*HALF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
IF( J.GT.1 ) THEN
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?