sormqr.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 286 行 · 第 1/2 页
HTML
286 行
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Test the input arguments
</span><span class="comment">*</span><span class="comment">
</span> INFO = 0
LEFT = <a name="LSAME.129"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SIDE, <span class="string">'L'</span> )
NOTRAN = <a name="LSAME.130"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANS, <span class="string">'N'</span> )
LQUERY = ( LWORK.EQ.-1 )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> NQ is the order of Q and NW is the minimum dimension of WORK
</span><span class="comment">*</span><span class="comment">
</span> IF( LEFT ) THEN
NQ = M
NW = N
ELSE
NQ = N
NW = M
END IF
IF( .NOT.LEFT .AND. .NOT.<a name="LSAME.142"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( SIDE, <span class="string">'R'</span> ) ) THEN
INFO = -1
ELSE IF( .NOT.NOTRAN .AND. .NOT.<a name="LSAME.144"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( TRANS, <span class="string">'T'</span> ) ) THEN
INFO = -2
ELSE IF( M.LT.0 ) THEN
INFO = -3
ELSE IF( N.LT.0 ) THEN
INFO = -4
ELSE IF( K.LT.0 .OR. K.GT.NQ ) THEN
INFO = -5
ELSE IF( LDA.LT.MAX( 1, NQ ) ) THEN
INFO = -7
ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
INFO = -10
ELSE IF( LWORK.LT.MAX( 1, NW ) .AND. .NOT.LQUERY ) THEN
INFO = -12
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Determine the block size. NB may be at most NBMAX, where NBMAX
</span><span class="comment">*</span><span class="comment"> is used to define the local array T.
</span><span class="comment">*</span><span class="comment">
</span> NB = MIN( NBMAX, <a name="ILAENV.165"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SORMQR.165"></a><a href="sormqr.f.html#SORMQR.1">SORMQR</a>'</span>, SIDE // TRANS, M, N, K,
$ -1 ) )
LWKOPT = MAX( 1, NW )*NB
WORK( 1 ) = LWKOPT
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.172"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="SORMQR.172"></a><a href="sormqr.f.html#SORMQR.1">SORMQR</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( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THEN
WORK( 1 ) = 1
RETURN
END IF
<span class="comment">*</span><span class="comment">
</span> NBMIN = 2
LDWORK = NW
IF( NB.GT.1 .AND. NB.LT.K ) THEN
IWS = NW*NB
IF( LWORK.LT.IWS ) THEN
NB = LWORK / LDWORK
NBMIN = MAX( 2, <a name="ILAENV.191"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 2, <span class="string">'<a name="SORMQR.191"></a><a href="sormqr.f.html#SORMQR.1">SORMQR</a>'</span>, SIDE // TRANS, M, N, K,
$ -1 ) )
END IF
ELSE
IWS = NW
END IF
<span class="comment">*</span><span class="comment">
</span> IF( NB.LT.NBMIN .OR. NB.GE.K ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Use unblocked code
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SORM2R.202"></a><a href="sorm2r.f.html#SORM2R.1">SORM2R</a>( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK,
$ IINFO )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Use blocked code
</span><span class="comment">*</span><span class="comment">
</span> IF( ( LEFT .AND. .NOT.NOTRAN ) .OR.
$ ( .NOT.LEFT .AND. NOTRAN ) ) THEN
I1 = 1
I2 = K
I3 = NB
ELSE
I1 = ( ( K-1 ) / NB )*NB + 1
I2 = 1
I3 = -NB
END IF
<span class="comment">*</span><span class="comment">
</span> IF( LEFT ) THEN
NI = N
JC = 1
ELSE
MI = M
IC = 1
END IF
<span class="comment">*</span><span class="comment">
</span> DO 10 I = I1, I2, I3
IB = MIN( NB, K-I+1 )
<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) H(i+1) . . . H(i+ib-1)
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SLARFT.233"></a><a href="slarft.f.html#SLARFT.1">SLARFT</a>( <span class="string">'Forward'</span>, <span class="string">'Columnwise'</span>, NQ-I+1, IB, A( I, I ),
$ LDA, TAU( I ), T, LDT )
IF( LEFT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> H or H' is applied to C(i:m,1:n)
</span><span class="comment">*</span><span class="comment">
</span> MI = M - I + 1
IC = I
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> H or H' is applied to C(1:m,i:n)
</span><span class="comment">*</span><span class="comment">
</span> NI = N - I + 1
JC = I
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Apply H or H'
</span><span class="comment">*</span><span class="comment">
</span> CALL <a name="SLARFB.251"></a><a href="slarfb.f.html#SLARFB.1">SLARFB</a>( SIDE, TRANS, <span class="string">'Forward'</span>, <span class="string">'Columnwise'</span>, MI, NI,
$ IB, A( I, I ), LDA, T, LDT, C( IC, JC ), LDC,
$ WORK, LDWORK )
10 CONTINUE
END IF
WORK( 1 ) = LWKOPT
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="SORMQR.259"></a><a href="sormqr.f.html#SORMQR.1">SORMQR</a>
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?