dlatrs.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 726 行 · 第 1/4 页
HTML
726 行
<span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
IF( J.GT.1 ) 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(1:j-1) := x(1:j-1) - x(j) * A(1:j-1,j)
</span><span class="comment">*</span><span class="comment">
</span> CALL DAXPY( J-1, -X( J )*TSCAL, A( 1, J ), 1, X,
$ 1 )
I = IDAMAX( 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:n) := x(j+1:n) - x(j) * A(j+1:n,j)
</span><span class="comment">*</span><span class="comment">
</span> CALL DAXPY( N-J, -X( J )*TSCAL, A( J+1, J ), 1,
$ X( J+1 ), 1 )
I = J + IDAMAX( N-J, X( J+1 ), 1 )
XMAX = ABS( X( I ) )
END IF
END IF
110 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 160 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<>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 = A( J, 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) > 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 DSCAL( 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 DDOT to perform the dot product.
</span><span class="comment">*</span><span class="comment">
</span> IF( UPPER ) THEN
SUMJ = DDOT( J-1, A( 1, J ), 1, X, 1 )
ELSE IF( J.LT.N ) THEN
SUMJ = DDOT( N-J, A( J+1, 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
DO 120 I = 1, J - 1
SUMJ = SUMJ + ( A( I, J )*USCAL )*X( I )
120 CONTINUE
ELSE IF( J.LT.N ) THEN
DO 130 I = J + 1, N
SUMJ = SUMJ + ( A( I, J )*USCAL )*X( I )
130 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
TJJS = A( J, J )*TSCAL
ELSE
TJJS = TSCAL
IF( TSCAL.EQ.ONE )
$ GO TO 150
END IF
<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> 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/abs(x(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
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">
</span> REC = ( TJJ*BIGNUM ) / XJ
CALL DSCAL( 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 140 I = 1, N
X( I ) = ZERO
140 CONTINUE
X( J ) = ONE
SCALE = ZERO
XMAX = ZERO
END IF
150 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 ) ) )
160 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="DLATRS.699"></a><a href="dlatrs.f.html#DLATRS.1">DLATRS</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?