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


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