corth.f 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. *DECK CORTH
  2. SUBROUTINE CORTH (NM, N, LOW, IGH, AR, AI, ORTR, ORTI)
  3. C***BEGIN PROLOGUE CORTH
  4. C***PURPOSE Reduce a complex general matrix to complex upper Hessenberg
  5. C form using unitary similarity transformations.
  6. C***LIBRARY SLATEC (EISPACK)
  7. C***CATEGORY D4C1B2
  8. C***TYPE COMPLEX (ORTHES-S, CORTH-C)
  9. C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK
  10. C***AUTHOR Smith, B. T., et al.
  11. C***DESCRIPTION
  12. C
  13. C This subroutine is a translation of a complex analogue of
  14. C the ALGOL procedure ORTHES, NUM. MATH. 12, 349-368(1968)
  15. C by Martin and Wilkinson.
  16. C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971).
  17. C
  18. C Given a COMPLEX GENERAL matrix, this subroutine
  19. C reduces a submatrix situated in rows and columns
  20. C LOW through IGH to upper Hessenberg form by
  21. C unitary similarity transformations.
  22. C
  23. C On INPUT
  24. C
  25. C NM must be set to the row dimension of the two-dimensional
  26. C array parameters, AR and AI, as declared in the calling
  27. C program dimension statement. NM is an INTEGER variable.
  28. C
  29. C N is the order of the matrix A=(AR,AI). N is an INTEGER
  30. C variable. N must be less than or equal to NM.
  31. C
  32. C LOW and IGH are two INTEGER variables determined by the
  33. C balancing subroutine CBAL. If CBAL has not been used,
  34. C set LOW=1 and IGH equal to the order of the matrix, N.
  35. C
  36. C AR and AI contain the real and imaginary parts, respectively,
  37. C of the complex input matrix. AR and AI are two-dimensional
  38. C REAL arrays, dimensioned AR(NM,N) and AI(NM,N).
  39. C
  40. C On OUTPUT
  41. C
  42. C AR and AI contain the real and imaginary parts, respectively,
  43. C of the Hessenberg matrix. Information about the unitary
  44. C transformations used in the reduction is stored in the
  45. C remaining triangles under the Hessenberg matrix.
  46. C
  47. C ORTR and ORTI contain further information about the unitary
  48. C transformations. Only elements LOW through IGH are used.
  49. C ORTR and ORTI are one-dimensional REAL arrays, dimensioned
  50. C ORTR(IGH) and ORTI(IGH).
  51. C
  52. C Calls PYTHAG(A,B) for sqrt(A**2 + B**2).
  53. C
  54. C Questions and comments should be directed to B. S. Garbow,
  55. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  56. C ------------------------------------------------------------------
  57. C
  58. C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
  59. C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
  60. C system Routines - EISPACK Guide, Springer-Verlag,
  61. C 1976.
  62. C***ROUTINES CALLED PYTHAG
  63. C***REVISION HISTORY (YYMMDD)
  64. C 760101 DATE WRITTEN
  65. C 890831 Modified array declarations. (WRB)
  66. C 890831 REVISION DATE from Version 3.2
  67. C 891214 Prologue converted to Version 4.0 format. (BAB)
  68. C 920501 Reformatted the REFERENCES section. (WRB)
  69. C***END PROLOGUE CORTH
  70. C
  71. INTEGER I,J,M,N,II,JJ,LA,MP,NM,IGH,KP1,LOW
  72. REAL AR(NM,*),AI(NM,*),ORTR(*),ORTI(*)
  73. REAL F,G,H,FI,FR,SCALE
  74. REAL PYTHAG
  75. C
  76. C***FIRST EXECUTABLE STATEMENT CORTH
  77. LA = IGH - 1
  78. KP1 = LOW + 1
  79. IF (LA .LT. KP1) GO TO 200
  80. C
  81. DO 180 M = KP1, LA
  82. H = 0.0E0
  83. ORTR(M) = 0.0E0
  84. ORTI(M) = 0.0E0
  85. SCALE = 0.0E0
  86. C .......... SCALE COLUMN (ALGOL TOL THEN NOT NEEDED) ..........
  87. DO 90 I = M, IGH
  88. 90 SCALE = SCALE + ABS(AR(I,M-1)) + ABS(AI(I,M-1))
  89. C
  90. IF (SCALE .EQ. 0.0E0) GO TO 180
  91. MP = M + IGH
  92. C .......... FOR I=IGH STEP -1 UNTIL M DO -- ..........
  93. DO 100 II = M, IGH
  94. I = MP - II
  95. ORTR(I) = AR(I,M-1) / SCALE
  96. ORTI(I) = AI(I,M-1) / SCALE
  97. H = H + ORTR(I) * ORTR(I) + ORTI(I) * ORTI(I)
  98. 100 CONTINUE
  99. C
  100. G = SQRT(H)
  101. F = PYTHAG(ORTR(M),ORTI(M))
  102. IF (F .EQ. 0.0E0) GO TO 103
  103. H = H + F * G
  104. G = G / F
  105. ORTR(M) = (1.0E0 + G) * ORTR(M)
  106. ORTI(M) = (1.0E0 + G) * ORTI(M)
  107. GO TO 105
  108. C
  109. 103 ORTR(M) = G
  110. AR(M,M-1) = SCALE
  111. C .......... FORM (I-(U*UT)/H) * A ..........
  112. 105 DO 130 J = M, N
  113. FR = 0.0E0
  114. FI = 0.0E0
  115. C .......... FOR I=IGH STEP -1 UNTIL M DO -- ..........
  116. DO 110 II = M, IGH
  117. I = MP - II
  118. FR = FR + ORTR(I) * AR(I,J) + ORTI(I) * AI(I,J)
  119. FI = FI + ORTR(I) * AI(I,J) - ORTI(I) * AR(I,J)
  120. 110 CONTINUE
  121. C
  122. FR = FR / H
  123. FI = FI / H
  124. C
  125. DO 120 I = M, IGH
  126. AR(I,J) = AR(I,J) - FR * ORTR(I) + FI * ORTI(I)
  127. AI(I,J) = AI(I,J) - FR * ORTI(I) - FI * ORTR(I)
  128. 120 CONTINUE
  129. C
  130. 130 CONTINUE
  131. C .......... FORM (I-(U*UT)/H)*A*(I-(U*UT)/H) ..........
  132. DO 160 I = 1, IGH
  133. FR = 0.0E0
  134. FI = 0.0E0
  135. C .......... FOR J=IGH STEP -1 UNTIL M DO -- ..........
  136. DO 140 JJ = M, IGH
  137. J = MP - JJ
  138. FR = FR + ORTR(J) * AR(I,J) - ORTI(J) * AI(I,J)
  139. FI = FI + ORTR(J) * AI(I,J) + ORTI(J) * AR(I,J)
  140. 140 CONTINUE
  141. C
  142. FR = FR / H
  143. FI = FI / H
  144. C
  145. DO 150 J = M, IGH
  146. AR(I,J) = AR(I,J) - FR * ORTR(J) - FI * ORTI(J)
  147. AI(I,J) = AI(I,J) + FR * ORTI(J) - FI * ORTR(J)
  148. 150 CONTINUE
  149. C
  150. 160 CONTINUE
  151. C
  152. ORTR(M) = SCALE * ORTR(M)
  153. ORTI(M) = SCALE * ORTI(M)
  154. AR(M,M-1) = -G * AR(M,M-1)
  155. AI(M,M-1) = -G * AI(M,M-1)
  156. 180 CONTINUE
  157. C
  158. 200 RETURN
  159. END