Télécharger dqrank.eso

Retour à la liste

Numérotation des lignes :

dqrank
  1. C DQRANK SOURCE PV090527 23/02/07 11:58:36 11592
  2. subroutine dqrank ( a, lda, m, n, tol, kr, jpvt, qraux, work )
  3.  
  4. c*****************************************************************************80
  5. c
  6. c! DQRANK computes the QR factorization of a rectangular matrix.
  7. c
  8. c Discussion:
  9. c
  10. c This routine is used in conjunction with sqrlss to solve
  11. c overdetermined, underdetermined and singular linear systems
  12. c in a least squares sense.
  13. c
  14. c DQRANK uses the LINPACK subroutine DQRDC to compute the QR
  15. c factorization, with column pivoting, of an M by N matrix A.
  16. c The numerical rank is determined using the tolerance TOL.
  17. c
  18. c Note that on output, ABS ( A(1,1) ) / ABS ( A(KR,KR) ) is an estimate
  19. c of the condition number of the matrix of independent columns,
  20. c and of R. This estimate will be .le. 1/TOL.
  21. c
  22. c Reference:
  23. c
  24. c Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart,
  25. c LINPACK User's Guide,
  26. c SIAM, 1979,
  27. c ISBN13: 978-0-898711-72-1,
  28. c LC: QA214.L56.
  29. c
  30. c Parameters:
  31. c
  32. c Input/output, real*8 A(LDA,N). On input, the matrix whose
  33. c decomposition is to be computed. On output, the information from DQRDC.
  34. c The triangular matrix R of the QR factorization is contained in the
  35. c upper triangle and information needed to recover the orthogonal
  36. c matrix Q is stored below the diagonal in A and in the vector QRAUX.
  37. c
  38. c Input, integer LDA, the leading dimension of A, which must
  39. c be at least M.
  40. c
  41. c Input, integer M, the number of rows of A.
  42. c
  43. c Input, integer N, the number of columns of A.
  44. c
  45. c Input, real*8 TOL, a relative tolerance used to determine the
  46. c numerical rank. The problem should be scaled so that all the elements
  47. c of A have roughly the same absolute accuracy, EPS. Then a reasonable
  48. c value for TOL is roughly EPS divided by the magnitude of the largest
  49. c element.
  50. c
  51. c Output, integer KR, the numerical rank.
  52. c
  53. c Output, integer JPVT(N), the pivot information from DQRDC.
  54. c Columns JPVT(1), ..., JPVT(KR) of the original matrix are linearly
  55. c independent to within the tolerance TOL and the remaining columns
  56. c are linearly dependent.
  57. c
  58. c Output, real*8 QRAUX(N), will contain extra information defining
  59. c the QR factorization.
  60. c
  61. c Workspace, real*8 WORK(N).
  62. c
  63. implicit real*8 (a-h,o-z)
  64. implicit integer (i-n)
  65.  
  66. integer lda
  67. integer n
  68.  
  69. real*8 a(lda,n)
  70. integer j
  71. integer job
  72. integer jpvt(n)
  73. integer k
  74. integer kr
  75. integer m
  76. real*8 qraux(n)
  77. real*8 tol
  78. real*8 work(n)
  79.  
  80. jpvt(1:n) = 0
  81. job = 1
  82.  
  83. call dqrdc ( a, lda, m, n, qraux, jpvt, work, job )
  84.  
  85. kr = 0
  86. k = min ( m, n )
  87.  
  88. do j = 1, k
  89. if ( abs ( a(j,j) ) .le. tol * abs ( a(1,1) ) ) then
  90. return
  91. end if
  92. kr = j
  93. end do
  94.  
  95. return
  96. end
  97.  
  98.  

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