sgelsd.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 563 行 · 第 1/4 页
HTML
563 行
</span><span class="comment">*</span><span class="comment"> < 0: if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment"> > 0: the algorithm for computing the SVD failed to converge;
</span><span class="comment">*</span><span class="comment"> if INFO = i, i off-diagonal elements of an intermediate
</span><span class="comment">*</span><span class="comment"> bidiagonal form did not converge to zero.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Further Details
</span><span class="comment">*</span><span class="comment"> ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Based on contributions by
</span><span class="comment">*</span><span class="comment"> Ming Gu and Ren-Cang Li, Computer Science Division, University of
</span><span class="comment">*</span><span class="comment"> California at Berkeley, USA
</span><span class="comment">*</span><span class="comment"> Osni Marques, LBNL/NERSC, USA
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Parameters ..
</span> REAL ZERO, ONE, TWO
PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL LQUERY
INTEGER IASCL, IBSCL, IE, IL, ITAU, ITAUP, ITAUQ,
$ LDWORK, LIWORK, MAXMN, MAXWRK, MINMN, MINWRK,
$ MM, MNTHR, NLVL, NWORK, SMLSIZ, WLALSD
REAL ANRM, BIGNUM, BNRM, EPS, SFMIN, SMLNUM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL <a name="SGEBRD.150"></a><a href="sgebrd.f.html#SGEBRD.1">SGEBRD</a>, <a name="SGELQF.150"></a><a href="sgelqf.f.html#SGELQF.1">SGELQF</a>, <a name="SGEQRF.150"></a><a href="sgeqrf.f.html#SGEQRF.1">SGEQRF</a>, <a name="SLABAD.150"></a><a href="slabad.f.html#SLABAD.1">SLABAD</a>, <a name="SLACPY.150"></a><a href="slacpy.f.html#SLACPY.1">SLACPY</a>, <a name="SLALSD.150"></a><a href="slalsd.f.html#SLALSD.1">SLALSD</a>,
$ <a name="SLASCL.151"></a><a href="slascl.f.html#SLASCL.1">SLASCL</a>, <a name="SLASET.151"></a><a href="slaset.f.html#SLASET.1">SLASET</a>, <a name="SORMBR.151"></a><a href="sormbr.f.html#SORMBR.1">SORMBR</a>, <a name="SORMLQ.151"></a><a href="sormlq.f.html#SORMLQ.1">SORMLQ</a>, <a name="SORMQR.151"></a><a href="sormqr.f.html#SORMQR.1">SORMQR</a>, <a name="XERBLA.151"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Functions ..
</span> INTEGER <a name="ILAENV.154"></a><a href="hfy-index.html#ILAENV">ILAENV</a>
REAL <a name="SLAMCH.155"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANGE.155"></a><a href="slange.f.html#SLANGE.1">SLANGE</a>
EXTERNAL <a name="SLAMCH.156"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>, <a name="SLANGE.156"></a><a href="slange.f.html#SLANGE.1">SLANGE</a>, <a name="ILAENV.156"></a><a href="hfy-index.html#ILAENV">ILAENV</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC INT, LOG, MAX, MIN, REAL
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Executable Statements ..
</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
MINMN = MIN( M, N )
MAXMN = MAX( M, N )
LQUERY = ( LWORK.EQ.-1 )
IF( M.LT.0 ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( NRHS.LT.0 ) THEN
INFO = -3
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -5
ELSE IF( LDB.LT.MAX( 1, MAXMN ) ) THEN
INFO = -7
END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Compute workspace.
</span><span class="comment">*</span><span class="comment"> (Note: Comments in the code beginning "Workspace:" describe the
</span><span class="comment">*</span><span class="comment"> minimal amount of workspace needed at that point in the code,
</span><span class="comment">*</span><span class="comment"> as well as the preferred amount for good performance.
</span><span class="comment">*</span><span class="comment"> NB refers to the optimal block size for the immediately
</span><span class="comment">*</span><span class="comment"> following subroutine, as returned by <a name="ILAENV.186"></a><a href="hfy-index.html#ILAENV">ILAENV</a>.)
</span><span class="comment">*</span><span class="comment">
</span> IF( INFO.EQ.0 ) THEN
MINWRK = 1
MAXWRK = 1
LIWORK = 1
IF( MINMN.GT.0 ) THEN
SMLSIZ = <a name="ILAENV.193"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 9, <span class="string">'<a name="SGELSD.193"></a><a href="sgelsd.f.html#SGELSD.1">SGELSD</a>'</span>, <span class="string">' '</span>, 0, 0, 0, 0 )
MNTHR = <a name="ILAENV.194"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 6, <span class="string">'<a name="SGELSD.194"></a><a href="sgelsd.f.html#SGELSD.1">SGELSD</a>'</span>, <span class="string">' '</span>, M, N, NRHS, -1 )
NLVL = MAX( INT( LOG( REAL( MINMN ) / REAL( SMLSIZ + 1 ) ) /
$ LOG( TWO ) ) + 1, 0 )
LIWORK = 3*MINMN*NLVL + 11*MINMN
MM = M
IF( M.GE.N .AND. M.GE.MNTHR ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Path 1a - overdetermined, with many more rows than
</span><span class="comment">*</span><span class="comment"> columns.
</span><span class="comment">*</span><span class="comment">
</span> MM = N
MAXWRK = MAX( MAXWRK, N + N*<a name="ILAENV.205"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SGEQRF.205"></a><a href="sgeqrf.f.html#SGEQRF.1">SGEQRF</a>'</span>, <span class="string">' '</span>, M,
$ N, -1, -1 ) )
MAXWRK = MAX( MAXWRK, N + NRHS*<a name="ILAENV.207"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SORMQR.207"></a><a href="sormqr.f.html#SORMQR.1">SORMQR</a>'</span>, <span class="string">'LT'</span>,
$ M, NRHS, N, -1 ) )
END IF
IF( M.GE.N ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Path 1 - overdetermined or exactly determined.
</span><span class="comment">*</span><span class="comment">
</span> MAXWRK = MAX( MAXWRK, 3*N + ( MM + N )*<a name="ILAENV.214"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1,
$ <span class="string">'<a name="SGEBRD.215"></a><a href="sgebrd.f.html#SGEBRD.1">SGEBRD</a>'</span>, <span class="string">' '</span>, MM, N, -1, -1 ) )
MAXWRK = MAX( MAXWRK, 3*N + NRHS*<a name="ILAENV.216"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SORMBR.216"></a><a href="sormbr.f.html#SORMBR.1">SORMBR</a>'</span>,
$ <span class="string">'QLT'</span>, MM, NRHS, N, -1 ) )
MAXWRK = MAX( MAXWRK, 3*N + ( N - 1 )*<a name="ILAENV.218"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1,
$ <span class="string">'<a name="SORMBR.219"></a><a href="sormbr.f.html#SORMBR.1">SORMBR</a>'</span>, <span class="string">'PLN'</span>, N, NRHS, N, -1 ) )
WLALSD = 9*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS +
$ ( SMLSIZ + 1 )**2
MAXWRK = MAX( MAXWRK, 3*N + WLALSD )
MINWRK = MAX( 3*N + MM, 3*N + NRHS, 3*N + WLALSD )
END IF
IF( N.GT.M ) THEN
WLALSD = 9*M + 2*M*SMLSIZ + 8*M*NLVL + M*NRHS +
$ ( SMLSIZ + 1 )**2
IF( N.GE.MNTHR ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Path 2a - underdetermined, with many more columns
</span><span class="comment">*</span><span class="comment"> than rows.
</span><span class="comment">*</span><span class="comment">
</span> MAXWRK = M + M*<a name="ILAENV.233"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SGELQF.233"></a><a href="sgelqf.f.html#SGELQF.1">SGELQF</a>'</span>, <span class="string">' '</span>, M, N, -1,
$ -1 )
MAXWRK = MAX( MAXWRK, M*M + 4*M + 2*M*<a name="ILAENV.235"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1,
$ <span class="string">'<a name="SGEBRD.236"></a><a href="sgebrd.f.html#SGEBRD.1">SGEBRD</a>'</span>, <span class="string">' '</span>, M, M, -1, -1 ) )
MAXWRK = MAX( MAXWRK, M*M + 4*M + NRHS*<a name="ILAENV.237"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1,
$ <span class="string">'<a name="SORMBR.238"></a><a href="sormbr.f.html#SORMBR.1">SORMBR</a>'</span>, <span class="string">'QLT'</span>, M, NRHS, M, -1 ) )
MAXWRK = MAX( MAXWRK, M*M + 4*M + ( M - 1 )*<a name="ILAENV.239"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1,
$ <span class="string">'<a name="SORMBR.240"></a><a href="sormbr.f.html#SORMBR.1">SORMBR</a>'</span>, <span class="string">'PLN'</span>, M, NRHS, M, -1 ) )
IF( NRHS.GT.1 ) THEN
MAXWRK = MAX( MAXWRK, M*M + M + M*NRHS )
ELSE
MAXWRK = MAX( MAXWRK, M*M + 2*M )
END IF
MAXWRK = MAX( MAXWRK, M + NRHS*<a name="ILAENV.246"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SORMLQ.246"></a><a href="sormlq.f.html#SORMLQ.1">SORMLQ</a>'</span>,
$ <span class="string">'LT'</span>, N, NRHS, M, -1 ) )
MAXWRK = MAX( MAXWRK, M*M + 4*M + WLALSD )
ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Path 2 - remaining underdetermined cases.
</span><span class="comment">*</span><span class="comment">
</span> MAXWRK = 3*M + ( N + M )*<a name="ILAENV.253"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SGEBRD.253"></a><a href="sgebrd.f.html#SGEBRD.1">SGEBRD</a>'</span>, <span class="string">' '</span>, M,
$ N, -1, -1 )
MAXWRK = MAX( MAXWRK, 3*M + NRHS*<a name="ILAENV.255"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SORMBR.255"></a><a href="sormbr.f.html#SORMBR.1">SORMBR</a>'</span>,
$ <span class="string">'QLT'</span>, M, NRHS, N, -1 ) )
MAXWRK = MAX( MAXWRK, 3*M + M*<a name="ILAENV.257"></a><a href="hfy-index.html#ILAENV">ILAENV</a>( 1, <span class="string">'<a name="SORMBR.257"></a><a href="sormbr.f.html#SORMBR.1">SORMBR</a>'</span>,
$ <span class="string">'PLN'</span>, N, NRHS, M, -1 ) )
MAXWRK = MAX( MAXWRK, 3*M + WLALSD )
END IF
MINWRK = MAX( 3*M + NRHS, 3*M + M, 3*M + WLALSD )
END IF
END IF
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?