d1mpyq.f 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. *DECK D1MPYQ
  2. SUBROUTINE D1MPYQ (M, N, A, LDA, V, W)
  3. C***BEGIN PROLOGUE D1MPYQ
  4. C***SUBSIDIARY
  5. C***PURPOSE Subsidiary to DNSQ and DNSQE
  6. C***LIBRARY SLATEC
  7. C***TYPE DOUBLE PRECISION (R1MPYQ-S, D1MPYQ-D)
  8. C***AUTHOR (UNKNOWN)
  9. C***DESCRIPTION
  10. C
  11. C Given an M by N matrix A, this subroutine computes A*Q where
  12. C Q is the product of 2*(N - 1) transformations
  13. C
  14. C GV(N-1)*...*GV(1)*GW(1)*...*GW(N-1)
  15. C
  16. C and GV(I), GW(I) are Givens rotations in the (I,N) plane which
  17. C eliminate elements in the I-th and N-th planes, respectively.
  18. C Q itself is not given, rather the information to recover the
  19. C GV, GW rotations is supplied.
  20. C
  21. C The SUBROUTINE statement is
  22. C
  23. C SUBROUTINE D1MPYQ(M,N,A,LDA,V,W)
  24. C
  25. C where
  26. C
  27. C M is a positive integer input variable set to the number
  28. C of rows of A.
  29. C
  30. C N IS a positive integer input variable set to the number
  31. C of columns of A.
  32. C
  33. C A is an M by N array. On input A must contain the matrix
  34. C to be postmultiplied by the orthogonal matrix Q
  35. C described above. On output A*Q has replaced A.
  36. C
  37. C LDA is a positive integer input variable not less than M
  38. C which specifies the leading dimension of the array A.
  39. C
  40. C V is an input array of length N. V(I) must contain the
  41. C information necessary to recover the Givens rotation GV(I)
  42. C described above.
  43. C
  44. C W is an input array of length N. W(I) must contain the
  45. C information necessary to recover the Givens rotation GW(I)
  46. C described above.
  47. C
  48. C***SEE ALSO DNSQ, DNSQE
  49. C***ROUTINES CALLED (NONE)
  50. C***REVISION HISTORY (YYMMDD)
  51. C 800301 DATE WRITTEN
  52. C 890531 Changed all specific intrinsics to generic. (WRB)
  53. C 890831 Modified array declarations. (WRB)
  54. C 891214 Prologue converted to Version 4.0 format. (BAB)
  55. C 900326 Removed duplicate information from DESCRIPTION section.
  56. C (WRB)
  57. C 900328 Added TYPE section. (WRB)
  58. C***END PROLOGUE D1MPYQ
  59. INTEGER I, J, LDA, M, N, NM1, NMJ
  60. DOUBLE PRECISION A(LDA,*), COS, ONE, SIN, TEMP, V(*), W(*)
  61. SAVE ONE
  62. DATA ONE /1.0D0/
  63. C
  64. C APPLY THE FIRST SET OF GIVENS ROTATIONS TO A.
  65. C
  66. C***FIRST EXECUTABLE STATEMENT D1MPYQ
  67. NM1 = N - 1
  68. IF (NM1 .LT. 1) GO TO 50
  69. DO 20 NMJ = 1, NM1
  70. J = N - NMJ
  71. IF (ABS(V(J)) .GT. ONE) COS = ONE/V(J)
  72. IF (ABS(V(J)) .GT. ONE) SIN = SQRT(ONE-COS**2)
  73. IF (ABS(V(J)) .LE. ONE) SIN = V(J)
  74. IF (ABS(V(J)) .LE. ONE) COS = SQRT(ONE-SIN**2)
  75. DO 10 I = 1, M
  76. TEMP = COS*A(I,J) - SIN*A(I,N)
  77. A(I,N) = SIN*A(I,J) + COS*A(I,N)
  78. A(I,J) = TEMP
  79. 10 CONTINUE
  80. 20 CONTINUE
  81. C
  82. C APPLY THE SECOND SET OF GIVENS ROTATIONS TO A.
  83. C
  84. DO 40 J = 1, NM1
  85. IF (ABS(W(J)) .GT. ONE) COS = ONE/W(J)
  86. IF (ABS(W(J)) .GT. ONE) SIN = SQRT(ONE-COS**2)
  87. IF (ABS(W(J)) .LE. ONE) SIN = W(J)
  88. IF (ABS(W(J)) .LE. ONE) COS = SQRT(ONE-SIN**2)
  89. DO 30 I = 1, M
  90. TEMP = COS*A(I,J) + SIN*A(I,N)
  91. A(I,N) = -SIN*A(I,J) + COS*A(I,N)
  92. A(I,J) = TEMP
  93. 30 CONTINUE
  94. 40 CONTINUE
  95. 50 CONTINUE
  96. RETURN
  97. C
  98. C LAST CARD OF SUBROUTINE D1MPYQ.
  99. C
  100. END