00001 /* sspr2.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 sspr2_(char *uplo, integer *n, real *alpha, real *x, 00017 integer *incx, real *y, integer *incy, real *ap) 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 /* SSPR2 performs the symmetric rank 2 operation */ 00037 00038 /* A := alpha*x*y' + alpha*y*x' + A, */ 00039 00040 /* where alpha is a scalar, x and y are n element vectors and A is an */ 00041 /* 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 /* X - REAL array of dimension at least */ 00069 /* ( 1 + ( n - 1 )*abs( INCX ) ). */ 00070 /* Before entry, the incremented array X must contain the n */ 00071 /* element vector x. */ 00072 /* Unchanged on exit. */ 00073 00074 /* INCX - INTEGER. */ 00075 /* On entry, INCX specifies the increment for the elements of */ 00076 /* X. INCX must not be zero. */ 00077 /* Unchanged on exit. */ 00078 00079 /* Y - REAL array of dimension at least */ 00080 /* ( 1 + ( n - 1 )*abs( INCY ) ). */ 00081 /* Before entry, the incremented array Y must contain the n */ 00082 /* element vector y. */ 00083 /* Unchanged on exit. */ 00084 00085 /* INCY - INTEGER. */ 00086 /* On entry, INCY specifies the increment for the elements of */ 00087 /* Y. INCY must not be zero. */ 00088 /* Unchanged on exit. */ 00089 00090 /* AP - REAL array of DIMENSION at least */ 00091 /* ( ( n*( n + 1 ) )/2 ). */ 00092 /* Before entry with UPLO = 'U' or 'u', the array AP must */ 00093 /* contain the upper triangular part of the symmetric matrix */ 00094 /* packed sequentially, column by column, so that AP( 1 ) */ 00095 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */ 00096 /* and a( 2, 2 ) respectively, and so on. On exit, the array */ 00097 /* AP is overwritten by the upper triangular part of the */ 00098 /* updated matrix. */ 00099 /* Before entry with UPLO = 'L' or 'l', the array AP must */ 00100 /* contain the lower triangular part of the symmetric matrix */ 00101 /* packed sequentially, column by column, so that AP( 1 ) */ 00102 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */ 00103 /* and a( 3, 1 ) respectively, and so on. On exit, the array */ 00104 /* AP is overwritten by the lower triangular part of the */ 00105 /* updated matrix. */ 00106 00107 00108 /* Level 2 Blas routine. */ 00109 00110 /* -- Written on 22-October-1986. */ 00111 /* Jack Dongarra, Argonne National Lab. */ 00112 /* Jeremy Du Croz, Nag Central Office. */ 00113 /* Sven Hammarling, Nag Central Office. */ 00114 /* Richard Hanson, Sandia National Labs. */ 00115 00116 00117 /* .. Parameters .. */ 00118 /* .. */ 00119 /* .. Local Scalars .. */ 00120 /* .. */ 00121 /* .. External Functions .. */ 00122 /* .. */ 00123 /* .. External Subroutines .. */ 00124 /* .. */ 00125 00126 /* Test the input parameters. */ 00127 00128 /* Parameter adjustments */ 00129 --ap; 00130 --y; 00131 --x; 00132 00133 /* Function Body */ 00134 info = 0; 00135 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { 00136 info = 1; 00137 } else if (*n < 0) { 00138 info = 2; 00139 } else if (*incx == 0) { 00140 info = 5; 00141 } else if (*incy == 0) { 00142 info = 7; 00143 } 00144 if (info != 0) { 00145 xerbla_("SSPR2 ", &info); 00146 return 0; 00147 } 00148 00149 /* Quick return if possible. */ 00150 00151 if (*n == 0 || *alpha == 0.f) { 00152 return 0; 00153 } 00154 00155 /* Set up the start points in X and Y if the increments are not both */ 00156 /* unity. */ 00157 00158 if (*incx != 1 || *incy != 1) { 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 jx = kx; 00170 jy = ky; 00171 } 00172 00173 /* Start the operations. In this version the elements of the array AP */ 00174 /* are accessed sequentially with one pass through AP. */ 00175 00176 kk = 1; 00177 if (lsame_(uplo, "U")) { 00178 00179 /* Form A when upper triangle is stored in AP. */ 00180 00181 if (*incx == 1 && *incy == 1) { 00182 i__1 = *n; 00183 for (j = 1; j <= i__1; ++j) { 00184 if (x[j] != 0.f || y[j] != 0.f) { 00185 temp1 = *alpha * y[j]; 00186 temp2 = *alpha * x[j]; 00187 k = kk; 00188 i__2 = j; 00189 for (i__ = 1; i__ <= i__2; ++i__) { 00190 ap[k] = ap[k] + x[i__] * temp1 + y[i__] * temp2; 00191 ++k; 00192 /* L10: */ 00193 } 00194 } 00195 kk += j; 00196 /* L20: */ 00197 } 00198 } else { 00199 i__1 = *n; 00200 for (j = 1; j <= i__1; ++j) { 00201 if (x[jx] != 0.f || y[jy] != 0.f) { 00202 temp1 = *alpha * y[jy]; 00203 temp2 = *alpha * x[jx]; 00204 ix = kx; 00205 iy = ky; 00206 i__2 = kk + j - 1; 00207 for (k = kk; k <= i__2; ++k) { 00208 ap[k] = ap[k] + x[ix] * temp1 + y[iy] * temp2; 00209 ix += *incx; 00210 iy += *incy; 00211 /* L30: */ 00212 } 00213 } 00214 jx += *incx; 00215 jy += *incy; 00216 kk += j; 00217 /* L40: */ 00218 } 00219 } 00220 } else { 00221 00222 /* Form A when lower triangle is stored in AP. */ 00223 00224 if (*incx == 1 && *incy == 1) { 00225 i__1 = *n; 00226 for (j = 1; j <= i__1; ++j) { 00227 if (x[j] != 0.f || y[j] != 0.f) { 00228 temp1 = *alpha * y[j]; 00229 temp2 = *alpha * x[j]; 00230 k = kk; 00231 i__2 = *n; 00232 for (i__ = j; i__ <= i__2; ++i__) { 00233 ap[k] = ap[k] + x[i__] * temp1 + y[i__] * temp2; 00234 ++k; 00235 /* L50: */ 00236 } 00237 } 00238 kk = kk + *n - j + 1; 00239 /* L60: */ 00240 } 00241 } else { 00242 i__1 = *n; 00243 for (j = 1; j <= i__1; ++j) { 00244 if (x[jx] != 0.f || y[jy] != 0.f) { 00245 temp1 = *alpha * y[jy]; 00246 temp2 = *alpha * x[jx]; 00247 ix = jx; 00248 iy = jy; 00249 i__2 = kk + *n - j; 00250 for (k = kk; k <= i__2; ++k) { 00251 ap[k] = ap[k] + x[ix] * temp1 + y[iy] * temp2; 00252 ix += *incx; 00253 iy += *incy; 00254 /* L70: */ 00255 } 00256 } 00257 jx += *incx; 00258 jy += *incy; 00259 kk = kk + *n - j + 1; 00260 /* L80: */ 00261 } 00262 } 00263 } 00264 00265 return 0; 00266 00267 /* End of SSPR2 . */ 00268 00269 } /* sspr2_ */