ssyr2.c
Go to the documentation of this file.
00001 /* ssyr2.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 ssyr2_(char *uplo, integer *n, real *alpha, real *x, 
00017         integer *incx, real *y, integer *incy, real *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, iy, jx, jy, kx, ky, info;
00024     real temp1, temp2;
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 /*  SSYR2  performs the symmetric rank 2 operation */
00037 
00038 /*     A := alpha*x*y' + alpha*y*x' + A, */
00039 
00040 /*  where alpha is a scalar, x and y are n element vectors and A is an n */
00041 /*  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  - REAL            . */
00065 /*           On entry, ALPHA specifies the scalar alpha. */
00066 /*           Unchanged on exit. */
00067 
00068 /*  X      - REAL             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 /*  Y      - REAL             array of dimension at least */
00080 /*           ( 1 + ( n - 1 )*abs( INCY ) ). */
00081 /*           Before entry, the incremented array Y must contain the n */
00082 /*           element vector y. */
00083 /*           Unchanged on exit. */
00084 
00085 /*  INCY   - INTEGER. */
00086 /*           On entry, INCY specifies the increment for the elements of */
00087 /*           Y. INCY must not be zero. */
00088 /*           Unchanged on exit. */
00089 
00090 /*  A      - REAL             array of DIMENSION ( LDA, n ). */
00091 /*           Before entry with  UPLO = 'U' or 'u', the leading n by n */
00092 /*           upper triangular part of the array A must contain the upper */
00093 /*           triangular part of the symmetric matrix and the strictly */
00094 /*           lower triangular part of A is not referenced. On exit, the */
00095 /*           upper triangular part of the array A is overwritten by the */
00096 /*           upper triangular part of the updated matrix. */
00097 /*           Before entry with UPLO = 'L' or 'l', the leading n by n */
00098 /*           lower triangular part of the array A must contain the lower */
00099 /*           triangular part of the symmetric matrix and the strictly */
00100 /*           upper triangular part of A is not referenced. On exit, the */
00101 /*           lower triangular part of the array A is overwritten by the */
00102 /*           lower triangular part of the updated matrix. */
00103 
00104 /*  LDA    - INTEGER. */
00105 /*           On entry, LDA specifies the first dimension of A as declared */
00106 /*           in the calling (sub) program. LDA must be at least */
00107 /*           max( 1, n ). */
00108 /*           Unchanged on exit. */
00109 
00110 
00111 /*  Level 2 Blas routine. */
00112 
00113 /*  -- Written on 22-October-1986. */
00114 /*     Jack Dongarra, Argonne National Lab. */
00115 /*     Jeremy Du Croz, Nag Central Office. */
00116 /*     Sven Hammarling, Nag Central Office. */
00117 /*     Richard Hanson, Sandia National Labs. */
00118 
00119 
00120 /*     .. Parameters .. */
00121 /*     .. */
00122 /*     .. Local Scalars .. */
00123 /*     .. */
00124 /*     .. External Functions .. */
00125 /*     .. */
00126 /*     .. External Subroutines .. */
00127 /*     .. */
00128 /*     .. Intrinsic Functions .. */
00129 /*     .. */
00130 
00131 /*     Test the input parameters. */
00132 
00133     /* Parameter adjustments */
00134     --x;
00135     --y;
00136     a_dim1 = *lda;
00137     a_offset = 1 + a_dim1;
00138     a -= a_offset;
00139 
00140     /* Function Body */
00141     info = 0;
00142     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00143         info = 1;
00144     } else if (*n < 0) {
00145         info = 2;
00146     } else if (*incx == 0) {
00147         info = 5;
00148     } else if (*incy == 0) {
00149         info = 7;
00150     } else if (*lda < max(1,*n)) {
00151         info = 9;
00152     }
00153     if (info != 0) {
00154         xerbla_("SSYR2 ", &info);
00155         return 0;
00156     }
00157 
00158 /*     Quick return if possible. */
00159 
00160     if (*n == 0 || *alpha == 0.f) {
00161         return 0;
00162     }
00163 
00164 /*     Set up the start points in X and Y if the increments are not both */
00165 /*     unity. */
00166 
00167     if (*incx != 1 || *incy != 1) {
00168         if (*incx > 0) {
00169             kx = 1;
00170         } else {
00171             kx = 1 - (*n - 1) * *incx;
00172         }
00173         if (*incy > 0) {
00174             ky = 1;
00175         } else {
00176             ky = 1 - (*n - 1) * *incy;
00177         }
00178         jx = kx;
00179         jy = ky;
00180     }
00181 
00182 /*     Start the operations. In this version the elements of A are */
00183 /*     accessed sequentially with one pass through the triangular part */
00184 /*     of A. */
00185 
00186     if (lsame_(uplo, "U")) {
00187 
00188 /*        Form  A  when A is stored in the upper triangle. */
00189 
00190         if (*incx == 1 && *incy == 1) {
00191             i__1 = *n;
00192             for (j = 1; j <= i__1; ++j) {
00193                 if (x[j] != 0.f || y[j] != 0.f) {
00194                     temp1 = *alpha * y[j];
00195                     temp2 = *alpha * x[j];
00196                     i__2 = j;
00197                     for (i__ = 1; i__ <= i__2; ++i__) {
00198                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] * 
00199                                 temp1 + y[i__] * temp2;
00200 /* L10: */
00201                     }
00202                 }
00203 /* L20: */
00204             }
00205         } else {
00206             i__1 = *n;
00207             for (j = 1; j <= i__1; ++j) {
00208                 if (x[jx] != 0.f || y[jy] != 0.f) {
00209                     temp1 = *alpha * y[jy];
00210                     temp2 = *alpha * x[jx];
00211                     ix = kx;
00212                     iy = ky;
00213                     i__2 = j;
00214                     for (i__ = 1; i__ <= i__2; ++i__) {
00215                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] * 
00216                                 temp1 + y[iy] * temp2;
00217                         ix += *incx;
00218                         iy += *incy;
00219 /* L30: */
00220                     }
00221                 }
00222                 jx += *incx;
00223                 jy += *incy;
00224 /* L40: */
00225             }
00226         }
00227     } else {
00228 
00229 /*        Form  A  when A is stored in the lower triangle. */
00230 
00231         if (*incx == 1 && *incy == 1) {
00232             i__1 = *n;
00233             for (j = 1; j <= i__1; ++j) {
00234                 if (x[j] != 0.f || y[j] != 0.f) {
00235                     temp1 = *alpha * y[j];
00236                     temp2 = *alpha * x[j];
00237                     i__2 = *n;
00238                     for (i__ = j; i__ <= i__2; ++i__) {
00239                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] * 
00240                                 temp1 + y[i__] * temp2;
00241 /* L50: */
00242                     }
00243                 }
00244 /* L60: */
00245             }
00246         } else {
00247             i__1 = *n;
00248             for (j = 1; j <= i__1; ++j) {
00249                 if (x[jx] != 0.f || y[jy] != 0.f) {
00250                     temp1 = *alpha * y[jy];
00251                     temp2 = *alpha * x[jx];
00252                     ix = jx;
00253                     iy = jy;
00254                     i__2 = *n;
00255                     for (i__ = j; i__ <= i__2; ++i__) {
00256                         a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] * 
00257                                 temp1 + y[iy] * temp2;
00258                         ix += *incx;
00259                         iy += *incy;
00260 /* L70: */
00261                     }
00262                 }
00263                 jx += *incx;
00264                 jy += *incy;
00265 /* L80: */
00266             }
00267         }
00268     }
00269 
00270     return 0;
00271 
00272 /*     End of SSYR2 . */
00273 
00274 } /* ssyr2_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:14