dsyr2.c
Go to the documentation of this file.
00001 /* dsyr2.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Subroutine */ int dsyr2_(char *uplo, integer *n, doublereal *alpha, 
00017         doublereal *x, integer *incx, doublereal *y, integer *incy, 
00018         doublereal *a, integer *lda)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, i__1, i__2;
00022 
00023     /* Local variables */
00024     integer i__, j, ix, iy, jx, jy, kx, ky, info;
00025     doublereal temp1, temp2;
00026     extern logical lsame_(char *, char *);
00027     extern /* Subroutine */ int xerbla_(char *, integer *);
00028 
00029 /*     .. Scalar Arguments .. */
00030 /*     .. */
00031 /*     .. Array Arguments .. */
00032 /*     .. */
00033 
00034 /*  Purpose */
00035 /*  ======= */
00036 
00037 /*  DSYR2  performs the symmetric rank 2 operation */
00038 
00039 /*     A := alpha*x*y' + alpha*y*x' + A, */
00040 
00041 /*  where alpha is a scalar, x and y are n element vectors and A is an n */
00042 /*  by n symmetric matrix. */
00043 
00044 /*  Arguments */
00045 /*  ========== */
00046 
00047 /*  UPLO   - CHARACTER*1. */
00048 /*           On entry, UPLO specifies whether the upper or lower */
00049 /*           triangular part of the array A is to be referenced as */
00050 /*           follows: */
00051 
00052 /*              UPLO = 'U' or 'u'   Only the upper triangular part of A */
00053 /*                                  is to be referenced. */
00054 
00055 /*              UPLO = 'L' or 'l'   Only the lower triangular part of A */
00056 /*                                  is to be referenced. */
00057 
00058 /*           Unchanged on exit. */
00059 
00060 /*  N      - INTEGER. */
00061 /*           On entry, N specifies the order of the matrix A. */
00062 /*           N must be at least zero. */
00063 /*           Unchanged on exit. */
00064 
00065 /*  ALPHA  - DOUBLE PRECISION. */
00066 /*           On entry, ALPHA specifies the scalar alpha. */
00067 /*           Unchanged on exit. */
00068 
00069 /*  X      - DOUBLE PRECISION array of dimension at least */
00070 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00071 /*           Before entry, the incremented array X must contain the n */
00072 /*           element vector x. */
00073 /*           Unchanged on exit. */
00074 
00075 /*  INCX   - INTEGER. */
00076 /*           On entry, INCX specifies the increment for the elements of */
00077 /*           X. INCX must not be zero. */
00078 /*           Unchanged on exit. */
00079 
00080 /*  Y      - DOUBLE PRECISION array of dimension at least */
00081 /*           ( 1 + ( n - 1 )*abs( INCY ) ). */
00082 /*           Before entry, the incremented array Y must contain the n */
00083 /*           element vector y. */
00084 /*           Unchanged on exit. */
00085 
00086 /*  INCY   - INTEGER. */
00087 /*           On entry, INCY specifies the increment for the elements of */
00088 /*           Y. INCY must not be zero. */
00089 /*           Unchanged on exit. */
00090 
00091 /*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
00092 /*           Before entry with  UPLO = 'U' or 'u', the leading n by n */
00093 /*           upper triangular part of the array A must contain the upper */
00094 /*           triangular part of the symmetric matrix and the strictly */
00095 /*           lower triangular part of A is not referenced. On exit, the */
00096 /*           upper triangular part of the array A is overwritten by the */
00097 /*           upper triangular part of the updated matrix. */
00098 /*           Before entry with UPLO = 'L' or 'l', the leading n by n */
00099 /*           lower triangular part of the array A must contain the lower */
00100 /*           triangular part of the symmetric matrix and the strictly */
00101 /*           upper triangular part of A is not referenced. On exit, the */
00102 /*           lower triangular part of the array A is overwritten by the */
00103 /*           lower triangular part of the updated matrix. */
00104 
00105 /*  LDA    - INTEGER. */
00106 /*           On entry, LDA specifies the first dimension of A as declared */
00107 /*           in the calling (sub) program. LDA must be at least */
00108 /*           max( 1, n ). */
00109 /*           Unchanged on exit. */
00110 
00111 
00112 /*  Level 2 Blas routine. */
00113 
00114 /*  -- Written on 22-October-1986. */
00115 /*     Jack Dongarra, Argonne National Lab. */
00116 /*     Jeremy Du Croz, Nag Central Office. */
00117 /*     Sven Hammarling, Nag Central Office. */
00118 /*     Richard Hanson, Sandia National Labs. */
00119 
00120 
00121 /*     .. Parameters .. */
00122 /*     .. */
00123 /*     .. Local Scalars .. */
00124 /*     .. */
00125 /*     .. External Functions .. */
00126 /*     .. */
00127 /*     .. External Subroutines .. */
00128 /*     .. */
00129 /*     .. Intrinsic Functions .. */
00130 /*     .. */
00131 
00132 /*     Test the input parameters. */
00133 
00134     /* Parameter adjustments */
00135     --x;
00136     --y;
00137     a_dim1 = *lda;
00138     a_offset = 1 + a_dim1;
00139     a -= a_offset;
00140 
00141     /* Function Body */
00142     info = 0;
00143     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00144         info = 1;
00145     } else if (*n < 0) {
00146         info = 2;
00147     } else if (*incx == 0) {
00148         info = 5;
00149     } else if (*incy == 0) {
00150         info = 7;
00151     } else if (*lda < max(1,*n)) {
00152         info = 9;
00153     }
00154     if (info != 0) {
00155         xerbla_("DSYR2 ", &info);
00156         return 0;
00157     }
00158 
00159 /*     Quick return if possible. */
00160 
00161     if (*n == 0 || *alpha == 0.) {
00162         return 0;
00163     }
00164 
00165 /*     Set up the start points in X and Y if the increments are not both */
00166 /*     unity. */
00167 
00168     if (*incx != 1 || *incy != 1) {
00169         if (*incx > 0) {
00170             kx = 1;
00171         } else {
00172             kx = 1 - (*n - 1) * *incx;
00173         }
00174         if (*incy > 0) {
00175             ky = 1;
00176         } else {
00177             ky = 1 - (*n - 1) * *incy;
00178         }
00179         jx = kx;
00180         jy = ky;
00181     }
00182 
00183 /*     Start the operations. In this version the elements of A are */
00184 /*     accessed sequentially with one pass through the triangular part */
00185 /*     of A. */
00186 
00187     if (lsame_(uplo, "U")) {
00188 
00189 /*        Form  A  when A is stored in the upper triangle. */
00190 
00191         if (*incx == 1 && *incy == 1) {
00192             i__1 = *n;
00193             for (j = 1; j <= i__1; ++j) {
00194                 if (x[j] != 0. || y[j] != 0.) {
00195                     temp1 = *alpha * y[j];
00196                     temp2 = *alpha * x[j];
00197                     i__2 = j;
00198                     for (i__ = 1; i__ <= i__2; ++i__) {
00199                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] * 
00200                                 temp1 + y[i__] * temp2;
00201 /* L10: */
00202                     }
00203                 }
00204 /* L20: */
00205             }
00206         } else {
00207             i__1 = *n;
00208             for (j = 1; j <= i__1; ++j) {
00209                 if (x[jx] != 0. || y[jy] != 0.) {
00210                     temp1 = *alpha * y[jy];
00211                     temp2 = *alpha * x[jx];
00212                     ix = kx;
00213                     iy = ky;
00214                     i__2 = j;
00215                     for (i__ = 1; i__ <= i__2; ++i__) {
00216                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] * 
00217                                 temp1 + y[iy] * temp2;
00218                         ix += *incx;
00219                         iy += *incy;
00220 /* L30: */
00221                     }
00222                 }
00223                 jx += *incx;
00224                 jy += *incy;
00225 /* L40: */
00226             }
00227         }
00228     } else {
00229 
00230 /*        Form  A  when A is stored in the lower triangle. */
00231 
00232         if (*incx == 1 && *incy == 1) {
00233             i__1 = *n;
00234             for (j = 1; j <= i__1; ++j) {
00235                 if (x[j] != 0. || y[j] != 0.) {
00236                     temp1 = *alpha * y[j];
00237                     temp2 = *alpha * x[j];
00238                     i__2 = *n;
00239                     for (i__ = j; i__ <= i__2; ++i__) {
00240                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] * 
00241                                 temp1 + y[i__] * temp2;
00242 /* L50: */
00243                     }
00244                 }
00245 /* L60: */
00246             }
00247         } else {
00248             i__1 = *n;
00249             for (j = 1; j <= i__1; ++j) {
00250                 if (x[jx] != 0. || y[jy] != 0.) {
00251                     temp1 = *alpha * y[jy];
00252                     temp2 = *alpha * x[jx];
00253                     ix = jx;
00254                     iy = jy;
00255                     i__2 = *n;
00256                     for (i__ = j; i__ <= i__2; ++i__) {
00257                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] * 
00258                                 temp1 + y[iy] * temp2;
00259                         ix += *incx;
00260                         iy += *incy;
00261 /* L70: */
00262                     }
00263                 }
00264                 jx += *incx;
00265                 jy += *incy;
00266 /* L80: */
00267             }
00268         }
00269     }
00270 
00271     return 0;
00272 
00273 /*     End of DSYR2 . */
00274 
00275 } /* dsyr2_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:49