cchud.f 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. *DECK CCHUD
  2. SUBROUTINE CCHUD (R, LDR, P, X, Z, LDZ, NZ, Y, RHO, C, S)
  3. C***BEGIN PROLOGUE CCHUD
  4. C***PURPOSE Update an augmented Cholesky decomposition of the
  5. C triangular part of an augmented QR decomposition.
  6. C***LIBRARY SLATEC (LINPACK)
  7. C***CATEGORY D7B
  8. C***TYPE COMPLEX (SCHUD-S, DCHUD-D, CCHUD-C)
  9. C***KEYWORDS CHOLESKY DECOMPOSITION, LINEAR ALGEBRA, LINPACK, MATRIX,
  10. C UPDATE
  11. C***AUTHOR Stewart, G. W., (U. of Maryland)
  12. C***DESCRIPTION
  13. C
  14. C CCHUD updates an augmented Cholesky decomposition of the
  15. C triangular part of an augmented QR decomposition. Specifically,
  16. C given an upper triangular matrix R of order P, a row vector
  17. C X, a column vector Z, and a scalar Y, CCHUD determines a
  18. C unitary matrix U and a scalar ZETA such that
  19. C
  20. C
  21. C (R Z) (RR ZZ )
  22. C U * ( ) = ( ) ,
  23. C (X Y) ( 0 ZETA)
  24. C
  25. C where RR is upper triangular. If R and Z have been
  26. C obtained from the factorization of a least squares
  27. C problem, then RR and ZZ are the factors corresponding to
  28. C the problem with the observation (X,Y) appended. In this
  29. C case, if RHO is the norm of the residual vector, then the
  30. C norm of the residual vector of the updated problem is
  31. C SQRT(RHO**2 + ZETA**2). CCHUD will simultaneously update
  32. C several triplets (Z,Y,RHO).
  33. C
  34. C For a less terse description of what CCHUD does and how
  35. C it may be applied see the LINPACK Guide.
  36. C
  37. C The matrix U is determined as the product U(P)*...*U(1),
  38. C where U(I) is a rotation in the (I,P+1) plane of the
  39. C form
  40. C
  41. C ( (CI) S(I) )
  42. C ( ) .
  43. C ( -CONJG(S(I)) (CI) )
  44. C
  45. C The rotations are chosen so that C(I) is real.
  46. C
  47. C On Entry
  48. C
  49. C R COMPLEX(LDR,P), where LDR .GE. P.
  50. C R contains the upper triangular matrix
  51. C that is to be updated. The part of R
  52. C below the diagonal is not referenced.
  53. C
  54. C LDR INTEGER.
  55. C LDR is the leading dimension of the array R.
  56. C
  57. C P INTEGER.
  58. C P is the order of the matrix R.
  59. C
  60. C X COMPLEX(P).
  61. C X contains the row to be added to R. X is
  62. C not altered by CCHUD.
  63. C
  64. C Z COMPLEX(LDZ,NZ), where LDZ .GE. P.
  65. C Z is an array containing NZ P-vectors to
  66. C be updated with R.
  67. C
  68. C LDZ INTEGER.
  69. C LDZ is the leading dimension of the array Z.
  70. C
  71. C NZ INTEGER.
  72. C NZ is the number of vectors to be updated
  73. C NZ may be zero, in which case Z, Y, and RHO
  74. C are not referenced.
  75. C
  76. C Y COMPLEX(NZ).
  77. C Y contains the scalars for updating the vectors
  78. C Z. Y is not altered by CCHUD.
  79. C
  80. C RHO REAL(NZ).
  81. C RHO contains the norms of the residual
  82. C vectors that are to be updated. If RHO(J)
  83. C is negative, it is left unaltered.
  84. C
  85. C On Return
  86. C
  87. C RC
  88. C RHO contain the updated quantities.
  89. C Z
  90. C
  91. C C REAL(P).
  92. C C contains the cosines of the transforming
  93. C rotations.
  94. C
  95. C S COMPLEX(P).
  96. C S contains the sines of the transforming
  97. C rotations.
  98. C
  99. C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
  100. C Stewart, LINPACK Users' Guide, SIAM, 1979.
  101. C***ROUTINES CALLED CROTG
  102. C***REVISION HISTORY (YYMMDD)
  103. C 780814 DATE WRITTEN
  104. C 890531 Changed all specific intrinsics to generic. (WRB)
  105. C 890831 Modified array declarations. (WRB)
  106. C 890831 REVISION DATE from Version 3.2
  107. C 891214 Prologue converted to Version 4.0 format. (BAB)
  108. C 900326 Removed duplicate information from DESCRIPTION section.
  109. C (WRB)
  110. C 920501 Reformatted the REFERENCES section. (WRB)
  111. C***END PROLOGUE CCHUD
  112. INTEGER LDR,P,LDZ,NZ
  113. REAL RHO(*),C(*)
  114. COMPLEX R(LDR,*),X(*),Z(LDZ,*),Y(*),S(*)
  115. C
  116. INTEGER I,J,JM1
  117. REAL AZETA,SCALE
  118. COMPLEX T,XJ,ZETA
  119. C
  120. C UPDATE R.
  121. C
  122. C***FIRST EXECUTABLE STATEMENT CCHUD
  123. DO 30 J = 1, P
  124. XJ = X(J)
  125. C
  126. C APPLY THE PREVIOUS ROTATIONS.
  127. C
  128. JM1 = J - 1
  129. IF (JM1 .LT. 1) GO TO 20
  130. DO 10 I = 1, JM1
  131. T = C(I)*R(I,J) + S(I)*XJ
  132. XJ = C(I)*XJ - CONJG(S(I))*R(I,J)
  133. R(I,J) = T
  134. 10 CONTINUE
  135. 20 CONTINUE
  136. C
  137. C COMPUTE THE NEXT ROTATION.
  138. C
  139. CALL CROTG(R(J,J),XJ,C(J),S(J))
  140. 30 CONTINUE
  141. C
  142. C IF REQUIRED, UPDATE Z AND RHO.
  143. C
  144. IF (NZ .LT. 1) GO TO 70
  145. DO 60 J = 1, NZ
  146. ZETA = Y(J)
  147. DO 40 I = 1, P
  148. T = C(I)*Z(I,J) + S(I)*ZETA
  149. ZETA = C(I)*ZETA - CONJG(S(I))*Z(I,J)
  150. Z(I,J) = T
  151. 40 CONTINUE
  152. AZETA = ABS(ZETA)
  153. IF (AZETA .EQ. 0.0E0 .OR. RHO(J) .LT. 0.0E0) GO TO 50
  154. SCALE = AZETA + RHO(J)
  155. RHO(J) = SCALE*SQRT((AZETA/SCALE)**2+(RHO(J)/SCALE)**2)
  156. 50 CONTINUE
  157. 60 CONTINUE
  158. 70 CONTINUE
  159. RETURN
  160. END