slatbs.f.html

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

HTML
748
字号
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                    Compute the update
</span><span class="comment">*</span><span class="comment">                       x(max(1,j-kd):j-1) := x(max(1,j-kd):j-1) -
</span><span class="comment">*</span><span class="comment">                                             x(j)* A(max(1,j-kd):j-1,j)
</span><span class="comment">*</span><span class="comment">
</span>                     JLEN = MIN( KD, J-1 )
                     CALL SAXPY( JLEN, -X( J )*TSCAL,
     $                           AB( KD+1-JLEN, J ), 1, X( J-JLEN ), 1 )
                     I = ISAMAX( J-1, X, 1 )
                     XMAX = ABS( X( I ) )
                  END IF
               ELSE IF( J.LT.N ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Compute the update
</span><span class="comment">*</span><span class="comment">                    x(j+1:min(j+kd,n)) := x(j+1:min(j+kd,n)) -
</span><span class="comment">*</span><span class="comment">                                          x(j) * A(j+1:min(j+kd,n),j)
</span><span class="comment">*</span><span class="comment">
</span>                  JLEN = MIN( KD, N-J )
                  IF( JLEN.GT.0 )
     $               CALL SAXPY( JLEN, -X( J )*TSCAL, AB( 2, J ), 1,
     $                           X( J+1 ), 1 )
                  I = J + ISAMAX( N-J, X( J+1 ), 1 )
                  XMAX = ABS( X( I ) )
               END IF
  100       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' * x = b
</span><span class="comment">*</span><span class="comment">
</span>            DO 140 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 = ABS( 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 = AB( MAIND, J )*TSCAL
                  ELSE
                     TJJS = TSCAL
                  END IF
                     TJJ = ABS( 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 = USCAL / TJJS
                     END IF
                  IF( REC.LT.ONE ) THEN
                     CALL SSCAL( N, REC, X, 1 )
                     SCALE = SCALE*REC
                     XMAX = XMAX*REC
                  END IF
               END IF
<span class="comment">*</span><span class="comment">
</span>               SUMJ = ZERO
               IF( USCAL.EQ.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 SDOT to perform the dot product.
</span><span class="comment">*</span><span class="comment">
</span>                  IF( UPPER ) THEN
                     JLEN = MIN( KD, J-1 )
                     SUMJ = SDOT( JLEN, AB( KD+1-JLEN, J ), 1,
     $                      X( J-JLEN ), 1 )
                  ELSE
                     JLEN = MIN( KD, N-J )
                     IF( JLEN.GT.0 )
     $                  SUMJ = SDOT( 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 110 I = 1, JLEN
                        SUMJ = SUMJ + ( AB( KD+I-JLEN, J )*USCAL )*
     $                         X( J-JLEN-1+I )
  110                CONTINUE
                  ELSE
                     JLEN = MIN( KD, N-J )
                     DO 120 I = 1, JLEN
                        SUMJ = SUMJ + ( AB( I+1, J )*USCAL )*X( J+I )
  120                CONTINUE
                  END IF
               END IF
<span class="comment">*</span><span class="comment">
</span>               IF( USCAL.EQ.TSCAL ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Compute x(j) := ( x(j) - sumj ) / 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 ) - SUMJ
                  XJ = ABS( 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 135
                  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)) &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 SSCAL( N, REC, X, 1 )
                              SCALE = SCALE*REC
                              XMAX = XMAX*REC
                           END IF
                        END IF
                        X( J ) = 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 SSCAL( N, REC, X, 1 )
                           SCALE = SCALE*REC
                           XMAX = XMAX*REC
                        END IF
                        X( J ) = 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'*x = 0.
</span><span class="comment">*</span><span class="comment">
</span>                        DO 130 I = 1, N
                           X( I ) = ZERO
  130                   CONTINUE
                        X( J ) = ONE
                        SCALE = ZERO
                        XMAX = ZERO
                     END IF
  135             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) - sumj 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 ) = X( J ) / TJJS - SUMJ
               END IF
               XMAX = MAX( XMAX, ABS( X( J ) ) )
  140       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 SSCAL( 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="SLATBS.721"></a><a href="slatbs.f.html#SLATBS.1">SLATBS</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

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