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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:43