chfrk.c
Go to the documentation of this file.
00001 /* chfrk.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 chfrk_(char *transr, char *uplo, char *trans, integer *n, 
00017          integer *k, real *alpha, complex *a, integer *lda, real *beta, 
00018         complex *c__)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, i__1, i__2;
00022     complex q__1;
00023 
00024     /* Local variables */
00025     integer j, n1, n2, nk, info;
00026     complex cbeta;
00027     logical normaltransr;
00028     extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, 
00029             integer *, complex *, complex *, integer *, complex *, integer *, 
00030             complex *, complex *, integer *), cherk_(char *, 
00031             char *, integer *, integer *, real *, complex *, integer *, real *
00032 , complex *, integer *);
00033     extern logical lsame_(char *, char *);
00034     integer nrowa;
00035     logical lower;
00036     complex calpha;
00037     extern /* Subroutine */ int xerbla_(char *, integer *);
00038     logical nisodd, notrans;
00039 
00040 
00041 /*  -- LAPACK routine (version 3.2)                                    -- */
00042 
00043 /*  -- Contributed by Julien Langou of the Univ. of Colorado Denver    -- */
00044 /*  -- November 2008                                                   -- */
00045 
00046 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
00047 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
00048 
00049 /*     .. */
00050 /*     .. Scalar Arguments .. */
00051 /*     .. */
00052 /*     .. Array Arguments .. */
00053 /*     .. */
00054 
00055 /*  Purpose */
00056 /*  ======= */
00057 
00058 /*  Level 3 BLAS like routine for C in RFP Format. */
00059 
00060 /*  CHFRK performs one of the Hermitian rank--k operations */
00061 
00062 /*     C := alpha*A*conjg( A' ) + beta*C, */
00063 
00064 /*  or */
00065 
00066 /*     C := alpha*conjg( A' )*A + beta*C, */
00067 
00068 /*  where alpha and beta are real scalars, C is an n--by--n Hermitian */
00069 /*  matrix and A is an n--by--k matrix in the first case and a k--by--n */
00070 /*  matrix in the second case. */
00071 
00072 /*  Arguments */
00073 /*  ========== */
00074 
00075 /*  TRANSR - (input) CHARACTER. */
00076 /*          = 'N':  The Normal Form of RFP A is stored; */
00077 /*          = 'C':  The Conjugate-transpose Form of RFP A is stored. */
00078 
00079 /*  UPLO   - (input) CHARACTER. */
00080 /*           On  entry,   UPLO  specifies  whether  the  upper  or  lower */
00081 /*           triangular  part  of the  array  C  is to be  referenced  as */
00082 /*           follows: */
00083 
00084 /*              UPLO = 'U' or 'u'   Only the  upper triangular part of  C */
00085 /*                                  is to be referenced. */
00086 
00087 /*              UPLO = 'L' or 'l'   Only the  lower triangular part of  C */
00088 /*                                  is to be referenced. */
00089 
00090 /*           Unchanged on exit. */
00091 
00092 /*  TRANS  - (input) CHARACTER. */
00093 /*           On entry,  TRANS  specifies the operation to be performed as */
00094 /*           follows: */
00095 
00096 /*              TRANS = 'N' or 'n'   C := alpha*A*conjg( A' ) + beta*C. */
00097 
00098 /*              TRANS = 'C' or 'c'   C := alpha*conjg( A' )*A + beta*C. */
00099 
00100 /*           Unchanged on exit. */
00101 
00102 /*  N      - (input) INTEGER. */
00103 /*           On entry,  N specifies the order of the matrix C.  N must be */
00104 /*           at least zero. */
00105 /*           Unchanged on exit. */
00106 
00107 /*  K      - (input) INTEGER. */
00108 /*           On entry with  TRANS = 'N' or 'n',  K  specifies  the number */
00109 /*           of  columns   of  the   matrix   A,   and  on   entry   with */
00110 /*           TRANS = 'C' or 'c',  K  specifies  the number of rows of the */
00111 /*           matrix A.  K must be at least zero. */
00112 /*           Unchanged on exit. */
00113 
00114 /*  ALPHA  - (input) REAL. */
00115 /*           On entry, ALPHA specifies the scalar alpha. */
00116 /*           Unchanged on exit. */
00117 
00118 /*  A      - (input) COMPLEX array of DIMENSION ( LDA, ka ), where KA */
00119 /*           is K  when TRANS = 'N' or 'n', and is N otherwise. Before */
00120 /*           entry with TRANS = 'N' or 'n', the leading N--by--K part of */
00121 /*           the array A must contain the matrix A, otherwise the leading */
00122 /*           K--by--N part of the array A must contain the matrix A. */
00123 /*           Unchanged on exit. */
00124 
00125 /*  LDA    - (input) INTEGER. */
00126 /*           On entry, LDA specifies the first dimension of A as declared */
00127 /*           in  the  calling  (sub)  program.   When  TRANS = 'N' or 'n' */
00128 /*           then  LDA must be at least  max( 1, n ), otherwise  LDA must */
00129 /*           be at least  max( 1, k ). */
00130 /*           Unchanged on exit. */
00131 
00132 /*  BETA   - (input) REAL. */
00133 /*           On entry, BETA specifies the scalar beta. */
00134 /*           Unchanged on exit. */
00135 
00136 /*  C      - (input/output) COMPLEX array, dimension ( N*(N+1)/2 ). */
00137 /*           On entry, the matrix A in RFP Format. RFP Format is */
00138 /*           described by TRANSR, UPLO and N. Note that the imaginary */
00139 /*           parts of the diagonal elements need not be set, they are */
00140 /*           assumed to be zero, and on exit they are set to zero. */
00141 
00142 /*  Arguments */
00143 /*  ========== */
00144 
00145 /*     .. */
00146 /*     .. Parameters .. */
00147 /*     .. */
00148 /*     .. Local Scalars .. */
00149 /*     .. */
00150 /*     .. External Functions .. */
00151 /*     .. */
00152 /*     .. External Subroutines .. */
00153 /*     .. */
00154 /*     .. Intrinsic Functions .. */
00155 /*     .. */
00156 /*     .. Executable Statements .. */
00157 
00158 
00159 /*     Test the input parameters. */
00160 
00161     /* Parameter adjustments */
00162     a_dim1 = *lda;
00163     a_offset = 1 + a_dim1;
00164     a -= a_offset;
00165     --c__;
00166 
00167     /* Function Body */
00168     info = 0;
00169     normaltransr = lsame_(transr, "N");
00170     lower = lsame_(uplo, "L");
00171     notrans = lsame_(trans, "N");
00172 
00173     if (notrans) {
00174         nrowa = *n;
00175     } else {
00176         nrowa = *k;
00177     }
00178 
00179     if (! normaltransr && ! lsame_(transr, "C")) {
00180         info = -1;
00181     } else if (! lower && ! lsame_(uplo, "U")) {
00182         info = -2;
00183     } else if (! notrans && ! lsame_(trans, "C")) {
00184         info = -3;
00185     } else if (*n < 0) {
00186         info = -4;
00187     } else if (*k < 0) {
00188         info = -5;
00189     } else if (*lda < max(1,nrowa)) {
00190         info = -8;
00191     }
00192     if (info != 0) {
00193         i__1 = -info;
00194         xerbla_("CHFRK ", &i__1);
00195         return 0;
00196     }
00197 
00198 /*     Quick return if possible. */
00199 
00200 /*     The quick return case: ((ALPHA.EQ.0).AND.(BETA.NE.ZERO)) is not */
00201 /*     done (it is in CHERK for example) and left in the general case. */
00202 
00203     if (*n == 0 || (*alpha == 0.f || *k == 0) && *beta == 1.f) {
00204         return 0;
00205     }
00206 
00207     if (*alpha == 0.f && *beta == 0.f) {
00208         i__1 = *n * (*n + 1) / 2;
00209         for (j = 1; j <= i__1; ++j) {
00210             i__2 = j;
00211             c__[i__2].r = 0.f, c__[i__2].i = 0.f;
00212         }
00213         return 0;
00214     }
00215 
00216     q__1.r = *alpha, q__1.i = 0.f;
00217     calpha.r = q__1.r, calpha.i = q__1.i;
00218     q__1.r = *beta, q__1.i = 0.f;
00219     cbeta.r = q__1.r, cbeta.i = q__1.i;
00220 
00221 /*     C is N-by-N. */
00222 /*     If N is odd, set NISODD = .TRUE., and N1 and N2. */
00223 /*     If N is even, NISODD = .FALSE., and NK. */
00224 
00225     if (*n % 2 == 0) {
00226         nisodd = FALSE_;
00227         nk = *n / 2;
00228     } else {
00229         nisodd = TRUE_;
00230         if (lower) {
00231             n2 = *n / 2;
00232             n1 = *n - n2;
00233         } else {
00234             n1 = *n / 2;
00235             n2 = *n - n1;
00236         }
00237     }
00238 
00239     if (nisodd) {
00240 
00241 /*        N is odd */
00242 
00243         if (normaltransr) {
00244 
00245 /*           N is odd and TRANSR = 'N' */
00246 
00247             if (lower) {
00248 
00249 /*              N is odd, TRANSR = 'N', and UPLO = 'L' */
00250 
00251                 if (notrans) {
00252 
00253 /*                 N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'N' */
00254 
00255                     cherk_("L", "N", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00256                              &c__[1], n);
00257                     cherk_("U", "N", &n2, k, alpha, &a[n1 + 1 + a_dim1], lda, 
00258                             beta, &c__[*n + 1], n);
00259                     cgemm_("N", "C", &n2, &n1, k, &calpha, &a[n1 + 1 + a_dim1]
00260 , lda, &a[a_dim1 + 1], lda, &cbeta, &c__[n1 + 1], 
00261                             n);
00262 
00263                 } else {
00264 
00265 /*                 N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'C' */
00266 
00267                     cherk_("L", "C", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00268                              &c__[1], n);
00269                     cherk_("U", "C", &n2, k, alpha, &a[(n1 + 1) * a_dim1 + 1], 
00270                              lda, beta, &c__[*n + 1], n)
00271                             ;
00272                     cgemm_("C", "N", &n2, &n1, k, &calpha, &a[(n1 + 1) * 
00273                             a_dim1 + 1], lda, &a[a_dim1 + 1], lda, &cbeta, &
00274                             c__[n1 + 1], n);
00275 
00276                 }
00277 
00278             } else {
00279 
00280 /*              N is odd, TRANSR = 'N', and UPLO = 'U' */
00281 
00282                 if (notrans) {
00283 
00284 /*                 N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'N' */
00285 
00286                     cherk_("L", "N", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00287                              &c__[n2 + 1], n);
00288                     cherk_("U", "N", &n2, k, alpha, &a[n2 + a_dim1], lda, 
00289                             beta, &c__[n1 + 1], n);
00290                     cgemm_("N", "C", &n1, &n2, k, &calpha, &a[a_dim1 + 1], 
00291                             lda, &a[n2 + a_dim1], lda, &cbeta, &c__[1], n);
00292 
00293                 } else {
00294 
00295 /*                 N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'C' */
00296 
00297                     cherk_("L", "C", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00298                              &c__[n2 + 1], n);
00299                     cherk_("U", "C", &n2, k, alpha, &a[n2 * a_dim1 + 1], lda, 
00300                             beta, &c__[n1 + 1], n);
00301                     cgemm_("C", "N", &n1, &n2, k, &calpha, &a[a_dim1 + 1], 
00302                             lda, &a[n2 * a_dim1 + 1], lda, &cbeta, &c__[1], n);
00303 
00304                 }
00305 
00306             }
00307 
00308         } else {
00309 
00310 /*           N is odd, and TRANSR = 'C' */
00311 
00312             if (lower) {
00313 
00314 /*              N is odd, TRANSR = 'C', and UPLO = 'L' */
00315 
00316                 if (notrans) {
00317 
00318 /*                 N is odd, TRANSR = 'C', UPLO = 'L', and TRANS = 'N' */
00319 
00320                     cherk_("U", "N", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00321                              &c__[1], &n1);
00322                     cherk_("L", "N", &n2, k, alpha, &a[n1 + 1 + a_dim1], lda, 
00323                             beta, &c__[2], &n1);
00324                     cgemm_("N", "C", &n1, &n2, k, &calpha, &a[a_dim1 + 1], 
00325                             lda, &a[n1 + 1 + a_dim1], lda, &cbeta, &c__[n1 * 
00326                             n1 + 1], &n1);
00327 
00328                 } else {
00329 
00330 /*                 N is odd, TRANSR = 'C', UPLO = 'L', and TRANS = 'C' */
00331 
00332                     cherk_("U", "C", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00333                              &c__[1], &n1);
00334                     cherk_("L", "C", &n2, k, alpha, &a[(n1 + 1) * a_dim1 + 1], 
00335                              lda, beta, &c__[2], &n1);
00336                     cgemm_("C", "N", &n1, &n2, k, &calpha, &a[a_dim1 + 1], 
00337                             lda, &a[(n1 + 1) * a_dim1 + 1], lda, &cbeta, &c__[
00338                             n1 * n1 + 1], &n1);
00339 
00340                 }
00341 
00342             } else {
00343 
00344 /*              N is odd, TRANSR = 'C', and UPLO = 'U' */
00345 
00346                 if (notrans) {
00347 
00348 /*                 N is odd, TRANSR = 'C', UPLO = 'U', and TRANS = 'N' */
00349 
00350                     cherk_("U", "N", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00351                              &c__[n2 * n2 + 1], &n2);
00352                     cherk_("L", "N", &n2, k, alpha, &a[n1 + 1 + a_dim1], lda, 
00353                             beta, &c__[n1 * n2 + 1], &n2);
00354                     cgemm_("N", "C", &n2, &n1, k, &calpha, &a[n1 + 1 + a_dim1]
00355 , lda, &a[a_dim1 + 1], lda, &cbeta, &c__[1], &n2);
00356 
00357                 } else {
00358 
00359 /*                 N is odd, TRANSR = 'C', UPLO = 'U', and TRANS = 'C' */
00360 
00361                     cherk_("U", "C", &n1, k, alpha, &a[a_dim1 + 1], lda, beta, 
00362                              &c__[n2 * n2 + 1], &n2);
00363                     cherk_("L", "C", &n2, k, alpha, &a[(n1 + 1) * a_dim1 + 1], 
00364                              lda, beta, &c__[n1 * n2 + 1], &n2);
00365                     cgemm_("C", "N", &n2, &n1, k, &calpha, &a[(n1 + 1) * 
00366                             a_dim1 + 1], lda, &a[a_dim1 + 1], lda, &cbeta, &
00367                             c__[1], &n2);
00368 
00369                 }
00370 
00371             }
00372 
00373         }
00374 
00375     } else {
00376 
00377 /*        N is even */
00378 
00379         if (normaltransr) {
00380 
00381 /*           N is even and TRANSR = 'N' */
00382 
00383             if (lower) {
00384 
00385 /*              N is even, TRANSR = 'N', and UPLO = 'L' */
00386 
00387                 if (notrans) {
00388 
00389 /*                 N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'N' */
00390 
00391                     i__1 = *n + 1;
00392                     cherk_("L", "N", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00393                              &c__[2], &i__1);
00394                     i__1 = *n + 1;
00395                     cherk_("U", "N", &nk, k, alpha, &a[nk + 1 + a_dim1], lda, 
00396                             beta, &c__[1], &i__1);
00397                     i__1 = *n + 1;
00398                     cgemm_("N", "C", &nk, &nk, k, &calpha, &a[nk + 1 + a_dim1]
00399 , lda, &a[a_dim1 + 1], lda, &cbeta, &c__[nk + 2], 
00400                             &i__1);
00401 
00402                 } else {
00403 
00404 /*                 N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'C' */
00405 
00406                     i__1 = *n + 1;
00407                     cherk_("L", "C", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00408                              &c__[2], &i__1);
00409                     i__1 = *n + 1;
00410                     cherk_("U", "C", &nk, k, alpha, &a[(nk + 1) * a_dim1 + 1], 
00411                              lda, beta, &c__[1], &i__1);
00412                     i__1 = *n + 1;
00413                     cgemm_("C", "N", &nk, &nk, k, &calpha, &a[(nk + 1) * 
00414                             a_dim1 + 1], lda, &a[a_dim1 + 1], lda, &cbeta, &
00415                             c__[nk + 2], &i__1);
00416 
00417                 }
00418 
00419             } else {
00420 
00421 /*              N is even, TRANSR = 'N', and UPLO = 'U' */
00422 
00423                 if (notrans) {
00424 
00425 /*                 N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'N' */
00426 
00427                     i__1 = *n + 1;
00428                     cherk_("L", "N", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00429                              &c__[nk + 2], &i__1);
00430                     i__1 = *n + 1;
00431                     cherk_("U", "N", &nk, k, alpha, &a[nk + 1 + a_dim1], lda, 
00432                             beta, &c__[nk + 1], &i__1);
00433                     i__1 = *n + 1;
00434                     cgemm_("N", "C", &nk, &nk, k, &calpha, &a[a_dim1 + 1], 
00435                             lda, &a[nk + 1 + a_dim1], lda, &cbeta, &c__[1], &
00436                             i__1);
00437 
00438                 } else {
00439 
00440 /*                 N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'C' */
00441 
00442                     i__1 = *n + 1;
00443                     cherk_("L", "C", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00444                              &c__[nk + 2], &i__1);
00445                     i__1 = *n + 1;
00446                     cherk_("U", "C", &nk, k, alpha, &a[(nk + 1) * a_dim1 + 1], 
00447                              lda, beta, &c__[nk + 1], &i__1);
00448                     i__1 = *n + 1;
00449                     cgemm_("C", "N", &nk, &nk, k, &calpha, &a[a_dim1 + 1], 
00450                             lda, &a[(nk + 1) * a_dim1 + 1], lda, &cbeta, &c__[
00451                             1], &i__1);
00452 
00453                 }
00454 
00455             }
00456 
00457         } else {
00458 
00459 /*           N is even, and TRANSR = 'C' */
00460 
00461             if (lower) {
00462 
00463 /*              N is even, TRANSR = 'C', and UPLO = 'L' */
00464 
00465                 if (notrans) {
00466 
00467 /*                 N is even, TRANSR = 'C', UPLO = 'L', and TRANS = 'N' */
00468 
00469                     cherk_("U", "N", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00470                              &c__[nk + 1], &nk);
00471                     cherk_("L", "N", &nk, k, alpha, &a[nk + 1 + a_dim1], lda, 
00472                             beta, &c__[1], &nk);
00473                     cgemm_("N", "C", &nk, &nk, k, &calpha, &a[a_dim1 + 1], 
00474                             lda, &a[nk + 1 + a_dim1], lda, &cbeta, &c__[(nk + 
00475                             1) * nk + 1], &nk);
00476 
00477                 } else {
00478 
00479 /*                 N is even, TRANSR = 'C', UPLO = 'L', and TRANS = 'C' */
00480 
00481                     cherk_("U", "C", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00482                              &c__[nk + 1], &nk);
00483                     cherk_("L", "C", &nk, k, alpha, &a[(nk + 1) * a_dim1 + 1], 
00484                              lda, beta, &c__[1], &nk);
00485                     cgemm_("C", "N", &nk, &nk, k, &calpha, &a[a_dim1 + 1], 
00486                             lda, &a[(nk + 1) * a_dim1 + 1], lda, &cbeta, &c__[
00487                             (nk + 1) * nk + 1], &nk);
00488 
00489                 }
00490 
00491             } else {
00492 
00493 /*              N is even, TRANSR = 'C', and UPLO = 'U' */
00494 
00495                 if (notrans) {
00496 
00497 /*                 N is even, TRANSR = 'C', UPLO = 'U', and TRANS = 'N' */
00498 
00499                     cherk_("U", "N", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00500                              &c__[nk * (nk + 1) + 1], &nk);
00501                     cherk_("L", "N", &nk, k, alpha, &a[nk + 1 + a_dim1], lda, 
00502                             beta, &c__[nk * nk + 1], &nk);
00503                     cgemm_("N", "C", &nk, &nk, k, &calpha, &a[nk + 1 + a_dim1]
00504 , lda, &a[a_dim1 + 1], lda, &cbeta, &c__[1], &nk);
00505 
00506                 } else {
00507 
00508 /*                 N is even, TRANSR = 'C', UPLO = 'U', and TRANS = 'C' */
00509 
00510                     cherk_("U", "C", &nk, k, alpha, &a[a_dim1 + 1], lda, beta, 
00511                              &c__[nk * (nk + 1) + 1], &nk);
00512                     cherk_("L", "C", &nk, k, alpha, &a[(nk + 1) * a_dim1 + 1], 
00513                              lda, beta, &c__[nk * nk + 1], &nk);
00514                     cgemm_("C", "N", &nk, &nk, k, &calpha, &a[(nk + 1) * 
00515                             a_dim1 + 1], lda, &a[a_dim1 + 1], lda, &cbeta, &
00516                             c__[1], &nk);
00517 
00518                 }
00519 
00520             }
00521 
00522         }
00523 
00524     }
00525 
00526     return 0;
00527 
00528 /*     End of CHFRK */
00529 
00530 } /* chfrk_ */


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