zgeru.c 5.8 KB

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