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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:49