dgels.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 447 行 · 第 1/3 页
HTML
447 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dgels.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="DGELS.1"></a><a href="dgels.f.html#DGELS.1">DGELS</a>( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK,
$ 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> CHARACTER TRANS
INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> DOUBLE PRECISION 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"> <a name="DGELS.19"></a><a href="dgels.f.html#DGELS.1">DGELS</a> solves overdetermined or underdetermined real linear systems
</span><span class="comment">*</span><span class="comment"> involving an M-by-N matrix A, or its transpose, using a QR or LQ
</span><span class="comment">*</span><span class="comment"> factorization of A. It is assumed that A has full rank.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> The following options are provided:
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 1. If TRANS = 'N' and m >= n: find the least squares solution of
</span><span class="comment">*</span><span class="comment"> an overdetermined system, i.e., solve the least squares problem
</span><span class="comment">*</span><span class="comment"> minimize || B - A*X ||.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 2. If TRANS = 'N' and m < n: find the minimum norm solution of
</span><span class="comment">*</span><span class="comment"> an underdetermined system A * X = B.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 3. If TRANS = 'T' and m >= n: find the minimum norm solution of
</span><span class="comment">*</span><span class="comment"> an undetermined system A**T * X = B.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> 4. If TRANS = 'T' and m < n: find the least squares solution of
</span><span class="comment">*</span><span class="comment"> an overdetermined system, i.e., solve the least squares problem
</span><span class="comment">*</span><span class="comment"> minimize || B - A**T * X ||.
</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"> 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"> TRANS (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment"> = 'N': the linear system involves A;
</span><span class="comment">*</span><span class="comment"> = 'T': the linear system involves A**T.
</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 the 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) DOUBLE PRECISION 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,
</span><span class="comment">*</span><span class="comment"> if M >= N, A is overwritten by details of its QR
</span><span class="comment">*</span><span class="comment"> factorization as returned by <a name="DGEQRF.65"></a><a href="dgeqrf.f.html#DGEQRF.1">DGEQRF</a>;
</span><span class="comment">*</span><span class="comment"> if M < N, A is overwritten by details of its LQ
</span><span class="comment">*</span><span class="comment"> factorization as returned by <a name="DGELQF.67"></a><a href="dgelqf.f.html#DGELQF.1">DGELQF</a>.
</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) DOUBLE PRECISION array, dimension (LDB,NRHS)
</span><span class="comment">*</span><span class="comment"> On entry, the matrix B of right hand side vectors, stored
</span><span class="comment">*</span><span class="comment"> columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS
</span><span class="comment">*</span><span class="comment"> if TRANS = 'T'.
</span><span class="comment">*</span><span class="comment"> On exit, if INFO = 0, B is overwritten by the solution
</span><span class="comment">*</span><span class="comment"> vectors, stored columnwise:
</span><span class="comment">*</span><span class="comment"> if TRANS = 'N' and m >= n, rows 1 to n of B contain the least
</span><span class="comment">*</span><span class="comment"> squares solution vectors; the residual sum of squares for the
</span><span class="comment">*</span><span class="comment"> solution in each column is given by the sum of squares of
</span><span class="comment">*</span><span class="comment"> elements N+1 to M in that column;
</span><span class="comment">*</span><span class="comment"> if TRANS = 'N' and m < n, rows 1 to N of B contain the
</span><span class="comment">*</span><span class="comment"> minimum norm solution vectors;
</span><span class="comment">*</span><span class="comment"> if TRANS = 'T' and m >= n, rows 1 to M of B contain the
</span><span class="comment">*</span><span class="comment"> minimum norm solution vectors;
</span><span class="comment">*</span><span class="comment"> if TRANS = 'T' and m < n, rows 1 to M of B contain the
</span><span class="comment">*</span><span class="comment"> least squares solution vectors; the residual sum of squares
</span><span class="comment">*</span><span class="comment"> for the solution in each column is given by the sum of
</span><span class="comment">*</span><span class="comment"> squares of elements M+1 to N 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"> WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
</span><span class="comment">*</span><span class="comment"> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> LWORK (input) INTEGER
</span><span class="comment">*</span><span class="comment"> The dimension of the array WORK.
</span><span class="comment">*</span><span class="comment"> LWORK >= max( 1, MN + max( MN, NRHS ) ).
</span><span class="comment">*</span><span class="comment"> For optimal performance,
</span><span class="comment">*</span><span class="comment"> LWORK >= max( 1, MN + max( MN, NRHS )*NB ).
</span><span class="comment">*</span><span class="comment"> where MN = min(M,N) and NB is the optimum block size.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> If LWORK = -1, then a workspace query is assumed; the routine
</span><span class="comment">*</span><span class="comment"> only calculates the optimal size of the WORK array, returns
</span><span class="comment">*</span><span class="comment"> this value as the first entry of the WORK array, and no error
</span><span class="comment">*</span><span class="comment"> message related to LWORK is issued by <a name="XERBLA.107"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</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"> > 0: if INFO = i, the i-th diagonal element of the
</span><span class="comment">*</span><span class="comment"> triangular factor of A is zero, so that A does not have
</span><span class="comment">*</span><span class="comment"> full rank; the least squares solution could not be
</span><span class="comment">*</span><span class="comment"> computed.
</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> DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> LOGICAL LQUERY, TPSD
INTEGER BROW, I, IASCL, IBSCL, J, MN, NB, SCLLEN, WSIZE
DOUBLE PRECISION ANRM, BIGNUM, BNRM, SMLNUM
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Arrays ..
</span> DOUBLE PRECISION RWORK( 1 )
<span class="comment">*</span><span class="comment"> ..
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?