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


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