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


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