zher2.c
Go to the documentation of this file.
00001 /* zher2.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 zher2_(char *uplo, integer *n, doublecomplex *alpha, 
00017         doublecomplex *x, integer *incx, doublecomplex *y, integer *incy, 
00018         doublecomplex *a, integer *lda)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00022     doublereal d__1;
00023     doublecomplex z__1, z__2, z__3, z__4;
00024 
00025     /* Builtin functions */
00026     void d_cnjg(doublecomplex *, doublecomplex *);
00027 
00028     /* Local variables */
00029     integer i__, j, ix, iy, jx, jy, kx, ky, info;
00030     doublecomplex temp1, temp2;
00031     extern logical lsame_(char *, char *);
00032     extern /* Subroutine */ int xerbla_(char *, integer *);
00033 
00034 /*     .. Scalar Arguments .. */
00035 /*     .. */
00036 /*     .. Array Arguments .. */
00037 /*     .. */
00038 
00039 /*  Purpose */
00040 /*  ======= */
00041 
00042 /*  ZHER2  performs the hermitian rank 2 operation */
00043 
00044 /*     A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A, */
00045 
00046 /*  where alpha is a scalar, x and y are n element vectors and A is an n */
00047 /*  by n hermitian matrix. */
00048 
00049 /*  Arguments */
00050 /*  ========== */
00051 
00052 /*  UPLO   - 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      - 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  - COMPLEX*16      . */
00071 /*           On entry, ALPHA specifies the scalar alpha. */
00072 /*           Unchanged on exit. */
00073 
00074 /*  X      - COMPLEX*16       array of 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   - 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 /*  Y      - COMPLEX*16       array of dimension at least */
00086 /*           ( 1 + ( n - 1 )*abs( INCY ) ). */
00087 /*           Before entry, the incremented array Y must contain the n */
00088 /*           element vector y. */
00089 /*           Unchanged on exit. */
00090 
00091 /*  INCY   - INTEGER. */
00092 /*           On entry, INCY specifies the increment for the elements of */
00093 /*           Y. INCY must not be zero. */
00094 /*           Unchanged on exit. */
00095 
00096 /*  A      - COMPLEX*16       array of DIMENSION ( LDA, n ). */
00097 /*           Before entry with  UPLO = 'U' or 'u', the leading n by n */
00098 /*           upper triangular part of the array A must contain the upper */
00099 /*           triangular part of the hermitian matrix and the strictly */
00100 /*           lower triangular part of A is not referenced. On exit, the */
00101 /*           upper triangular part of the array A is overwritten by the */
00102 /*           upper triangular part of the updated matrix. */
00103 /*           Before entry with UPLO = 'L' or 'l', the leading n by n */
00104 /*           lower triangular part of the array A must contain the lower */
00105 /*           triangular part of the hermitian matrix and the strictly */
00106 /*           upper triangular part of A is not referenced. On exit, the */
00107 /*           lower triangular part of the array A is overwritten by the */
00108 /*           lower triangular part of the updated matrix. */
00109 /*           Note that the imaginary parts of the diagonal elements need */
00110 /*           not be set, they are assumed to be zero, and on exit they */
00111 /*           are set to zero. */
00112 
00113 /*  LDA    - INTEGER. */
00114 /*           On entry, LDA specifies the first dimension of A as declared */
00115 /*           in the calling (sub) program. LDA must be at least */
00116 /*           max( 1, n ). */
00117 /*           Unchanged on exit. */
00118 
00119 
00120 /*  Level 2 Blas routine. */
00121 
00122 /*  -- Written on 22-October-1986. */
00123 /*     Jack Dongarra, Argonne National Lab. */
00124 /*     Jeremy Du Croz, Nag Central Office. */
00125 /*     Sven Hammarling, Nag Central Office. */
00126 /*     Richard Hanson, Sandia National Labs. */
00127 
00128 
00129 /*     .. Parameters .. */
00130 /*     .. */
00131 /*     .. Local Scalars .. */
00132 /*     .. */
00133 /*     .. External Functions .. */
00134 /*     .. */
00135 /*     .. External Subroutines .. */
00136 /*     .. */
00137 /*     .. Intrinsic Functions .. */
00138 /*     .. */
00139 
00140 /*     Test the input parameters. */
00141 
00142     /* Parameter adjustments */
00143     --x;
00144     --y;
00145     a_dim1 = *lda;
00146     a_offset = 1 + a_dim1;
00147     a -= a_offset;
00148 
00149     /* Function Body */
00150     info = 0;
00151     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00152         info = 1;
00153     } else if (*n < 0) {
00154         info = 2;
00155     } else if (*incx == 0) {
00156         info = 5;
00157     } else if (*incy == 0) {
00158         info = 7;
00159     } else if (*lda < max(1,*n)) {
00160         info = 9;
00161     }
00162     if (info != 0) {
00163         xerbla_("ZHER2 ", &info);
00164         return 0;
00165     }
00166 
00167 /*     Quick return if possible. */
00168 
00169     if (*n == 0 || alpha->r == 0. && alpha->i == 0.) {
00170         return 0;
00171     }
00172 
00173 /*     Set up the start points in X and Y if the increments are not both */
00174 /*     unity. */
00175 
00176     if (*incx != 1 || *incy != 1) {
00177         if (*incx > 0) {
00178             kx = 1;
00179         } else {
00180             kx = 1 - (*n - 1) * *incx;
00181         }
00182         if (*incy > 0) {
00183             ky = 1;
00184         } else {
00185             ky = 1 - (*n - 1) * *incy;
00186         }
00187         jx = kx;
00188         jy = ky;
00189     }
00190 
00191 /*     Start the operations. In this version the elements of A are */
00192 /*     accessed sequentially with one pass through the triangular part */
00193 /*     of A. */
00194 
00195     if (lsame_(uplo, "U")) {
00196 
00197 /*        Form  A  when A is stored in the upper triangle. */
00198 
00199         if (*incx == 1 && *incy == 1) {
00200             i__1 = *n;
00201             for (j = 1; j <= i__1; ++j) {
00202                 i__2 = j;
00203                 i__3 = j;
00204                 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || 
00205                         y[i__3].i != 0.)) {
00206                     d_cnjg(&z__2, &y[j]);
00207                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00208                             alpha->r * z__2.i + alpha->i * z__2.r;
00209                     temp1.r = z__1.r, temp1.i = z__1.i;
00210                     i__2 = j;
00211                     z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00212                             z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00213                             .r;
00214                     d_cnjg(&z__1, &z__2);
00215                     temp2.r = z__1.r, temp2.i = z__1.i;
00216                     i__2 = j - 1;
00217                     for (i__ = 1; i__ <= i__2; ++i__) {
00218                         i__3 = i__ + j * a_dim1;
00219                         i__4 = i__ + j * a_dim1;
00220                         i__5 = i__;
00221                         z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, 
00222                                 z__3.i = x[i__5].r * temp1.i + x[i__5].i * 
00223                                 temp1.r;
00224                         z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + 
00225                                 z__3.i;
00226                         i__6 = i__;
00227                         z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, 
00228                                 z__4.i = y[i__6].r * temp2.i + y[i__6].i * 
00229                                 temp2.r;
00230                         z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00231                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00232 /* L10: */
00233                     }
00234                     i__2 = j + j * a_dim1;
00235                     i__3 = j + j * a_dim1;
00236                     i__4 = j;
00237                     z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, 
00238                             z__2.i = x[i__4].r * temp1.i + x[i__4].i * 
00239                             temp1.r;
00240                     i__5 = j;
00241                     z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, 
00242                             z__3.i = y[i__5].r * temp2.i + y[i__5].i * 
00243                             temp2.r;
00244                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00245                     d__1 = a[i__3].r + z__1.r;
00246                     a[i__2].r = d__1, a[i__2].i = 0.;
00247                 } else {
00248                     i__2 = j + j * a_dim1;
00249                     i__3 = j + j * a_dim1;
00250                     d__1 = a[i__3].r;
00251                     a[i__2].r = d__1, a[i__2].i = 0.;
00252                 }
00253 /* L20: */
00254             }
00255         } else {
00256             i__1 = *n;
00257             for (j = 1; j <= i__1; ++j) {
00258                 i__2 = jx;
00259                 i__3 = jy;
00260                 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || 
00261                         y[i__3].i != 0.)) {
00262                     d_cnjg(&z__2, &y[jy]);
00263                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00264                             alpha->r * z__2.i + alpha->i * z__2.r;
00265                     temp1.r = z__1.r, temp1.i = z__1.i;
00266                     i__2 = jx;
00267                     z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00268                             z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00269                             .r;
00270                     d_cnjg(&z__1, &z__2);
00271                     temp2.r = z__1.r, temp2.i = z__1.i;
00272                     ix = kx;
00273                     iy = ky;
00274                     i__2 = j - 1;
00275                     for (i__ = 1; i__ <= i__2; ++i__) {
00276                         i__3 = i__ + j * a_dim1;
00277                         i__4 = i__ + j * a_dim1;
00278                         i__5 = ix;
00279                         z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, 
00280                                 z__3.i = x[i__5].r * temp1.i + x[i__5].i * 
00281                                 temp1.r;
00282                         z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + 
00283                                 z__3.i;
00284                         i__6 = iy;
00285                         z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, 
00286                                 z__4.i = y[i__6].r * temp2.i + y[i__6].i * 
00287                                 temp2.r;
00288                         z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00289                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00290                         ix += *incx;
00291                         iy += *incy;
00292 /* L30: */
00293                     }
00294                     i__2 = j + j * a_dim1;
00295                     i__3 = j + j * a_dim1;
00296                     i__4 = jx;
00297                     z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, 
00298                             z__2.i = x[i__4].r * temp1.i + x[i__4].i * 
00299                             temp1.r;
00300                     i__5 = jy;
00301                     z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, 
00302                             z__3.i = y[i__5].r * temp2.i + y[i__5].i * 
00303                             temp2.r;
00304                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00305                     d__1 = a[i__3].r + z__1.r;
00306                     a[i__2].r = d__1, a[i__2].i = 0.;
00307                 } else {
00308                     i__2 = j + j * a_dim1;
00309                     i__3 = j + j * a_dim1;
00310                     d__1 = a[i__3].r;
00311                     a[i__2].r = d__1, a[i__2].i = 0.;
00312                 }
00313                 jx += *incx;
00314                 jy += *incy;
00315 /* L40: */
00316             }
00317         }
00318     } else {
00319 
00320 /*        Form  A  when A is stored in the lower triangle. */
00321 
00322         if (*incx == 1 && *incy == 1) {
00323             i__1 = *n;
00324             for (j = 1; j <= i__1; ++j) {
00325                 i__2 = j;
00326                 i__3 = j;
00327                 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || 
00328                         y[i__3].i != 0.)) {
00329                     d_cnjg(&z__2, &y[j]);
00330                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00331                             alpha->r * z__2.i + alpha->i * z__2.r;
00332                     temp1.r = z__1.r, temp1.i = z__1.i;
00333                     i__2 = j;
00334                     z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00335                             z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00336                             .r;
00337                     d_cnjg(&z__1, &z__2);
00338                     temp2.r = z__1.r, temp2.i = z__1.i;
00339                     i__2 = j + j * a_dim1;
00340                     i__3 = j + j * a_dim1;
00341                     i__4 = j;
00342                     z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, 
00343                             z__2.i = x[i__4].r * temp1.i + x[i__4].i * 
00344                             temp1.r;
00345                     i__5 = j;
00346                     z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, 
00347                             z__3.i = y[i__5].r * temp2.i + y[i__5].i * 
00348                             temp2.r;
00349                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00350                     d__1 = a[i__3].r + z__1.r;
00351                     a[i__2].r = d__1, a[i__2].i = 0.;
00352                     i__2 = *n;
00353                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00354                         i__3 = i__ + j * a_dim1;
00355                         i__4 = i__ + j * a_dim1;
00356                         i__5 = i__;
00357                         z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, 
00358                                 z__3.i = x[i__5].r * temp1.i + x[i__5].i * 
00359                                 temp1.r;
00360                         z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + 
00361                                 z__3.i;
00362                         i__6 = i__;
00363                         z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, 
00364                                 z__4.i = y[i__6].r * temp2.i + y[i__6].i * 
00365                                 temp2.r;
00366                         z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00367                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00368 /* L50: */
00369                     }
00370                 } else {
00371                     i__2 = j + j * a_dim1;
00372                     i__3 = j + j * a_dim1;
00373                     d__1 = a[i__3].r;
00374                     a[i__2].r = d__1, a[i__2].i = 0.;
00375                 }
00376 /* L60: */
00377             }
00378         } else {
00379             i__1 = *n;
00380             for (j = 1; j <= i__1; ++j) {
00381                 i__2 = jx;
00382                 i__3 = jy;
00383                 if (x[i__2].r != 0. || x[i__2].i != 0. || (y[i__3].r != 0. || 
00384                         y[i__3].i != 0.)) {
00385                     d_cnjg(&z__2, &y[jy]);
00386                     z__1.r = alpha->r * z__2.r - alpha->i * z__2.i, z__1.i = 
00387                             alpha->r * z__2.i + alpha->i * z__2.r;
00388                     temp1.r = z__1.r, temp1.i = z__1.i;
00389                     i__2 = jx;
00390                     z__2.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00391                             z__2.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00392                             .r;
00393                     d_cnjg(&z__1, &z__2);
00394                     temp2.r = z__1.r, temp2.i = z__1.i;
00395                     i__2 = j + j * a_dim1;
00396                     i__3 = j + j * a_dim1;
00397                     i__4 = jx;
00398                     z__2.r = x[i__4].r * temp1.r - x[i__4].i * temp1.i, 
00399                             z__2.i = x[i__4].r * temp1.i + x[i__4].i * 
00400                             temp1.r;
00401                     i__5 = jy;
00402                     z__3.r = y[i__5].r * temp2.r - y[i__5].i * temp2.i, 
00403                             z__3.i = y[i__5].r * temp2.i + y[i__5].i * 
00404                             temp2.r;
00405                     z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00406                     d__1 = a[i__3].r + z__1.r;
00407                     a[i__2].r = d__1, a[i__2].i = 0.;
00408                     ix = jx;
00409                     iy = jy;
00410                     i__2 = *n;
00411                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00412                         ix += *incx;
00413                         iy += *incy;
00414                         i__3 = i__ + j * a_dim1;
00415                         i__4 = i__ + j * a_dim1;
00416                         i__5 = ix;
00417                         z__3.r = x[i__5].r * temp1.r - x[i__5].i * temp1.i, 
00418                                 z__3.i = x[i__5].r * temp1.i + x[i__5].i * 
00419                                 temp1.r;
00420                         z__2.r = a[i__4].r + z__3.r, z__2.i = a[i__4].i + 
00421                                 z__3.i;
00422                         i__6 = iy;
00423                         z__4.r = y[i__6].r * temp2.r - y[i__6].i * temp2.i, 
00424                                 z__4.i = y[i__6].r * temp2.i + y[i__6].i * 
00425                                 temp2.r;
00426                         z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
00427                         a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00428 /* L70: */
00429                     }
00430                 } else {
00431                     i__2 = j + j * a_dim1;
00432                     i__3 = j + j * a_dim1;
00433                     d__1 = a[i__3].r;
00434                     a[i__2].r = d__1, a[i__2].i = 0.;
00435                 }
00436                 jx += *incx;
00437                 jy += *incy;
00438 /* L80: */
00439             }
00440         }
00441     }
00442 
00443     return 0;
00444 
00445 /*     End of ZHER2 . */
00446 
00447 } /* zher2_ */


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