zgerc.c 5.9 KB

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