orthes.f 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. *DECK ORTHES
  2. SUBROUTINE ORTHES (NM, N, LOW, IGH, A, ORT)
  3. C***BEGIN PROLOGUE ORTHES
  4. C***PURPOSE Reduce a real general matrix to upper Hessenberg form
  5. C using orthogonal similarity transformations.
  6. C***LIBRARY SLATEC (EISPACK)
  7. C***CATEGORY D4C1B2
  8. C***TYPE SINGLE PRECISION (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 the ALGOL procedure ORTHES,
  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 orthogonal 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 general matrix to be reduced to upper
  36. C Hessenberg form. A is a two-dimensional REAL array,
  37. C dimensioned A(NM,N).
  38. C
  39. C On OUTPUT
  40. C
  41. C A contains the upper Hessenberg matrix. Some information about
  42. C the orthogonal transformations used in the reduction
  43. C is stored in the remaining triangle under the Hessenberg
  44. C matrix.
  45. C
  46. C ORT contains further information about the orthogonal trans-
  47. C formations used in the reduction. Only elements LOW+1
  48. C through IGH are used. ORT is a one-dimensional REAL array,
  49. C dimensioned ORT(IGH).
  50. C
  51. C Questions and comments should be directed to B. S. Garbow,
  52. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  53. C ------------------------------------------------------------------
  54. C
  55. C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
  56. C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
  57. C system Routines - EISPACK Guide, Springer-Verlag,
  58. C 1976.
  59. C***ROUTINES CALLED (NONE)
  60. C***REVISION HISTORY (YYMMDD)
  61. C 760101 DATE WRITTEN
  62. C 890831 Modified array declarations. (WRB)
  63. C 890831 REVISION DATE from Version 3.2
  64. C 891214 Prologue converted to Version 4.0 format. (BAB)
  65. C 920501 Reformatted the REFERENCES section. (WRB)
  66. C***END PROLOGUE ORTHES
  67. C
  68. INTEGER I,J,M,N,II,JJ,LA,MP,NM,IGH,KP1,LOW
  69. REAL A(NM,*),ORT(*)
  70. REAL F,G,H,SCALE
  71. C
  72. C***FIRST EXECUTABLE STATEMENT ORTHES
  73. LA = IGH - 1
  74. KP1 = LOW + 1
  75. IF (LA .LT. KP1) GO TO 200
  76. C
  77. DO 180 M = KP1, LA
  78. H = 0.0E0
  79. ORT(M) = 0.0E0
  80. SCALE = 0.0E0
  81. C .......... SCALE COLUMN (ALGOL TOL THEN NOT NEEDED) ..........
  82. DO 90 I = M, IGH
  83. 90 SCALE = SCALE + ABS(A(I,M-1))
  84. C
  85. IF (SCALE .EQ. 0.0E0) GO TO 180
  86. MP = M + IGH
  87. C .......... FOR I=IGH STEP -1 UNTIL M DO -- ..........
  88. DO 100 II = M, IGH
  89. I = MP - II
  90. ORT(I) = A(I,M-1) / SCALE
  91. H = H + ORT(I) * ORT(I)
  92. 100 CONTINUE
  93. C
  94. G = -SIGN(SQRT(H),ORT(M))
  95. H = H - ORT(M) * G
  96. ORT(M) = ORT(M) - G
  97. C .......... FORM (I-(U*UT)/H) * A ..........
  98. DO 130 J = M, N
  99. F = 0.0E0
  100. C .......... FOR I=IGH STEP -1 UNTIL M DO -- ..........
  101. DO 110 II = M, IGH
  102. I = MP - II
  103. F = F + ORT(I) * A(I,J)
  104. 110 CONTINUE
  105. C
  106. F = F / H
  107. C
  108. DO 120 I = M, IGH
  109. 120 A(I,J) = A(I,J) - F * ORT(I)
  110. C
  111. 130 CONTINUE
  112. C .......... FORM (I-(U*UT)/H)*A*(I-(U*UT)/H) ..........
  113. DO 160 I = 1, IGH
  114. F = 0.0E0
  115. C .......... FOR J=IGH STEP -1 UNTIL M DO -- ..........
  116. DO 140 JJ = M, IGH
  117. J = MP - JJ
  118. F = F + ORT(J) * A(I,J)
  119. 140 CONTINUE
  120. C
  121. F = F / H
  122. C
  123. DO 150 J = M, IGH
  124. 150 A(I,J) = A(I,J) - F * ORT(J)
  125. C
  126. 160 CONTINUE
  127. C
  128. ORT(M) = SCALE * ORT(M)
  129. A(M,M-1) = SCALE * G
  130. 180 CONTINUE
  131. C
  132. 200 RETURN
  133. END