dsuds.f 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. *DECK DSUDS
  2. SUBROUTINE DSUDS (A, X, B, NEQ, NUK, NRDA, IFLAG, MLSO, WORK,
  3. + IWORK)
  4. C***BEGIN PROLOGUE DSUDS
  5. C***SUBSIDIARY
  6. C***PURPOSE Subsidiary to DBVSUP
  7. C***LIBRARY SLATEC
  8. C***TYPE DOUBLE PRECISION (SUDS-S, DSUDS-D)
  9. C***AUTHOR Watts, H. A., (SNLA)
  10. C***DESCRIPTION
  11. C
  12. C DSUDS solves the underdetermined system of linear equations A Z =
  13. C B where A is NEQ by NUK and NEQ .LE. NUK. in particular, if rank
  14. C A equals IRA, a vector X and a matrix U are determined such that
  15. C X is the UNIQUE solution of smallest length, satisfying A X = B,
  16. C and the columns of U form an orthonormal basis for the null
  17. C space of A, satisfying A U = 0 . Then all solutions Z are
  18. C given by
  19. C Z = X + C(1)*U(1) + ..... + C(NUK-IRA)*U(NUK-IRA)
  20. C where U(J) represents the J-th column of U and the C(J) are
  21. C arbitrary constants.
  22. C If the system of equations are not compatible, only the least
  23. C squares solution of minimal length is computed.
  24. C DSUDS is an interfacing routine which calls subroutine DLSSUD
  25. C for the solution. DLSSUD in turn calls subroutine DORTHR and
  26. C possibly subroutine DOHTRL for the decomposition of A by
  27. C orthogonal transformations. In the process, DORTHR calls upon
  28. C subroutine DCSCAL for scaling.
  29. C
  30. C ********************************************************************
  31. C INPUT
  32. C ********************************************************************
  33. C
  34. C A -- Contains the matrix of NEQ equations in NUK unknowns and must
  35. C be dimensioned NRDA by NUK. The original A is destroyed.
  36. C X -- Solution array of length at least NUK.
  37. C B -- Given constant vector of length NEQ, B is destroyed.
  38. C NEQ -- Number of equations, NEQ greater or equal to 1.
  39. C NUK -- Number of columns in the matrix (which is also the number
  40. C of unknowns), NUK not smaller than NEQ.
  41. C NRDA -- Row dimension of A, NRDA greater or equal to NEQ.
  42. C IFLAG -- Status indicator
  43. C =0 for the first call (and for each new problem defined by
  44. C a new matrix A) when the matrix data is treated as exact
  45. C =-K for the first call (and for each new problem defined by
  46. C a new matrix A) when the matrix data is assumed to be
  47. C accurate to about K digits.
  48. C =1 for subsequent calls whenever the matrix A has already
  49. C been decomposed (problems with new vectors B but
  50. C same matrix A can be handled efficiently).
  51. C MLSO -- =0 if only the minimal length solution is wanted.
  52. C =1 if the complete solution is wanted, includes the
  53. C linear space defined by the matrix U in the abstract.
  54. C WORK(*),IWORK(*) -- Arrays for storage of internal information,
  55. C WORK must be dimensioned at least
  56. C NUK + 3*NEQ + MLSO*NUK*(NUK-RANK A)
  57. C where it is possible for 0 .LE. RANK A .LE. NEQ
  58. C IWORK must be dimensioned at least 3 + NEQ
  59. C IWORK(2) -- Scaling indicator
  60. C =-1 if the matrix is to be pre-scaled by
  61. C columns when appropriate.
  62. C If the scaling indicator is not equal to -1
  63. C no scaling will be attempted.
  64. C For most problems scaling will probably not be necessary
  65. C
  66. C *********************************************************************
  67. C OUTPUT
  68. C *********************************************************************
  69. C
  70. C IFLAG -- Status indicator
  71. C =1 if solution was obtained.
  72. C =2 if improper input is detected.
  73. C =3 if rank of matrix is less than NEQ.
  74. C to continue simply reset IFLAG=1 and call DSUDS again.
  75. C =4 if the system of equations appears to be inconsistent.
  76. C However, the least squares solution of minimal length
  77. C was obtained.
  78. C X -- Minimal length least squares solution of A X = B.
  79. C A -- Contains the strictly upper triangular part of the reduced
  80. C matrix and transformation information.
  81. C WORK(*),IWORK(*) -- Contains information needed on subsequent
  82. C calls (IFLAG=1 case on input) which must not
  83. C be altered.
  84. C The matrix U described in the abstract is
  85. C stored in the NUK*(NUK-rank A) elements of
  86. C the WORK array beginning at WORK(1+NUK+3*NEQ).
  87. C However U is not defined when MLSO=0 or
  88. C IFLAG=4.
  89. C IWORK(1) contains the numerically determined
  90. C rank of the matrix A
  91. C
  92. C *********************************************************************
  93. C
  94. C***SEE ALSO DBVSUP
  95. C***REFERENCES H. A. Watts, Solving linear least squares problems
  96. C using SODS/SUDS/CODS, Sandia Report SAND77-0683,
  97. C Sandia Laboratories, 1977.
  98. C***ROUTINES CALLED DLSSUD
  99. C***REVISION HISTORY (YYMMDD)
  100. C 750601 DATE WRITTEN
  101. C 890831 Modified array declarations. (WRB)
  102. C 891214 Prologue converted to Version 4.0 format. (BAB)
  103. C 900328 Added TYPE section. (WRB)
  104. C 910408 Updated the AUTHOR and REFERENCES sections. (WRB)
  105. C 920501 Reformatted the REFERENCES section. (WRB)
  106. C***END PROLOGUE DSUDS
  107. INTEGER IFLAG, IL, IP, IS, IWORK(*), KS, KT, KU, KV, MLSO, NEQ,
  108. 1 NRDA, NUK
  109. DOUBLE PRECISION A(NRDA,*), B(*), WORK(*), X(*)
  110. C
  111. C***FIRST EXECUTABLE STATEMENT DSUDS
  112. IS = 2
  113. IP = 3
  114. IL = IP + NEQ
  115. KV = 1 + NEQ
  116. KT = KV + NEQ
  117. KS = KT + NEQ
  118. KU = KS + NUK
  119. C
  120. CALL DLSSUD(A,X,B,NEQ,NUK,NRDA,WORK(KU),NUK,IFLAG,MLSO,IWORK(1),
  121. 1 IWORK(IS),A,WORK(1),IWORK(IP),B,WORK(KV),WORK(KT),
  122. 2 IWORK(IL),WORK(KS))
  123. C
  124. RETURN
  125. END