zlatbs.f.html

来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 933 行 · 第 1/4 页

HTML
933
字号
</span><span class="comment">*</span><span class="comment">                 was not used to scale the dotproduct.
</span><span class="comment">*</span><span class="comment">
</span>                  X( J ) = X( J ) - CSUMJ
                  XJ = CABS1( X( J ) )
                  IF( NOUNIT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                    Compute x(j) = x(j) / A(j,j), scaling if necessary.
</span><span class="comment">*</span><span class="comment">
</span>                     TJJS = AB( MAIND, J )*TSCAL
                  ELSE
                     TJJS = TSCAL
                     IF( TSCAL.EQ.ONE )
     $                  GO TO 160
                  END IF
                  TJJ = CABS1( 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)) &gt; 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/abs(x(j)).
</span><span class="comment">*</span><span class="comment">
</span>                           REC = ONE / XJ
                           CALL ZDSCAL( N, REC, X, 1 )
                           SCALE = SCALE*REC
                           XMAX = XMAX*REC
                        END IF
                     END IF
                     X( J ) = <a name="ZLADIV.714"></a><a href="zladiv.f.html#ZLADIV.1">ZLADIV</a>( X( J ), TJJS )
                  ELSE IF( TJJ.GT.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                       0 &lt; abs(A(j,j)) &lt;= 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">
</span>                        REC = ( TJJ*BIGNUM ) / XJ
                        CALL ZDSCAL( N, REC, X, 1 )
                        SCALE = SCALE*REC
                        XMAX = XMAX*REC
                     END IF
                     X( J ) = <a name="ZLADIV.728"></a><a href="zladiv.f.html#ZLADIV.1">ZLADIV</a>( X( J ), TJJS )
                  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**T *x = 0.
</span><span class="comment">*</span><span class="comment">
</span>                     DO 150 I = 1, N
                        X( I ) = ZERO
  150                CONTINUE
                     X( J ) = ONE
                     SCALE = ZERO
                     XMAX = ZERO
                  END IF
  160             CONTINUE
               ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot
</span><span class="comment">*</span><span class="comment">                 product has already been divided by 1/A(j,j).
</span><span class="comment">*</span><span class="comment">
</span>                  X( J ) = <a name="ZLADIV.747"></a><a href="zladiv.f.html#ZLADIV.1">ZLADIV</a>( X( J ), TJJS ) - CSUMJ
               END IF
               XMAX = MAX( XMAX, CABS1( X( J ) ) )
  170       CONTINUE
<span class="comment">*</span><span class="comment">
</span>         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Solve A**H * x = b
</span><span class="comment">*</span><span class="comment">
</span>            DO 220 J = JFIRST, JLAST, JINC
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute x(j) = b(j) - sum A(k,j)*x(k).
</span><span class="comment">*</span><span class="comment">                                    k&lt;&gt;j
</span><span class="comment">*</span><span class="comment">
</span>               XJ = CABS1( X( J ) )
               USCAL = TSCAL
               REC = ONE / MAX( XMAX, ONE )
               IF( CNORM( J ).GT.( BIGNUM-XJ )*REC ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 If x(j) could overflow, scale x by 1/(2*XMAX).
</span><span class="comment">*</span><span class="comment">
</span>                  REC = REC*HALF
                  IF( NOUNIT ) THEN
                     TJJS = DCONJG( AB( MAIND, J ) )*TSCAL
                  ELSE
                     TJJS = TSCAL
                  END IF
                  TJJ = CABS1( TJJS )
                  IF( TJJ.GT.ONE ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                       Divide by A(j,j) when scaling x if A(j,j) &gt; 1.
</span><span class="comment">*</span><span class="comment">
</span>                     REC = MIN( ONE, REC*TJJ )
                     USCAL = <a name="ZLADIV.780"></a><a href="zladiv.f.html#ZLADIV.1">ZLADIV</a>( USCAL, TJJS )
                  END IF
                  IF( REC.LT.ONE ) THEN
                     CALL ZDSCAL( N, REC, X, 1 )
                     SCALE = SCALE*REC
                     XMAX = XMAX*REC
                  END IF
               END IF
<span class="comment">*</span><span class="comment">
</span>               CSUMJ = ZERO
               IF( USCAL.EQ.DCMPLX( ONE ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 If the scaling needed for A in the dot product is 1,
</span><span class="comment">*</span><span class="comment">                 call ZDOTC to perform the dot product.
</span><span class="comment">*</span><span class="comment">
</span>                  IF( UPPER ) THEN
                     JLEN = MIN( KD, J-1 )
                     CSUMJ = ZDOTC( JLEN, AB( KD+1-JLEN, J ), 1,
     $                       X( J-JLEN ), 1 )
                  ELSE
                     JLEN = MIN( KD, N-J )
                     IF( JLEN.GT.1 )
     $                  CSUMJ = ZDOTC( JLEN, AB( 2, J ), 1, X( J+1 ),
     $                          1 )
                  END IF
               ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Otherwise, use in-line code for the dot product.
</span><span class="comment">*</span><span class="comment">
</span>                  IF( UPPER ) THEN
                     JLEN = MIN( KD, J-1 )
                     DO 180 I = 1, JLEN
                        CSUMJ = CSUMJ + ( DCONJG( AB( KD+I-JLEN, J ) )*
     $                          USCAL )*X( J-JLEN-1+I )
  180                CONTINUE
                  ELSE
                     JLEN = MIN( KD, N-J )
                     DO 190 I = 1, JLEN
                        CSUMJ = CSUMJ + ( DCONJG( AB( I+1, J ) )*USCAL )
     $                          *X( J+I )
  190                CONTINUE
                  END IF
               END IF
<span class="comment">*</span><span class="comment">
</span>               IF( USCAL.EQ.DCMPLX( TSCAL ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j)
</span><span class="comment">*</span><span class="comment">                 was not used to scale the dotproduct.
</span><span class="comment">*</span><span class="comment">
</span>                  X( J ) = X( J ) - CSUMJ
                  XJ = CABS1( X( J ) )
                  IF( NOUNIT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                    Compute x(j) = x(j) / A(j,j), scaling if necessary.
</span><span class="comment">*</span><span class="comment">
</span>                     TJJS = DCONJG( AB( MAIND, J ) )*TSCAL
                  ELSE
                     TJJS = TSCAL
                     IF( TSCAL.EQ.ONE )
     $                  GO TO 210
                  END IF
                  TJJ = CABS1( 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)) &gt; 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/abs(x(j)).
</span><span class="comment">*</span><span class="comment">
</span>                           REC = ONE / XJ
                           CALL ZDSCAL( N, REC, X, 1 )
                           SCALE = SCALE*REC
                           XMAX = XMAX*REC
                        END IF
                     END IF
                     X( J ) = <a name="ZLADIV.857"></a><a href="zladiv.f.html#ZLADIV.1">ZLADIV</a>( X( J ), TJJS )
                  ELSE IF( TJJ.GT.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                       0 &lt; abs(A(j,j)) &lt;= 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">
</span>                        REC = ( TJJ*BIGNUM ) / XJ
                        CALL ZDSCAL( N, REC, X, 1 )
                        SCALE = SCALE*REC
                        XMAX = XMAX*REC
                     END IF
                     X( J ) = <a name="ZLADIV.871"></a><a href="zladiv.f.html#ZLADIV.1">ZLADIV</a>( X( J ), TJJS )
                  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**H *x = 0.
</span><span class="comment">*</span><span class="comment">
</span>                     DO 200 I = 1, N
                        X( I ) = ZERO
  200                CONTINUE
                     X( J ) = ONE
                     SCALE = ZERO
                     XMAX = ZERO
                  END IF
  210             CONTINUE
               ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot
</span><span class="comment">*</span><span class="comment">                 product has already been divided by 1/A(j,j).
</span><span class="comment">*</span><span class="comment">
</span>                  X( J ) = <a name="ZLADIV.890"></a><a href="zladiv.f.html#ZLADIV.1">ZLADIV</a>( X( J ), TJJS ) - CSUMJ
               END IF
               XMAX = MAX( XMAX, CABS1( X( J ) ) )
  220       CONTINUE
         END IF
         SCALE = SCALE / TSCAL
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Scale the column norms by 1/TSCAL for return.
</span><span class="comment">*</span><span class="comment">
</span>      IF( TSCAL.NE.ONE ) THEN
         CALL DSCAL( N, ONE / TSCAL, CNORM, 1 )
      END IF
<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="ZLATBS.906"></a><a href="zlatbs.f.html#ZLATBS.1">ZLATBS</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?