dger.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* dger.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 dger_(integer *m, integer *n, doublereal *alpha,
  14. doublereal *x, integer *incx, doublereal *y, integer *incy,
  15. doublereal *a, integer *lda)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, i__1, i__2;
  19. /* Local variables */
  20. integer i__, j, ix, jy, kx, info;
  21. doublereal temp;
  22. extern /* Subroutine */ int xerbla_(char *, integer *);
  23. /* .. Scalar Arguments .. */
  24. /* .. */
  25. /* .. Array Arguments .. */
  26. /* .. */
  27. /* Purpose */
  28. /* ======= */
  29. /* DGER 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 - DOUBLE PRECISION. */
  44. /* On entry, ALPHA specifies the scalar alpha. */
  45. /* Unchanged on exit. */
  46. /* X - DOUBLE PRECISION 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 - DOUBLE PRECISION 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 - DOUBLE PRECISION 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_("DGER ", &info);
  109. return 0;
  110. }
  111. /* Quick return if possible. */
  112. if (*m == 0 || *n == 0 || *alpha == 0.) {
  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. if (y[jy] != 0.) {
  126. temp = *alpha * y[jy];
  127. i__2 = *m;
  128. for (i__ = 1; i__ <= i__2; ++i__) {
  129. a[i__ + j * a_dim1] += x[i__] * temp;
  130. /* L10: */
  131. }
  132. }
  133. jy += *incy;
  134. /* L20: */
  135. }
  136. } else {
  137. if (*incx > 0) {
  138. kx = 1;
  139. } else {
  140. kx = 1 - (*m - 1) * *incx;
  141. }
  142. i__1 = *n;
  143. for (j = 1; j <= i__1; ++j) {
  144. if (y[jy] != 0.) {
  145. temp = *alpha * y[jy];
  146. ix = kx;
  147. i__2 = *m;
  148. for (i__ = 1; i__ <= i__2; ++i__) {
  149. a[i__ + j * a_dim1] += x[ix] * temp;
  150. ix += *incx;
  151. /* L30: */
  152. }
  153. }
  154. jy += *incy;
  155. /* L40: */
  156. }
  157. }
  158. return 0;
  159. /* End of DGER . */
  160. } /* dger_ */