zsyr.c
Go to the documentation of this file.
00001 /* zsyr.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 zsyr_(char *uplo, integer *n, doublecomplex *alpha, 
00017         doublecomplex *x, integer *incx, doublecomplex *a, integer *lda)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
00021     doublecomplex z__1, z__2;
00022 
00023     /* Local variables */
00024     integer i__, j, ix, jx, kx, info;
00025     doublecomplex temp;
00026     extern logical lsame_(char *, char *);
00027     extern /* Subroutine */ int xerbla_(char *, integer *);
00028 
00029 
00030 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00031 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00032 /*     November 2006 */
00033 
00034 /*     .. Scalar Arguments .. */
00035 /*     .. */
00036 /*     .. Array Arguments .. */
00037 /*     .. */
00038 
00039 /*  Purpose */
00040 /*  ======= */
00041 
00042 /*  ZSYR   performs the symmetric rank 1 operation */
00043 
00044 /*     A := alpha*x*( x' ) + A, */
00045 
00046 /*  where alpha is a complex scalar, x is an n element vector and A is an */
00047 /*  n by n symmetric matrix. */
00048 
00049 /*  Arguments */
00050 /*  ========== */
00051 
00052 /*  UPLO     (input) CHARACTER*1 */
00053 /*           On entry, UPLO specifies whether the upper or lower */
00054 /*           triangular part of the array A is to be referenced as */
00055 /*           follows: */
00056 
00057 /*              UPLO = 'U' or 'u'   Only the upper triangular part of A */
00058 /*                                  is to be referenced. */
00059 
00060 /*              UPLO = 'L' or 'l'   Only the lower triangular part of A */
00061 /*                                  is to be referenced. */
00062 
00063 /*           Unchanged on exit. */
00064 
00065 /*  N        (input) INTEGER */
00066 /*           On entry, N specifies the order of the matrix A. */
00067 /*           N must be at least zero. */
00068 /*           Unchanged on exit. */
00069 
00070 /*  ALPHA    (input) COMPLEX*16 */
00071 /*           On entry, ALPHA specifies the scalar alpha. */
00072 /*           Unchanged on exit. */
00073 
00074 /*  X        (input) COMPLEX*16 array, dimension at least */
00075 /*           ( 1 + ( N - 1 )*abs( INCX ) ). */
00076 /*           Before entry, the incremented array X must contain the N- */
00077 /*           element vector x. */
00078 /*           Unchanged on exit. */
00079 
00080 /*  INCX     (input) INTEGER */
00081 /*           On entry, INCX specifies the increment for the elements of */
00082 /*           X. INCX must not be zero. */
00083 /*           Unchanged on exit. */
00084 
00085 /*  A        (input/output) COMPLEX*16 array, dimension ( LDA, N ) */
00086 /*           Before entry, with  UPLO = 'U' or 'u', the leading n by n */
00087 /*           upper triangular part of the array A must contain the upper */
00088 /*           triangular part of the symmetric matrix and the strictly */
00089 /*           lower triangular part of A is not referenced. On exit, the */
00090 /*           upper triangular part of the array A is overwritten by the */
00091 /*           upper triangular part of the updated matrix. */
00092 /*           Before entry, with UPLO = 'L' or 'l', the leading n by n */
00093 /*           lower triangular part of the array A must contain the lower */
00094 /*           triangular part of the symmetric matrix and the strictly */
00095 /*           upper triangular part of A is not referenced. On exit, the */
00096 /*           lower triangular part of the array A is overwritten by the */
00097 /*           lower triangular part of the updated matrix. */
00098 
00099 /*  LDA      (input) INTEGER */
00100 /*           On entry, LDA specifies the first dimension of A as declared */
00101 /*           in the calling (sub) program. LDA must be at least */
00102 /*           max( 1, N ). */
00103 /*           Unchanged on exit. */
00104 
00105 /* ===================================================================== */
00106 
00107 /*     .. Parameters .. */
00108 /*     .. */
00109 /*     .. Local Scalars .. */
00110 /*     .. */
00111 /*     .. External Functions .. */
00112 /*     .. */
00113 /*     .. External Subroutines .. */
00114 /*     .. */
00115 /*     .. Intrinsic Functions .. */
00116 /*     .. */
00117 /*     .. Executable Statements .. */
00118 
00119 /*     Test the input parameters. */
00120 
00121     /* Parameter adjustments */
00122     --x;
00123     a_dim1 = *lda;
00124     a_offset = 1 + a_dim1;
00125     a -= a_offset;
00126 
00127     /* Function Body */
00128     info = 0;
00129     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00130         info = 1;
00131     } else if (*n < 0) {
00132         info = 2;
00133     } else if (*incx == 0) {
00134         info = 5;
00135     } else if (*lda < max(1,*n)) {
00136         info = 7;
00137     }
00138     if (info != 0) {
00139         xerbla_("ZSYR  ", &info);
00140         return 0;
00141     }
00142 
00143 /*     Quick return if possible. */
00144 
00145     if (*n == 0 || alpha->r == 0. && alpha->i == 0.) {
00146         return 0;
00147     }
00148 
00149 /*     Set the start point in X if the increment is not unity. */
00150 
00151     if (*incx <= 0) {
00152         kx = 1 - (*n - 1) * *incx;
00153     } else if (*incx != 1) {
00154         kx = 1;
00155     }
00156 
00157 /*     Start the operations. In this version the elements of A are */
00158 /*     accessed sequentially with one pass through the triangular part */
00159 /*     of A. */
00160 
00161     if (lsame_(uplo, "U")) {
00162 
00163 /*        Form  A  when A is stored in upper triangle. */
00164 
00165         if (*incx == 1) {
00166             i__1 = *n;
00167             for (j = 1; j <= i__1; ++j) {
00168                 i__2 = j;
00169                 if (x[i__2].r != 0. || x[i__2].i != 0.) {
00170                     i__2 = j;
00171                     z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00172                             z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00173                             .r;
00174                     temp.r = z__1.r, temp.i = z__1.i;
00175                     i__2 = j;
00176                     for (i__ = 1; i__ <= i__2; ++i__) {
00177                         i__3 = i__ + j * a_dim1;
00178                         i__4 = i__ + j * a_dim1;
00179                         i__5 = i__;
00180                         z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00181                                 z__2.i = x[i__5].r * temp.i + x[i__5].i * 
00182                                 temp.r;
00183                         z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + 
00184                                 z__2.i;
00185                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00186 /* L10: */
00187                     }
00188                 }
00189 /* L20: */
00190             }
00191         } else {
00192             jx = kx;
00193             i__1 = *n;
00194             for (j = 1; j <= i__1; ++j) {
00195                 i__2 = jx;
00196                 if (x[i__2].r != 0. || x[i__2].i != 0.) {
00197                     i__2 = jx;
00198                     z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00199                             z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00200                             .r;
00201                     temp.r = z__1.r, temp.i = z__1.i;
00202                     ix = kx;
00203                     i__2 = j;
00204                     for (i__ = 1; i__ <= i__2; ++i__) {
00205                         i__3 = i__ + j * a_dim1;
00206                         i__4 = i__ + j * a_dim1;
00207                         i__5 = ix;
00208                         z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00209                                 z__2.i = x[i__5].r * temp.i + x[i__5].i * 
00210                                 temp.r;
00211                         z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + 
00212                                 z__2.i;
00213                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00214                         ix += *incx;
00215 /* L30: */
00216                     }
00217                 }
00218                 jx += *incx;
00219 /* L40: */
00220             }
00221         }
00222     } else {
00223 
00224 /*        Form  A  when A is stored in lower triangle. */
00225 
00226         if (*incx == 1) {
00227             i__1 = *n;
00228             for (j = 1; j <= i__1; ++j) {
00229                 i__2 = j;
00230                 if (x[i__2].r != 0. || x[i__2].i != 0.) {
00231                     i__2 = j;
00232                     z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00233                             z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00234                             .r;
00235                     temp.r = z__1.r, temp.i = z__1.i;
00236                     i__2 = *n;
00237                     for (i__ = j; i__ <= i__2; ++i__) {
00238                         i__3 = i__ + j * a_dim1;
00239                         i__4 = i__ + j * a_dim1;
00240                         i__5 = i__;
00241                         z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00242                                 z__2.i = x[i__5].r * temp.i + x[i__5].i * 
00243                                 temp.r;
00244                         z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + 
00245                                 z__2.i;
00246                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00247 /* L50: */
00248                     }
00249                 }
00250 /* L60: */
00251             }
00252         } else {
00253             jx = kx;
00254             i__1 = *n;
00255             for (j = 1; j <= i__1; ++j) {
00256                 i__2 = jx;
00257                 if (x[i__2].r != 0. || x[i__2].i != 0.) {
00258                     i__2 = jx;
00259                     z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00260                             z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00261                             .r;
00262                     temp.r = z__1.r, temp.i = z__1.i;
00263                     ix = jx;
00264                     i__2 = *n;
00265                     for (i__ = j; i__ <= i__2; ++i__) {
00266                         i__3 = i__ + j * a_dim1;
00267                         i__4 = i__ + j * a_dim1;
00268                         i__5 = ix;
00269                         z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00270                                 z__2.i = x[i__5].r * temp.i + x[i__5].i * 
00271                                 temp.r;
00272                         z__1.r = a[i__4].r + z__2.r, z__1.i = a[i__4].i + 
00273                                 z__2.i;
00274                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00275                         ix += *incx;
00276 /* L70: */
00277                     }
00278                 }
00279                 jx += *incx;
00280 /* L80: */
00281             }
00282         }
00283     }
00284 
00285     return 0;
00286 
00287 /*     End of ZSYR */
00288 
00289 } /* zsyr_ */


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