zgbmv.c
Go to the documentation of this file.
00001 /* zgbmv.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 zgbmv_(char *trans, integer *m, integer *n, integer *kl, 
00017         integer *ku, doublecomplex *alpha, doublecomplex *a, integer *lda, 
00018         doublecomplex *x, integer *incx, doublecomplex *beta, doublecomplex *
00019         y, integer *incy)
00020 {
00021     /* System generated locals */
00022     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00023     doublecomplex z__1, z__2, z__3;
00024 
00025     /* Builtin functions */
00026     void d_cnjg(doublecomplex *, doublecomplex *);
00027 
00028     /* Local variables */
00029     integer i__, j, k, ix, iy, jx, jy, kx, ky, kup1, info;
00030     doublecomplex temp;
00031     integer lenx, leny;
00032     extern logical lsame_(char *, char *);
00033     extern /* Subroutine */ int xerbla_(char *, integer *);
00034     logical noconj;
00035 
00036 /*     .. Scalar Arguments .. */
00037 /*     .. */
00038 /*     .. Array Arguments .. */
00039 /*     .. */
00040 
00041 /*  Purpose */
00042 /*  ======= */
00043 
00044 /*  ZGBMV  performs one of the matrix-vector operations */
00045 
00046 /*     y := alpha*A*x + beta*y,   or   y := alpha*A'*x + beta*y,   or */
00047 
00048 /*     y := alpha*conjg( A' )*x + beta*y, */
00049 
00050 /*  where alpha and beta are scalars, x and y are vectors and A is an */
00051 /*  m by n band matrix, with kl sub-diagonals and ku super-diagonals. */
00052 
00053 /*  Arguments */
00054 /*  ========== */
00055 
00056 /*  TRANS  - CHARACTER*1. */
00057 /*           On entry, TRANS specifies the operation to be performed as */
00058 /*           follows: */
00059 
00060 /*              TRANS = 'N' or 'n'   y := alpha*A*x + beta*y. */
00061 
00062 /*              TRANS = 'T' or 't'   y := alpha*A'*x + beta*y. */
00063 
00064 /*              TRANS = 'C' or 'c'   y := alpha*conjg( A' )*x + beta*y. */
00065 
00066 /*           Unchanged on exit. */
00067 
00068 /*  M      - INTEGER. */
00069 /*           On entry, M specifies the number of rows of the matrix A. */
00070 /*           M must be at least zero. */
00071 /*           Unchanged on exit. */
00072 
00073 /*  N      - INTEGER. */
00074 /*           On entry, N specifies the number of columns of the matrix A. */
00075 /*           N must be at least zero. */
00076 /*           Unchanged on exit. */
00077 
00078 /*  KL     - INTEGER. */
00079 /*           On entry, KL specifies the number of sub-diagonals of the */
00080 /*           matrix A. KL must satisfy  0 .le. KL. */
00081 /*           Unchanged on exit. */
00082 
00083 /*  KU     - INTEGER. */
00084 /*           On entry, KU specifies the number of super-diagonals of the */
00085 /*           matrix A. KU must satisfy  0 .le. KU. */
00086 /*           Unchanged on exit. */
00087 
00088 /*  ALPHA  - COMPLEX*16      . */
00089 /*           On entry, ALPHA specifies the scalar alpha. */
00090 /*           Unchanged on exit. */
00091 
00092 /*  A      - COMPLEX*16       array of DIMENSION ( LDA, n ). */
00093 /*           Before entry, the leading ( kl + ku + 1 ) by n part of the */
00094 /*           array A must contain the matrix of coefficients, supplied */
00095 /*           column by column, with the leading diagonal of the matrix in */
00096 /*           row ( ku + 1 ) of the array, the first super-diagonal */
00097 /*           starting at position 2 in row ku, the first sub-diagonal */
00098 /*           starting at position 1 in row ( ku + 2 ), and so on. */
00099 /*           Elements in the array A that do not correspond to elements */
00100 /*           in the band matrix (such as the top left ku by ku triangle) */
00101 /*           are not referenced. */
00102 /*           The following program segment will transfer a band matrix */
00103 /*           from conventional full matrix storage to band storage: */
00104 
00105 /*                 DO 20, J = 1, N */
00106 /*                    K = KU + 1 - J */
00107 /*                    DO 10, I = MAX( 1, J - KU ), MIN( M, J + KL ) */
00108 /*                       A( K + I, J ) = matrix( I, J ) */
00109 /*              10    CONTINUE */
00110 /*              20 CONTINUE */
00111 
00112 /*           Unchanged on exit. */
00113 
00114 /*  LDA    - INTEGER. */
00115 /*           On entry, LDA specifies the first dimension of A as declared */
00116 /*           in the calling (sub) program. LDA must be at least */
00117 /*           ( kl + ku + 1 ). */
00118 /*           Unchanged on exit. */
00119 
00120 /*  X      - COMPLEX*16       array of DIMENSION at least */
00121 /*           ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */
00122 /*           and at least */
00123 /*           ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */
00124 /*           Before entry, the incremented array X must contain the */
00125 /*           vector x. */
00126 /*           Unchanged on exit. */
00127 
00128 /*  INCX   - INTEGER. */
00129 /*           On entry, INCX specifies the increment for the elements of */
00130 /*           X. INCX must not be zero. */
00131 /*           Unchanged on exit. */
00132 
00133 /*  BETA   - COMPLEX*16      . */
00134 /*           On entry, BETA specifies the scalar beta. When BETA is */
00135 /*           supplied as zero then Y need not be set on input. */
00136 /*           Unchanged on exit. */
00137 
00138 /*  Y      - COMPLEX*16       array of DIMENSION at least */
00139 /*           ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */
00140 /*           and at least */
00141 /*           ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */
00142 /*           Before entry, the incremented array Y must contain the */
00143 /*           vector y. On exit, Y is overwritten by the updated vector y. */
00144 
00145 
00146 /*  INCY   - INTEGER. */
00147 /*           On entry, INCY specifies the increment for the elements of */
00148 /*           Y. INCY must not be zero. */
00149 /*           Unchanged on exit. */
00150 
00151 
00152 /*  Level 2 Blas routine. */
00153 
00154 /*  -- Written on 22-October-1986. */
00155 /*     Jack Dongarra, Argonne National Lab. */
00156 /*     Jeremy Du Croz, Nag Central Office. */
00157 /*     Sven Hammarling, Nag Central Office. */
00158 /*     Richard Hanson, Sandia National Labs. */
00159 
00160 
00161 /*     .. Parameters .. */
00162 /*     .. */
00163 /*     .. Local Scalars .. */
00164 /*     .. */
00165 /*     .. External Functions .. */
00166 /*     .. */
00167 /*     .. External Subroutines .. */
00168 /*     .. */
00169 /*     .. Intrinsic Functions .. */
00170 /*     .. */
00171 
00172 /*     Test the input parameters. */
00173 
00174     /* Parameter adjustments */
00175     a_dim1 = *lda;
00176     a_offset = 1 + a_dim1;
00177     a -= a_offset;
00178     --x;
00179     --y;
00180 
00181     /* Function Body */
00182     info = 0;
00183     if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C")
00184             ) {
00185         info = 1;
00186     } else if (*m < 0) {
00187         info = 2;
00188     } else if (*n < 0) {
00189         info = 3;
00190     } else if (*kl < 0) {
00191         info = 4;
00192     } else if (*ku < 0) {
00193         info = 5;
00194     } else if (*lda < *kl + *ku + 1) {
00195         info = 8;
00196     } else if (*incx == 0) {
00197         info = 10;
00198     } else if (*incy == 0) {
00199         info = 13;
00200     }
00201     if (info != 0) {
00202         xerbla_("ZGBMV ", &info);
00203         return 0;
00204     }
00205 
00206 /*     Quick return if possible. */
00207 
00208     if (*m == 0 || *n == 0 || alpha->r == 0. && alpha->i == 0. && (beta->r == 
00209             1. && beta->i == 0.)) {
00210         return 0;
00211     }
00212 
00213     noconj = lsame_(trans, "T");
00214 
00215 /*     Set  LENX  and  LENY, the lengths of the vectors x and y, and set */
00216 /*     up the start points in  X  and  Y. */
00217 
00218     if (lsame_(trans, "N")) {
00219         lenx = *n;
00220         leny = *m;
00221     } else {
00222         lenx = *m;
00223         leny = *n;
00224     }
00225     if (*incx > 0) {
00226         kx = 1;
00227     } else {
00228         kx = 1 - (lenx - 1) * *incx;
00229     }
00230     if (*incy > 0) {
00231         ky = 1;
00232     } else {
00233         ky = 1 - (leny - 1) * *incy;
00234     }
00235 
00236 /*     Start the operations. In this version the elements of A are */
00237 /*     accessed sequentially with one pass through the band part of A. */
00238 
00239 /*     First form  y := beta*y. */
00240 
00241     if (beta->r != 1. || beta->i != 0.) {
00242         if (*incy == 1) {
00243             if (beta->r == 0. && beta->i == 0.) {
00244                 i__1 = leny;
00245                 for (i__ = 1; i__ <= i__1; ++i__) {
00246                     i__2 = i__;
00247                     y[i__2].r = 0., y[i__2].i = 0.;
00248 /* L10: */
00249                 }
00250             } else {
00251                 i__1 = leny;
00252                 for (i__ = 1; i__ <= i__1; ++i__) {
00253                     i__2 = i__;
00254                     i__3 = i__;
00255                     z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i, 
00256                             z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
00257                             .r;
00258                     y[i__2].r = z__1.r, y[i__2].i = z__1.i;
00259 /* L20: */
00260                 }
00261             }
00262         } else {
00263             iy = ky;
00264             if (beta->r == 0. && beta->i == 0.) {
00265                 i__1 = leny;
00266                 for (i__ = 1; i__ <= i__1; ++i__) {
00267                     i__2 = iy;
00268                     y[i__2].r = 0., y[i__2].i = 0.;
00269                     iy += *incy;
00270 /* L30: */
00271                 }
00272             } else {
00273                 i__1 = leny;
00274                 for (i__ = 1; i__ <= i__1; ++i__) {
00275                     i__2 = iy;
00276                     i__3 = iy;
00277                     z__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i, 
00278                             z__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
00279                             .r;
00280                     y[i__2].r = z__1.r, y[i__2].i = z__1.i;
00281                     iy += *incy;
00282 /* L40: */
00283                 }
00284             }
00285         }
00286     }
00287     if (alpha->r == 0. && alpha->i == 0.) {
00288         return 0;
00289     }
00290     kup1 = *ku + 1;
00291     if (lsame_(trans, "N")) {
00292 
00293 /*        Form  y := alpha*A*x + y. */
00294 
00295         jx = kx;
00296         if (*incy == 1) {
00297             i__1 = *n;
00298             for (j = 1; j <= i__1; ++j) {
00299                 i__2 = jx;
00300                 if (x[i__2].r != 0. || x[i__2].i != 0.) {
00301                     i__2 = jx;
00302                     z__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, 
00303                             z__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
00304                             .r;
00305                     temp.r = z__1.r, temp.i = z__1.i;
00306                     k = kup1 - j;
00307 /* Computing MAX */
00308                     i__2 = 1, i__3 = j - *ku;
00309 /* Computing MIN */
00310                     i__5 = *m, i__6 = j + *kl;
00311                     i__4 = min(i__5,i__6);
00312                     for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00313                         i__2 = i__;
00314                         i__3 = i__;
00315                         i__5 = k + i__ + j * a_dim1;
00316                         z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i, 
00317                                 z__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
00318                                 .r;
00319                         z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + 
00320                                 z__2.i;
00321                         y[i__2].r = z__1.r, y[i__2].i = z__1.i;
00322 /* L50: */
00323                     }
00324                 }
00325                 jx += *incx;
00326 /* L60: */
00327             }
00328         } else {
00329             i__1 = *n;
00330             for (j = 1; j <= i__1; ++j) {
00331                 i__4 = jx;
00332                 if (x[i__4].r != 0. || x[i__4].i != 0.) {
00333                     i__4 = jx;
00334                     z__1.r = alpha->r * x[i__4].r - alpha->i * x[i__4].i, 
00335                             z__1.i = alpha->r * x[i__4].i + alpha->i * x[i__4]
00336                             .r;
00337                     temp.r = z__1.r, temp.i = z__1.i;
00338                     iy = ky;
00339                     k = kup1 - j;
00340 /* Computing MAX */
00341                     i__4 = 1, i__2 = j - *ku;
00342 /* Computing MIN */
00343                     i__5 = *m, i__6 = j + *kl;
00344                     i__3 = min(i__5,i__6);
00345                     for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
00346                         i__4 = iy;
00347                         i__2 = iy;
00348                         i__5 = k + i__ + j * a_dim1;
00349                         z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i, 
00350                                 z__2.i = temp.r * a[i__5].i + temp.i * a[i__5]
00351                                 .r;
00352                         z__1.r = y[i__2].r + z__2.r, z__1.i = y[i__2].i + 
00353                                 z__2.i;
00354                         y[i__4].r = z__1.r, y[i__4].i = z__1.i;
00355                         iy += *incy;
00356 /* L70: */
00357                     }
00358                 }
00359                 jx += *incx;
00360                 if (j > *ku) {
00361                     ky += *incy;
00362                 }
00363 /* L80: */
00364             }
00365         }
00366     } else {
00367 
00368 /*        Form  y := alpha*A'*x + y  or  y := alpha*conjg( A' )*x + y. */
00369 
00370         jy = ky;
00371         if (*incx == 1) {
00372             i__1 = *n;
00373             for (j = 1; j <= i__1; ++j) {
00374                 temp.r = 0., temp.i = 0.;
00375                 k = kup1 - j;
00376                 if (noconj) {
00377 /* Computing MAX */
00378                     i__3 = 1, i__4 = j - *ku;
00379 /* Computing MIN */
00380                     i__5 = *m, i__6 = j + *kl;
00381                     i__2 = min(i__5,i__6);
00382                     for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) {
00383                         i__3 = k + i__ + j * a_dim1;
00384                         i__4 = i__;
00385                         z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4]
00386                                 .i, z__2.i = a[i__3].r * x[i__4].i + a[i__3]
00387                                 .i * x[i__4].r;
00388                         z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
00389                         temp.r = z__1.r, temp.i = z__1.i;
00390 /* L90: */
00391                     }
00392                 } else {
00393 /* Computing MAX */
00394                     i__2 = 1, i__3 = j - *ku;
00395 /* Computing MIN */
00396                     i__5 = *m, i__6 = j + *kl;
00397                     i__4 = min(i__5,i__6);
00398                     for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00399                         d_cnjg(&z__3, &a[k + i__ + j * a_dim1]);
00400                         i__2 = i__;
00401                         z__2.r = z__3.r * x[i__2].r - z__3.i * x[i__2].i, 
00402                                 z__2.i = z__3.r * x[i__2].i + z__3.i * x[i__2]
00403                                 .r;
00404                         z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
00405                         temp.r = z__1.r, temp.i = z__1.i;
00406 /* L100: */
00407                     }
00408                 }
00409                 i__4 = jy;
00410                 i__2 = jy;
00411                 z__2.r = alpha->r * temp.r - alpha->i * temp.i, z__2.i = 
00412                         alpha->r * temp.i + alpha->i * temp.r;
00413                 z__1.r = y[i__2].r + z__2.r, z__1.i = y[i__2].i + z__2.i;
00414                 y[i__4].r = z__1.r, y[i__4].i = z__1.i;
00415                 jy += *incy;
00416 /* L110: */
00417             }
00418         } else {
00419             i__1 = *n;
00420             for (j = 1; j <= i__1; ++j) {
00421                 temp.r = 0., temp.i = 0.;
00422                 ix = kx;
00423                 k = kup1 - j;
00424                 if (noconj) {
00425 /* Computing MAX */
00426                     i__4 = 1, i__2 = j - *ku;
00427 /* Computing MIN */
00428                     i__5 = *m, i__6 = j + *kl;
00429                     i__3 = min(i__5,i__6);
00430                     for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
00431                         i__4 = k + i__ + j * a_dim1;
00432                         i__2 = ix;
00433                         z__2.r = a[i__4].r * x[i__2].r - a[i__4].i * x[i__2]
00434                                 .i, z__2.i = a[i__4].r * x[i__2].i + a[i__4]
00435                                 .i * x[i__2].r;
00436                         z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
00437                         temp.r = z__1.r, temp.i = z__1.i;
00438                         ix += *incx;
00439 /* L120: */
00440                     }
00441                 } else {
00442 /* Computing MAX */
00443                     i__3 = 1, i__4 = j - *ku;
00444 /* Computing MIN */
00445                     i__5 = *m, i__6 = j + *kl;
00446                     i__2 = min(i__5,i__6);
00447                     for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) {
00448                         d_cnjg(&z__3, &a[k + i__ + j * a_dim1]);
00449                         i__3 = ix;
00450                         z__2.r = z__3.r * x[i__3].r - z__3.i * x[i__3].i, 
00451                                 z__2.i = z__3.r * x[i__3].i + z__3.i * x[i__3]
00452                                 .r;
00453                         z__1.r = temp.r + z__2.r, z__1.i = temp.i + z__2.i;
00454                         temp.r = z__1.r, temp.i = z__1.i;
00455                         ix += *incx;
00456 /* L130: */
00457                     }
00458                 }
00459                 i__2 = jy;
00460                 i__3 = jy;
00461                 z__2.r = alpha->r * temp.r - alpha->i * temp.i, z__2.i = 
00462                         alpha->r * temp.i + alpha->i * temp.r;
00463                 z__1.r = y[i__3].r + z__2.r, z__1.i = y[i__3].i + z__2.i;
00464                 y[i__2].r = z__1.r, y[i__2].i = z__1.i;
00465                 jy += *incy;
00466                 if (j > *ku) {
00467                     kx += *incx;
00468                 }
00469 /* L140: */
00470             }
00471         }
00472     }
00473 
00474     return 0;
00475 
00476 /*     End of ZGBMV . */
00477 
00478 } /* zgbmv_ */


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