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.

dspr2f.f 7.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. SUBROUTINE DSPR2F( UPLO, N, ALPHA, X, INCX, Y, INCY, AP )
  2. * .. Scalar Arguments ..
  3. DOUBLE PRECISION ALPHA
  4. INTEGER INCX, INCY, N
  5. CHARACTER*1 UPLO
  6. * .. Array Arguments ..
  7. DOUBLE PRECISION AP( * ), X( * ), Y( * )
  8. * ..
  9. *
  10. * Purpose
  11. * =======
  12. *
  13. * DSPR2 performs the symmetric rank 2 operation
  14. *
  15. * A := alpha*x*y' + alpha*y*x' + A,
  16. *
  17. * where alpha is a scalar, x and y are n element vectors and A is an
  18. * n by n symmetric matrix, supplied in packed form.
  19. *
  20. * Parameters
  21. * ==========
  22. *
  23. * UPLO - CHARACTER*1.
  24. * On entry, UPLO specifies whether the upper or lower
  25. * triangular part of the matrix A is supplied in the packed
  26. * array AP as follows:
  27. *
  28. * UPLO = 'U' or 'u' The upper triangular part of A is
  29. * supplied in AP.
  30. *
  31. * UPLO = 'L' or 'l' The lower triangular part of A is
  32. * supplied in AP.
  33. *
  34. * Unchanged on exit.
  35. *
  36. * N - INTEGER.
  37. * On entry, N specifies the order of the matrix A.
  38. * N must be at least zero.
  39. * Unchanged on exit.
  40. *
  41. * ALPHA - DOUBLE PRECISION.
  42. * On entry, ALPHA specifies the scalar alpha.
  43. * Unchanged on exit.
  44. *
  45. * X - DOUBLE PRECISION array of dimension at least
  46. * ( 1 + ( n - 1 )*abs( INCX ) ).
  47. * Before entry, the incremented array X must contain the n
  48. * element vector x.
  49. * Unchanged on exit.
  50. *
  51. * INCX - INTEGER.
  52. * On entry, INCX specifies the increment for the elements of
  53. * X. INCX must not be zero.
  54. * Unchanged on exit.
  55. *
  56. * Y - DOUBLE PRECISION array of dimension at least
  57. * ( 1 + ( n - 1 )*abs( INCY ) ).
  58. * Before entry, the incremented array Y must contain the n
  59. * element vector y.
  60. * Unchanged on exit.
  61. *
  62. * INCY - INTEGER.
  63. * On entry, INCY specifies the increment for the elements of
  64. * Y. INCY must not be zero.
  65. * Unchanged on exit.
  66. *
  67. * AP - DOUBLE PRECISION array of DIMENSION at least
  68. * ( ( n*( n + 1 ) )/2 ).
  69. * Before entry with UPLO = 'U' or 'u', the array AP must
  70. * contain the upper triangular part of the symmetric matrix
  71. * packed sequentially, column by column, so that AP( 1 )
  72. * contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
  73. * and a( 2, 2 ) respectively, and so on. On exit, the array
  74. * AP is overwritten by the upper triangular part of the
  75. * updated matrix.
  76. * Before entry with UPLO = 'L' or 'l', the array AP must
  77. * contain the lower triangular part of the symmetric matrix
  78. * packed sequentially, column by column, so that AP( 1 )
  79. * contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
  80. * and a( 3, 1 ) respectively, and so on. On exit, the array
  81. * AP is overwritten by the lower triangular part of the
  82. * updated matrix.
  83. *
  84. *
  85. * Level 2 Blas routine.
  86. *
  87. * -- Written on 22-October-1986.
  88. * Jack Dongarra, Argonne National Lab.
  89. * Jeremy Du Croz, Nag Central Office.
  90. * Sven Hammarling, Nag Central Office.
  91. * Richard Hanson, Sandia National Labs.
  92. *
  93. *
  94. * .. Parameters ..
  95. DOUBLE PRECISION ZERO
  96. PARAMETER ( ZERO = 0.0D+0 )
  97. * .. Local Scalars ..
  98. DOUBLE PRECISION TEMP1, TEMP2
  99. INTEGER I, INFO, IX, IY, J, JX, JY, K, KK, KX, KY
  100. * .. External Functions ..
  101. LOGICAL LSAME
  102. EXTERNAL LSAME
  103. * .. External Subroutines ..
  104. EXTERNAL XERBLA
  105. * ..
  106. * .. Executable Statements ..
  107. *
  108. * Test the input parameters.
  109. *
  110. INFO = 0
  111. IF ( .NOT.LSAME( UPLO, 'U' ).AND.
  112. $ .NOT.LSAME( UPLO, 'L' ) )THEN
  113. INFO = 1
  114. ELSE IF( N.LT.0 )THEN
  115. INFO = 2
  116. ELSE IF( INCX.EQ.0 )THEN
  117. INFO = 5
  118. ELSE IF( INCY.EQ.0 )THEN
  119. INFO = 7
  120. END IF
  121. IF( INFO.NE.0 )THEN
  122. CALL XERBLA( 'DSPR2 ', INFO )
  123. RETURN
  124. END IF
  125. *
  126. * Quick return if possible.
  127. *
  128. IF( ( N.EQ.0 ).OR.( ALPHA.EQ.ZERO ) )
  129. $ RETURN
  130. *
  131. * Set up the start points in X and Y if the increments are not both
  132. * unity.
  133. *
  134. IF( ( INCX.NE.1 ).OR.( INCY.NE.1 ) )THEN
  135. IF( INCX.GT.0 )THEN
  136. KX = 1
  137. ELSE
  138. KX = 1 - ( N - 1 )*INCX
  139. END IF
  140. IF( INCY.GT.0 )THEN
  141. KY = 1
  142. ELSE
  143. KY = 1 - ( N - 1 )*INCY
  144. END IF
  145. JX = KX
  146. JY = KY
  147. END IF
  148. *
  149. * Start the operations. In this version the elements of the array AP
  150. * are accessed sequentially with one pass through AP.
  151. *
  152. KK = 1
  153. IF( LSAME( UPLO, 'U' ) )THEN
  154. *
  155. * Form A when upper triangle is stored in AP.
  156. *
  157. IF( ( INCX.EQ.1 ).AND.( INCY.EQ.1 ) )THEN
  158. DO 20, J = 1, N
  159. IF( ( X( J ).NE.ZERO ).OR.( Y( J ).NE.ZERO ) )THEN
  160. TEMP1 = ALPHA*Y( J )
  161. TEMP2 = ALPHA*X( J )
  162. K = KK
  163. DO 10, I = 1, J
  164. AP( K ) = AP( K ) + X( I )*TEMP1 + Y( I )*TEMP2
  165. K = K + 1
  166. 10 CONTINUE
  167. END IF
  168. KK = KK + J
  169. 20 CONTINUE
  170. ELSE
  171. DO 40, J = 1, N
  172. IF( ( X( JX ).NE.ZERO ).OR.( Y( JY ).NE.ZERO ) )THEN
  173. TEMP1 = ALPHA*Y( JY )
  174. TEMP2 = ALPHA*X( JX )
  175. IX = KX
  176. IY = KY
  177. DO 30, K = KK, KK + J - 1
  178. AP( K ) = AP( K ) + X( IX )*TEMP1 + Y( IY )*TEMP2
  179. IX = IX + INCX
  180. IY = IY + INCY
  181. 30 CONTINUE
  182. END IF
  183. JX = JX + INCX
  184. JY = JY + INCY
  185. KK = KK + J
  186. 40 CONTINUE
  187. END IF
  188. ELSE
  189. *
  190. * Form A when lower triangle is stored in AP.
  191. *
  192. IF( ( INCX.EQ.1 ).AND.( INCY.EQ.1 ) )THEN
  193. DO 60, J = 1, N
  194. IF( ( X( J ).NE.ZERO ).OR.( Y( J ).NE.ZERO ) )THEN
  195. TEMP1 = ALPHA*Y( J )
  196. TEMP2 = ALPHA*X( J )
  197. K = KK
  198. DO 50, I = J, N
  199. AP( K ) = AP( K ) + X( I )*TEMP1 + Y( I )*TEMP2
  200. K = K + 1
  201. 50 CONTINUE
  202. END IF
  203. KK = KK + N - J + 1
  204. 60 CONTINUE
  205. ELSE
  206. DO 80, J = 1, N
  207. IF( ( X( JX ).NE.ZERO ).OR.( Y( JY ).NE.ZERO ) )THEN
  208. TEMP1 = ALPHA*Y( JY )
  209. TEMP2 = ALPHA*X( JX )
  210. IX = JX
  211. IY = JY
  212. DO 70, K = KK, KK + N - J
  213. AP( K ) = AP( K ) + X( IX )*TEMP1 + Y( IY )*TEMP2
  214. IX = IX + INCX
  215. IY = IY + INCY
  216. 70 CONTINUE
  217. END IF
  218. JX = JX + INCX
  219. JY = JY + INCY
  220. KK = KK + N - J + 1
  221. 80 CONTINUE
  222. END IF
  223. END IF
  224. *
  225. RETURN
  226. *
  227. * End of DSPR2 .
  228. *
  229. END