dsyr.c
Go to the documentation of this file.
00001 /* dsyr.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 dsyr_(char *uplo, integer *n, doublereal *alpha, 
00017         doublereal *x, integer *incx, doublereal *a, integer *lda)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, i__1, i__2;
00021 
00022     /* Local variables */
00023     integer i__, j, ix, jx, kx, info;
00024     doublereal temp;
00025     extern logical lsame_(char *, char *);
00026     extern /* Subroutine */ int xerbla_(char *, integer *);
00027 
00028 /*     .. Scalar Arguments .. */
00029 /*     .. */
00030 /*     .. Array Arguments .. */
00031 /*     .. */
00032 
00033 /*  Purpose */
00034 /*  ======= */
00035 
00036 /*  DSYR   performs the symmetric rank 1 operation */
00037 
00038 /*     A := alpha*x*x' + A, */
00039 
00040 /*  where alpha is a real scalar, x is an n element vector and A is an */
00041 /*  n by n symmetric matrix. */
00042 
00043 /*  Arguments */
00044 /*  ========== */
00045 
00046 /*  UPLO   - CHARACTER*1. */
00047 /*           On entry, UPLO specifies whether the upper or lower */
00048 /*           triangular part of the array A is to be referenced as */
00049 /*           follows: */
00050 
00051 /*              UPLO = 'U' or 'u'   Only the upper triangular part of A */
00052 /*                                  is to be referenced. */
00053 
00054 /*              UPLO = 'L' or 'l'   Only the lower triangular part of A */
00055 /*                                  is to be referenced. */
00056 
00057 /*           Unchanged on exit. */
00058 
00059 /*  N      - INTEGER. */
00060 /*           On entry, N specifies the order of the matrix A. */
00061 /*           N must be at least zero. */
00062 /*           Unchanged on exit. */
00063 
00064 /*  ALPHA  - DOUBLE PRECISION. */
00065 /*           On entry, ALPHA specifies the scalar alpha. */
00066 /*           Unchanged on exit. */
00067 
00068 /*  X      - DOUBLE PRECISION array of dimension at least */
00069 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00070 /*           Before entry, the incremented array X must contain the n */
00071 /*           element vector x. */
00072 /*           Unchanged on exit. */
00073 
00074 /*  INCX   - INTEGER. */
00075 /*           On entry, INCX specifies the increment for the elements of */
00076 /*           X. INCX must not be zero. */
00077 /*           Unchanged on exit. */
00078 
00079 /*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
00080 /*           Before entry with  UPLO = 'U' or 'u', the leading n by n */
00081 /*           upper triangular part of the array A must contain the upper */
00082 /*           triangular part of the symmetric matrix and the strictly */
00083 /*           lower triangular part of A is not referenced. On exit, the */
00084 /*           upper triangular part of the array A is overwritten by the */
00085 /*           upper triangular part of the updated matrix. */
00086 /*           Before entry with UPLO = 'L' or 'l', the leading n by n */
00087 /*           lower triangular part of the array A must contain the lower */
00088 /*           triangular part of the symmetric matrix and the strictly */
00089 /*           upper triangular part of A is not referenced. On exit, the */
00090 /*           lower triangular part of the array A is overwritten by the */
00091 /*           lower triangular part of the updated matrix. */
00092 
00093 /*  LDA    - INTEGER. */
00094 /*           On entry, LDA specifies the first dimension of A as declared */
00095 /*           in the calling (sub) program. LDA must be at least */
00096 /*           max( 1, n ). */
00097 /*           Unchanged on exit. */
00098 
00099 
00100 /*  Level 2 Blas routine. */
00101 
00102 /*  -- Written on 22-October-1986. */
00103 /*     Jack Dongarra, Argonne National Lab. */
00104 /*     Jeremy Du Croz, Nag Central Office. */
00105 /*     Sven Hammarling, Nag Central Office. */
00106 /*     Richard Hanson, Sandia National Labs. */
00107 
00108 
00109 /*     .. Parameters .. */
00110 /*     .. */
00111 /*     .. Local Scalars .. */
00112 /*     .. */
00113 /*     .. External Functions .. */
00114 /*     .. */
00115 /*     .. External Subroutines .. */
00116 /*     .. */
00117 /*     .. Intrinsic Functions .. */
00118 /*     .. */
00119 
00120 /*     Test the input parameters. */
00121 
00122     /* Parameter adjustments */
00123     --x;
00124     a_dim1 = *lda;
00125     a_offset = 1 + a_dim1;
00126     a -= a_offset;
00127 
00128     /* Function Body */
00129     info = 0;
00130     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00131         info = 1;
00132     } else if (*n < 0) {
00133         info = 2;
00134     } else if (*incx == 0) {
00135         info = 5;
00136     } else if (*lda < max(1,*n)) {
00137         info = 7;
00138     }
00139     if (info != 0) {
00140         xerbla_("DSYR  ", &info);
00141         return 0;
00142     }
00143 
00144 /*     Quick return if possible. */
00145 
00146     if (*n == 0 || *alpha == 0.) {
00147         return 0;
00148     }
00149 
00150 /*     Set the start point in X if the increment is not unity. */
00151 
00152     if (*incx <= 0) {
00153         kx = 1 - (*n - 1) * *incx;
00154     } else if (*incx != 1) {
00155         kx = 1;
00156     }
00157 
00158 /*     Start the operations. In this version the elements of A are */
00159 /*     accessed sequentially with one pass through the triangular part */
00160 /*     of A. */
00161 
00162     if (lsame_(uplo, "U")) {
00163 
00164 /*        Form  A  when A is stored in upper triangle. */
00165 
00166         if (*incx == 1) {
00167             i__1 = *n;
00168             for (j = 1; j <= i__1; ++j) {
00169                 if (x[j] != 0.) {
00170                     temp = *alpha * x[j];
00171                     i__2 = j;
00172                     for (i__ = 1; i__ <= i__2; ++i__) {
00173                         a[i__ + j * a_dim1] += x[i__] * temp;
00174 /* L10: */
00175                     }
00176                 }
00177 /* L20: */
00178             }
00179         } else {
00180             jx = kx;
00181             i__1 = *n;
00182             for (j = 1; j <= i__1; ++j) {
00183                 if (x[jx] != 0.) {
00184                     temp = *alpha * x[jx];
00185                     ix = kx;
00186                     i__2 = j;
00187                     for (i__ = 1; i__ <= i__2; ++i__) {
00188                         a[i__ + j * a_dim1] += x[ix] * temp;
00189                         ix += *incx;
00190 /* L30: */
00191                     }
00192                 }
00193                 jx += *incx;
00194 /* L40: */
00195             }
00196         }
00197     } else {
00198 
00199 /*        Form  A  when A is stored in lower triangle. */
00200 
00201         if (*incx == 1) {
00202             i__1 = *n;
00203             for (j = 1; j <= i__1; ++j) {
00204                 if (x[j] != 0.) {
00205                     temp = *alpha * x[j];
00206                     i__2 = *n;
00207                     for (i__ = j; i__ <= i__2; ++i__) {
00208                         a[i__ + j * a_dim1] += x[i__] * temp;
00209 /* L50: */
00210                     }
00211                 }
00212 /* L60: */
00213             }
00214         } else {
00215             jx = kx;
00216             i__1 = *n;
00217             for (j = 1; j <= i__1; ++j) {
00218                 if (x[jx] != 0.) {
00219                     temp = *alpha * x[jx];
00220                     ix = jx;
00221                     i__2 = *n;
00222                     for (i__ = j; i__ <= i__2; ++i__) {
00223                         a[i__ + j * a_dim1] += x[ix] * temp;
00224                         ix += *incx;
00225 /* L70: */
00226                     }
00227                 }
00228                 jx += *incx;
00229 /* L80: */
00230             }
00231         }
00232     }
00233 
00234     return 0;
00235 
00236 /*     End of DSYR  . */
00237 
00238 } /* dsyr_ */


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