LAPACK 3.3.0

dtpttf.f

Go to the documentation of this file.
00001       SUBROUTINE DTPTTF( TRANSR, UPLO, N, AP, ARF, INFO )
00002 *
00003 *  -- LAPACK routine (version 3.3.0)                                    --
00004 *
00005 *  -- Contributed by Fred Gustavson of the IBM Watson Research Center --
00006 *     November 2010
00007 *
00008 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00009 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00010 *
00011 *     ..
00012 *     .. Scalar Arguments ..
00013       CHARACTER          TRANSR, UPLO
00014       INTEGER            INFO, N
00015 *     ..
00016 *     .. Array Arguments ..
00017       DOUBLE PRECISION   AP( 0: * ), ARF( 0: * )
00018 *
00019 *  Purpose
00020 *  =======
00021 *
00022 *  DTPTTF copies a triangular matrix A from standard packed format (TP)
00023 *  to rectangular full packed format (TF).
00024 *
00025 *  Arguments
00026 *  =========
00027 *
00028 *  TRANSR  (input) CHARACTER*1
00029 *          = 'N':  ARF in Normal format is wanted;
00030 *          = 'T':  ARF in Conjugate-transpose format is wanted.
00031 *
00032 *  UPLO    (input) CHARACTER*1
00033 *          = 'U':  A is upper triangular;
00034 *          = 'L':  A is lower triangular.
00035 *
00036 *  N       (input) INTEGER
00037 *          The order of the matrix A.  N >= 0.
00038 *
00039 *  AP      (input) DOUBLE PRECISION array, dimension ( N*(N+1)/2 ),
00040 *          On entry, the upper or lower triangular matrix A, packed
00041 *          columnwise in a linear array. The j-th column of A is stored
00042 *          in the array AP as follows:
00043 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00044 *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
00045 *
00046 *  ARF     (output) DOUBLE PRECISION array, dimension ( N*(N+1)/2 ),
00047 *          On exit, the upper or lower triangular matrix A stored in
00048 *          RFP format. For a further discussion see Notes below.
00049 *
00050 *  INFO    (output) INTEGER
00051 *          = 0:  successful exit
00052 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00053 *
00054 *  Further Details
00055 *  ===============
00056 *
00057 *  We first consider Rectangular Full Packed (RFP) Format when N is
00058 *  even. We give an example where N = 6.
00059 *
00060 *      AP is Upper             AP is Lower
00061 *
00062 *   00 01 02 03 04 05       00
00063 *      11 12 13 14 15       10 11
00064 *         22 23 24 25       20 21 22
00065 *            33 34 35       30 31 32 33
00066 *               44 45       40 41 42 43 44
00067 *                  55       50 51 52 53 54 55
00068 *
00069 *
00070 *  Let TRANSR = 'N'. RFP holds AP as follows:
00071 *  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
00072 *  three columns of AP upper. The lower triangle A(4:6,0:2) consists of
00073 *  the transpose of the first three columns of AP upper.
00074 *  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
00075 *  three columns of AP lower. The upper triangle A(0:2,0:2) consists of
00076 *  the transpose of the last three columns of AP lower.
00077 *  This covers the case N even and TRANSR = 'N'.
00078 *
00079 *         RFP A                   RFP A
00080 *
00081 *        03 04 05                33 43 53
00082 *        13 14 15                00 44 54
00083 *        23 24 25                10 11 55
00084 *        33 34 35                20 21 22
00085 *        00 44 45                30 31 32
00086 *        01 11 55                40 41 42
00087 *        02 12 22                50 51 52
00088 *
00089 *  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
00090 *  transpose of RFP A above. One therefore gets:
00091 *
00092 *
00093 *           RFP A                   RFP A
00094 *
00095 *     03 13 23 33 00 01 02    33 00 10 20 30 40 50
00096 *     04 14 24 34 44 11 12    43 44 11 21 31 41 51
00097 *     05 15 25 35 45 55 22    53 54 55 22 32 42 52
00098 *
00099 *
00100 *  We then consider Rectangular Full Packed (RFP) Format when N is
00101 *  odd. We give an example where N = 5.
00102 *
00103 *     AP is Upper                 AP is Lower
00104 *
00105 *   00 01 02 03 04              00
00106 *      11 12 13 14              10 11
00107 *         22 23 24              20 21 22
00108 *            33 34              30 31 32 33
00109 *               44              40 41 42 43 44
00110 *
00111 *
00112 *  Let TRANSR = 'N'. RFP holds AP as follows:
00113 *  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
00114 *  three columns of AP upper. The lower triangle A(3:4,0:1) consists of
00115 *  the transpose of the first two columns of AP upper.
00116 *  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
00117 *  three columns of AP lower. The upper triangle A(0:1,1:2) consists of
00118 *  the transpose of the last two columns of AP lower.
00119 *  This covers the case N odd and TRANSR = 'N'.
00120 *
00121 *         RFP A                   RFP A
00122 *
00123 *        02 03 04                00 33 43
00124 *        12 13 14                10 11 44
00125 *        22 23 24                20 21 22
00126 *        00 33 34                30 31 32
00127 *        01 11 44                40 41 42
00128 *
00129 *  Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
00130 *  transpose of RFP A above. One therefore gets:
00131 *
00132 *           RFP A                   RFP A
00133 *
00134 *     02 12 22 00 01             00 10 20 30 40 50
00135 *     03 13 23 33 11             33 11 21 31 41 51
00136 *     04 14 24 34 44             43 44 22 32 42 52
00137 *
00138 *  =====================================================================
00139 *
00140 *     .. Parameters ..
00141 *     ..
00142 *     .. Local Scalars ..
00143       LOGICAL            LOWER, NISODD, NORMALTRANSR
00144       INTEGER            N1, N2, K, NT
00145       INTEGER            I, J, IJ
00146       INTEGER            IJP, JP, LDA, JS
00147 *     ..
00148 *     .. External Functions ..
00149       LOGICAL            LSAME
00150       EXTERNAL           LSAME
00151 *     ..
00152 *     .. External Subroutines ..
00153       EXTERNAL           XERBLA
00154 *     ..
00155 *     .. Intrinsic Functions ..
00156       INTRINSIC          MOD
00157 *     ..
00158 *     .. Executable Statements ..
00159 *
00160 *     Test the input parameters.
00161 *
00162       INFO = 0
00163       NORMALTRANSR = LSAME( TRANSR, 'N' )
00164       LOWER = LSAME( UPLO, 'L' )
00165       IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'T' ) ) THEN
00166          INFO = -1
00167       ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
00168          INFO = -2
00169       ELSE IF( N.LT.0 ) THEN
00170          INFO = -3
00171       END IF
00172       IF( INFO.NE.0 ) THEN
00173          CALL XERBLA( 'DTPTTF', -INFO )
00174          RETURN
00175       END IF
00176 *
00177 *     Quick return if possible
00178 *
00179       IF( N.EQ.0 )
00180      +   RETURN
00181 *
00182       IF( N.EQ.1 ) THEN
00183          IF( NORMALTRANSR ) THEN
00184             ARF( 0 ) = AP( 0 )
00185          ELSE
00186             ARF( 0 ) = AP( 0 )
00187          END IF
00188          RETURN
00189       END IF
00190 *
00191 *     Size of array ARF(0:NT-1)
00192 *
00193       NT = N*( N+1 ) / 2
00194 *
00195 *     Set N1 and N2 depending on LOWER
00196 *
00197       IF( LOWER ) THEN
00198          N2 = N / 2
00199          N1 = N - N2
00200       ELSE
00201          N1 = N / 2
00202          N2 = N - N1
00203       END IF
00204 *
00205 *     If N is odd, set NISODD = .TRUE.
00206 *     If N is even, set K = N/2 and NISODD = .FALSE.
00207 *
00208 *     set lda of ARF^C; ARF^C is (0:(N+1)/2-1,0:N-noe)
00209 *     where noe = 0 if n is even, noe = 1 if n is odd
00210 *
00211       IF( MOD( N, 2 ).EQ.0 ) THEN
00212          K = N / 2
00213          NISODD = .FALSE.
00214          LDA = N + 1
00215       ELSE
00216          NISODD = .TRUE.
00217          LDA = N
00218       END IF
00219 *
00220 *     ARF^C has lda rows and n+1-noe cols
00221 *
00222       IF( .NOT.NORMALTRANSR )
00223      +   LDA = ( N+1 ) / 2
00224 *
00225 *     start execution: there are eight cases
00226 *
00227       IF( NISODD ) THEN
00228 *
00229 *        N is odd
00230 *
00231          IF( NORMALTRANSR ) THEN
00232 *
00233 *           N is odd and TRANSR = 'N'
00234 *
00235             IF( LOWER ) THEN
00236 *
00237 *              N is odd, TRANSR = 'N', and UPLO = 'L'
00238 *
00239                IJP = 0
00240                JP = 0
00241                DO J = 0, N2
00242                   DO I = J, N - 1
00243                      IJ = I + JP
00244                      ARF( IJ ) = AP( IJP )
00245                      IJP = IJP + 1
00246                   END DO
00247                   JP = JP + LDA
00248                END DO
00249                DO I = 0, N2 - 1
00250                   DO J = 1 + I, N2
00251                      IJ = I + J*LDA
00252                      ARF( IJ ) = AP( IJP )
00253                      IJP = IJP + 1
00254                   END DO
00255                END DO
00256 *
00257             ELSE
00258 *
00259 *              N is odd, TRANSR = 'N', and UPLO = 'U'
00260 *
00261                IJP = 0
00262                DO J = 0, N1 - 1
00263                   IJ = N2 + J
00264                   DO I = 0, J
00265                      ARF( IJ ) = AP( IJP )
00266                      IJP = IJP + 1
00267                      IJ = IJ + LDA
00268                   END DO
00269                END DO
00270                JS = 0
00271                DO J = N1, N - 1
00272                   IJ = JS
00273                   DO IJ = JS, JS + J
00274                      ARF( IJ ) = AP( IJP )
00275                      IJP = IJP + 1
00276                   END DO
00277                   JS = JS + LDA
00278                END DO
00279 *
00280             END IF
00281 *
00282          ELSE
00283 *
00284 *           N is odd and TRANSR = 'T'
00285 *
00286             IF( LOWER ) THEN
00287 *
00288 *              N is odd, TRANSR = 'T', and UPLO = 'L'
00289 *
00290                IJP = 0
00291                DO I = 0, N2
00292                   DO IJ = I*( LDA+1 ), N*LDA - 1, LDA
00293                      ARF( IJ ) = AP( IJP )
00294                      IJP = IJP + 1
00295                   END DO
00296                END DO
00297                JS = 1
00298                DO J = 0, N2 - 1
00299                   DO IJ = JS, JS + N2 - J - 1
00300                      ARF( IJ ) = AP( IJP )
00301                      IJP = IJP + 1
00302                   END DO
00303                   JS = JS + LDA + 1
00304                END DO
00305 *
00306             ELSE
00307 *
00308 *              N is odd, TRANSR = 'T', and UPLO = 'U'
00309 *
00310                IJP = 0
00311                JS = N2*LDA
00312                DO J = 0, N1 - 1
00313                   DO IJ = JS, JS + J
00314                      ARF( IJ ) = AP( IJP )
00315                      IJP = IJP + 1
00316                   END DO
00317                   JS = JS + LDA
00318                END DO
00319                DO I = 0, N1
00320                   DO IJ = I, I + ( N1+I )*LDA, LDA
00321                      ARF( IJ ) = AP( IJP )
00322                      IJP = IJP + 1
00323                   END DO
00324                END DO
00325 *
00326             END IF
00327 *
00328          END IF
00329 *
00330       ELSE
00331 *
00332 *        N is even
00333 *
00334          IF( NORMALTRANSR ) THEN
00335 *
00336 *           N is even and TRANSR = 'N'
00337 *
00338             IF( LOWER ) THEN
00339 *
00340 *              N is even, TRANSR = 'N', and UPLO = 'L'
00341 *
00342                IJP = 0
00343                JP = 0
00344                DO J = 0, K - 1
00345                   DO I = J, N - 1
00346                      IJ = 1 + I + JP
00347                      ARF( IJ ) = AP( IJP )
00348                      IJP = IJP + 1
00349                   END DO
00350                   JP = JP + LDA
00351                END DO
00352                DO I = 0, K - 1
00353                   DO J = I, K - 1
00354                      IJ = I + J*LDA
00355                      ARF( IJ ) = AP( IJP )
00356                      IJP = IJP + 1
00357                   END DO
00358                END DO
00359 *
00360             ELSE
00361 *
00362 *              N is even, TRANSR = 'N', and UPLO = 'U'
00363 *
00364                IJP = 0
00365                DO J = 0, K - 1
00366                   IJ = K + 1 + J
00367                   DO I = 0, J
00368                      ARF( IJ ) = AP( IJP )
00369                      IJP = IJP + 1
00370                      IJ = IJ + LDA
00371                   END DO
00372                END DO
00373                JS = 0
00374                DO J = K, N - 1
00375                   IJ = JS
00376                   DO IJ = JS, JS + J
00377                      ARF( IJ ) = AP( IJP )
00378                      IJP = IJP + 1
00379                   END DO
00380                   JS = JS + LDA
00381                END DO
00382 *
00383             END IF
00384 *
00385          ELSE
00386 *
00387 *           N is even and TRANSR = 'T'
00388 *
00389             IF( LOWER ) THEN
00390 *
00391 *              N is even, TRANSR = 'T', and UPLO = 'L'
00392 *
00393                IJP = 0
00394                DO I = 0, K - 1
00395                   DO IJ = I + ( I+1 )*LDA, ( N+1 )*LDA - 1, LDA
00396                      ARF( IJ ) = AP( IJP )
00397                      IJP = IJP + 1
00398                   END DO
00399                END DO
00400                JS = 0
00401                DO J = 0, K - 1
00402                   DO IJ = JS, JS + K - J - 1
00403                      ARF( IJ ) = AP( IJP )
00404                      IJP = IJP + 1
00405                   END DO
00406                   JS = JS + LDA + 1
00407                END DO
00408 *
00409             ELSE
00410 *
00411 *              N is even, TRANSR = 'T', and UPLO = 'U'
00412 *
00413                IJP = 0
00414                JS = ( K+1 )*LDA
00415                DO J = 0, K - 1
00416                   DO IJ = JS, JS + J
00417                      ARF( IJ ) = AP( IJP )
00418                      IJP = IJP + 1
00419                   END DO
00420                   JS = JS + LDA
00421                END DO
00422                DO I = 0, K - 1
00423                   DO IJ = I, I + ( K+I )*LDA, LDA
00424                      ARF( IJ ) = AP( IJP )
00425                      IJP = IJP + 1
00426                   END DO
00427                END DO
00428 *
00429             END IF
00430 *
00431          END IF
00432 *
00433       END IF
00434 *
00435       RETURN
00436 *
00437 *     End of DTPTTF
00438 *
00439       END
 All Files Functions