sgeqlf.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 238 行 · 第 1/2 页
HTML
238 行
LQUERY = ( LWORK.EQ.-1 )
IF( M.LT.0 ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -4
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 ) THEN
K = MIN( M, N )
IF( K.EQ.0 ) THEN
LWKOPT = 1
ELSE
NB = <a name="ILAENV.115"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SGEQLF.115"></a><a href="sgeqlf.f.html#SGEQLF.1">SGEQLF</a>'</span>, <span class="string">' '</span>, M, N, -1, -1 )
LWKOPT = N*NB
END IF
WORK( 1 ) = LWKOPT
<span class="comment">*</span><span class="comment">
</span> IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
INFO = -7
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.126"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SGEQLF.126"></a><a href="sgeqlf.f.html#SGEQLF.1">SGEQLF</a>'</span>, -INFO )
RETURN
ELSE IF( LQUERY ) THEN
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span> IF( K.EQ.0 ) THEN
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span> NBMIN = 2
NX = 1
IWS = N
IF( NB.GT.1 .AND. NB.LT.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Determine when to cross over from blocked to unblocked code.
</span><span class="comment">*</span><span class="comment">
</span> NX = MAX( 0, <a name="ILAENV.145"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 3, <span class="string">'<a name="SGEQLF.145"></a><a href="sgeqlf.f.html#SGEQLF.1">SGEQLF</a>'</span>, <span class="string">' '</span>, M, N, -1, -1 ) )
IF( NX.LT.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Determine if workspace is large enough for blocked code.
</span><span class="comment">*</span><span class="comment">
</span> LDWORK = N
IWS = LDWORK*NB
IF( LWORK.LT.IWS ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Not enough workspace to use optimal NB: reduce NB and
</span><span class="comment">*</span><span class="comment"> determine the minimum value of NB.
</span><span class="comment">*</span><span class="comment">
</span> NB = LWORK / LDWORK
NBMIN = MAX( 2, <a name="ILAENV.158"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 2, <span class="string">'<a name="SGEQLF.158"></a><a href="sgeqlf.f.html#SGEQLF.1">SGEQLF</a>'</span>, <span class="string">' '</span>, M, N, -1,
$ -1 ) )
END IF
END IF
END IF
<span class="comment">*</span><span class="comment">
</span> IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Use blocked code initially.
</span><span class="comment">*</span><span class="comment"> The last kk columns are handled by the block method.
</span><span class="comment">*</span><span class="comment">
</span> KI = ( ( K-NX-1 ) / NB )*NB
KK = MIN( K, KI+NB )
<span class="comment">*</span><span class="comment">
</span> DO 10 I = K - KK + KI + 1, K - KK + 1, -NB
IB = MIN( K-I+1, NB )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute the QL factorization of the current block
</span><span class="comment">*</span><span class="comment"> A(1:m-k+i+ib-1,n-k+i:n-k+i+ib-1)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SGEQL2.178"></a><a href="sgeql2.f.html#SGEQL2.1">SGEQL2</a>( M-K+I+IB-1, IB, A( 1, N-K+I ), LDA, TAU( I ),
$ WORK, IINFO )
IF( N-K+I.GT.1 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Form the triangular factor of the block reflector
</span><span class="comment">*</span><span class="comment"> H = H(i+ib-1) . . . H(i+1) H(i)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SLARFT.185"></a><a href="slarft.f.html#SLARFT.1">SLARFT</a>( <span class="string">'Backward'</span>, <span class="string">'Columnwise'</span>, M-K+I+IB-1, IB,
$ A( 1, N-K+I ), LDA, TAU( I ), WORK, LDWORK )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply H' to A(1:m-k+i+ib-1,1:n-k+i-1) from the left
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SLARFB.190"></a><a href="slarfb.f.html#SLARFB.1">SLARFB</a>( <span class="string">'Left'</span>, <span class="string">'Transpose'</span>, <span class="string">'Backward'</span>,
$ <span class="string">'Columnwise'</span>, M-K+I+IB-1, N-K+I-1, IB,
$ A( 1, N-K+I ), LDA, WORK, LDWORK, A, LDA,
$ WORK( IB+1 ), LDWORK )
END IF
10 CONTINUE
MU = M - K + I + NB - 1
NU = N - K + I + NB - 1
ELSE
MU = M
NU = N
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Use unblocked code to factor the last or only block
</span><span class="comment">*</span><span class="comment">
</span> IF( MU.GT.0 .AND. NU.GT.0 )
$ CALL <a name="SGEQL2.206"></a><a href="sgeql2.f.html#SGEQL2.1">SGEQL2</a>( MU, NU, A, LDA, TAU, WORK, IINFO )
<span class="comment">*</span><span class="comment">
</span> WORK( 1 ) = IWS
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="SGEQLF.211"></a><a href="sgeqlf.f.html#SGEQLF.1">SGEQLF</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?