sger.c 4.8 KB

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