mndspmv.cxx

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

Generated on Tue Jul 5 14:37:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1