annotate ext/cblas/src/dger.c @ 464:0076c66d2932

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