dspmv.c
Go to the documentation of this file.
00001 /* dspmv.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 dspmv_(char *uplo, integer *n, doublereal *alpha, 
00017         doublereal *ap, doublereal *x, integer *incx, doublereal *beta, 
00018         doublereal *y, integer *incy)
00019 {
00020     /* System generated locals */
00021     integer i__1, i__2;
00022 
00023     /* Local variables */
00024     integer i__, j, k, kk, ix, iy, jx, jy, kx, ky, info;
00025     doublereal temp1, temp2;
00026     extern logical lsame_(char *, char *);
00027     extern /* Subroutine */ int xerbla_(char *, integer *);
00028 
00029 /*     .. Scalar Arguments .. */
00030 /*     .. */
00031 /*     .. Array Arguments .. */
00032 /*     .. */
00033 
00034 /*  Purpose */
00035 /*  ======= */
00036 
00037 /*  DSPMV  performs the matrix-vector operation */
00038 
00039 /*     y := alpha*A*x + beta*y, */
00040 
00041 /*  where alpha and beta are scalars, x and y are n element vectors and */
00042 /*  A is an n by n symmetric matrix, supplied in packed form. */
00043 
00044 /*  Arguments */
00045 /*  ========== */
00046 
00047 /*  UPLO   - CHARACTER*1. */
00048 /*           On entry, UPLO specifies whether the upper or lower */
00049 /*           triangular part of the matrix A is supplied in the packed */
00050 /*           array AP as follows: */
00051 
00052 /*              UPLO = 'U' or 'u'   The upper triangular part of A is */
00053 /*                                  supplied in AP. */
00054 
00055 /*              UPLO = 'L' or 'l'   The lower triangular part of A is */
00056 /*                                  supplied in AP. */
00057 
00058 /*           Unchanged on exit. */
00059 
00060 /*  N      - INTEGER. */
00061 /*           On entry, N specifies the order of the matrix A. */
00062 /*           N must be at least zero. */
00063 /*           Unchanged on exit. */
00064 
00065 /*  ALPHA  - DOUBLE PRECISION. */
00066 /*           On entry, ALPHA specifies the scalar alpha. */
00067 /*           Unchanged on exit. */
00068 
00069 /*  AP     - DOUBLE PRECISION array of DIMENSION at least */
00070 /*           ( ( n*( n + 1 ) )/2 ). */
00071 /*           Before entry with UPLO = 'U' or 'u', the array AP must */
00072 /*           contain the upper triangular part of the symmetric matrix */
00073 /*           packed sequentially, column by column, so that AP( 1 ) */
00074 /*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
00075 /*           and a( 2, 2 ) respectively, and so on. */
00076 /*           Before entry with UPLO = 'L' or 'l', the array AP must */
00077 /*           contain the lower triangular part of the symmetric matrix */
00078 /*           packed sequentially, column by column, so that AP( 1 ) */
00079 /*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
00080 /*           and a( 3, 1 ) respectively, and so on. */
00081 /*           Unchanged on exit. */
00082 
00083 /*  X      - DOUBLE PRECISION array of dimension at least */
00084 /*           ( 1 + ( n - 1 )*abs( INCX ) ). */
00085 /*           Before entry, the incremented array X must contain the n */
00086 /*           element vector x. */
00087 /*           Unchanged on exit. */
00088 
00089 /*  INCX   - INTEGER. */
00090 /*           On entry, INCX specifies the increment for the elements of */
00091 /*           X. INCX must not be zero. */
00092 /*           Unchanged on exit. */
00093 
00094 /*  BETA   - DOUBLE PRECISION. */
00095 /*           On entry, BETA specifies the scalar beta. When BETA is */
00096 /*           supplied as zero then Y need not be set on input. */
00097 /*           Unchanged on exit. */
00098 
00099 /*  Y      - DOUBLE PRECISION array of dimension at least */
00100 /*           ( 1 + ( n - 1 )*abs( INCY ) ). */
00101 /*           Before entry, the incremented array Y must contain the n */
00102 /*           element vector y. On exit, Y is overwritten by the updated */
00103 /*           vector y. */
00104 
00105 /*  INCY   - INTEGER. */
00106 /*           On entry, INCY specifies the increment for the elements of */
00107 /*           Y. INCY must not be zero. */
00108 /*           Unchanged on exit. */
00109 
00110 
00111 /*  Level 2 Blas routine. */
00112 
00113 /*  -- Written on 22-October-1986. */
00114 /*     Jack Dongarra, Argonne National Lab. */
00115 /*     Jeremy Du Croz, Nag Central Office. */
00116 /*     Sven Hammarling, Nag Central Office. */
00117 /*     Richard Hanson, Sandia National Labs. */
00118 
00119 
00120 /*     .. Parameters .. */
00121 /*     .. */
00122 /*     .. Local Scalars .. */
00123 /*     .. */
00124 /*     .. External Functions .. */
00125 /*     .. */
00126 /*     .. External Subroutines .. */
00127 /*     .. */
00128 
00129 /*     Test the input parameters. */
00130 
00131     /* Parameter adjustments */
00132     --y;
00133     --x;
00134     --ap;
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 = 6;
00144     } else if (*incy == 0) {
00145         info = 9;
00146     }
00147     if (info != 0) {
00148         xerbla_("DSPMV ", &info);
00149         return 0;
00150     }
00151 
00152 /*     Quick return if possible. */
00153 
00154     if (*n == 0 || *alpha == 0. && *beta == 1.) {
00155         return 0;
00156     }
00157 
00158 /*     Set up the start points in  X  and  Y. */
00159 
00160     if (*incx > 0) {
00161         kx = 1;
00162     } else {
00163         kx = 1 - (*n - 1) * *incx;
00164     }
00165     if (*incy > 0) {
00166         ky = 1;
00167     } else {
00168         ky = 1 - (*n - 1) * *incy;
00169     }
00170 
00171 /*     Start the operations. In this version the elements of the array AP */
00172 /*     are accessed sequentially with one pass through AP. */
00173 
00174 /*     First form  y := beta*y. */
00175 
00176     if (*beta != 1.) {
00177         if (*incy == 1) {
00178             if (*beta == 0.) {
00179                 i__1 = *n;
00180                 for (i__ = 1; i__ <= i__1; ++i__) {
00181                     y[i__] = 0.;
00182 /* L10: */
00183                 }
00184             } else {
00185                 i__1 = *n;
00186                 for (i__ = 1; i__ <= i__1; ++i__) {
00187                     y[i__] = *beta * y[i__];
00188 /* L20: */
00189                 }
00190             }
00191         } else {
00192             iy = ky;
00193             if (*beta == 0.) {
00194                 i__1 = *n;
00195                 for (i__ = 1; i__ <= i__1; ++i__) {
00196                     y[iy] = 0.;
00197                     iy += *incy;
00198 /* L30: */
00199                 }
00200             } else {
00201                 i__1 = *n;
00202                 for (i__ = 1; i__ <= i__1; ++i__) {
00203                     y[iy] = *beta * y[iy];
00204                     iy += *incy;
00205 /* L40: */
00206                 }
00207             }
00208         }
00209     }
00210     if (*alpha == 0.) {
00211         return 0;
00212     }
00213     kk = 1;
00214     if (lsame_(uplo, "U")) {
00215 
00216 /*        Form  y  when AP contains the upper triangle. */
00217 
00218         if (*incx == 1 && *incy == 1) {
00219             i__1 = *n;
00220             for (j = 1; j <= i__1; ++j) {
00221                 temp1 = *alpha * x[j];
00222                 temp2 = 0.;
00223                 k = kk;
00224                 i__2 = j - 1;
00225                 for (i__ = 1; i__ <= i__2; ++i__) {
00226                     y[i__] += temp1 * ap[k];
00227                     temp2 += ap[k] * x[i__];
00228                     ++k;
00229 /* L50: */
00230                 }
00231                 y[j] = y[j] + temp1 * ap[kk + j - 1] + *alpha * temp2;
00232                 kk += j;
00233 /* L60: */
00234             }
00235         } else {
00236             jx = kx;
00237             jy = ky;
00238             i__1 = *n;
00239             for (j = 1; j <= i__1; ++j) {
00240                 temp1 = *alpha * x[jx];
00241                 temp2 = 0.;
00242                 ix = kx;
00243                 iy = ky;
00244                 i__2 = kk + j - 2;
00245                 for (k = kk; k <= i__2; ++k) {
00246                     y[iy] += temp1 * ap[k];
00247                     temp2 += ap[k] * x[ix];
00248                     ix += *incx;
00249                     iy += *incy;
00250 /* L70: */
00251                 }
00252                 y[jy] = y[jy] + temp1 * ap[kk + j - 1] + *alpha * temp2;
00253                 jx += *incx;
00254                 jy += *incy;
00255                 kk += j;
00256 /* L80: */
00257             }
00258         }
00259     } else {
00260 
00261 /*        Form  y  when AP contains the lower triangle. */
00262 
00263         if (*incx == 1 && *incy == 1) {
00264             i__1 = *n;
00265             for (j = 1; j <= i__1; ++j) {
00266                 temp1 = *alpha * x[j];
00267                 temp2 = 0.;
00268                 y[j] += temp1 * ap[kk];
00269                 k = kk + 1;
00270                 i__2 = *n;
00271                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00272                     y[i__] += temp1 * ap[k];
00273                     temp2 += ap[k] * x[i__];
00274                     ++k;
00275 /* L90: */
00276                 }
00277                 y[j] += *alpha * temp2;
00278                 kk += *n - j + 1;
00279 /* L100: */
00280             }
00281         } else {
00282             jx = kx;
00283             jy = ky;
00284             i__1 = *n;
00285             for (j = 1; j <= i__1; ++j) {
00286                 temp1 = *alpha * x[jx];
00287                 temp2 = 0.;
00288                 y[jy] += temp1 * ap[kk];
00289                 ix = jx;
00290                 iy = jy;
00291                 i__2 = kk + *n - j;
00292                 for (k = kk + 1; k <= i__2; ++k) {
00293                     ix += *incx;
00294                     iy += *incy;
00295                     y[iy] += temp1 * ap[k];
00296                     temp2 += ap[k] * x[ix];
00297 /* L110: */
00298                 }
00299                 y[jy] += *alpha * temp2;
00300                 jx += *incx;
00301                 jy += *incy;
00302                 kk += *n - j + 1;
00303 /* L120: */
00304             }
00305         }
00306     }
00307 
00308     return 0;
00309 
00310 /*     End of DSPMV . */
00311 
00312 } /* dspmv_ */


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