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

dsyr2k.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__ dsyr2k_(char *uplo, char *trans, integer *n, integer *k, 
00011         doublereal *alpha, doublereal *a, integer *lda, doublereal *b, 
00012         integer *ldb, doublereal *beta, doublereal *c, integer *ldc)
00013 {
00014 
00015 
00016     /* System generated locals */
00017     integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2, 
00018             i__3;
00019 
00020     /* Local variables */
00021     static integer info;
00022     static doublereal temp1, temp2;
00023     static integer i, j, l;
00024     extern logical lsame_(char *, char *);
00025     static integer nrowa;
00026     static logical upper;
00027     extern /* Subroutine */ int xerbla_(char *, integer *);
00028 
00029 
00030 /*  Purpose   
00031     =======   
00032 
00033     DSYR2K  performs one of the symmetric rank 2k operations   
00034 
00035        C := alpha*A*B' + alpha*B*A' + beta*C,   
00036 
00037     or   
00038 
00039        C := alpha*A'*B + alpha*B'*A + beta*C,   
00040 
00041     where  alpha and beta  are scalars, C is an  n by n  symmetric matrix 
00042   
00043     and  A and B  are  n by k  matrices  in the  first  case  and  k by n 
00044   
00045     matrices in the second case.   
00046 
00047     Parameters   
00048     ==========   
00049 
00050     UPLO   - CHARACTER*1.   
00051              On  entry,   UPLO  specifies  whether  the  upper  or  lower 
00052   
00053              triangular  part  of the  array  C  is to be  referenced  as 
00054   
00055              follows:   
00056 
00057                 UPLO = 'U' or 'u'   Only the  upper triangular part of  C 
00058   
00059                                     is to be referenced.   
00060 
00061                 UPLO = 'L' or 'l'   Only the  lower triangular part of  C 
00062   
00063                                     is to be referenced.   
00064 
00065              Unchanged on exit.   
00066 
00067     TRANS  - CHARACTER*1.   
00068              On entry,  TRANS  specifies the operation to be performed as 
00069   
00070              follows:   
00071 
00072                 TRANS = 'N' or 'n'   C := alpha*A*B' + alpha*B*A' +   
00073                                           beta*C.   
00074 
00075                 TRANS = 'T' or 't'   C := alpha*A'*B + alpha*B'*A +   
00076                                           beta*C.   
00077 
00078                 TRANS = 'C' or 'c'   C := alpha*A'*B + alpha*B'*A +   
00079                                           beta*C.   
00080 
00081              Unchanged on exit.   
00082 
00083     N      - INTEGER.   
00084              On entry,  N specifies the order of the matrix C.  N must be 
00085   
00086              at least zero.   
00087              Unchanged on exit.   
00088 
00089     K      - INTEGER.   
00090              On entry with  TRANS = 'N' or 'n',  K  specifies  the number 
00091   
00092              of  columns  of the  matrices  A and B,  and on  entry  with 
00093   
00094              TRANS = 'T' or 't' or 'C' or 'c',  K  specifies  the  number 
00095   
00096              of rows of the matrices  A and B.  K must be at least  zero. 
00097   
00098              Unchanged on exit.   
00099 
00100     ALPHA  - DOUBLE PRECISION.   
00101              On entry, ALPHA specifies the scalar alpha.   
00102              Unchanged on exit.   
00103 
00104     A      - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is 
00105   
00106              k  when  TRANS = 'N' or 'n',  and is  n  otherwise.   
00107              Before entry with  TRANS = 'N' or 'n',  the  leading  n by k 
00108   
00109              part of the array  A  must contain the matrix  A,  otherwise 
00110   
00111              the leading  k by n  part of the array  A  must contain  the 
00112   
00113              matrix A.   
00114              Unchanged on exit.   
00115 
00116     LDA    - INTEGER.   
00117              On entry, LDA specifies the first dimension of A as declared 
00118   
00119              in  the  calling  (sub)  program.   When  TRANS = 'N' or 'n' 
00120   
00121              then  LDA must be at least  max( 1, n ), otherwise  LDA must 
00122   
00123              be at least  max( 1, k ).   
00124              Unchanged on exit.   
00125 
00126     B      - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is 
00127   
00128              k  when  TRANS = 'N' or 'n',  and is  n  otherwise.   
00129              Before entry with  TRANS = 'N' or 'n',  the  leading  n by k 
00130   
00131              part of the array  B  must contain the matrix  B,  otherwise 
00132   
00133              the leading  k by n  part of the array  B  must contain  the 
00134   
00135              matrix B.   
00136              Unchanged on exit.   
00137 
00138     LDB    - INTEGER.   
00139              On entry, LDB specifies the first dimension of B as declared 
00140   
00141              in  the  calling  (sub)  program.   When  TRANS = 'N' or 'n' 
00142   
00143              then  LDB must be at least  max( 1, n ), otherwise  LDB must 
00144   
00145              be at least  max( 1, k ).   
00146              Unchanged on exit.   
00147 
00148     BETA   - DOUBLE PRECISION.   
00149              On entry, BETA specifies the scalar beta.   
00150              Unchanged on exit.   
00151 
00152     C      - DOUBLE PRECISION array of DIMENSION ( LDC, n ).   
00153              Before entry  with  UPLO = 'U' or 'u',  the leading  n by n 
00154   
00155              upper triangular part of the array C must contain the upper 
00156   
00157              triangular part  of the  symmetric matrix  and the strictly 
00158   
00159              lower triangular part of C is not referenced.  On exit, the 
00160   
00161              upper triangular part of the array  C is overwritten by the 
00162   
00163              upper triangular part of the updated matrix.   
00164              Before entry  with  UPLO = 'L' or 'l',  the leading  n by n 
00165   
00166              lower triangular part of the array C must contain the lower 
00167   
00168              triangular part  of the  symmetric matrix  and the strictly 
00169   
00170              upper triangular part of C is not referenced.  On exit, the 
00171   
00172              lower triangular part of the array  C is overwritten by the 
00173   
00174              lower triangular part of the updated matrix.   
00175 
00176     LDC    - INTEGER.   
00177              On entry, LDC specifies the first dimension of C as declared 
00178   
00179              in  the  calling  (sub)  program.   LDC  must  be  at  least 
00180   
00181              max( 1, n ).   
00182              Unchanged on exit.   
00183 
00184 
00185     Level 3 Blas routine.   
00186 
00187 
00188     -- Written on 8-February-1989.   
00189        Jack Dongarra, Argonne National Laboratory.   
00190        Iain Duff, AERE Harwell.   
00191        Jeremy Du Croz, Numerical Algorithms Group Ltd.   
00192        Sven Hammarling, Numerical Algorithms Group Ltd.   
00193 
00194 
00195 
00196        Test the input parameters.   
00197 
00198     
00199    Parameter adjustments   
00200        Function Body */
00201 
00202 #define A(I,J) a[(I)-1 + ((J)-1)* ( *lda)]
00203 #define B(I,J) b[(I)-1 + ((J)-1)* ( *ldb)]
00204 #define C(I,J) c[(I)-1 + ((J)-1)* ( *ldc)]
00205 
00206     if (lsame_(trans, "N")) {
00207         nrowa = *n;
00208     } else {
00209         nrowa = *k;
00210     }
00211     upper = lsame_(uplo, "U");
00212 
00213     info = 0;
00214     if (! upper && ! lsame_(uplo, "L")) {
00215         info = 1;
00216     } else if (! lsame_(trans, "N") && ! lsame_(trans, "T") &&
00217              ! lsame_(trans, "C")) {
00218         info = 2;
00219     } else if (*n < 0) {
00220         info = 3;
00221     } else if (*k < 0) {
00222         info = 4;
00223     } else if (*lda < max(1,nrowa)) {
00224         info = 7;
00225     } else if (*ldb < max(1,nrowa)) {
00226         info = 9;
00227     } else if (*ldc < max(1,*n)) {
00228         info = 12;
00229     }
00230     if (info != 0) {
00231         xerbla_("DSYR2K", &info);
00232         return 0;
00233     }
00234 
00235 /*     Quick return if possible. */
00236 
00237     if (*n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
00238         return 0;
00239     }
00240 
00241 /*     And when  alpha.eq.zero. */
00242 
00243     if (*alpha == 0.) {
00244         if (upper) {
00245             if (*beta == 0.) {
00246                 i__1 = *n;
00247                 for (j = 1; j <= *n; ++j) {
00248                     i__2 = j;
00249                     for (i = 1; i <= j; ++i) {
00250                         C(i,j) = 0.;
00251 /* L10: */
00252                     }
00253 /* L20: */
00254                 }
00255             } else {
00256                 i__1 = *n;
00257                 for (j = 1; j <= *n; ++j) {
00258                     i__2 = j;
00259                     for (i = 1; i <= j; ++i) {
00260                         C(i,j) = *beta * C(i,j);
00261 /* L30: */
00262                     }
00263 /* L40: */
00264                 }
00265             }
00266         } else {
00267             if (*beta == 0.) {
00268                 i__1 = *n;
00269                 for (j = 1; j <= *n; ++j) {
00270                     i__2 = *n;
00271                     for (i = j; i <= *n; ++i) {
00272                         C(i,j) = 0.;
00273 /* L50: */
00274                     }
00275 /* L60: */
00276                 }
00277             } else {
00278                 i__1 = *n;
00279                 for (j = 1; j <= *n; ++j) {
00280                     i__2 = *n;
00281                     for (i = j; i <= *n; ++i) {
00282                         C(i,j) = *beta * C(i,j);
00283 /* L70: */
00284                     }
00285 /* L80: */
00286                 }
00287             }
00288         }
00289         return 0;
00290     }
00291 
00292 /*     Start the operations. */
00293 
00294     if (lsame_(trans, "N")) {
00295 
00296 /*        Form  C := alpha*A*B' + alpha*B*A' + C. */
00297 
00298         if (upper) {
00299             i__1 = *n;
00300             for (j = 1; j <= *n; ++j) {
00301                 if (*beta == 0.) {
00302                     i__2 = j;
00303                     for (i = 1; i <= j; ++i) {
00304                         C(i,j) = 0.;
00305 /* L90: */
00306                     }
00307                 } else if (*beta != 1.) {
00308                     i__2 = j;
00309                     for (i = 1; i <= j; ++i) {
00310                         C(i,j) = *beta * C(i,j);
00311 /* L100: */
00312                     }
00313                 }
00314                 i__2 = *k;
00315                 for (l = 1; l <= *k; ++l) {
00316                     if (A(j,l) != 0. || B(j,l) != 0.) {
00317                         temp1 = *alpha * B(j,l);
00318                         temp2 = *alpha * A(j,l);
00319                         i__3 = j;
00320                         for (i = 1; i <= j; ++i) {
00321                             C(i,j) = C(i,j) + A(i,l) * temp1 + B(i,l) * 
00322                                     temp2;
00323 /* L110: */
00324                         }
00325                     }
00326 /* L120: */
00327                 }
00328 /* L130: */
00329             }
00330         } else {
00331             i__1 = *n;
00332             for (j = 1; j <= *n; ++j) {
00333                 if (*beta == 0.) {
00334                     i__2 = *n;
00335                     for (i = j; i <= *n; ++i) {
00336                         C(i,j) = 0.;
00337 /* L140: */
00338                     }
00339                 } else if (*beta != 1.) {
00340                     i__2 = *n;
00341                     for (i = j; i <= *n; ++i) {
00342                         C(i,j) = *beta * C(i,j);
00343 /* L150: */
00344                     }
00345                 }
00346                 i__2 = *k;
00347                 for (l = 1; l <= *k; ++l) {
00348                     if (A(j,l) != 0. || B(j,l) != 0.) {
00349                         temp1 = *alpha * B(j,l);
00350                         temp2 = *alpha * A(j,l);
00351                         i__3 = *n;
00352                         for (i = j; i <= *n; ++i) {
00353                             C(i,j) = C(i,j) + A(i,l) * temp1 + B(i,l) * 
00354                                     temp2;
00355 /* L160: */
00356                         }
00357                     }
00358 /* L170: */
00359                 }
00360 /* L180: */
00361             }
00362         }
00363     } else {
00364 
00365 /*        Form  C := alpha*A'*B + alpha*B'*A + C. */
00366 
00367         if (upper) {
00368             i__1 = *n;
00369             for (j = 1; j <= *n; ++j) {
00370                 i__2 = j;
00371                 for (i = 1; i <= j; ++i) {
00372                     temp1 = 0.;
00373                     temp2 = 0.;
00374                     i__3 = *k;
00375                     for (l = 1; l <= *k; ++l) {
00376                         temp1 += A(l,i) * B(l,j);
00377                         temp2 += B(l,i) * A(l,j);
00378 /* L190: */
00379                     }
00380                     if (*beta == 0.) {
00381                         C(i,j) = *alpha * temp1 + *alpha * temp2;
00382                     } else {
00383                         C(i,j) = *beta * C(i,j) + *
00384                                 alpha * temp1 + *alpha * temp2;
00385                     }
00386 /* L200: */
00387                 }
00388 /* L210: */
00389             }
00390         } else {
00391             i__1 = *n;
00392             for (j = 1; j <= *n; ++j) {
00393                 i__2 = *n;
00394                 for (i = j; i <= *n; ++i) {
00395                     temp1 = 0.;
00396                     temp2 = 0.;
00397                     i__3 = *k;
00398                     for (l = 1; l <= *k; ++l) {
00399                         temp1 += A(l,i) * B(l,j);
00400                         temp2 += B(l,i) * A(l,j);
00401 /* L220: */
00402                     }
00403                     if (*beta == 0.) {
00404                         C(i,j) = *alpha * temp1 + *alpha * temp2;
00405                     } else {
00406                         C(i,j) = *beta * C(i,j) + *
00407                                 alpha * temp1 + *alpha * temp2;
00408                     }
00409 /* L230: */
00410                 }
00411 /* L240: */
00412             }
00413         }
00414     }
00415 
00416     return 0;
00417 
00418 /*     End of DSYR2K. */
00419 
00420 } /* dsyr2k_ */
00421 

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