cgelsx.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 382 行 · 第 1/2 页
HTML
382 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>cgelsx.f</title>
<meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!--
body { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default a { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
span.string { color: rgb(188, 143, 143); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.string a { color: rgb(188, 143, 143); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
span.comment { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.comment a { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
--></style>
</head>
<body>
<pre>
SUBROUTINE <a name="CGELSX.1"></a><a href="cgelsx.f.html#CGELSX.1">CGELSX</a>( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK,
$ WORK, RWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> -- LAPACK driver routine (version 3.1) --
</span><span class="comment">*</span><span class="comment"> Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment"> November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Scalar Arguments ..
</span> INTEGER INFO, LDA, LDB, M, N, NRHS, RANK
REAL RCOND
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> INTEGER JPVT( * )
REAL RWORK( * )
COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Purpose
</span><span class="comment">*</span><span class="comment"> =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> This routine is deprecated and has been replaced by routine <a name="CGELSY.21"></a><a href="cgelsy.f.html#CGELSY.1">CGELSY</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> <a name="CGELSX.23"></a><a href="cgelsx.f.html#CGELSX.1">CGELSX</a> computes the minimum-norm solution to a complex linear least
</span><span class="comment">*</span><span class="comment"> squares problem:
</span><span class="comment">*</span><span class="comment"> minimize || A * X - B ||
</span><span class="comment">*</span><span class="comment"> using a complete orthogonal factorization of A. A is an M-by-N
</span><span class="comment">*</span><span class="comment"> matrix which may be rank-deficient.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Several right hand side vectors b and solution vectors x can be
</span><span class="comment">*</span><span class="comment"> handled in a single call; they are stored as the columns of the
</span><span class="comment">*</span><span class="comment"> M-by-NRHS right hand side matrix B and the N-by-NRHS solution
</span><span class="comment">*</span><span class="comment"> matrix X.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> The routine first computes a QR factorization with column pivoting:
</span><span class="comment">*</span><span class="comment"> A * P = Q * [ R11 R12 ]
</span><span class="comment">*</span><span class="comment"> [ 0 R22 ]
</span><span class="comment">*</span><span class="comment"> with R11 defined as the largest leading submatrix whose estimated
</span><span class="comment">*</span><span class="comment"> condition number is less than 1/RCOND. The order of R11, RANK,
</span><span class="comment">*</span><span class="comment"> is the effective rank of A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Then, R22 is considered to be negligible, and R12 is annihilated
</span><span class="comment">*</span><span class="comment"> by unitary transformations from the right, arriving at the
</span><span class="comment">*</span><span class="comment"> complete orthogonal factorization:
</span><span class="comment">*</span><span class="comment"> A * P = Q * [ T11 0 ] * Z
</span><span class="comment">*</span><span class="comment"> [ 0 0 ]
</span><span class="comment">*</span><span class="comment"> The minimum-norm solution is then
</span><span class="comment">*</span><span class="comment"> X = P * Z' [ inv(T11)*Q1'*B ]
</span><span class="comment">*</span><span class="comment"> [ 0 ]
</span><span class="comment">*</span><span class="comment"> where Q1 consists of the first RANK columns of Q.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Arguments
</span><span class="comment">*</span><span class="comment"> =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> M (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The number of rows of the matrix A. M >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> N (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The number of columns of the matrix A. N >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> NRHS (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The number of right hand sides, i.e., the number of
</span><span class="comment">*</span><span class="comment"> columns of matrices B and X. NRHS >= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> A (input/output) COMPLEX array, dimension (LDA,N)
</span><span class="comment">*</span><span class="comment"> On entry, the M-by-N matrix A.
</span><span class="comment">*</span><span class="comment"> On exit, A has been overwritten by details of its
</span><span class="comment">*</span><span class="comment"> complete orthogonal factorization.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDA (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array A. LDA >= max(1,M).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> B (input/output) COMPLEX array, dimension (LDB,NRHS)
</span><span class="comment">*</span><span class="comment"> On entry, the M-by-NRHS right hand side matrix B.
</span><span class="comment">*</span><span class="comment"> On exit, the N-by-NRHS solution matrix X.
</span><span class="comment">*</span><span class="comment"> If m >= n and RANK = n, the residual sum-of-squares for
</span><span class="comment">*</span><span class="comment"> the solution in the i-th column is given by the sum of
</span><span class="comment">*</span><span class="comment"> squares of elements N+1:M in that column.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LDB (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The leading dimension of the array B. LDB >= max(1,M,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> JPVT (input/output) INTEGER array, dimension (N)
</span><span class="comment">*</span><span class="comment"> On entry, if JPVT(i) .ne. 0, the i-th column of A is an
</span><span class="comment">*</span><span class="comment"> initial column, otherwise it is a free column. Before
</span><span class="comment">*</span><span class="comment"> the QR factorization of A, all initial columns are
</span><span class="comment">*</span><span class="comment"> permuted to the leading positions; only the remaining
</span><span class="comment">*</span><span class="comment"> free columns are moved as a result of column pivoting
</span><span class="comment">*</span><span class="comment"> during the factorization.
</span><span class="comment">*</span><span class="comment"> On exit, if JPVT(i) = k, then the i-th column of A*P
</span><span class="comment">*</span><span class="comment"> was the k-th column of A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> RCOND (input) REAL
</span><span class="comment">*</span><span class="comment"> RCOND is used to determine the effective rank of A, which
</span><span class="comment">*</span><span class="comment"> is defined as the order of the largest leading triangular
</span><span class="comment">*</span><span class="comment"> submatrix R11 in the QR factorization with pivoting of A,
</span><span class="comment">*</span><span class="comment"> whose estimated condition number < 1/RCOND.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> RANK (output) INTEGER
</span><span class="comment">*</span><span class="comment"> The effective rank of A, i.e., the order of the submatrix
</span><span class="comment">*</span><span class="comment"> R11. This is the same as the order of the submatrix T11
</span><span class="comment">*</span><span class="comment"> in the complete orthogonal factorization of A.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> WORK (workspace) COMPLEX array, dimension
</span><span class="comment">*</span><span class="comment"> (min(M,N) + max( N, 2*min(M,N)+NRHS )),
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> RWORK (workspace) REAL array, dimension (2*N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> INFO (output) INTEGER
</span><span class="comment">*</span><span class="comment"> = 0: successful exit
</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">
</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> INTEGER IMAX, IMIN
PARAMETER ( IMAX = 1, IMIN = 2 )
REAL ZERO, ONE, DONE, NTDONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, DONE = ZERO,
$ NTDONE = ONE )
COMPLEX CZERO, CONE
PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ),
$ CONE = ( 1.0E+0, 0.0E+0 ) )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> INTEGER I, IASCL, IBSCL, ISMAX, ISMIN, J, K, MN
REAL ANRM, BIGNUM, BNRM, SMAX, SMAXPR, SMIN, SMINPR,
$ SMLNUM
COMPLEX C1, C2, S1, S2, T1, T2
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. External Subroutines ..
</span> EXTERNAL <a name="CGEQPF.131"></a><a href="cgeqpf.f.html#CGEQPF.1">CGEQPF</a>, <a name="CLAIC1.131"></a><a href="claic1.f.html#CLAIC1.1">CLAIC1</a>, <a name="CLASCL.131"></a><a href="clascl.f.html#CLASCL.1">CLASCL</a>, <a name="CLASET.131"></a><a href="claset.f.html#CLASET.1">CLASET</a>, <a name="CLATZM.131"></a><a href="clatzm.f.html#CLATZM.1">CLATZM</a>, CTRSM,
$ <a name="CTZRQF.132"></a><a href="ctzrqf.f.html#CTZRQF.1">CTZRQF</a>, <a name="CUNM2R.132"></a><a href="cunm2r.f.html#CUNM2R.1">CUNM2R</a>, <a name="SLABAD.132"></a><a href="slabad.f.html#SLABAD.1">SLABAD</a>, <a name="XERBLA.132"></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> REAL <a name="CLANGE.135"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>, <a name="SLAMCH.135"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
EXTERNAL <a name="CLANGE.136"></a><a href="clange.f.html#CLANGE.1">CLANGE</a>, <a name="SLAMCH.136"></a><a href="slamch.f.html#SLAMCH.1">SLAMCH</a>
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC ABS, CONJG, MAX, MIN
<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> MN = MIN( M, N )
ISMIN = MN + 1
ISMAX = 2*MN + 1
<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
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, M, N ) ) THEN
INFO = -7
END IF
<span class="comment">*</span><span class="comment">
</span> IF( INFO.NE.0 ) THEN
CALL <a name="XERBLA.163"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="CGELSX.163"></a><a href="cgelsx.f.html#CGELSX.1">CGELSX</a>'</span>, -INFO )
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( MIN( M, N, NRHS ).EQ.0 ) THEN
RANK = 0
RETURN
END IF
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?