elmhes.f 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. *DECK ELMHES
  2. SUBROUTINE ELMHES (NM, N, LOW, IGH, A, INT)
  3. C***BEGIN PROLOGUE ELMHES
  4. C***PURPOSE Reduce a real general matrix to upper Hessenberg form
  5. C using stabilized elementary similarity transformations.
  6. C***LIBRARY SLATEC (EISPACK)
  7. C***CATEGORY D4C1B2
  8. C***TYPE SINGLE PRECISION (ELMHES-S, COMHES-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 the ALGOL procedure ELMHES,
  14. C NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson.
  15. C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971).
  16. C
  17. C Given a REAL GENERAL matrix, this subroutine
  18. C reduces a submatrix situated in rows and columns
  19. C LOW through IGH to upper Hessenberg form by
  20. C stabilized elementary similarity transformations.
  21. C
  22. C On INPUT
  23. C
  24. C NM must be set to the row dimension of the two-dimensional
  25. C array parameter, A, as declared in the calling program
  26. C dimension statement. NM is an INTEGER variable.
  27. C
  28. C N is the order of the matrix, A. N is an INTEGER variable.
  29. C N must be less than or equal to NM.
  30. C
  31. C LOW and IGH are two INTEGER variables determined by the
  32. C balancing subroutine BALANC. If BALANC has not been
  33. C used, set LOW=1 and IGH equal to the order of the matrix, N.
  34. C
  35. C A contains the input matrix. A is a two-dimensional REAL
  36. C array, dimensioned A(NM,N).
  37. C
  38. C On OUTPUT
  39. C
  40. C A contains the upper Hessenberg matrix. The multipliers which
  41. C were used in the reduction are stored in the remaining
  42. C triangle under the Hessenberg matrix.
  43. C
  44. C INT contains information on the rows and columns interchanged
  45. C in the reduction. Only elements LOW through IGH are used.
  46. C INT is a one-dimensional INTEGER array, dimensioned INT(IGH).
  47. C
  48. C Questions and comments should be directed to B. S. Garbow,
  49. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  50. C ------------------------------------------------------------------
  51. C
  52. C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
  53. C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
  54. C system Routines - EISPACK Guide, Springer-Verlag,
  55. C 1976.
  56. C***ROUTINES CALLED (NONE)
  57. C***REVISION HISTORY (YYMMDD)
  58. C 760101 DATE WRITTEN
  59. C 890831 Modified array declarations. (WRB)
  60. C 890831 REVISION DATE from Version 3.2
  61. C 891214 Prologue converted to Version 4.0 format. (BAB)
  62. C 920501 Reformatted the REFERENCES section. (WRB)
  63. C***END PROLOGUE ELMHES
  64. C
  65. INTEGER I,J,M,N,LA,NM,IGH,KP1,LOW,MM1,MP1
  66. REAL A(NM,*)
  67. REAL X,Y
  68. INTEGER INT(*)
  69. C
  70. C***FIRST EXECUTABLE STATEMENT ELMHES
  71. LA = IGH - 1
  72. KP1 = LOW + 1
  73. IF (LA .LT. KP1) GO TO 200
  74. C
  75. DO 180 M = KP1, LA
  76. MM1 = M - 1
  77. X = 0.0E0
  78. I = M
  79. C
  80. DO 100 J = M, IGH
  81. IF (ABS(A(J,MM1)) .LE. ABS(X)) GO TO 100
  82. X = A(J,MM1)
  83. I = J
  84. 100 CONTINUE
  85. C
  86. INT(M) = I
  87. IF (I .EQ. M) GO TO 130
  88. C .......... INTERCHANGE ROWS AND COLUMNS OF A ..........
  89. DO 110 J = MM1, N
  90. Y = A(I,J)
  91. A(I,J) = A(M,J)
  92. A(M,J) = Y
  93. 110 CONTINUE
  94. C
  95. DO 120 J = 1, IGH
  96. Y = A(J,I)
  97. A(J,I) = A(J,M)
  98. A(J,M) = Y
  99. 120 CONTINUE
  100. C .......... END INTERCHANGE ..........
  101. 130 IF (X .EQ. 0.0E0) GO TO 180
  102. MP1 = M + 1
  103. C
  104. DO 160 I = MP1, IGH
  105. Y = A(I,MM1)
  106. IF (Y .EQ. 0.0E0) GO TO 160
  107. Y = Y / X
  108. A(I,MM1) = Y
  109. C
  110. DO 140 J = M, N
  111. 140 A(I,J) = A(I,J) - Y * A(M,J)
  112. C
  113. DO 150 J = 1, IGH
  114. 150 A(J,M) = A(J,M) + Y * A(J,I)
  115. C
  116. 160 CONTINUE
  117. C
  118. 180 CONTINUE
  119. C
  120. 200 RETURN
  121. END