Annotation of rpl/lapack/lapack/dspgst.f, revision 1.18

1.9       bertrand    1: *> \brief \b DSPGST
                      2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
1.15      bertrand    5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
1.9       bertrand    7: *
                      8: *> \htmlonly
1.15      bertrand    9: *> Download DSPGST + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspgst.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspgst.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspgst.f">
1.9       bertrand   15: *> [TXT]</a>
1.15      bertrand   16: *> \endhtmlonly
1.9       bertrand   17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE DSPGST( ITYPE, UPLO, N, AP, BP, INFO )
1.15      bertrand   22: *
1.9       bertrand   23: *       .. Scalar Arguments ..
                     24: *       CHARACTER          UPLO
                     25: *       INTEGER            INFO, ITYPE, N
                     26: *       ..
                     27: *       .. Array Arguments ..
                     28: *       DOUBLE PRECISION   AP( * ), BP( * )
                     29: *       ..
1.15      bertrand   30: *
1.9       bertrand   31: *
                     32: *> \par Purpose:
                     33: *  =============
                     34: *>
                     35: *> \verbatim
                     36: *>
                     37: *> DSPGST reduces a real symmetric-definite generalized eigenproblem
                     38: *> to standard form, using packed storage.
                     39: *>
                     40: *> If ITYPE = 1, the problem is A*x = lambda*B*x,
                     41: *> and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T)
                     42: *>
                     43: *> If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or
                     44: *> B*A*x = lambda*x, and A is overwritten by U*A*U**T or L**T*A*L.
                     45: *>
                     46: *> B must have been previously factorized as U**T*U or L*L**T by DPPTRF.
                     47: *> \endverbatim
                     48: *
                     49: *  Arguments:
                     50: *  ==========
                     51: *
                     52: *> \param[in] ITYPE
                     53: *> \verbatim
                     54: *>          ITYPE is INTEGER
                     55: *>          = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T);
                     56: *>          = 2 or 3: compute U*A*U**T or L**T*A*L.
                     57: *> \endverbatim
                     58: *>
                     59: *> \param[in] UPLO
                     60: *> \verbatim
                     61: *>          UPLO is CHARACTER*1
                     62: *>          = 'U':  Upper triangle of A is stored and B is factored as
                     63: *>                  U**T*U;
                     64: *>          = 'L':  Lower triangle of A is stored and B is factored as
                     65: *>                  L*L**T.
                     66: *> \endverbatim
                     67: *>
                     68: *> \param[in] N
                     69: *> \verbatim
                     70: *>          N is INTEGER
                     71: *>          The order of the matrices A and B.  N >= 0.
                     72: *> \endverbatim
                     73: *>
                     74: *> \param[in,out] AP
                     75: *> \verbatim
                     76: *>          AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
                     77: *>          On entry, the upper or lower triangle of the symmetric matrix
                     78: *>          A, packed columnwise in a linear array.  The j-th column of A
                     79: *>          is stored in the array AP as follows:
                     80: *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
                     81: *>          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
                     82: *>
                     83: *>          On exit, if INFO = 0, the transformed matrix, stored in the
                     84: *>          same format as A.
                     85: *> \endverbatim
                     86: *>
                     87: *> \param[in] BP
                     88: *> \verbatim
                     89: *>          BP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
                     90: *>          The triangular factor from the Cholesky factorization of B,
                     91: *>          stored in the same format as A, as returned by DPPTRF.
                     92: *> \endverbatim
                     93: *>
                     94: *> \param[out] INFO
                     95: *> \verbatim
                     96: *>          INFO is INTEGER
                     97: *>          = 0:  successful exit
                     98: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
                     99: *> \endverbatim
                    100: *
                    101: *  Authors:
                    102: *  ========
                    103: *
1.15      bertrand  104: *> \author Univ. of Tennessee
                    105: *> \author Univ. of California Berkeley
                    106: *> \author Univ. of Colorado Denver
                    107: *> \author NAG Ltd.
1.9       bertrand  108: *
                    109: *> \ingroup doubleOTHERcomputational
                    110: *
                    111: *  =====================================================================
1.1       bertrand  112:       SUBROUTINE DSPGST( ITYPE, UPLO, N, AP, BP, INFO )
                    113: *
1.18    ! bertrand  114: *  -- LAPACK computational routine --
1.1       bertrand  115: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    116: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
                    117: *
                    118: *     .. Scalar Arguments ..
                    119:       CHARACTER          UPLO
                    120:       INTEGER            INFO, ITYPE, N
                    121: *     ..
                    122: *     .. Array Arguments ..
                    123:       DOUBLE PRECISION   AP( * ), BP( * )
                    124: *     ..
                    125: *
                    126: *  =====================================================================
                    127: *
                    128: *     .. Parameters ..
                    129:       DOUBLE PRECISION   ONE, HALF
                    130:       PARAMETER          ( ONE = 1.0D0, HALF = 0.5D0 )
                    131: *     ..
                    132: *     .. Local Scalars ..
                    133:       LOGICAL            UPPER
                    134:       INTEGER            J, J1, J1J1, JJ, K, K1, K1K1, KK
                    135:       DOUBLE PRECISION   AJJ, AKK, BJJ, BKK, CT
                    136: *     ..
                    137: *     .. External Subroutines ..
                    138:       EXTERNAL           DAXPY, DSCAL, DSPMV, DSPR2, DTPMV, DTPSV,
                    139:      $                   XERBLA
                    140: *     ..
                    141: *     .. External Functions ..
                    142:       LOGICAL            LSAME
                    143:       DOUBLE PRECISION   DDOT
                    144:       EXTERNAL           LSAME, DDOT
                    145: *     ..
                    146: *     .. Executable Statements ..
                    147: *
                    148: *     Test the input parameters.
                    149: *
                    150:       INFO = 0
                    151:       UPPER = LSAME( UPLO, 'U' )
                    152:       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
                    153:          INFO = -1
                    154:       ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
                    155:          INFO = -2
                    156:       ELSE IF( N.LT.0 ) THEN
                    157:          INFO = -3
                    158:       END IF
                    159:       IF( INFO.NE.0 ) THEN
                    160:          CALL XERBLA( 'DSPGST', -INFO )
                    161:          RETURN
                    162:       END IF
                    163: *
                    164:       IF( ITYPE.EQ.1 ) THEN
                    165:          IF( UPPER ) THEN
                    166: *
1.8       bertrand  167: *           Compute inv(U**T)*A*inv(U)
1.1       bertrand  168: *
                    169: *           J1 and JJ are the indices of A(1,j) and A(j,j)
                    170: *
                    171:             JJ = 0
                    172:             DO 10 J = 1, N
                    173:                J1 = JJ + 1
                    174:                JJ = JJ + J
                    175: *
                    176: *              Compute the j-th column of the upper triangle of A
                    177: *
                    178:                BJJ = BP( JJ )
                    179:                CALL DTPSV( UPLO, 'Transpose', 'Nonunit', J, BP,
                    180:      $                     AP( J1 ), 1 )
                    181:                CALL DSPMV( UPLO, J-1, -ONE, AP, BP( J1 ), 1, ONE,
                    182:      $                     AP( J1 ), 1 )
                    183:                CALL DSCAL( J-1, ONE / BJJ, AP( J1 ), 1 )
                    184:                AP( JJ ) = ( AP( JJ )-DDOT( J-1, AP( J1 ), 1, BP( J1 ),
                    185:      $                    1 ) ) / BJJ
                    186:    10       CONTINUE
                    187:          ELSE
                    188: *
1.8       bertrand  189: *           Compute inv(L)*A*inv(L**T)
1.1       bertrand  190: *
                    191: *           KK and K1K1 are the indices of A(k,k) and A(k+1,k+1)
                    192: *
                    193:             KK = 1
                    194:             DO 20 K = 1, N
                    195:                K1K1 = KK + N - K + 1
                    196: *
                    197: *              Update the lower triangle of A(k:n,k:n)
                    198: *
                    199:                AKK = AP( KK )
                    200:                BKK = BP( KK )
                    201:                AKK = AKK / BKK**2
                    202:                AP( KK ) = AKK
                    203:                IF( K.LT.N ) THEN
                    204:                   CALL DSCAL( N-K, ONE / BKK, AP( KK+1 ), 1 )
                    205:                   CT = -HALF*AKK
                    206:                   CALL DAXPY( N-K, CT, BP( KK+1 ), 1, AP( KK+1 ), 1 )
                    207:                   CALL DSPR2( UPLO, N-K, -ONE, AP( KK+1 ), 1,
                    208:      $                        BP( KK+1 ), 1, AP( K1K1 ) )
                    209:                   CALL DAXPY( N-K, CT, BP( KK+1 ), 1, AP( KK+1 ), 1 )
                    210:                   CALL DTPSV( UPLO, 'No transpose', 'Non-unit', N-K,
                    211:      $                        BP( K1K1 ), AP( KK+1 ), 1 )
                    212:                END IF
                    213:                KK = K1K1
                    214:    20       CONTINUE
                    215:          END IF
                    216:       ELSE
                    217:          IF( UPPER ) THEN
                    218: *
1.8       bertrand  219: *           Compute U*A*U**T
1.1       bertrand  220: *
                    221: *           K1 and KK are the indices of A(1,k) and A(k,k)
                    222: *
                    223:             KK = 0
                    224:             DO 30 K = 1, N
                    225:                K1 = KK + 1
                    226:                KK = KK + K
                    227: *
                    228: *              Update the upper triangle of A(1:k,1:k)
                    229: *
                    230:                AKK = AP( KK )
                    231:                BKK = BP( KK )
                    232:                CALL DTPMV( UPLO, 'No transpose', 'Non-unit', K-1, BP,
                    233:      $                     AP( K1 ), 1 )
                    234:                CT = HALF*AKK
                    235:                CALL DAXPY( K-1, CT, BP( K1 ), 1, AP( K1 ), 1 )
                    236:                CALL DSPR2( UPLO, K-1, ONE, AP( K1 ), 1, BP( K1 ), 1,
                    237:      $                     AP )
                    238:                CALL DAXPY( K-1, CT, BP( K1 ), 1, AP( K1 ), 1 )
                    239:                CALL DSCAL( K-1, BKK, AP( K1 ), 1 )
                    240:                AP( KK ) = AKK*BKK**2
                    241:    30       CONTINUE
                    242:          ELSE
                    243: *
1.8       bertrand  244: *           Compute L**T *A*L
1.1       bertrand  245: *
                    246: *           JJ and J1J1 are the indices of A(j,j) and A(j+1,j+1)
                    247: *
                    248:             JJ = 1
                    249:             DO 40 J = 1, N
                    250:                J1J1 = JJ + N - J + 1
                    251: *
                    252: *              Compute the j-th column of the lower triangle of A
                    253: *
                    254:                AJJ = AP( JJ )
                    255:                BJJ = BP( JJ )
                    256:                AP( JJ ) = AJJ*BJJ + DDOT( N-J, AP( JJ+1 ), 1,
                    257:      $                    BP( JJ+1 ), 1 )
                    258:                CALL DSCAL( N-J, BJJ, AP( JJ+1 ), 1 )
                    259:                CALL DSPMV( UPLO, N-J, ONE, AP( J1J1 ), BP( JJ+1 ), 1,
                    260:      $                     ONE, AP( JJ+1 ), 1 )
                    261:                CALL DTPMV( UPLO, 'Transpose', 'Non-unit', N-J+1,
                    262:      $                     BP( JJ ), AP( JJ ), 1 )
                    263:                JJ = J1J1
                    264:    40       CONTINUE
                    265:          END IF
                    266:       END IF
                    267:       RETURN
                    268: *
                    269: *     End of DSPGST
                    270: *
                    271:       END

CVSweb interface <joel.bertrand@systella.fr>