ctrmv.c
Go to the documentation of this file.
00001 /* ctrmv.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 ctrmv_(char *uplo, char *trans, char *diag, integer *n, 
00017         complex *a, integer *lda, complex *x, integer *incx)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
00021     complex q__1, q__2, q__3;
00022 
00023     /* Builtin functions */
00024     void r_cnjg(complex *, complex *);
00025 
00026     /* Local variables */
00027     integer i__, j, ix, jx, kx, info;
00028     complex temp;
00029     extern logical lsame_(char *, char *);
00030     extern /* Subroutine */ int xerbla_(char *, integer *);
00031     logical noconj, nounit;
00032 
00033 /*     .. Scalar Arguments .. */
00034 /*     .. */
00035 /*     .. Array Arguments .. */
00036 /*     .. */
00037 
00038 /*  Purpose */
00039 /*  ======= */
00040 
00041 /*  CTRMV  performs one of the matrix-vector operations */
00042 
00043 /*     x := A*x,   or   x := A'*x,   or   x := conjg( A' )*x, */
00044 
00045 /*  where x is an n element vector and  A is an n by n unit, or non-unit, */
00046 /*  upper or lower triangular matrix. */
00047 
00048 /*  Arguments */
00049 /*  ========== */
00050 
00051 /*  UPLO   - CHARACTER*1. */
00052 /*           On entry, UPLO specifies whether the matrix is an upper or */
00053 /*           lower triangular matrix as follows: */
00054 
00055 /*              UPLO = 'U' or 'u'   A is an upper triangular matrix. */
00056 
00057 /*              UPLO = 'L' or 'l'   A is a lower triangular matrix. */
00058 
00059 /*           Unchanged on exit. */
00060 
00061 /*  TRANS  - CHARACTER*1. */
00062 /*           On entry, TRANS specifies the operation to be performed as */
00063 /*           follows: */
00064 
00065 /*              TRANS = 'N' or 'n'   x := A*x. */
00066 
00067 /*              TRANS = 'T' or 't'   x := A'*x. */
00068 
00069 /*              TRANS = 'C' or 'c'   x := conjg( A' )*x. */
00070 
00071 /*           Unchanged on exit. */
00072 
00073 /*  DIAG   - CHARACTER*1. */
00074 /*           On entry, DIAG specifies whether or not A is unit */
00075 /*           triangular as follows: */
00076 
00077 /*              DIAG = 'U' or 'u'   A is assumed to be unit triangular. */
00078 
00079 /*              DIAG = 'N' or 'n'   A is not assumed to be unit */
00080 /*                                  triangular. */
00081 
00082 /*           Unchanged on exit. */
00083 
00084 /*  N      - INTEGER. */
00085 /*           On entry, N specifies the order of the matrix A. */
00086 /*           N must be at least zero. */
00087 /*           Unchanged on exit. */
00088 
00089 /*  A      - COMPLEX          array of DIMENSION ( LDA, n ). */
00090 /*           Before entry with  UPLO = 'U' or 'u', the leading n by n */
00091 /*           upper triangular part of the array A must contain the upper */
00092 /*           triangular matrix and the strictly lower triangular part of */
00093 /*           A is not referenced. */
00094 /*           Before entry with UPLO = 'L' or 'l', the leading n by n */
00095 /*           lower triangular part of the array A must contain the lower */
00096 /*           triangular matrix and the strictly upper triangular part of */
00097 /*           A is not referenced. */
00098 /*           Note that when  DIAG = 'U' or 'u', the diagonal elements of */
00099 /*           A are not referenced either, but are assumed to be unity. */
00100 /*           Unchanged on exit. */
00101 
00102 /*  LDA    - INTEGER. */
00103 /*           On entry, LDA specifies the first dimension of A as declared */
00104 /*           in the calling (sub) program. LDA must be at least */
00105 /*           max( 1, n ). */
00106 /*           Unchanged on exit. */
00107 
00108 /*  X      - COMPLEX          array of dimension at least */
00109 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00110 /*           Before entry, the incremented array X must contain the n */
00111 /*           element vector x. On exit, X is overwritten with the */
00112 /*           tranformed vector x. */
00113 
00114 /*  INCX   - INTEGER. */
00115 /*           On entry, INCX specifies the increment for the elements of */
00116 /*           X. INCX must not be zero. */
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     a_dim1 = *lda;
00144     a_offset = 1 + a_dim1;
00145     a -= a_offset;
00146     --x;
00147 
00148     /* Function Body */
00149     info = 0;
00150     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00151         info = 1;
00152     } else if (! lsame_(trans, "N") && ! lsame_(trans, 
00153             "T") && ! lsame_(trans, "C")) {
00154         info = 2;
00155     } else if (! lsame_(diag, "U") && ! lsame_(diag, 
00156             "N")) {
00157         info = 3;
00158     } else if (*n < 0) {
00159         info = 4;
00160     } else if (*lda < max(1,*n)) {
00161         info = 6;
00162     } else if (*incx == 0) {
00163         info = 8;
00164     }
00165     if (info != 0) {
00166         xerbla_("CTRMV ", &info);
00167         return 0;
00168     }
00169 
00170 /*     Quick return if possible. */
00171 
00172     if (*n == 0) {
00173         return 0;
00174     }
00175 
00176     noconj = lsame_(trans, "T");
00177     nounit = lsame_(diag, "N");
00178 
00179 /*     Set up the start point in X if the increment is not unity. This */
00180 /*     will be  ( N - 1 )*INCX  too small for descending loops. */
00181 
00182     if (*incx <= 0) {
00183         kx = 1 - (*n - 1) * *incx;
00184     } else if (*incx != 1) {
00185         kx = 1;
00186     }
00187 
00188 /*     Start the operations. In this version the elements of A are */
00189 /*     accessed sequentially with one pass through A. */
00190 
00191     if (lsame_(trans, "N")) {
00192 
00193 /*        Form  x := A*x. */
00194 
00195         if (lsame_(uplo, "U")) {
00196             if (*incx == 1) {
00197                 i__1 = *n;
00198                 for (j = 1; j <= i__1; ++j) {
00199                     i__2 = j;
00200                     if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
00201                         i__2 = j;
00202                         temp.r = x[i__2].r, temp.i = x[i__2].i;
00203                         i__2 = j - 1;
00204                         for (i__ = 1; i__ <= i__2; ++i__) {
00205                             i__3 = i__;
00206                             i__4 = i__;
00207                             i__5 = i__ + j * a_dim1;
00208                             q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i, 
00209                                     q__2.i = temp.r * a[i__5].i + temp.i * a[
00210                                     i__5].r;
00211                             q__1.r = x[i__4].r + q__2.r, q__1.i = x[i__4].i + 
00212                                     q__2.i;
00213                             x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00214 /* L10: */
00215                         }
00216                         if (nounit) {
00217                             i__2 = j;
00218                             i__3 = j;
00219                             i__4 = j + j * a_dim1;
00220                             q__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
00221                                     i__4].i, q__1.i = x[i__3].r * a[i__4].i + 
00222                                     x[i__3].i * a[i__4].r;
00223                             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00224                         }
00225                     }
00226 /* L20: */
00227                 }
00228             } else {
00229                 jx = kx;
00230                 i__1 = *n;
00231                 for (j = 1; j <= i__1; ++j) {
00232                     i__2 = jx;
00233                     if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
00234                         i__2 = jx;
00235                         temp.r = x[i__2].r, temp.i = x[i__2].i;
00236                         ix = kx;
00237                         i__2 = j - 1;
00238                         for (i__ = 1; i__ <= i__2; ++i__) {
00239                             i__3 = ix;
00240                             i__4 = ix;
00241                             i__5 = i__ + j * a_dim1;
00242                             q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i, 
00243                                     q__2.i = temp.r * a[i__5].i + temp.i * a[
00244                                     i__5].r;
00245                             q__1.r = x[i__4].r + q__2.r, q__1.i = x[i__4].i + 
00246                                     q__2.i;
00247                             x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00248                             ix += *incx;
00249 /* L30: */
00250                         }
00251                         if (nounit) {
00252                             i__2 = jx;
00253                             i__3 = jx;
00254                             i__4 = j + j * a_dim1;
00255                             q__1.r = x[i__3].r * a[i__4].r - x[i__3].i * a[
00256                                     i__4].i, q__1.i = x[i__3].r * a[i__4].i + 
00257                                     x[i__3].i * a[i__4].r;
00258                             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00259                         }
00260                     }
00261                     jx += *incx;
00262 /* L40: */
00263                 }
00264             }
00265         } else {
00266             if (*incx == 1) {
00267                 for (j = *n; j >= 1; --j) {
00268                     i__1 = j;
00269                     if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
00270                         i__1 = j;
00271                         temp.r = x[i__1].r, temp.i = x[i__1].i;
00272                         i__1 = j + 1;
00273                         for (i__ = *n; i__ >= i__1; --i__) {
00274                             i__2 = i__;
00275                             i__3 = i__;
00276                             i__4 = i__ + j * a_dim1;
00277                             q__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i, 
00278                                     q__2.i = temp.r * a[i__4].i + temp.i * a[
00279                                     i__4].r;
00280                             q__1.r = x[i__3].r + q__2.r, q__1.i = x[i__3].i + 
00281                                     q__2.i;
00282                             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00283 /* L50: */
00284                         }
00285                         if (nounit) {
00286                             i__1 = j;
00287                             i__2 = j;
00288                             i__3 = j + j * a_dim1;
00289                             q__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
00290                                     i__3].i, q__1.i = x[i__2].r * a[i__3].i + 
00291                                     x[i__2].i * a[i__3].r;
00292                             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00293                         }
00294                     }
00295 /* L60: */
00296                 }
00297             } else {
00298                 kx += (*n - 1) * *incx;
00299                 jx = kx;
00300                 for (j = *n; j >= 1; --j) {
00301                     i__1 = jx;
00302                     if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
00303                         i__1 = jx;
00304                         temp.r = x[i__1].r, temp.i = x[i__1].i;
00305                         ix = kx;
00306                         i__1 = j + 1;
00307                         for (i__ = *n; i__ >= i__1; --i__) {
00308                             i__2 = ix;
00309                             i__3 = ix;
00310                             i__4 = i__ + j * a_dim1;
00311                             q__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i, 
00312                                     q__2.i = temp.r * a[i__4].i + temp.i * a[
00313                                     i__4].r;
00314                             q__1.r = x[i__3].r + q__2.r, q__1.i = x[i__3].i + 
00315                                     q__2.i;
00316                             x[i__2].r = q__1.r, x[i__2].i = q__1.i;
00317                             ix -= *incx;
00318 /* L70: */
00319                         }
00320                         if (nounit) {
00321                             i__1 = jx;
00322                             i__2 = jx;
00323                             i__3 = j + j * a_dim1;
00324                             q__1.r = x[i__2].r * a[i__3].r - x[i__2].i * a[
00325                                     i__3].i, q__1.i = x[i__2].r * a[i__3].i + 
00326                                     x[i__2].i * a[i__3].r;
00327                             x[i__1].r = q__1.r, x[i__1].i = q__1.i;
00328                         }
00329                     }
00330                     jx -= *incx;
00331 /* L80: */
00332                 }
00333             }
00334         }
00335     } else {
00336 
00337 /*        Form  x := A'*x  or  x := conjg( A' )*x. */
00338 
00339         if (lsame_(uplo, "U")) {
00340             if (*incx == 1) {
00341                 for (j = *n; j >= 1; --j) {
00342                     i__1 = j;
00343                     temp.r = x[i__1].r, temp.i = x[i__1].i;
00344                     if (noconj) {
00345                         if (nounit) {
00346                             i__1 = j + j * a_dim1;
00347                             q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i, 
00348                                     q__1.i = temp.r * a[i__1].i + temp.i * a[
00349                                     i__1].r;
00350                             temp.r = q__1.r, temp.i = q__1.i;
00351                         }
00352                         for (i__ = j - 1; i__ >= 1; --i__) {
00353                             i__1 = i__ + j * a_dim1;
00354                             i__2 = i__;
00355                             q__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
00356                                     i__2].i, q__2.i = a[i__1].r * x[i__2].i + 
00357                                     a[i__1].i * x[i__2].r;
00358                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00359                                     q__2.i;
00360                             temp.r = q__1.r, temp.i = q__1.i;
00361 /* L90: */
00362                         }
00363                     } else {
00364                         if (nounit) {
00365                             r_cnjg(&q__2, &a[j + j * a_dim1]);
00366                             q__1.r = temp.r * q__2.r - temp.i * q__2.i, 
00367                                     q__1.i = temp.r * q__2.i + temp.i * 
00368                                     q__2.r;
00369                             temp.r = q__1.r, temp.i = q__1.i;
00370                         }
00371                         for (i__ = j - 1; i__ >= 1; --i__) {
00372                             r_cnjg(&q__3, &a[i__ + j * a_dim1]);
00373                             i__1 = i__;
00374                             q__2.r = q__3.r * x[i__1].r - q__3.i * x[i__1].i, 
00375                                     q__2.i = q__3.r * x[i__1].i + q__3.i * x[
00376                                     i__1].r;
00377                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00378                                     q__2.i;
00379                             temp.r = q__1.r, temp.i = q__1.i;
00380 /* L100: */
00381                         }
00382                     }
00383                     i__1 = j;
00384                     x[i__1].r = temp.r, x[i__1].i = temp.i;
00385 /* L110: */
00386                 }
00387             } else {
00388                 jx = kx + (*n - 1) * *incx;
00389                 for (j = *n; j >= 1; --j) {
00390                     i__1 = jx;
00391                     temp.r = x[i__1].r, temp.i = x[i__1].i;
00392                     ix = jx;
00393                     if (noconj) {
00394                         if (nounit) {
00395                             i__1 = j + j * a_dim1;
00396                             q__1.r = temp.r * a[i__1].r - temp.i * a[i__1].i, 
00397                                     q__1.i = temp.r * a[i__1].i + temp.i * a[
00398                                     i__1].r;
00399                             temp.r = q__1.r, temp.i = q__1.i;
00400                         }
00401                         for (i__ = j - 1; i__ >= 1; --i__) {
00402                             ix -= *incx;
00403                             i__1 = i__ + j * a_dim1;
00404                             i__2 = ix;
00405                             q__2.r = a[i__1].r * x[i__2].r - a[i__1].i * x[
00406                                     i__2].i, q__2.i = a[i__1].r * x[i__2].i + 
00407                                     a[i__1].i * x[i__2].r;
00408                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00409                                     q__2.i;
00410                             temp.r = q__1.r, temp.i = q__1.i;
00411 /* L120: */
00412                         }
00413                     } else {
00414                         if (nounit) {
00415                             r_cnjg(&q__2, &a[j + j * a_dim1]);
00416                             q__1.r = temp.r * q__2.r - temp.i * q__2.i, 
00417                                     q__1.i = temp.r * q__2.i + temp.i * 
00418                                     q__2.r;
00419                             temp.r = q__1.r, temp.i = q__1.i;
00420                         }
00421                         for (i__ = j - 1; i__ >= 1; --i__) {
00422                             ix -= *incx;
00423                             r_cnjg(&q__3, &a[i__ + j * a_dim1]);
00424                             i__1 = ix;
00425                             q__2.r = q__3.r * x[i__1].r - q__3.i * x[i__1].i, 
00426                                     q__2.i = q__3.r * x[i__1].i + q__3.i * x[
00427                                     i__1].r;
00428                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00429                                     q__2.i;
00430                             temp.r = q__1.r, temp.i = q__1.i;
00431 /* L130: */
00432                         }
00433                     }
00434                     i__1 = jx;
00435                     x[i__1].r = temp.r, x[i__1].i = temp.i;
00436                     jx -= *incx;
00437 /* L140: */
00438                 }
00439             }
00440         } else {
00441             if (*incx == 1) {
00442                 i__1 = *n;
00443                 for (j = 1; j <= i__1; ++j) {
00444                     i__2 = j;
00445                     temp.r = x[i__2].r, temp.i = x[i__2].i;
00446                     if (noconj) {
00447                         if (nounit) {
00448                             i__2 = j + j * a_dim1;
00449                             q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i, 
00450                                     q__1.i = temp.r * a[i__2].i + temp.i * a[
00451                                     i__2].r;
00452                             temp.r = q__1.r, temp.i = q__1.i;
00453                         }
00454                         i__2 = *n;
00455                         for (i__ = j + 1; i__ <= i__2; ++i__) {
00456                             i__3 = i__ + j * a_dim1;
00457                             i__4 = i__;
00458                             q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
00459                                     i__4].i, q__2.i = a[i__3].r * x[i__4].i + 
00460                                     a[i__3].i * x[i__4].r;
00461                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00462                                     q__2.i;
00463                             temp.r = q__1.r, temp.i = q__1.i;
00464 /* L150: */
00465                         }
00466                     } else {
00467                         if (nounit) {
00468                             r_cnjg(&q__2, &a[j + j * a_dim1]);
00469                             q__1.r = temp.r * q__2.r - temp.i * q__2.i, 
00470                                     q__1.i = temp.r * q__2.i + temp.i * 
00471                                     q__2.r;
00472                             temp.r = q__1.r, temp.i = q__1.i;
00473                         }
00474                         i__2 = *n;
00475                         for (i__ = j + 1; i__ <= i__2; ++i__) {
00476                             r_cnjg(&q__3, &a[i__ + j * a_dim1]);
00477                             i__3 = i__;
00478                             q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, 
00479                                     q__2.i = q__3.r * x[i__3].i + q__3.i * x[
00480                                     i__3].r;
00481                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00482                                     q__2.i;
00483                             temp.r = q__1.r, temp.i = q__1.i;
00484 /* L160: */
00485                         }
00486                     }
00487                     i__2 = j;
00488                     x[i__2].r = temp.r, x[i__2].i = temp.i;
00489 /* L170: */
00490                 }
00491             } else {
00492                 jx = kx;
00493                 i__1 = *n;
00494                 for (j = 1; j <= i__1; ++j) {
00495                     i__2 = jx;
00496                     temp.r = x[i__2].r, temp.i = x[i__2].i;
00497                     ix = jx;
00498                     if (noconj) {
00499                         if (nounit) {
00500                             i__2 = j + j * a_dim1;
00501                             q__1.r = temp.r * a[i__2].r - temp.i * a[i__2].i, 
00502                                     q__1.i = temp.r * a[i__2].i + temp.i * a[
00503                                     i__2].r;
00504                             temp.r = q__1.r, temp.i = q__1.i;
00505                         }
00506                         i__2 = *n;
00507                         for (i__ = j + 1; i__ <= i__2; ++i__) {
00508                             ix += *incx;
00509                             i__3 = i__ + j * a_dim1;
00510                             i__4 = ix;
00511                             q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
00512                                     i__4].i, q__2.i = a[i__3].r * x[i__4].i + 
00513                                     a[i__3].i * x[i__4].r;
00514                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00515                                     q__2.i;
00516                             temp.r = q__1.r, temp.i = q__1.i;
00517 /* L180: */
00518                         }
00519                     } else {
00520                         if (nounit) {
00521                             r_cnjg(&q__2, &a[j + j * a_dim1]);
00522                             q__1.r = temp.r * q__2.r - temp.i * q__2.i, 
00523                                     q__1.i = temp.r * q__2.i + temp.i * 
00524                                     q__2.r;
00525                             temp.r = q__1.r, temp.i = q__1.i;
00526                         }
00527                         i__2 = *n;
00528                         for (i__ = j + 1; i__ <= i__2; ++i__) {
00529                             ix += *incx;
00530                             r_cnjg(&q__3, &a[i__ + j * a_dim1]);
00531                             i__3 = ix;
00532                             q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, 
00533                                     q__2.i = q__3.r * x[i__3].i + q__3.i * x[
00534                                     i__3].r;
00535                             q__1.r = temp.r + q__2.r, q__1.i = temp.i + 
00536                                     q__2.i;
00537                             temp.r = q__1.r, temp.i = q__1.i;
00538 /* L190: */
00539                         }
00540                     }
00541                     i__2 = jx;
00542                     x[i__2].r = temp.r, x[i__2].i = temp.i;
00543                     jx += *incx;
00544 /* L200: */
00545                 }
00546             }
00547         }
00548     }
00549 
00550     return 0;
00551 
00552 /*     End of CTRMV . */
00553 
00554 } /* ctrmv_ */


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