Numérotation des lignes :

dqrls
C DQRLS     SOURCE    PV090527  23/02/07    11:58:37     11592                subroutine dqrls ( a, lda, m, n, tol, kr, b, x,r,jpvt,qraux,work,     #  itask, ind ) c*****************************************************************************80cc! DQRLS factors and solves a linear system in the least squares sense.cc  Discussion:cc    The linear system may be overdetermined, underdetermined or singular.c    The solution is obtained using a QR factorization of thec    coefficient matrix.cc    DQRLS can be efficiently used to solve several least squaresc    problems with the same matrix A.  The first system is solvedc    with ITASK = 1.  The subsequent systems are solved withc    ITASK = 2, to avoid the recomputation of the matrix factors.c    The parameters KR, JPVT, and QRAUX must not be modifiedc    between calls to DQRLS.cc    DQRLS is used to solve in a least squares sensec    overdetermined, underdetermined and singular linear systems.c    The system is A*X approximates B where A is M by N.c    B is a given M-vector, and X is the N-vector to be computed.c    A solution X is found which minimimzes the sum of squares (2-norm)c    of the residual,  A*X - B.cc    The numerical rank of A is determined using the tolerance TOL.cc    DQRLS uses the LINPACK subroutine DQRDC to compute the QRc    factorization, with column pivoting, of an M by N matrix A.cc  Modified:cc    15 April 2012cc  Reference:cc    David Kahaner, Cleve Moler, Steven Nash,c    Numerical Methods and Software,c    Prentice Hall, 1989,c    ISBN: 0-13-627258-4,c    LC: TA345.K34.cc  Parameters:cc    Input/output, real*8 A(LDA,N), an M by N matrix.c    On input, the matrix whose decomposition is to be computed.c    In a least squares data fitting problem, A(I,J) is thec    value of the J-th basis (model) function at the I-th data point.c    On output, A contains the output from DQRDC.  The triangular matrix Rc    of the QR factorization is contained in the upper triangle andc    information needed to recover the orthogonal matrix Q is storedc    below the diagonal in A and in the vector QRAUX.cc    Input, integer LDA, the leading dimension of A.cc    Input, integer M, the number of rows of A.cc    Input, integer N, the number of columns of A.cc    Input, real*8 TOL, a relative tolerance used to determine thec    numerical rank.  The problem should be scaled so that all the elementsc    of A have roughly the same absolute accuracy EPS.  Then a reasonablec    value for TOL is roughly EPS divided by the magnitude of the largestc    element.cc    Output, integer KR, the numerical rank.cc    Input, real*8 B(M), the right hand side of the linear system.cc    Output, real*8 X(N), a least squares solution to the linearc    system.cc    Output, real*8 R(M), the residual, B - A*X.  R mayc    overwrite B.cc    Workspace, integer JPVT(N), required if ITASK = 1.c    Columns JPVT(1), ..., JPVT(KR) of the original matrix are linearlyc    independent to within the tolerance TOL and the remaining columnsc    are linearly dependent.  ABS ( A(1,1) ) / ABS ( A(KR,KR) ) is an estimatec    of the condition number of the matrix of independent columns,c    and of R.  This estimate will be .le. 1/TOL.cc    Workspace, real*8 QRAUX(N), required if ITASK = 1.cc    Workspace, real*8 WORK(N), required if ITASK = 1.cc    Input, integer ITASK.c    1, DQRLS factors the matrix A and solves the least squares problem.c    2, DQRLS assumes that the matrix A was factored with an earlierc       call to DQRLS, and only solves the least squares problem.cc    Output, integer IND, error code.c    0:  no errorc    -1: LDA .lt. M   (fatal error)c    -2: N .lt. 1     (fatal error)c    -3: ITASK .lt. 1 (fatal error)c        implicit real*8 (a-h,o-z)        implicit integer (i-n)         integer lda        integer m        integer n         real*8 a(lda,n)        real*8 b(m)        integer ind        integer itask        integer jpvt(n)        integer kr        real*8 qraux(n)        real*8 r(m)        real*8 tol        real*8 work(n)        real*8 x(n)         if ( lda .lt. m ) then          write ( *, '(a)' ) ' '          write ( *, '(a)' ) 'DQRLS - Fatal error!'          write ( *, '(a)' ) '  LDA .lt. M.'          stop        end if         if ( n .le. 0 ) then          write ( *, '(a)' ) ' '          write ( *, '(a)' ) 'DQRLS - Fatal error!'          write ( *, '(a)' ) '  N .le. 0.'          stop        end if         if ( itask .lt. 1 ) then          write ( *, '(a)' ) ' '          write ( *, '(a)' ) 'DQRLS - Fatal error!'          write ( *, '(a)' ) '  ITASK .lt. 1.'          stop        end if         ind = 0 c  Factor the matrix.         if ( itask .eq. 1 ) then          call dqrank ( a, lda, m, n, tol, kr, jpvt, qraux, work )        end if c  Solve the least-squares problem.         call dqrlss ( a, lda, m, n, kr, b, x, r, jpvt, qraux )         return      end  

© Cast3M 2003 - Tous droits réservés.
Mentions légales