cgeru.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* cgeru.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int cgeru_(integer *m, integer *n, complex *alpha, complex *
  14. x, integer *incx, complex *y, integer *incy, complex *a, integer *lda)
  15. {
  16. /* System generated locals */
  17. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
  18. complex q__1, q__2;
  19. /* Local variables */
  20. integer i__, j, ix, jy, kx, info;
  21. complex temp;
  22. extern /* Subroutine */ int xerbla_(char *, integer *);
  23. /* .. Scalar Arguments .. */
  24. /* .. */
  25. /* .. Array Arguments .. */
  26. /* .. */
  27. /* Purpose */
  28. /* ======= */
  29. /* CGERU performs the rank 1 operation */
  30. /* A := alpha*x*y' + A, */
  31. /* where alpha is a scalar, x is an m element vector, y is an n element */
  32. /* vector and A is an m by n matrix. */
  33. /* Arguments */
  34. /* ========== */
  35. /* M - INTEGER. */
  36. /* On entry, M specifies the number of rows of the matrix A. */
  37. /* M must be at least zero. */
  38. /* Unchanged on exit. */
  39. /* N - INTEGER. */
  40. /* On entry, N specifies the number of columns of the matrix A. */
  41. /* N must be at least zero. */
  42. /* Unchanged on exit. */
  43. /* ALPHA - COMPLEX . */
  44. /* On entry, ALPHA specifies the scalar alpha. */
  45. /* Unchanged on exit. */
  46. /* X - COMPLEX array of dimension at least */
  47. /* ( 1 + ( m - 1 )*abs( INCX ) ). */
  48. /* Before entry, the incremented array X must contain the m */
  49. /* element vector x. */
  50. /* Unchanged on exit. */
  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. /* Y - COMPLEX array of dimension at least */
  56. /* ( 1 + ( n - 1 )*abs( INCY ) ). */
  57. /* Before entry, the incremented array Y must contain the n */
  58. /* element vector y. */
  59. /* Unchanged on exit. */
  60. /* INCY - INTEGER. */
  61. /* On entry, INCY specifies the increment for the elements of */
  62. /* Y. INCY must not be zero. */
  63. /* Unchanged on exit. */
  64. /* A - COMPLEX array of DIMENSION ( LDA, n ). */
  65. /* Before entry, the leading m by n part of the array A must */
  66. /* contain the matrix of coefficients. On exit, A is */
  67. /* overwritten by the updated matrix. */
  68. /* LDA - INTEGER. */
  69. /* On entry, LDA specifies the first dimension of A as declared */
  70. /* in the calling (sub) program. LDA must be at least */
  71. /* max( 1, m ). */
  72. /* Unchanged on exit. */
  73. /* Level 2 Blas routine. */
  74. /* -- Written on 22-October-1986. */
  75. /* Jack Dongarra, Argonne National Lab. */
  76. /* Jeremy Du Croz, Nag Central Office. */
  77. /* Sven Hammarling, Nag Central Office. */
  78. /* Richard Hanson, Sandia National Labs. */
  79. /* .. Parameters .. */
  80. /* .. */
  81. /* .. Local Scalars .. */
  82. /* .. */
  83. /* .. External Subroutines .. */
  84. /* .. */
  85. /* .. Intrinsic Functions .. */
  86. /* .. */
  87. /* Test the input parameters. */
  88. /* Parameter adjustments */
  89. --x;
  90. --y;
  91. a_dim1 = *lda;
  92. a_offset = 1 + a_dim1;
  93. a -= a_offset;
  94. /* Function Body */
  95. info = 0;
  96. if (*m < 0) {
  97. info = 1;
  98. } else if (*n < 0) {
  99. info = 2;
  100. } else if (*incx == 0) {
  101. info = 5;
  102. } else if (*incy == 0) {
  103. info = 7;
  104. } else if (*lda < max(1,*m)) {
  105. info = 9;
  106. }
  107. if (info != 0) {
  108. xerbla_("CGERU ", &info);
  109. return 0;
  110. }
  111. /* Quick return if possible. */
  112. if (*m == 0 || *n == 0 || alpha->r == 0.f && alpha->i == 0.f) {
  113. return 0;
  114. }
  115. /* Start the operations. In this version the elements of A are */
  116. /* accessed sequentially with one pass through A. */
  117. if (*incy > 0) {
  118. jy = 1;
  119. } else {
  120. jy = 1 - (*n - 1) * *incy;
  121. }
  122. if (*incx == 1) {
  123. i__1 = *n;
  124. for (j = 1; j <= i__1; ++j) {
  125. i__2 = jy;
  126. if (y[i__2].r != 0.f || y[i__2].i != 0.f) {
  127. i__2 = jy;
  128. q__1.r = alpha->r * y[i__2].r - alpha->i * y[i__2].i, q__1.i =
  129. alpha->r * y[i__2].i + alpha->i * y[i__2].r;
  130. temp.r = q__1.r, temp.i = q__1.i;
  131. i__2 = *m;
  132. for (i__ = 1; i__ <= i__2; ++i__) {
  133. i__3 = i__ + j * a_dim1;
  134. i__4 = i__ + j * a_dim1;
  135. i__5 = i__;
  136. q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, q__2.i =
  137. x[i__5].r * temp.i + x[i__5].i * temp.r;
  138. q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + q__2.i;
  139. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  140. /* L10: */
  141. }
  142. }
  143. jy += *incy;
  144. /* L20: */
  145. }
  146. } else {
  147. if (*incx > 0) {
  148. kx = 1;
  149. } else {
  150. kx = 1 - (*m - 1) * *incx;
  151. }
  152. i__1 = *n;
  153. for (j = 1; j <= i__1; ++j) {
  154. i__2 = jy;
  155. if (y[i__2].r != 0.f || y[i__2].i != 0.f) {
  156. i__2 = jy;
  157. q__1.r = alpha->r * y[i__2].r - alpha->i * y[i__2].i, q__1.i =
  158. alpha->r * y[i__2].i + alpha->i * y[i__2].r;
  159. temp.r = q__1.r, temp.i = q__1.i;
  160. ix = kx;
  161. i__2 = *m;
  162. for (i__ = 1; i__ <= i__2; ++i__) {
  163. i__3 = i__ + j * a_dim1;
  164. i__4 = i__ + j * a_dim1;
  165. i__5 = ix;
  166. q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, q__2.i =
  167. x[i__5].r * temp.i + x[i__5].i * temp.r;
  168. q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + q__2.i;
  169. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  170. ix += *incx;
  171. /* L30: */
  172. }
  173. }
  174. jy += *incy;
  175. /* L40: */
  176. }
  177. }
  178. return 0;
  179. /* End of CGERU . */
  180. } /* cgeru_ */