cher.c
Go to the documentation of this file.
00001 /* cher.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 cher_(char *uplo, integer *n, real *alpha, complex *x, 
00017         integer *incx, complex *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     real r__1;
00022     complex q__1, q__2;
00023 
00024     /* Builtin functions */
00025     void r_cnjg(complex *, complex *);
00026 
00027     /* Local variables */
00028     integer i__, j, ix, jx, kx, info;
00029     complex temp;
00030     extern logical lsame_(char *, char *);
00031     extern /* Subroutine */ int xerbla_(char *, integer *);
00032 
00033 /*     .. Scalar Arguments .. */
00034 /*     .. */
00035 /*     .. Array Arguments .. */
00036 /*     .. */
00037 
00038 /*  Purpose */
00039 /*  ======= */
00040 
00041 /*  CHER   performs the hermitian rank 1 operation */
00042 
00043 /*     A := alpha*x*conjg( x' ) + A, */
00044 
00045 /*  where alpha is a real scalar, x is an n element vector and A is an */
00046 /*  n by n hermitian matrix. */
00047 
00048 /*  Arguments */
00049 /*  ========== */
00050 
00051 /*  UPLO   - CHARACTER*1. */
00052 /*           On entry, UPLO specifies whether the upper or lower */
00053 /*           triangular part of the array A is to be referenced as */
00054 /*           follows: */
00055 
00056 /*              UPLO = 'U' or 'u'   Only the upper triangular part of A */
00057 /*                                  is to be referenced. */
00058 
00059 /*              UPLO = 'L' or 'l'   Only the lower triangular part of A */
00060 /*                                  is to be referenced. */
00061 
00062 /*           Unchanged on exit. */
00063 
00064 /*  N      - INTEGER. */
00065 /*           On entry, N specifies the order of the matrix A. */
00066 /*           N must be at least zero. */
00067 /*           Unchanged on exit. */
00068 
00069 /*  ALPHA  - REAL            . */
00070 /*           On entry, ALPHA specifies the scalar alpha. */
00071 /*           Unchanged on exit. */
00072 
00073 /*  X      - COMPLEX          array of dimension at least */
00074 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00075 /*           Before entry, the incremented array X must contain the n */
00076 /*           element vector x. */
00077 /*           Unchanged on exit. */
00078 
00079 /*  INCX   - INTEGER. */
00080 /*           On entry, INCX specifies the increment for the elements of */
00081 /*           X. INCX must not be zero. */
00082 /*           Unchanged on exit. */
00083 
00084 /*  A      - COMPLEX          array of DIMENSION ( LDA, n ). */
00085 /*           Before entry with  UPLO = 'U' or 'u', the leading n by n */
00086 /*           upper triangular part of the array A must contain the upper */
00087 /*           triangular part of the hermitian matrix and the strictly */
00088 /*           lower triangular part of A is not referenced. On exit, the */
00089 /*           upper triangular part of the array A is overwritten by the */
00090 /*           upper triangular part of the updated matrix. */
00091 /*           Before entry with UPLO = 'L' or 'l', the leading n by n */
00092 /*           lower triangular part of the array A must contain the lower */
00093 /*           triangular part of the hermitian matrix and the strictly */
00094 /*           upper triangular part of A is not referenced. On exit, the */
00095 /*           lower triangular part of the array A is overwritten by the */
00096 /*           lower triangular part of the updated matrix. */
00097 /*           Note that the imaginary parts of the diagonal elements need */
00098 /*           not be set, they are assumed to be zero, and on exit they */
00099 /*           are set to zero. */
00100 
00101 /*  LDA    - INTEGER. */
00102 /*           On entry, LDA specifies the first dimension of A as declared */
00103 /*           in the calling (sub) program. LDA must be at least */
00104 /*           max( 1, n ). */
00105 /*           Unchanged on exit. */
00106 
00107 
00108 /*  Level 2 Blas routine. */
00109 
00110 /*  -- Written on 22-October-1986. */
00111 /*     Jack Dongarra, Argonne National Lab. */
00112 /*     Jeremy Du Croz, Nag Central Office. */
00113 /*     Sven Hammarling, Nag Central Office. */
00114 /*     Richard Hanson, Sandia National Labs. */
00115 
00116 
00117 /*     .. Parameters .. */
00118 /*     .. */
00119 /*     .. Local Scalars .. */
00120 /*     .. */
00121 /*     .. External Functions .. */
00122 /*     .. */
00123 /*     .. External Subroutines .. */
00124 /*     .. */
00125 /*     .. Intrinsic Functions .. */
00126 /*     .. */
00127 
00128 /*     Test the input parameters. */
00129 
00130     /* Parameter adjustments */
00131     --x;
00132     a_dim1 = *lda;
00133     a_offset = 1 + a_dim1;
00134     a -= a_offset;
00135 
00136     /* Function Body */
00137     info = 0;
00138     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00139         info = 1;
00140     } else if (*n < 0) {
00141         info = 2;
00142     } else if (*incx == 0) {
00143         info = 5;
00144     } else if (*lda < max(1,*n)) {
00145         info = 7;
00146     }
00147     if (info != 0) {
00148         xerbla_("CHER  ", &info);
00149         return 0;
00150     }
00151 
00152 /*     Quick return if possible. */
00153 
00154     if (*n == 0 || *alpha == 0.f) {
00155         return 0;
00156     }
00157 
00158 /*     Set the start point in X if the increment is not unity. */
00159 
00160     if (*incx <= 0) {
00161         kx = 1 - (*n - 1) * *incx;
00162     } else if (*incx != 1) {
00163         kx = 1;
00164     }
00165 
00166 /*     Start the operations. In this version the elements of A are */
00167 /*     accessed sequentially with one pass through the triangular part */
00168 /*     of A. */
00169 
00170     if (lsame_(uplo, "U")) {
00171 
00172 /*        Form  A  when A is stored in upper triangle. */
00173 
00174         if (*incx == 1) {
00175             i__1 = *n;
00176             for (j = 1; j <= i__1; ++j) {
00177                 i__2 = j;
00178                 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
00179                     r_cnjg(&q__2, &x[j]);
00180                     q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
00181                     temp.r = q__1.r, temp.i = q__1.i;
00182                     i__2 = j - 1;
00183                     for (i__ = 1; i__ <= i__2; ++i__) {
00184                         i__3 = i__ + j * a_dim1;
00185                         i__4 = i__ + j * a_dim1;
00186                         i__5 = i__;
00187                         q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00188                                 q__2.i = x[i__5].r * temp.i + x[i__5].i * 
00189                                 temp.r;
00190                         q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + 
00191                                 q__2.i;
00192                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00193 /* L10: */
00194                     }
00195                     i__2 = j + j * a_dim1;
00196                     i__3 = j + j * a_dim1;
00197                     i__4 = j;
00198                     q__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, q__1.i =
00199                              x[i__4].r * temp.i + x[i__4].i * temp.r;
00200                     r__1 = a[i__3].r + q__1.r;
00201                     a[i__2].r = r__1, a[i__2].i = 0.f;
00202                 } else {
00203                     i__2 = j + j * a_dim1;
00204                     i__3 = j + j * a_dim1;
00205                     r__1 = a[i__3].r;
00206                     a[i__2].r = r__1, a[i__2].i = 0.f;
00207                 }
00208 /* L20: */
00209             }
00210         } else {
00211             jx = kx;
00212             i__1 = *n;
00213             for (j = 1; j <= i__1; ++j) {
00214                 i__2 = jx;
00215                 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
00216                     r_cnjg(&q__2, &x[jx]);
00217                     q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
00218                     temp.r = q__1.r, temp.i = q__1.i;
00219                     ix = kx;
00220                     i__2 = j - 1;
00221                     for (i__ = 1; i__ <= i__2; ++i__) {
00222                         i__3 = i__ + j * a_dim1;
00223                         i__4 = i__ + j * a_dim1;
00224                         i__5 = ix;
00225                         q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00226                                 q__2.i = x[i__5].r * temp.i + x[i__5].i * 
00227                                 temp.r;
00228                         q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + 
00229                                 q__2.i;
00230                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00231                         ix += *incx;
00232 /* L30: */
00233                     }
00234                     i__2 = j + j * a_dim1;
00235                     i__3 = j + j * a_dim1;
00236                     i__4 = jx;
00237                     q__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, q__1.i =
00238                              x[i__4].r * temp.i + x[i__4].i * temp.r;
00239                     r__1 = a[i__3].r + q__1.r;
00240                     a[i__2].r = r__1, a[i__2].i = 0.f;
00241                 } else {
00242                     i__2 = j + j * a_dim1;
00243                     i__3 = j + j * a_dim1;
00244                     r__1 = a[i__3].r;
00245                     a[i__2].r = r__1, a[i__2].i = 0.f;
00246                 }
00247                 jx += *incx;
00248 /* L40: */
00249             }
00250         }
00251     } else {
00252 
00253 /*        Form  A  when A is stored in lower triangle. */
00254 
00255         if (*incx == 1) {
00256             i__1 = *n;
00257             for (j = 1; j <= i__1; ++j) {
00258                 i__2 = j;
00259                 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
00260                     r_cnjg(&q__2, &x[j]);
00261                     q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
00262                     temp.r = q__1.r, temp.i = q__1.i;
00263                     i__2 = j + j * a_dim1;
00264                     i__3 = j + j * a_dim1;
00265                     i__4 = j;
00266                     q__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, q__1.i =
00267                              temp.r * x[i__4].i + temp.i * x[i__4].r;
00268                     r__1 = a[i__3].r + q__1.r;
00269                     a[i__2].r = r__1, a[i__2].i = 0.f;
00270                     i__2 = *n;
00271                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00272                         i__3 = i__ + j * a_dim1;
00273                         i__4 = i__ + j * a_dim1;
00274                         i__5 = i__;
00275                         q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00276                                 q__2.i = x[i__5].r * temp.i + x[i__5].i * 
00277                                 temp.r;
00278                         q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + 
00279                                 q__2.i;
00280                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00281 /* L50: */
00282                     }
00283                 } else {
00284                     i__2 = j + j * a_dim1;
00285                     i__3 = j + j * a_dim1;
00286                     r__1 = a[i__3].r;
00287                     a[i__2].r = r__1, a[i__2].i = 0.f;
00288                 }
00289 /* L60: */
00290             }
00291         } else {
00292             jx = kx;
00293             i__1 = *n;
00294             for (j = 1; j <= i__1; ++j) {
00295                 i__2 = jx;
00296                 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
00297                     r_cnjg(&q__2, &x[jx]);
00298                     q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
00299                     temp.r = q__1.r, temp.i = q__1.i;
00300                     i__2 = j + j * a_dim1;
00301                     i__3 = j + j * a_dim1;
00302                     i__4 = jx;
00303                     q__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, q__1.i =
00304                              temp.r * x[i__4].i + temp.i * x[i__4].r;
00305                     r__1 = a[i__3].r + q__1.r;
00306                     a[i__2].r = r__1, a[i__2].i = 0.f;
00307                     ix = jx;
00308                     i__2 = *n;
00309                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00310                         ix += *incx;
00311                         i__3 = i__ + j * a_dim1;
00312                         i__4 = i__ + j * a_dim1;
00313                         i__5 = ix;
00314                         q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i, 
00315                                 q__2.i = x[i__5].r * temp.i + x[i__5].i * 
00316                                 temp.r;
00317                         q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i + 
00318                                 q__2.i;
00319                         a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00320 /* L70: */
00321                     }
00322                 } else {
00323                     i__2 = j + j * a_dim1;
00324                     i__3 = j + j * a_dim1;
00325                     r__1 = a[i__3].r;
00326                     a[i__2].r = r__1, a[i__2].i = 0.f;
00327                 }
00328                 jx += *incx;
00329 /* L80: */
00330             }
00331         }
00332     }
00333 
00334     return 0;
00335 
00336 /*     End of CHER  . */
00337 
00338 } /* cher_ */


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