You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

slargv.f 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. *> \brief \b SLARGV generates a vector of plane rotations with real cosines and real sines.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SLARGV + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slargv.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slargv.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slargv.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SLARGV( N, X, INCX, Y, INCY, C, INCC )
  22. *
  23. * .. Scalar Arguments ..
  24. * INTEGER INCC, INCX, INCY, N
  25. * ..
  26. * .. Array Arguments ..
  27. * REAL C( * ), X( * ), Y( * )
  28. * ..
  29. *
  30. *
  31. *> \par Purpose:
  32. * =============
  33. *>
  34. *> \verbatim
  35. *>
  36. *> SLARGV generates a vector of real plane rotations, determined by
  37. *> elements of the real vectors x and y. For i = 1,2,...,n
  38. *>
  39. *> ( c(i) s(i) ) ( x(i) ) = ( a(i) )
  40. *> ( -s(i) c(i) ) ( y(i) ) = ( 0 )
  41. *> \endverbatim
  42. *
  43. * Arguments:
  44. * ==========
  45. *
  46. *> \param[in] N
  47. *> \verbatim
  48. *> N is INTEGER
  49. *> The number of plane rotations to be generated.
  50. *> \endverbatim
  51. *>
  52. *> \param[in,out] X
  53. *> \verbatim
  54. *> X is REAL array,
  55. *> dimension (1+(N-1)*INCX)
  56. *> On entry, the vector x.
  57. *> On exit, x(i) is overwritten by a(i), for i = 1,...,n.
  58. *> \endverbatim
  59. *>
  60. *> \param[in] INCX
  61. *> \verbatim
  62. *> INCX is INTEGER
  63. *> The increment between elements of X. INCX > 0.
  64. *> \endverbatim
  65. *>
  66. *> \param[in,out] Y
  67. *> \verbatim
  68. *> Y is REAL array,
  69. *> dimension (1+(N-1)*INCY)
  70. *> On entry, the vector y.
  71. *> On exit, the sines of the plane rotations.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] INCY
  75. *> \verbatim
  76. *> INCY is INTEGER
  77. *> The increment between elements of Y. INCY > 0.
  78. *> \endverbatim
  79. *>
  80. *> \param[out] C
  81. *> \verbatim
  82. *> C is REAL array, dimension (1+(N-1)*INCC)
  83. *> The cosines of the plane rotations.
  84. *> \endverbatim
  85. *>
  86. *> \param[in] INCC
  87. *> \verbatim
  88. *> INCC is INTEGER
  89. *> The increment between elements of C. INCC > 0.
  90. *> \endverbatim
  91. *
  92. * Authors:
  93. * ========
  94. *
  95. *> \author Univ. of Tennessee
  96. *> \author Univ. of California Berkeley
  97. *> \author Univ. of Colorado Denver
  98. *> \author NAG Ltd.
  99. *
  100. *> \ingroup realOTHERauxiliary
  101. *
  102. * =====================================================================
  103. SUBROUTINE SLARGV( N, X, INCX, Y, INCY, C, INCC )
  104. *
  105. * -- LAPACK auxiliary routine --
  106. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  107. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  108. *
  109. * .. Scalar Arguments ..
  110. INTEGER INCC, INCX, INCY, N
  111. * ..
  112. * .. Array Arguments ..
  113. REAL C( * ), X( * ), Y( * )
  114. * ..
  115. *
  116. * =====================================================================
  117. *
  118. * .. Parameters ..
  119. REAL ZERO, ONE
  120. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  121. * ..
  122. * .. Local Scalars ..
  123. INTEGER I, IC, IX, IY
  124. REAL F, G, T, TT
  125. * ..
  126. * .. Intrinsic Functions ..
  127. INTRINSIC ABS, SQRT
  128. * ..
  129. * .. Executable Statements ..
  130. *
  131. IX = 1
  132. IY = 1
  133. IC = 1
  134. DO 10 I = 1, N
  135. F = X( IX )
  136. G = Y( IY )
  137. IF( G.EQ.ZERO ) THEN
  138. C( IC ) = ONE
  139. ELSE IF( F.EQ.ZERO ) THEN
  140. C( IC ) = ZERO
  141. Y( IY ) = ONE
  142. X( IX ) = G
  143. ELSE IF( ABS( F ).GT.ABS( G ) ) THEN
  144. T = G / F
  145. TT = SQRT( ONE+T*T )
  146. C( IC ) = ONE / TT
  147. Y( IY ) = T*C( IC )
  148. X( IX ) = F*TT
  149. ELSE
  150. T = F / G
  151. TT = SQRT( ONE+T*T )
  152. Y( IY ) = ONE / TT
  153. C( IC ) = T*Y( IY )
  154. X( IX ) = G*TT
  155. END IF
  156. IC = IC + INCC
  157. IY = IY + INCY
  158. IX = IX + INCX
  159. 10 CONTINUE
  160. RETURN
  161. *
  162. * End of SLARGV
  163. *
  164. END