cgeru.f 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. *DECK CGERU
  2. SUBROUTINE CGERU (M, N, ALPHA, X, INCX, Y, INCY, A, LDA)
  3. C***BEGIN PROLOGUE CGERU
  4. C***PURPOSE Perform unconjugated rank 1 update of a complex general
  5. C matrix.
  6. C***LIBRARY SLATEC (BLAS)
  7. C***CATEGORY D1B4
  8. C***TYPE COMPLEX (SGERU-S, DGERU-D, CGERU-C)
  9. C***KEYWORDS LEVEL 2 BLAS, LINEAR ALGEBRA
  10. C***AUTHOR Dongarra, J. J., (ANL)
  11. C Du Croz, J., (NAG)
  12. C Hammarling, S., (NAG)
  13. C Hanson, R. J., (SNLA)
  14. C***DESCRIPTION
  15. C
  16. C CGERU performs the rank 1 operation
  17. C
  18. C A := alpha*x*y' + A,
  19. C
  20. C where alpha is a scalar, x is an m element vector, y is an n element
  21. C vector and A is an m by n matrix.
  22. C
  23. C Parameters
  24. C ==========
  25. C
  26. C M - INTEGER.
  27. C On entry, M specifies the number of rows of the matrix A.
  28. C M must be at least zero.
  29. C Unchanged on exit.
  30. C
  31. C N - INTEGER.
  32. C On entry, N specifies the number of columns of the matrix A.
  33. C N must be at least zero.
  34. C Unchanged on exit.
  35. C
  36. C ALPHA - COMPLEX .
  37. C On entry, ALPHA specifies the scalar alpha.
  38. C Unchanged on exit.
  39. C
  40. C X - COMPLEX array of dimension at least
  41. C ( 1 + ( m - 1)*abs( INCX)).
  42. C Before entry, the incremented array X must contain the m
  43. C element vector x.
  44. C Unchanged on exit.
  45. C
  46. C INCX - INTEGER.
  47. C On entry, INCX specifies the increment for the elements of
  48. C X. INCX must not be zero.
  49. C Unchanged on exit.
  50. C
  51. C Y - COMPLEX array of dimension at least
  52. C ( 1 + ( n - 1 )*abs( INCY ) ).
  53. C Before entry, the incremented array Y must contain the n
  54. C element vector y.
  55. C Unchanged on exit.
  56. C
  57. C INCY - INTEGER.
  58. C On entry, INCY specifies the increment for the elements of
  59. C Y. INCY must not be zero.
  60. C Unchanged on exit.
  61. C
  62. C A - COMPLEX array of DIMENSION ( LDA, n ).
  63. C Before entry, the leading m by n part of the array A must
  64. C contain the matrix of coefficients. On exit, A is
  65. C overwritten by the updated matrix.
  66. C
  67. C LDA - INTEGER.
  68. C On entry, LDA specifies the first dimension of A as declared
  69. C in the calling (sub) program. LDA must be at least
  70. C max( 1, m ).
  71. C Unchanged on exit.
  72. C
  73. C***REFERENCES Dongarra, J. J., Du Croz, J., Hammarling, S., and
  74. C Hanson, R. J. An extended set of Fortran basic linear
  75. C algebra subprograms. ACM TOMS, Vol. 14, No. 1,
  76. C pp. 1-17, March 1988.
  77. C***ROUTINES CALLED XERBLA
  78. C***REVISION HISTORY (YYMMDD)
  79. C 861022 DATE WRITTEN
  80. C 910605 Modified to meet SLATEC prologue standards. Only comment
  81. C lines were modified. (BKS)
  82. C***END PROLOGUE CGERU
  83. C .. Scalar Arguments ..
  84. COMPLEX ALPHA
  85. INTEGER INCX, INCY, LDA, M, N
  86. C .. Array Arguments ..
  87. COMPLEX A( LDA, * ), X( * ), Y( * )
  88. C .. Parameters ..
  89. COMPLEX ZERO
  90. PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) )
  91. C .. Local Scalars ..
  92. COMPLEX TEMP
  93. INTEGER I, INFO, IX, J, JY, KX
  94. C .. External Subroutines ..
  95. EXTERNAL XERBLA
  96. C .. Intrinsic Functions ..
  97. INTRINSIC MAX
  98. C***FIRST EXECUTABLE STATEMENT CGERU
  99. C
  100. C Test the input parameters.
  101. C
  102. INFO = 0
  103. IF ( M.LT.0 )THEN
  104. INFO = 1
  105. ELSE IF( N.LT.0 )THEN
  106. INFO = 2
  107. ELSE IF( INCX.EQ.0 )THEN
  108. INFO = 5
  109. ELSE IF( INCY.EQ.0 )THEN
  110. INFO = 7
  111. ELSE IF( LDA.LT.MAX( 1, M ) )THEN
  112. INFO = 9
  113. END IF
  114. IF( INFO.NE.0 )THEN
  115. CALL XERBLA( 'CGERU ', INFO )
  116. RETURN
  117. END IF
  118. C
  119. C Quick return if possible.
  120. C
  121. IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.( ALPHA.EQ.ZERO ) )
  122. $ RETURN
  123. C
  124. C Start the operations. In this version the elements of A are
  125. C accessed sequentially with one pass through A.
  126. C
  127. IF( INCY.GT.0 )THEN
  128. JY = 1
  129. ELSE
  130. JY = 1 - ( N - 1 )*INCY
  131. END IF
  132. IF( INCX.EQ.1 )THEN
  133. DO 20, J = 1, N
  134. IF( Y( JY ).NE.ZERO )THEN
  135. TEMP = ALPHA*Y( JY )
  136. DO 10, I = 1, M
  137. A( I, J ) = A( I, J ) + X( I )*TEMP
  138. 10 CONTINUE
  139. END IF
  140. JY = JY + INCY
  141. 20 CONTINUE
  142. ELSE
  143. IF( INCX.GT.0 )THEN
  144. KX = 1
  145. ELSE
  146. KX = 1 - ( M - 1 )*INCX
  147. END IF
  148. DO 40, J = 1, N
  149. IF( Y( JY ).NE.ZERO )THEN
  150. TEMP = ALPHA*Y( JY )
  151. IX = KX
  152. DO 30, I = 1, M
  153. A( I, J ) = A( I, J ) + X( IX )*TEMP
  154. IX = IX + INCX
  155. 30 CONTINUE
  156. END IF
  157. JY = JY + INCY
  158. 40 CONTINUE
  159. END IF
  160. C
  161. RETURN
  162. C
  163. C End of CGERU .
  164. C
  165. END