00001 // @(#)root/minuit2:$Id: mndspr.cxx 20880 2007-11-19 11:23:41Z rdm $ 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 /* dspr.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 mndspr(const char* uplo, unsigned int n, double alpha, 00024 const double* x, int incx, double* ap) { 00025 /* System generated locals */ 00026 int i__1, i__2; 00027 00028 /* Local variables */ 00029 int info; 00030 double temp; 00031 int i__, j, k; 00032 int kk, ix, jx, kx = 0; 00033 00034 /* .. Scalar Arguments .. */ 00035 /* .. Array Arguments .. */ 00036 /* .. */ 00037 00038 /* Purpose */ 00039 /* ======= */ 00040 00041 /* DSPR performs the symmetric rank 1 operation */ 00042 00043 /* A := alpha*x*x' + A, */ 00044 00045 /* where alpha is a real scalar, x is an n element vector and A is an */ 00046 /* n by n symmetric matrix, supplied in packed form. */ 00047 00048 /* Parameters */ 00049 /* ========== */ 00050 00051 /* UPLO - CHARACTER*1. */ 00052 /* On entry, UPLO specifies whether the Upper or Lower */ 00053 /* triangular part of the matrix A is supplied in the packed */ 00054 /* array AP as follows: */ 00055 00056 /* UPLO = 'U' or 'u' The Upper triangular part of A is */ 00057 /* supplied in AP. */ 00058 00059 /* UPLO = 'L' or 'l' The Lower triangular part of A is */ 00060 /* supplied in AP. */ 00061 00062 /* Unchanged on exit. */ 00063 00064 /* N - INTEGER. */ 00065 /* On entry, N specifies the order of the matrix A. */ 00066 /* N must be at least zero. */ 00067 /* Unchanged on exit. */ 00068 00069 /* ALPHA - DOUBLE PRECISION. */ 00070 /* On entry, ALPHA specifies the scalar alpha. */ 00071 /* Unchanged on exit. */ 00072 00073 /* X - DOUBLE PRECISION array of dimension at least */ 00074 /* ( 1 + ( n - 1 )*abs( INCX ) ). */ 00075 /* Before entry, the incremented array X must contain the n */ 00076 /* element vector x. */ 00077 /* Unchanged on exit. */ 00078 00079 /* INCX - INTEGER. */ 00080 /* On entry, INCX specifies the increment for the Elements of */ 00081 /* X. INCX must not be zero. */ 00082 /* Unchanged on exit. */ 00083 00084 /* AP - DOUBLE PRECISION array of DIMENSION at least */ 00085 /* ( ( n*( n + 1 ) )/2 ). */ 00086 /* Before entry with UPLO = 'U' or 'u', the array AP must */ 00087 /* contain the Upper triangular part of the symmetric matrix */ 00088 /* packed sequentially, column by column, so that AP( 1 ) */ 00089 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */ 00090 /* and a( 2, 2 ) respectively, and so on. On exit, the array */ 00091 /* AP is overwritten by the Upper triangular part of the */ 00092 /* updated matrix. */ 00093 /* Before entry with UPLO = 'L' or 'l', the array AP must */ 00094 /* contain the Lower triangular part of the symmetric matrix */ 00095 /* packed sequentially, column by column, so that AP( 1 ) */ 00096 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */ 00097 /* and a( 3, 1 ) respectively, and so on. On exit, the array */ 00098 /* AP is overwritten by the Lower triangular part of the */ 00099 /* updated matrix. */ 00100 00101 00102 /* Level 2 Blas routine. */ 00103 00104 /* -- Written on 22-October-1986. */ 00105 /* Jack Dongarra, Argonne National Lab. */ 00106 /* Jeremy Du Croz, Nag Central Office. */ 00107 /* Sven Hammarling, Nag Central Office. */ 00108 /* Richard Hanson, Sandia National Labs. */ 00109 00110 00111 /* .. Parameters .. */ 00112 /* .. Local Scalars .. */ 00113 /* .. External Functions .. */ 00114 /* .. External Subroutines .. */ 00115 /* .. */ 00116 /* .. Executable Statements .. */ 00117 00118 /* Test the input parameters. */ 00119 00120 /* Parameter adjustments */ 00121 --ap; 00122 --x; 00123 00124 /* Function Body */ 00125 info = 0; 00126 if (! mnlsame(uplo, "U") && ! mnlsame(uplo, "L")) { 00127 info = 1; 00128 } 00129 // else if (n < 0) { 00130 // info = 2; 00131 // } 00132 else if (incx == 0) { 00133 info = 5; 00134 } 00135 if (info != 0) { 00136 mnxerbla("DSPR ", info); 00137 return 0; 00138 } 00139 00140 /* Quick return if possible. */ 00141 00142 if (n == 0 || alpha == 0.) { 00143 return 0; 00144 } 00145 00146 /* Set the start point in X if the increment is not unity. */ 00147 00148 if (incx <= 0) { 00149 kx = 1 - (n - 1) * incx; 00150 } else if (incx != 1) { 00151 kx = 1; 00152 } 00153 00154 /* Start the operations. In this version the Elements of the array AP */ 00155 /* are accessed sequentially with one pass through AP. */ 00156 00157 kk = 1; 00158 if (mnlsame(uplo, "U")) { 00159 00160 /* Form A when Upper triangle is stored in AP. */ 00161 00162 if (incx == 1) { 00163 i__1 = n; 00164 for (j = 1; j <= i__1; ++j) { 00165 if (x[j] != 0.) { 00166 temp = alpha * x[j]; 00167 k = kk; 00168 i__2 = j; 00169 for (i__ = 1; i__ <= i__2; ++i__) { 00170 ap[k] += x[i__] * temp; 00171 ++k; 00172 /* L10: */ 00173 } 00174 } 00175 kk += j; 00176 /* L20: */ 00177 } 00178 } else { 00179 jx = kx; 00180 i__1 = n; 00181 for (j = 1; j <= i__1; ++j) { 00182 if (x[jx] != 0.) { 00183 temp = alpha * x[jx]; 00184 ix = kx; 00185 i__2 = kk + j - 1; 00186 for (k = kk; k <= i__2; ++k) { 00187 ap[k] += x[ix] * temp; 00188 ix += incx; 00189 /* L30: */ 00190 } 00191 } 00192 jx += incx; 00193 kk += j; 00194 /* L40: */ 00195 } 00196 } 00197 } else { 00198 00199 /* Form A when Lower triangle is stored in AP. */ 00200 00201 if (incx == 1) { 00202 i__1 = n; 00203 for (j = 1; j <= i__1; ++j) { 00204 if (x[j] != 0.) { 00205 temp = alpha * x[j]; 00206 k = kk; 00207 i__2 = n; 00208 for (i__ = j; i__ <= i__2; ++i__) { 00209 ap[k] += x[i__] * temp; 00210 ++k; 00211 /* L50: */ 00212 } 00213 } 00214 kk = kk + n - j + 1; 00215 /* L60: */ 00216 } 00217 } else { 00218 jx = kx; 00219 i__1 = n; 00220 for (j = 1; j <= i__1; ++j) { 00221 if (x[jx] != 0.) { 00222 temp = alpha * x[jx]; 00223 ix = jx; 00224 i__2 = kk + n - j; 00225 for (k = kk; k <= i__2; ++k) { 00226 ap[k] += x[ix] * temp; 00227 ix += incx; 00228 /* L70: */ 00229 } 00230 } 00231 jx += incx; 00232 kk = kk + n - j + 1; 00233 /* L80: */ 00234 } 00235 } 00236 } 00237 00238 return 0; 00239 00240 /* End of DSPR . */ 00241 00242 } /* dspr_ */ 00243 00244 00245 } // namespace Minuit2 00246 00247 } // namespace ROOT