Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dsyr2.c

Go to the documentation of this file.
00001 
00002 /*  -- translated by f2c (version 19940927).
00003    You must link the resulting object file with the libraries:
00004         -lf2c -lm   (in that order)
00005 */
00006 
00007 #include "f2c.h"
00008 #include "cblasimpexp.h"
00009 
00010 /* Subroutine */ int __IMPEXP__ dsyr2_(char *uplo, integer *n, doublereal *alpha, 
00011         doublereal *x, integer *incx, doublereal *y, integer *incy, 
00012         doublereal *a, integer *lda)
00013 {
00014 
00015 
00016     /* System generated locals */
00017     integer a_dim1, a_offset, i__1, i__2;
00018 
00019     /* Local variables */
00020     static integer info;
00021     static doublereal temp1, temp2;
00022     static integer i, j;
00023     extern logical lsame_(char *, char *);
00024     static integer ix, iy, jx, jy, kx, ky;
00025     extern /* Subroutine */ int xerbla_(char *, integer *);
00026 
00027 
00028 /*  Purpose   
00029     =======   
00030 
00031     DSYR2  performs the symmetric rank 2 operation   
00032 
00033        A := alpha*x*y' + alpha*y*x' + A,   
00034 
00035     where alpha is a scalar, x and y are n element vectors and A is an n 
00036   
00037     by n symmetric matrix.   
00038 
00039     Parameters   
00040     ==========   
00041 
00042     UPLO   - CHARACTER*1.   
00043              On entry, UPLO specifies whether the upper or lower   
00044              triangular part of the array A is to be referenced as   
00045              follows:   
00046 
00047                 UPLO = 'U' or 'u'   Only the upper triangular part of A   
00048                                     is to be referenced.   
00049 
00050                 UPLO = 'L' or 'l'   Only the lower triangular part of A   
00051                                     is to be referenced.   
00052 
00053              Unchanged on exit.   
00054 
00055     N      - INTEGER.   
00056              On entry, N specifies the order of the matrix A.   
00057              N must be at least zero.   
00058              Unchanged on exit.   
00059 
00060     ALPHA  - DOUBLE PRECISION.   
00061              On entry, ALPHA specifies the scalar alpha.   
00062              Unchanged on exit.   
00063 
00064     X      - DOUBLE PRECISION array of dimension at least   
00065              ( 1 + ( n - 1 )*abs( INCX ) ).   
00066              Before entry, the incremented array X must contain the n   
00067              element vector x.   
00068              Unchanged on exit.   
00069 
00070     INCX   - INTEGER.   
00071              On entry, INCX specifies the increment for the elements of   
00072              X. INCX must not be zero.   
00073              Unchanged on exit.   
00074 
00075     Y      - DOUBLE PRECISION array of dimension at least   
00076              ( 1 + ( n - 1 )*abs( INCY ) ).   
00077              Before entry, the incremented array Y must contain the n   
00078              element vector y.   
00079              Unchanged on exit.   
00080 
00081     INCY   - INTEGER.   
00082              On entry, INCY specifies the increment for the elements of   
00083              Y. INCY must not be zero.   
00084              Unchanged on exit.   
00085 
00086     A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ).   
00087              Before entry with  UPLO = 'U' or 'u', the leading n by n   
00088              upper triangular part of the array A must contain the upper 
00089   
00090              triangular part of the symmetric matrix and the strictly   
00091              lower triangular part of A is not referenced. On exit, the   
00092              upper triangular part of the array A is overwritten by the   
00093              upper triangular part of the updated matrix.   
00094              Before entry with UPLO = 'L' or 'l', the leading n by n   
00095              lower triangular part of the array A must contain the lower 
00096   
00097              triangular part of the symmetric matrix and the strictly   
00098              upper triangular part of A is not referenced. On exit, the   
00099              lower triangular part of the array A is overwritten by the   
00100              lower triangular part of the updated matrix.   
00101 
00102     LDA    - INTEGER.   
00103              On entry, LDA specifies the first dimension of A as declared 
00104   
00105              in the calling (sub) program. LDA must be at least   
00106              max( 1, n ).   
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 
00120        Test the input parameters.   
00121 
00122     
00123    Parameter adjustments   
00124        Function Body */
00125 #define X(I) x[(I)-1]
00126 #define Y(I) y[(I)-1]
00127 
00128 #define A(I,J) a[(I)-1 + ((J)-1)* ( *lda)]
00129 
00130     info = 0;
00131     if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00132         info = 1;
00133     } else if (*n < 0) {
00134         info = 2;
00135     } else if (*incx == 0) {
00136         info = 5;
00137     } else if (*incy == 0) {
00138         info = 7;
00139     } else if (*lda < max(1,*n)) {
00140         info = 9;
00141     }
00142     if (info != 0) {
00143         xerbla_("DSYR2 ", &info);
00144         return 0;
00145     }
00146 
00147 /*     Quick return if possible. */
00148 
00149     if (*n == 0 || *alpha == 0.) {
00150         return 0;
00151     }
00152 
00153 /*     Set up the start points in X and Y if the increments are not both 
00154   
00155        unity. */
00156 
00157     if (*incx != 1 || *incy != 1) {
00158         if (*incx > 0) {
00159             kx = 1;
00160         } else {
00161             kx = 1 - (*n - 1) * *incx;
00162         }
00163         if (*incy > 0) {
00164             ky = 1;
00165         } else {
00166             ky = 1 - (*n - 1) * *incy;
00167         }
00168         jx = kx;
00169         jy = ky;
00170     }
00171 
00172 /*     Start the operations. In this version the elements of A are   
00173        accessed sequentially with one pass through the triangular part   
00174        of A. */
00175 
00176     if (lsame_(uplo, "U")) {
00177 
00178 /*        Form  A  when A is stored in the upper triangle. */
00179 
00180         if (*incx == 1 && *incy == 1) {
00181             i__1 = *n;
00182             for (j = 1; j <= *n; ++j) {
00183                 if (X(j) != 0. || Y(j) != 0.) {
00184                     temp1 = *alpha * Y(j);
00185                     temp2 = *alpha * X(j);
00186                     i__2 = j;
00187                     for (i = 1; i <= j; ++i) {
00188                         A(i,j) = A(i,j) + X(i) * temp1 
00189                                 + Y(i) * temp2;
00190 /* L10: */
00191                     }
00192                 }
00193 /* L20: */
00194             }
00195         } else {
00196             i__1 = *n;
00197             for (j = 1; j <= *n; ++j) {
00198                 if (X(jx) != 0. || Y(jy) != 0.) {
00199                     temp1 = *alpha * Y(jy);
00200                     temp2 = *alpha * X(jx);
00201                     ix = kx;
00202                     iy = ky;
00203                     i__2 = j;
00204                     for (i = 1; i <= j; ++i) {
00205                         A(i,j) = A(i,j) + X(ix) * temp1 
00206                                 + Y(iy) * temp2;
00207                         ix += *incx;
00208                         iy += *incy;
00209 /* L30: */
00210                     }
00211                 }
00212                 jx += *incx;
00213                 jy += *incy;
00214 /* L40: */
00215             }
00216         }
00217     } else {
00218 
00219 /*        Form  A  when A is stored in the lower triangle. */
00220 
00221         if (*incx == 1 && *incy == 1) {
00222             i__1 = *n;
00223             for (j = 1; j <= *n; ++j) {
00224                 if (X(j) != 0. || Y(j) != 0.) {
00225                     temp1 = *alpha * Y(j);
00226                     temp2 = *alpha * X(j);
00227                     i__2 = *n;
00228                     for (i = j; i <= *n; ++i) {
00229                         A(i,j) = A(i,j) + X(i) * temp1 
00230                                 + Y(i) * temp2;
00231 /* L50: */
00232                     }
00233                 }
00234 /* L60: */
00235             }
00236         } else {
00237             i__1 = *n;
00238             for (j = 1; j <= *n; ++j) {
00239                 if (X(jx) != 0. || Y(jy) != 0.) {
00240                     temp1 = *alpha * Y(jy);
00241                     temp2 = *alpha * X(jx);
00242                     ix = jx;
00243                     iy = jy;
00244                     i__2 = *n;
00245                     for (i = j; i <= *n; ++i) {
00246                         A(i,j) = A(i,j) + X(ix) * temp1 
00247                                 + Y(iy) * temp2;
00248                         ix += *incx;
00249                         iy += *incy;
00250 /* L70: */
00251                     }
00252                 }
00253                 jx += *incx;
00254                 jy += *incy;
00255 /* L80: */
00256             }
00257         }
00258     }
00259 
00260     return 0;
00261 
00262 /*     End of DSYR2 . */
00263 
00264 } /* dsyr2_ */
00265 

Generated on Wed Sep 5 12:54:20 2007 for DSACSS Operational Code by  doxygen 1.3.9.1