suds.f 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. *DECK SUDS
  2. SUBROUTINE SUDS (A, X, B, NEQ, NUK, NRDA, IFLAG, MLSO, WORK,
  3. + IWORK)
  4. C***BEGIN PROLOGUE SUDS
  5. C***SUBSIDIARY
  6. C***PURPOSE Subsidiary to BVSUP
  7. C***LIBRARY SLATEC
  8. C***TYPE SINGLE PRECISION (SUDS-S, DSUDS-D)
  9. C***AUTHOR Watts, H. A., (SNLA)
  10. C***DESCRIPTION
  11. C
  12. C SUDS solves the underdetermined system of linear equations A Z = B
  13. C where A is NEQ by NUK and NEQ .LE. NUK. In particular, if rank A
  14. C 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 SUDS is an interfacing routine which calls subroutine LSSUDS
  25. C for the solution. LSSUDS in turn calls subroutine ORTHOR and
  26. C possibly subroutine OHTROL for the decomposition of A by
  27. C orthogonal transformations. In the process, ORTHOR calls upon
  28. C subroutine CSCALE 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 SUDS 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 BVSUP
  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 LSSUDS
  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 SUDS
  107. DIMENSION A(NRDA,*),X(*),B(*),WORK(*),IWORK(*)
  108. C
  109. C***FIRST EXECUTABLE STATEMENT SUDS
  110. IS=2
  111. IP=3
  112. IL=IP+NEQ
  113. KV=1+NEQ
  114. KT=KV+NEQ
  115. KS=KT+NEQ
  116. KU=KS+NUK
  117. C
  118. CALL LSSUDS(A,X,B,NEQ,NUK,NRDA,WORK(KU),NUK,IFLAG,MLSO,IWORK(1),
  119. 1 IWORK(IS),A,WORK(1),IWORK(IP),B,WORK(KV),WORK(KT),
  120. 2 IWORK(IL),WORK(KS))
  121. C
  122. RETURN
  123. END