Télécharger dgemv.eso

Retour à la liste

Numérotation des lignes :

dgemv
  1. C DGEMV SOURCE BP208322 22/09/16 21:15:02 11454
  2. *
  3. * Purpose
  4. * =======
  5. *
  6. * DGEMV performs one of the matrix-vector operations
  7. *
  8. * y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y,
  9. *
  10. * where alpha and beta are scalars, x and y are vectors and A is an
  11. * m by n matrix.
  12. *
  13. * Parameters
  14. * ==========
  15. *
  16. * TRANS - CHARACTER*1.
  17. * On entry, TRANS specifies the operation to be performed as
  18. * follows:
  19. *
  20. * TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
  21. *
  22. * TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
  23. *
  24. * TRANS = 'C' or 'c' y := alpha*A'*x + beta*y.
  25. *
  26. * Unchanged on exit.
  27. *
  28. * M - INTEGER.
  29. * On entry, M specifies the number of rows of the matrix A.
  30. * M must be at least zero.
  31. * Unchanged on exit.
  32. *
  33. * N - INTEGER.
  34. * On entry, N specifies the number of columns of the matrix A.
  35. * N must be at least zero.
  36. * Unchanged on exit.
  37. *
  38. * ALPHA - REAL*8.
  39. * On entry, ALPHA specifies the scalar alpha.
  40. * Unchanged on exit.
  41. *
  42. * A - REAL*8 array of DIMENSION ( LDA, n ).
  43. * Before entry, the leading m by n part of the array A must
  44. * contain the matrix of coefficients.
  45. * Unchanged on exit.
  46. *
  47. * LDA - INTEGER.
  48. * On entry, LDA specifies the first dimension of A as declared
  49. * in the calling (sub) program. LDA must be at least
  50. * max( 1, m ).
  51. * Unchanged on exit.
  52. *
  53. * X - REAL*8 array of DIMENSION at least
  54. * ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
  55. * and at least
  56. * ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
  57. * Before entry, the incremented array X must contain the
  58. * vector x.
  59. * Unchanged on exit.
  60. *
  61. * INCX - INTEGER.
  62. * On entry, INCX specifies the increment for the elements of
  63. * X. INCX must not be zero.
  64. * Unchanged on exit.
  65. *
  66. * BETA - REAL*8.
  67. * On entry, BETA specifies the scalar beta. When BETA is
  68. * supplied as zero then Y need not be set on input.
  69. * Unchanged on exit.
  70. *
  71. * Y - REAL*8 array of DIMENSION at least
  72. * ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
  73. * and at least
  74. * ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
  75. * Before entry with BETA non-zero, the incremented array Y
  76. * must contain the vector y. On exit, Y is overwritten by the
  77. * updated vector y.
  78. *
  79. * INCY - INTEGER.
  80. * On entry, INCY specifies the increment for the elements of
  81. * Y. INCY must not be zero.
  82. * Unchanged on exit.
  83. *
  84. * =====================================================================
  85. SUBROUTINE DGEMV ( TRANS, M, N, ALPHA, A, LDA, X, INCX,
  86. $ BETA, Y, INCY )
  87. *
  88. * Level 2 Blas routine.
  89. *
  90. * -- Written on 22-October-1986.
  91. * Jack Dongarra, Argonne National Lab.
  92. * Jeremy Du Croz, Nag Central Office.
  93. * Sven Hammarling, Nag Central Office.
  94. * Richard Hanson, Sandia National Labs.
  95. *
  96. * .. Scalar Arguments ..
  97. REAL*8 ALPHA, BETA
  98. INTEGER INCX, INCY, LDA, M, N
  99. CHARACTER*1 TRANS
  100. * .. Array Arguments ..
  101. REAL*8 A( LDA, * ), X( * ), Y( * )
  102. * ..
  103. *
  104. * =====================================================================
  105. *
  106. * .. Parameters ..
  107. REAL*8 ONE , ZERO
  108. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  109. * .. Local Scalars ..
  110. REAL*8 TEMP
  111. INTEGER I, INFO, IX, IY, J, JX, JY, KX, KY, LENX, LENY
  112. * .. External Functions ..
  113. LOGICAL LSAME
  114. EXTERNAL LSAME
  115. * .. External Subroutines ..
  116. EXTERNAL XERBLA
  117. ** .. Intrinsic Functions ..
  118. * INTRINSIC MAX
  119. ** ..
  120. ** .. Executable Statements ..
  121. *
  122. * Test the input parameters.
  123. *
  124. INFO = 0
  125. IF ( .NOT.LSAME( TRANS, 'N' ).AND.
  126. $ .NOT.LSAME( TRANS, 'T' ).AND.
  127. $ .NOT.LSAME( TRANS, 'C' ) )THEN
  128. INFO = 1
  129. ELSE IF( M.LT.0 )THEN
  130. INFO = 2
  131. ELSE IF( N.LT.0 )THEN
  132. INFO = 3
  133. ELSE IF( LDA.LT.MAX( 1, M ) )THEN
  134. INFO = 6
  135. ELSE IF( INCX.EQ.0 )THEN
  136. INFO = 8
  137. ELSE IF( INCY.EQ.0 )THEN
  138. INFO = 11
  139. END IF
  140. IF( INFO.NE.0 )THEN
  141. CALL XERBLA( 'DGEMV ', INFO )
  142. RETURN
  143. END IF
  144. *
  145. * Quick return if possible.
  146. *
  147. IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
  148. $ ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
  149. $ RETURN
  150. *
  151. * Set LENX and LENY, the lengths of the vectors x and y, and set
  152. * up the start points in X and Y.
  153. *
  154. IF( LSAME( TRANS, 'N' ) )THEN
  155. LENX = N
  156. LENY = M
  157. ELSE
  158. LENX = M
  159. LENY = N
  160. END IF
  161. IF( INCX.GT.0 )THEN
  162. KX = 1
  163. ELSE
  164. KX = 1 - ( LENX - 1 )*INCX
  165. END IF
  166. IF( INCY.GT.0 )THEN
  167. KY = 1
  168. ELSE
  169. KY = 1 - ( LENY - 1 )*INCY
  170. END IF
  171. *
  172. * Start the operations. In this version the elements of A are
  173. * accessed sequentially with one pass through A.
  174. *
  175. * First form y := beta*y.
  176. *
  177. IF( BETA.NE.ONE )THEN
  178. IF( INCY.EQ.1 )THEN
  179. IF( BETA.EQ.ZERO )THEN
  180. DO 10, I = 1, LENY
  181. Y( I ) = ZERO
  182. 10 CONTINUE
  183. ELSE
  184. DO 20, I = 1, LENY
  185. Y( I ) = BETA*Y( I )
  186. 20 CONTINUE
  187. END IF
  188. ELSE
  189. IY = KY
  190. IF( BETA.EQ.ZERO )THEN
  191. DO 30, I = 1, LENY
  192. Y( IY ) = ZERO
  193. IY = IY + INCY
  194. 30 CONTINUE
  195. ELSE
  196. DO 40, I = 1, LENY
  197. Y( IY ) = BETA*Y( IY )
  198. IY = IY + INCY
  199. 40 CONTINUE
  200. END IF
  201. END IF
  202. END IF
  203. IF( ALPHA.EQ.ZERO )
  204. $ RETURN
  205. IF( LSAME( TRANS, 'N' ) )THEN
  206. *
  207. * Form y := alpha*A*x + y.
  208. *
  209. JX = KX
  210. IF( INCY.EQ.1 )THEN
  211. DO 60, J = 1, N
  212. * IF( X( JX ).NE.ZERO )THEN
  213. TEMP = ALPHA*X( JX )
  214. DO 50, I = 1, M
  215. Y( I ) = Y( I ) + TEMP*A( I, J )
  216. 50 CONTINUE
  217. * END IF
  218. JX = JX + INCX
  219. 60 CONTINUE
  220. ELSE
  221. DO 80, J = 1, N
  222. * IF( X( JX ).NE.ZERO )THEN
  223. TEMP = ALPHA*X( JX )
  224. IY = KY
  225. DO 70, I = 1, M
  226. Y( IY ) = Y( IY ) + TEMP*A( I, J )
  227. IY = IY + INCY
  228. 70 CONTINUE
  229. * END IF
  230. JX = JX + INCX
  231. 80 CONTINUE
  232. END IF
  233. ELSE
  234. *
  235. * Form y := alpha*A'*x + y.
  236. *
  237. JY = KY
  238. IF( INCX.EQ.1 )THEN
  239. DO 100, J = 1, N
  240. TEMP = ZERO
  241. DO 90, I = 1, M
  242. TEMP = TEMP + A( I, J )*X( I )
  243. 90 CONTINUE
  244. Y( JY ) = Y( JY ) + ALPHA*TEMP
  245. JY = JY + INCY
  246. 100 CONTINUE
  247. ELSE
  248. DO 120, J = 1, N
  249. TEMP = ZERO
  250. IX = KX
  251. DO 110, I = 1, M
  252. TEMP = TEMP + A( I, J )*X( IX )
  253. IX = IX + INCX
  254. 110 CONTINUE
  255. Y( JY ) = Y( JY ) + ALPHA*TEMP
  256. JY = JY + INCY
  257. 120 CONTINUE
  258. END IF
  259. END IF
  260. *
  261. RETURN
  262. *
  263. * End of DGEMV
  264. *
  265. END
  266.  
  267.  
  268.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales