ctfttp.c
Go to the documentation of this file.
00001 /* ctfttp.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 ctfttp_(char *transr, char *uplo, integer *n, complex *
00017         arf, complex *ap, integer *info)
00018 {
00019     /* System generated locals */
00020     integer i__1, i__2, i__3, i__4;
00021     complex q__1;
00022 
00023     /* Builtin functions */
00024     void r_cnjg(complex *, complex *);
00025 
00026     /* Local variables */
00027     integer i__, j, k, n1, n2, ij, jp, js, nt, lda, ijp;
00028     logical normaltransr;
00029     extern logical lsame_(char *, char *);
00030     logical lower;
00031     extern /* Subroutine */ int xerbla_(char *, integer *);
00032     logical nisodd;
00033 
00034 
00035 /*  -- LAPACK routine (version 3.2)                                    -- */
00036 
00037 /*  -- Contributed by Fred Gustavson of the IBM Watson Research Center -- */
00038 /*  -- November 2008                                                   -- */
00039 
00040 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
00041 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
00042 
00043 /*     .. */
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  CTFTTP copies a triangular matrix A from rectangular full packed */
00053 /*  format (TF) to standard packed format (TP). */
00054 
00055 /*  Arguments */
00056 /*  ========= */
00057 
00058 /*  TRANSR   (input) CHARACTER */
00059 /*          = 'N':  ARF is in Normal format; */
00060 /*          = 'C':  ARF is in Conjugate-transpose format; */
00061 
00062 /*  UPLO    (input) CHARACTER */
00063 /*          = 'U':  A is upper triangular; */
00064 /*          = 'L':  A is lower triangular. */
00065 
00066 /*  N       (input) INTEGER */
00067 /*          The order of the matrix A. N >= 0. */
00068 
00069 /*  ARF     (input) COMPLEX array, dimension ( N*(N+1)/2 ), */
00070 /*          On entry, the upper or lower triangular matrix A stored in */
00071 /*          RFP format. For a further discussion see Notes below. */
00072 
00073 /*  AP      (output) COMPLEX array, dimension ( N*(N+1)/2 ), */
00074 /*          On exit, the upper or lower triangular matrix A, packed */
00075 /*          columnwise in a linear array. The j-th column of A is stored */
00076 /*          in the array AP as follows: */
00077 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00078 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00079 
00080 /*  INFO    (output) INTEGER */
00081 /*          = 0:  successful exit */
00082 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00083 
00084 /*  Notes: */
00085 /*  ====== */
00086 
00087 /*  We first consider Standard Packed Format when N is even. */
00088 /*  We give an example where N = 6. */
00089 
00090 /*      AP is Upper             AP is Lower */
00091 
00092 /*   00 01 02 03 04 05       00 */
00093 /*      11 12 13 14 15       10 11 */
00094 /*         22 23 24 25       20 21 22 */
00095 /*            33 34 35       30 31 32 33 */
00096 /*               44 45       40 41 42 43 44 */
00097 /*                  55       50 51 52 53 54 55 */
00098 
00099 
00100 /*  Let TRANSR = 'N'. RFP holds AP as follows: */
00101 /*  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
00102 /*  three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
00103 /*  conjugate-transpose of the first three columns of AP upper. */
00104 /*  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
00105 /*  three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
00106 /*  conjugate-transpose of the last three columns of AP lower. */
00107 /*  To denote conjugate we place -- above the element. This covers the */
00108 /*  case N even and TRANSR = 'N'. */
00109 
00110 /*         RFP A                   RFP A */
00111 
00112 /*                                -- -- -- */
00113 /*        03 04 05                33 43 53 */
00114 /*                                   -- -- */
00115 /*        13 14 15                00 44 54 */
00116 /*                                      -- */
00117 /*        23 24 25                10 11 55 */
00118 
00119 /*        33 34 35                20 21 22 */
00120 /*        -- */
00121 /*        00 44 45                30 31 32 */
00122 /*        -- -- */
00123 /*        01 11 55                40 41 42 */
00124 /*        -- -- -- */
00125 /*        02 12 22                50 51 52 */
00126 
00127 /*  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
00128 /*  transpose of RFP A above. One therefore gets: */
00129 
00130 
00131 /*           RFP A                   RFP A */
00132 
00133 /*     -- -- -- --                -- -- -- -- -- -- */
00134 /*     03 13 23 33 00 01 02    33 00 10 20 30 40 50 */
00135 /*     -- -- -- -- --                -- -- -- -- -- */
00136 /*     04 14 24 34 44 11 12    43 44 11 21 31 41 51 */
00137 /*     -- -- -- -- -- --                -- -- -- -- */
00138 /*     05 15 25 35 45 55 22    53 54 55 22 32 42 52 */
00139 
00140 
00141 /*  We next  consider Standard Packed Format when N is odd. */
00142 /*  We give an example where N = 5. */
00143 
00144 /*     AP is Upper                 AP is Lower */
00145 
00146 /*   00 01 02 03 04              00 */
00147 /*      11 12 13 14              10 11 */
00148 /*         22 23 24              20 21 22 */
00149 /*            33 34              30 31 32 33 */
00150 /*               44              40 41 42 43 44 */
00151 
00152 
00153 /*  Let TRANSR = 'N'. RFP holds AP as follows: */
00154 /*  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
00155 /*  three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
00156 /*  conjugate-transpose of the first two   columns of AP upper. */
00157 /*  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
00158 /*  three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
00159 /*  conjugate-transpose of the last two   columns of AP lower. */
00160 /*  To denote conjugate we place -- above the element. This covers the */
00161 /*  case N odd  and TRANSR = 'N'. */
00162 
00163 /*         RFP A                   RFP A */
00164 
00165 /*                                   -- -- */
00166 /*        02 03 04                00 33 43 */
00167 /*                                      -- */
00168 /*        12 13 14                10 11 44 */
00169 
00170 /*        22 23 24                20 21 22 */
00171 /*        -- */
00172 /*        00 33 34                30 31 32 */
00173 /*        -- -- */
00174 /*        01 11 44                40 41 42 */
00175 
00176 /*  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
00177 /*  transpose of RFP A above. One therefore gets: */
00178 
00179 
00180 /*           RFP A                   RFP A */
00181 
00182 /*     -- -- --                   -- -- -- -- -- -- */
00183 /*     02 12 22 00 01             00 10 20 30 40 50 */
00184 /*     -- -- -- --                   -- -- -- -- -- */
00185 /*     03 13 23 33 11             33 11 21 31 41 51 */
00186 /*     -- -- -- -- --                   -- -- -- -- */
00187 /*     04 14 24 34 44             43 44 22 32 42 52 */
00188 
00189 /*  ===================================================================== */
00190 
00191 /*     .. Parameters .. */
00192 /*     .. */
00193 /*     .. Local Scalars .. */
00194 /*     .. */
00195 /*     .. External Functions .. */
00196 /*     .. */
00197 /*     .. External Subroutines .. */
00198 /*     .. */
00199 /*     .. Intrinsic Functions .. */
00200 /*     .. */
00201 /*     .. Intrinsic Functions .. */
00202 /*     .. */
00203 /*     .. Executable Statements .. */
00204 
00205 /*     Test the input parameters. */
00206 
00207     *info = 0;
00208     normaltransr = lsame_(transr, "N");
00209     lower = lsame_(uplo, "L");
00210     if (! normaltransr && ! lsame_(transr, "C")) {
00211         *info = -1;
00212     } else if (! lower && ! lsame_(uplo, "U")) {
00213         *info = -2;
00214     } else if (*n < 0) {
00215         *info = -3;
00216     }
00217     if (*info != 0) {
00218         i__1 = -(*info);
00219         xerbla_("CTFTTP", &i__1);
00220         return 0;
00221     }
00222 
00223 /*     Quick return if possible */
00224 
00225     if (*n == 0) {
00226         return 0;
00227     }
00228 
00229     if (*n == 1) {
00230         if (normaltransr) {
00231             ap[0].r = arf[0].r, ap[0].i = arf[0].i;
00232         } else {
00233             r_cnjg(&q__1, arf);
00234             ap[0].r = q__1.r, ap[0].i = q__1.i;
00235         }
00236         return 0;
00237     }
00238 
00239 /*     Size of array ARF(0:NT-1) */
00240 
00241     nt = *n * (*n + 1) / 2;
00242 
00243 /*     Set N1 and N2 depending on LOWER */
00244 
00245     if (lower) {
00246         n2 = *n / 2;
00247         n1 = *n - n2;
00248     } else {
00249         n1 = *n / 2;
00250         n2 = *n - n1;
00251     }
00252 
00253 /*     If N is odd, set NISODD = .TRUE. */
00254 /*     If N is even, set K = N/2 and NISODD = .FALSE. */
00255 
00256 /*     set lda of ARF^C; ARF^C is (0:(N+1)/2-1,0:N-noe) */
00257 /*     where noe = 0 if n is even, noe = 1 if n is odd */
00258 
00259     if (*n % 2 == 0) {
00260         k = *n / 2;
00261         nisodd = FALSE_;
00262         lda = *n + 1;
00263     } else {
00264         nisodd = TRUE_;
00265         lda = *n;
00266     }
00267 
00268 /*     ARF^C has lda rows and n+1-noe cols */
00269 
00270     if (! normaltransr) {
00271         lda = (*n + 1) / 2;
00272     }
00273 
00274 /*     start execution: there are eight cases */
00275 
00276     if (nisodd) {
00277 
00278 /*        N is odd */
00279 
00280         if (normaltransr) {
00281 
00282 /*           N is odd and TRANSR = 'N' */
00283 
00284             if (lower) {
00285 
00286 /*             SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:n1-1) ) */
00287 /*             T1 -> a(0,0), T2 -> a(0,1), S -> a(n1,0) */
00288 /*             T1 -> a(0), T2 -> a(n), S -> a(n1); lda = n */
00289 
00290                 ijp = 0;
00291                 jp = 0;
00292                 i__1 = n2;
00293                 for (j = 0; j <= i__1; ++j) {
00294                     i__2 = *n - 1;
00295                     for (i__ = j; i__ <= i__2; ++i__) {
00296                         ij = i__ + jp;
00297                         i__3 = ijp;
00298                         i__4 = ij;
00299                         ap[i__3].r = arf[i__4].r, ap[i__3].i = arf[i__4].i;
00300                         ++ijp;
00301                     }
00302                     jp += lda;
00303                 }
00304                 i__1 = n2 - 1;
00305                 for (i__ = 0; i__ <= i__1; ++i__) {
00306                     i__2 = n2;
00307                     for (j = i__ + 1; j <= i__2; ++j) {
00308                         ij = i__ + j * lda;
00309                         i__3 = ijp;
00310                         r_cnjg(&q__1, &arf[ij]);
00311                         ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
00312                         ++ijp;
00313                     }
00314                 }
00315 
00316             } else {
00317 
00318 /*             SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:n2-1) */
00319 /*             T1 -> a(n1+1,0), T2 -> a(n1,0), S -> a(0,0) */
00320 /*             T1 -> a(n2), T2 -> a(n1), S -> a(0) */
00321 
00322                 ijp = 0;
00323                 i__1 = n1 - 1;
00324                 for (j = 0; j <= i__1; ++j) {
00325                     ij = n2 + j;
00326                     i__2 = j;
00327                     for (i__ = 0; i__ <= i__2; ++i__) {
00328                         i__3 = ijp;
00329                         r_cnjg(&q__1, &arf[ij]);
00330                         ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
00331                         ++ijp;
00332                         ij += lda;
00333                     }
00334                 }
00335                 js = 0;
00336                 i__1 = *n - 1;
00337                 for (j = n1; j <= i__1; ++j) {
00338                     ij = js;
00339                     i__2 = js + j;
00340                     for (ij = js; ij <= i__2; ++ij) {
00341                         i__3 = ijp;
00342                         i__4 = ij;
00343                         ap[i__3].r = arf[i__4].r, ap[i__3].i = arf[i__4].i;
00344                         ++ijp;
00345                     }
00346                     js += lda;
00347                 }
00348 
00349             }
00350 
00351         } else {
00352 
00353 /*           N is odd and TRANSR = 'C' */
00354 
00355             if (lower) {
00356 
00357 /*              SRPA for LOWER, TRANSPOSE and N is odd */
00358 /*              T1 -> A(0,0) , T2 -> A(1,0) , S -> A(0,n1) */
00359 /*              T1 -> a(0+0) , T2 -> a(1+0) , S -> a(0+n1*n1); lda=n1 */
00360 
00361                 ijp = 0;
00362                 i__1 = n2;
00363                 for (i__ = 0; i__ <= i__1; ++i__) {
00364                     i__2 = *n * lda - 1;
00365                     i__3 = lda;
00366                     for (ij = i__ * (lda + 1); i__3 < 0 ? ij >= i__2 : ij <= 
00367                             i__2; ij += i__3) {
00368                         i__4 = ijp;
00369                         r_cnjg(&q__1, &arf[ij]);
00370                         ap[i__4].r = q__1.r, ap[i__4].i = q__1.i;
00371                         ++ijp;
00372                     }
00373                 }
00374                 js = 1;
00375                 i__1 = n2 - 1;
00376                 for (j = 0; j <= i__1; ++j) {
00377                     i__3 = js + n2 - j - 1;
00378                     for (ij = js; ij <= i__3; ++ij) {
00379                         i__2 = ijp;
00380                         i__4 = ij;
00381                         ap[i__2].r = arf[i__4].r, ap[i__2].i = arf[i__4].i;
00382                         ++ijp;
00383                     }
00384                     js = js + lda + 1;
00385                 }
00386 
00387             } else {
00388 
00389 /*              SRPA for UPPER, TRANSPOSE and N is odd */
00390 /*              T1 -> A(0,n1+1), T2 -> A(0,n1), S -> A(0,0) */
00391 /*              T1 -> a(n2*n2), T2 -> a(n1*n2), S -> a(0); lda = n2 */
00392 
00393                 ijp = 0;
00394                 js = n2 * lda;
00395                 i__1 = n1 - 1;
00396                 for (j = 0; j <= i__1; ++j) {
00397                     i__3 = js + j;
00398                     for (ij = js; ij <= i__3; ++ij) {
00399                         i__2 = ijp;
00400                         i__4 = ij;
00401                         ap[i__2].r = arf[i__4].r, ap[i__2].i = arf[i__4].i;
00402                         ++ijp;
00403                     }
00404                     js += lda;
00405                 }
00406                 i__1 = n1;
00407                 for (i__ = 0; i__ <= i__1; ++i__) {
00408                     i__3 = i__ + (n1 + i__) * lda;
00409                     i__2 = lda;
00410                     for (ij = i__; i__2 < 0 ? ij >= i__3 : ij <= i__3; ij += 
00411                             i__2) {
00412                         i__4 = ijp;
00413                         r_cnjg(&q__1, &arf[ij]);
00414                         ap[i__4].r = q__1.r, ap[i__4].i = q__1.i;
00415                         ++ijp;
00416                     }
00417                 }
00418 
00419             }
00420 
00421         }
00422 
00423     } else {
00424 
00425 /*        N is even */
00426 
00427         if (normaltransr) {
00428 
00429 /*           N is even and TRANSR = 'N' */
00430 
00431             if (lower) {
00432 
00433 /*              SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) ) */
00434 /*              T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0) */
00435 /*              T1 -> a(1), T2 -> a(0), S -> a(k+1) */
00436 
00437                 ijp = 0;
00438                 jp = 0;
00439                 i__1 = k - 1;
00440                 for (j = 0; j <= i__1; ++j) {
00441                     i__2 = *n - 1;
00442                     for (i__ = j; i__ <= i__2; ++i__) {
00443                         ij = i__ + 1 + jp;
00444                         i__3 = ijp;
00445                         i__4 = ij;
00446                         ap[i__3].r = arf[i__4].r, ap[i__3].i = arf[i__4].i;
00447                         ++ijp;
00448                     }
00449                     jp += lda;
00450                 }
00451                 i__1 = k - 1;
00452                 for (i__ = 0; i__ <= i__1; ++i__) {
00453                     i__2 = k - 1;
00454                     for (j = i__; j <= i__2; ++j) {
00455                         ij = i__ + j * lda;
00456                         i__3 = ijp;
00457                         r_cnjg(&q__1, &arf[ij]);
00458                         ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
00459                         ++ijp;
00460                     }
00461                 }
00462 
00463             } else {
00464 
00465 /*              SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) ) */
00466 /*              T1 -> a(k+1,0) ,  T2 -> a(k,0),   S -> a(0,0) */
00467 /*              T1 -> a(k+1), T2 -> a(k), S -> a(0) */
00468 
00469                 ijp = 0;
00470                 i__1 = k - 1;
00471                 for (j = 0; j <= i__1; ++j) {
00472                     ij = k + 1 + j;
00473                     i__2 = j;
00474                     for (i__ = 0; i__ <= i__2; ++i__) {
00475                         i__3 = ijp;
00476                         r_cnjg(&q__1, &arf[ij]);
00477                         ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
00478                         ++ijp;
00479                         ij += lda;
00480                     }
00481                 }
00482                 js = 0;
00483                 i__1 = *n - 1;
00484                 for (j = k; j <= i__1; ++j) {
00485                     ij = js;
00486                     i__2 = js + j;
00487                     for (ij = js; ij <= i__2; ++ij) {
00488                         i__3 = ijp;
00489                         i__4 = ij;
00490                         ap[i__3].r = arf[i__4].r, ap[i__3].i = arf[i__4].i;
00491                         ++ijp;
00492                     }
00493                     js += lda;
00494                 }
00495 
00496             }
00497 
00498         } else {
00499 
00500 /*           N is even and TRANSR = 'C' */
00501 
00502             if (lower) {
00503 
00504 /*              SRPA for LOWER, TRANSPOSE and N is even (see paper) */
00505 /*              T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1) */
00506 /*              T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k */
00507 
00508                 ijp = 0;
00509                 i__1 = k - 1;
00510                 for (i__ = 0; i__ <= i__1; ++i__) {
00511                     i__2 = (*n + 1) * lda - 1;
00512                     i__3 = lda;
00513                     for (ij = i__ + (i__ + 1) * lda; i__3 < 0 ? ij >= i__2 : 
00514                             ij <= i__2; ij += i__3) {
00515                         i__4 = ijp;
00516                         r_cnjg(&q__1, &arf[ij]);
00517                         ap[i__4].r = q__1.r, ap[i__4].i = q__1.i;
00518                         ++ijp;
00519                     }
00520                 }
00521                 js = 0;
00522                 i__1 = k - 1;
00523                 for (j = 0; j <= i__1; ++j) {
00524                     i__3 = js + k - j - 1;
00525                     for (ij = js; ij <= i__3; ++ij) {
00526                         i__2 = ijp;
00527                         i__4 = ij;
00528                         ap[i__2].r = arf[i__4].r, ap[i__2].i = arf[i__4].i;
00529                         ++ijp;
00530                     }
00531                     js = js + lda + 1;
00532                 }
00533 
00534             } else {
00535 
00536 /*              SRPA for UPPER, TRANSPOSE and N is even (see paper) */
00537 /*              T1 -> B(0,k+1),     T2 -> B(0,k),   S -> B(0,0) */
00538 /*              T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k */
00539 
00540                 ijp = 0;
00541                 js = (k + 1) * lda;
00542                 i__1 = k - 1;
00543                 for (j = 0; j <= i__1; ++j) {
00544                     i__3 = js + j;
00545                     for (ij = js; ij <= i__3; ++ij) {
00546                         i__2 = ijp;
00547                         i__4 = ij;
00548                         ap[i__2].r = arf[i__4].r, ap[i__2].i = arf[i__4].i;
00549                         ++ijp;
00550                     }
00551                     js += lda;
00552                 }
00553                 i__1 = k - 1;
00554                 for (i__ = 0; i__ <= i__1; ++i__) {
00555                     i__3 = i__ + (k + i__) * lda;
00556                     i__2 = lda;
00557                     for (ij = i__; i__2 < 0 ? ij >= i__3 : ij <= i__3; ij += 
00558                             i__2) {
00559                         i__4 = ijp;
00560                         r_cnjg(&q__1, &arf[ij]);
00561                         ap[i__4].r = q__1.r, ap[i__4].i = q__1.i;
00562                         ++ijp;
00563                     }
00564                 }
00565 
00566             }
00567 
00568         }
00569 
00570     }
00571 
00572     return 0;
00573 
00574 /*     End of CTFTTP */
00575 
00576 } /* ctfttp_ */


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