LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
ctpttf.f
Go to the documentation of this file.
00001 *> \brief \b CTPTTF
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CTPTTF + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctpttf.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctpttf.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctpttf.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CTPTTF( TRANSR, UPLO, N, AP, ARF, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       CHARACTER          TRANSR, UPLO
00025 *       INTEGER            INFO, N
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       COMPLEX            AP( 0: * ), ARF( 0: * )
00029 *  
00030 *
00031 *> \par Purpose:
00032 *  =============
00033 *>
00034 *> \verbatim
00035 *>
00036 *> CTPTTF copies a triangular matrix A from standard packed format (TP)
00037 *> to rectangular full packed format (TF).
00038 *> \endverbatim
00039 *
00040 *  Arguments:
00041 *  ==========
00042 *
00043 *> \param[in] TRANSR
00044 *> \verbatim
00045 *>          TRANSR is CHARACTER*1
00046 *>          = 'N':  ARF in Normal format is wanted;
00047 *>          = 'C':  ARF in Conjugate-transpose format is wanted.
00048 *> \endverbatim
00049 *>
00050 *> \param[in] UPLO
00051 *> \verbatim
00052 *>          UPLO is CHARACTER*1
00053 *>          = 'U':  A is upper triangular;
00054 *>          = 'L':  A is lower triangular.
00055 *> \endverbatim
00056 *>
00057 *> \param[in] N
00058 *> \verbatim
00059 *>          N is INTEGER
00060 *>          The order of the matrix A.  N >= 0.
00061 *> \endverbatim
00062 *>
00063 *> \param[in] AP
00064 *> \verbatim
00065 *>          AP is COMPLEX array, dimension ( N*(N+1)/2 ),
00066 *>          On entry, the upper or lower triangular matrix A, packed
00067 *>          columnwise in a linear array. The j-th column of A is stored
00068 *>          in the array AP as follows:
00069 *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00070 *>          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
00071 *> \endverbatim
00072 *>
00073 *> \param[out] ARF
00074 *> \verbatim
00075 *>          ARF is COMPLEX array, dimension ( N*(N+1)/2 ),
00076 *>          On exit, the upper or lower triangular matrix A stored in
00077 *>          RFP format. For a further discussion see Notes below.
00078 *> \endverbatim
00079 *>
00080 *> \param[out] INFO
00081 *> \verbatim
00082 *>          INFO is INTEGER
00083 *>          = 0:  successful exit
00084 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00085 *> \endverbatim
00086 *
00087 *  Authors:
00088 *  ========
00089 *
00090 *> \author Univ. of Tennessee 
00091 *> \author Univ. of California Berkeley 
00092 *> \author Univ. of Colorado Denver 
00093 *> \author NAG Ltd. 
00094 *
00095 *> \date November 2011
00096 *
00097 *> \ingroup complexOTHERcomputational
00098 *
00099 *> \par Further Details:
00100 *  =====================
00101 *>
00102 *> \verbatim
00103 *>
00104 *>  We first consider Standard Packed Format when N is even.
00105 *>  We give an example where N = 6.
00106 *>
00107 *>      AP is Upper             AP is Lower
00108 *>
00109 *>   00 01 02 03 04 05       00
00110 *>      11 12 13 14 15       10 11
00111 *>         22 23 24 25       20 21 22
00112 *>            33 34 35       30 31 32 33
00113 *>               44 45       40 41 42 43 44
00114 *>                  55       50 51 52 53 54 55
00115 *>
00116 *>
00117 *>  Let TRANSR = 'N'. RFP holds AP as follows:
00118 *>  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
00119 *>  three columns of AP upper. The lower triangle A(4:6,0:2) consists of
00120 *>  conjugate-transpose of the first three columns of AP upper.
00121 *>  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
00122 *>  three columns of AP lower. The upper triangle A(0:2,0:2) consists of
00123 *>  conjugate-transpose of the last three columns of AP lower.
00124 *>  To denote conjugate we place -- above the element. This covers the
00125 *>  case N even and TRANSR = 'N'.
00126 *>
00127 *>         RFP A                   RFP A
00128 *>
00129 *>                                -- -- --
00130 *>        03 04 05                33 43 53
00131 *>                                   -- --
00132 *>        13 14 15                00 44 54
00133 *>                                      --
00134 *>        23 24 25                10 11 55
00135 *>
00136 *>        33 34 35                20 21 22
00137 *>        --
00138 *>        00 44 45                30 31 32
00139 *>        -- --
00140 *>        01 11 55                40 41 42
00141 *>        -- -- --
00142 *>        02 12 22                50 51 52
00143 *>
00144 *>  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate-
00145 *>  transpose of RFP A above. One therefore gets:
00146 *>
00147 *>
00148 *>           RFP A                   RFP A
00149 *>
00150 *>     -- -- -- --                -- -- -- -- -- --
00151 *>     03 13 23 33 00 01 02    33 00 10 20 30 40 50
00152 *>     -- -- -- -- --                -- -- -- -- --
00153 *>     04 14 24 34 44 11 12    43 44 11 21 31 41 51
00154 *>     -- -- -- -- -- --                -- -- -- --
00155 *>     05 15 25 35 45 55 22    53 54 55 22 32 42 52
00156 *>
00157 *>
00158 *>  We next  consider Standard Packed Format when N is odd.
00159 *>  We give an example where N = 5.
00160 *>
00161 *>     AP is Upper                 AP is Lower
00162 *>
00163 *>   00 01 02 03 04              00
00164 *>      11 12 13 14              10 11
00165 *>         22 23 24              20 21 22
00166 *>            33 34              30 31 32 33
00167 *>               44              40 41 42 43 44
00168 *>
00169 *>
00170 *>  Let TRANSR = 'N'. RFP holds AP as follows:
00171 *>  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
00172 *>  three columns of AP upper. The lower triangle A(3:4,0:1) consists of
00173 *>  conjugate-transpose of the first two   columns of AP upper.
00174 *>  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
00175 *>  three columns of AP lower. The upper triangle A(0:1,1:2) consists of
00176 *>  conjugate-transpose of the last two   columns of AP lower.
00177 *>  To denote conjugate we place -- above the element. This covers the
00178 *>  case N odd  and TRANSR = 'N'.
00179 *>
00180 *>         RFP A                   RFP A
00181 *>
00182 *>                                   -- --
00183 *>        02 03 04                00 33 43
00184 *>                                      --
00185 *>        12 13 14                10 11 44
00186 *>
00187 *>        22 23 24                20 21 22
00188 *>        --
00189 *>        00 33 34                30 31 32
00190 *>        -- --
00191 *>        01 11 44                40 41 42
00192 *>
00193 *>  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate-
00194 *>  transpose of RFP A above. One therefore gets:
00195 *>
00196 *>
00197 *>           RFP A                   RFP A
00198 *>
00199 *>     -- -- --                   -- -- -- -- -- --
00200 *>     02 12 22 00 01             00 10 20 30 40 50
00201 *>     -- -- -- --                   -- -- -- -- --
00202 *>     03 13 23 33 11             33 11 21 31 41 51
00203 *>     -- -- -- -- --                   -- -- -- --
00204 *>     04 14 24 34 44             43 44 22 32 42 52
00205 *> \endverbatim
00206 *>
00207 *  =====================================================================
00208       SUBROUTINE CTPTTF( TRANSR, UPLO, N, AP, ARF, INFO )
00209 *
00210 *  -- LAPACK computational routine (version 3.4.0) --
00211 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00212 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00213 *     November 2011
00214 *
00215 *     .. Scalar Arguments ..
00216       CHARACTER          TRANSR, UPLO
00217       INTEGER            INFO, N
00218 *     ..
00219 *     .. Array Arguments ..
00220       COMPLEX            AP( 0: * ), ARF( 0: * )
00221 *
00222 *  =====================================================================
00223 *
00224 *     .. Parameters ..
00225 *     ..
00226 *     .. Local Scalars ..
00227       LOGICAL            LOWER, NISODD, NORMALTRANSR
00228       INTEGER            N1, N2, K, NT
00229       INTEGER            I, J, IJ
00230       INTEGER            IJP, JP, LDA, JS
00231 *     ..
00232 *     .. External Functions ..
00233       LOGICAL            LSAME
00234       EXTERNAL           LSAME
00235 *     ..
00236 *     .. External Subroutines ..
00237       EXTERNAL           XERBLA
00238 *     ..
00239 *     .. Intrinsic Functions ..
00240       INTRINSIC          CONJG, MOD
00241 *     ..
00242 *     .. Executable Statements ..
00243 *
00244 *     Test the input parameters.
00245 *
00246       INFO = 0
00247       NORMALTRANSR = LSAME( TRANSR, 'N' )
00248       LOWER = LSAME( UPLO, 'L' )
00249       IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'C' ) ) THEN
00250          INFO = -1
00251       ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
00252          INFO = -2
00253       ELSE IF( N.LT.0 ) THEN
00254          INFO = -3
00255       END IF
00256       IF( INFO.NE.0 ) THEN
00257          CALL XERBLA( 'CTPTTF', -INFO )
00258          RETURN
00259       END IF
00260 *
00261 *     Quick return if possible
00262 *
00263       IF( N.EQ.0 )
00264      $   RETURN
00265 *
00266       IF( N.EQ.1 ) THEN
00267          IF( NORMALTRANSR ) THEN
00268             ARF( 0 ) = AP( 0 )
00269          ELSE
00270             ARF( 0 ) = CONJG( AP( 0 ) )
00271          END IF
00272          RETURN
00273       END IF
00274 *
00275 *     Size of array ARF(0:NT-1)
00276 *
00277       NT = N*( N+1 ) / 2
00278 *
00279 *     Set N1 and N2 depending on LOWER
00280 *
00281       IF( LOWER ) THEN
00282          N2 = N / 2
00283          N1 = N - N2
00284       ELSE
00285          N1 = N / 2
00286          N2 = N - N1
00287       END IF
00288 *
00289 *     If N is odd, set NISODD = .TRUE.
00290 *     If N is even, set K = N/2 and NISODD = .FALSE.
00291 *
00292 *     set lda of ARF^C; ARF^C is (0:(N+1)/2-1,0:N-noe)
00293 *     where noe = 0 if n is even, noe = 1 if n is odd
00294 *
00295       IF( MOD( N, 2 ).EQ.0 ) THEN
00296          K = N / 2
00297          NISODD = .FALSE.
00298          LDA = N + 1
00299       ELSE
00300          NISODD = .TRUE.
00301          LDA = N
00302       END IF
00303 *
00304 *     ARF^C has lda rows and n+1-noe cols
00305 *
00306       IF( .NOT.NORMALTRANSR )
00307      $   LDA = ( N+1 ) / 2
00308 *
00309 *     start execution: there are eight cases
00310 *
00311       IF( NISODD ) THEN
00312 *
00313 *        N is odd
00314 *
00315          IF( NORMALTRANSR ) THEN
00316 *
00317 *           N is odd and TRANSR = 'N'
00318 *
00319             IF( LOWER ) THEN
00320 *
00321 *             SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:n1-1) )
00322 *             T1 -> a(0,0), T2 -> a(0,1), S -> a(n1,0)
00323 *             T1 -> a(0), T2 -> a(n), S -> a(n1); lda = n
00324 *
00325                IJP = 0
00326                JP = 0
00327                DO J = 0, N2
00328                   DO I = J, N - 1
00329                      IJ = I + JP
00330                      ARF( IJ ) = AP( IJP )
00331                      IJP = IJP + 1
00332                   END DO
00333                   JP = JP + LDA
00334                END DO
00335                DO I = 0, N2 - 1
00336                   DO J = 1 + I, N2
00337                      IJ = I + J*LDA
00338                      ARF( IJ ) = CONJG( AP( IJP ) )
00339                      IJP = IJP + 1
00340                   END DO
00341                END DO
00342 *
00343             ELSE
00344 *
00345 *             SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:n2-1)
00346 *             T1 -> a(n1+1,0), T2 -> a(n1,0), S -> a(0,0)
00347 *             T1 -> a(n2), T2 -> a(n1), S -> a(0)
00348 *
00349                IJP = 0
00350                DO J = 0, N1 - 1
00351                   IJ = N2 + J
00352                   DO I = 0, J
00353                      ARF( IJ ) = CONJG( AP( IJP ) )
00354                      IJP = IJP + 1
00355                      IJ = IJ + LDA
00356                   END DO
00357                END DO
00358                JS = 0
00359                DO J = N1, N - 1
00360                   IJ = JS
00361                   DO IJ = JS, JS + J
00362                      ARF( IJ ) = AP( IJP )
00363                      IJP = IJP + 1
00364                   END DO
00365                   JS = JS + LDA
00366                END DO
00367 *
00368             END IF
00369 *
00370          ELSE
00371 *
00372 *           N is odd and TRANSR = 'C'
00373 *
00374             IF( LOWER ) THEN
00375 *
00376 *              SRPA for LOWER, TRANSPOSE and N is odd
00377 *              T1 -> A(0,0) , T2 -> A(1,0) , S -> A(0,n1)
00378 *              T1 -> a(0+0) , T2 -> a(1+0) , S -> a(0+n1*n1); lda=n1
00379 *
00380                IJP = 0
00381                DO I = 0, N2
00382                   DO IJ = I*( LDA+1 ), N*LDA - 1, LDA
00383                      ARF( IJ ) = CONJG( AP( IJP ) )
00384                      IJP = IJP + 1
00385                   END DO
00386                END DO
00387                JS = 1
00388                DO J = 0, N2 - 1
00389                   DO IJ = JS, JS + N2 - J - 1
00390                      ARF( IJ ) = AP( IJP )
00391                      IJP = IJP + 1
00392                   END DO
00393                   JS = JS + LDA + 1
00394                END DO
00395 *
00396             ELSE
00397 *
00398 *              SRPA for UPPER, TRANSPOSE and N is odd
00399 *              T1 -> A(0,n1+1), T2 -> A(0,n1), S -> A(0,0)
00400 *              T1 -> a(n2*n2), T2 -> a(n1*n2), S -> a(0); lda = n2
00401 *
00402                IJP = 0
00403                JS = N2*LDA
00404                DO J = 0, N1 - 1
00405                   DO IJ = JS, JS + J
00406                      ARF( IJ ) = AP( IJP )
00407                      IJP = IJP + 1
00408                   END DO
00409                   JS = JS + LDA
00410                END DO
00411                DO I = 0, N1
00412                   DO IJ = I, I + ( N1+I )*LDA, LDA
00413                      ARF( IJ ) = CONJG( AP( IJP ) )
00414                      IJP = IJP + 1
00415                   END DO
00416                END DO
00417 *
00418             END IF
00419 *
00420          END IF
00421 *
00422       ELSE
00423 *
00424 *        N is even
00425 *
00426          IF( NORMALTRANSR ) THEN
00427 *
00428 *           N is even and TRANSR = 'N'
00429 *
00430             IF( LOWER ) THEN
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                DO J = 0, K - 1
00439                   DO I = J, N - 1
00440                      IJ = 1 + I + JP
00441                      ARF( IJ ) = AP( IJP )
00442                      IJP = IJP + 1
00443                   END DO
00444                   JP = JP + LDA
00445                END DO
00446                DO I = 0, K - 1
00447                   DO J = I, K - 1
00448                      IJ = I + J*LDA
00449                      ARF( IJ ) = CONJG( AP( IJP ) )
00450                      IJP = IJP + 1
00451                   END DO
00452                END DO
00453 *
00454             ELSE
00455 *
00456 *              SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) )
00457 *              T1 -> a(k+1,0) ,  T2 -> a(k,0),   S -> a(0,0)
00458 *              T1 -> a(k+1), T2 -> a(k), S -> a(0)
00459 *
00460                IJP = 0
00461                DO J = 0, K - 1
00462                   IJ = K + 1 + J
00463                   DO I = 0, J
00464                      ARF( IJ ) = CONJG( AP( IJP ) )
00465                      IJP = IJP + 1
00466                      IJ = IJ + LDA
00467                   END DO
00468                END DO
00469                JS = 0
00470                DO J = K, N - 1
00471                   IJ = JS
00472                   DO IJ = JS, JS + J
00473                      ARF( IJ ) = AP( IJP )
00474                      IJP = IJP + 1
00475                   END DO
00476                   JS = JS + LDA
00477                END DO
00478 *
00479             END IF
00480 *
00481          ELSE
00482 *
00483 *           N is even and TRANSR = 'C'
00484 *
00485             IF( LOWER ) THEN
00486 *
00487 *              SRPA for LOWER, TRANSPOSE and N is even (see paper)
00488 *              T1 -> B(0,1), T2 -> B(0,0), S -> B(0,k+1)
00489 *              T1 -> a(0+k), T2 -> a(0+0), S -> a(0+k*(k+1)); lda=k
00490 *
00491                IJP = 0
00492                DO I = 0, K - 1
00493                   DO IJ = I + ( I+1 )*LDA, ( N+1 )*LDA - 1, LDA
00494                      ARF( IJ ) = CONJG( AP( IJP ) )
00495                      IJP = IJP + 1
00496                   END DO
00497                END DO
00498                JS = 0
00499                DO J = 0, K - 1
00500                   DO IJ = JS, JS + K - J - 1
00501                      ARF( IJ ) = AP( IJP )
00502                      IJP = IJP + 1
00503                   END DO
00504                   JS = JS + LDA + 1
00505                END DO
00506 *
00507             ELSE
00508 *
00509 *              SRPA for UPPER, TRANSPOSE and N is even (see paper)
00510 *              T1 -> B(0,k+1),     T2 -> B(0,k),   S -> B(0,0)
00511 *              T1 -> a(0+k*(k+1)), T2 -> a(0+k*k), S -> a(0+0)); lda=k
00512 *
00513                IJP = 0
00514                JS = ( K+1 )*LDA
00515                DO J = 0, K - 1
00516                   DO IJ = JS, JS + J
00517                      ARF( IJ ) = AP( IJP )
00518                      IJP = IJP + 1
00519                   END DO
00520                   JS = JS + LDA
00521                END DO
00522                DO I = 0, K - 1
00523                   DO IJ = I, I + ( K+I )*LDA, LDA
00524                      ARF( IJ ) = CONJG( AP( IJP ) )
00525                      IJP = IJP + 1
00526                   END DO
00527                END DO
00528 *
00529             END IF
00530 *
00531          END IF
00532 *
00533       END IF
00534 *
00535       RETURN
00536 *
00537 *     End of CTPTTF
00538 *
00539       END
 All Files Functions