Annotation of rpl/lapack/lapack/dlasd2.f, revision 1.10

1.9       bertrand    1: *> \brief \b DLASD2
                      2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
                      5: * Online html documentation available at 
                      6: *            http://www.netlib.org/lapack/explore-html/ 
                      7: *
                      8: *> \htmlonly
                      9: *> Download DLASD2 + dependencies 
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasd2.f"> 
                     11: *> [TGZ]</a> 
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasd2.f"> 
                     13: *> [ZIP]</a> 
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasd2.f"> 
                     15: *> [TXT]</a>
                     16: *> \endhtmlonly 
                     17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
                     22: *                          LDVT, DSIGMA, U2, LDU2, VT2, LDVT2, IDXP, IDX,
                     23: *                          IDXC, IDXQ, COLTYP, INFO )
                     24: * 
                     25: *       .. Scalar Arguments ..
                     26: *       INTEGER            INFO, K, LDU, LDU2, LDVT, LDVT2, NL, NR, SQRE
                     27: *       DOUBLE PRECISION   ALPHA, BETA
                     28: *       ..
                     29: *       .. Array Arguments ..
                     30: *       INTEGER            COLTYP( * ), IDX( * ), IDXC( * ), IDXP( * ),
                     31: *      $                   IDXQ( * )
                     32: *       DOUBLE PRECISION   D( * ), DSIGMA( * ), U( LDU, * ),
                     33: *      $                   U2( LDU2, * ), VT( LDVT, * ), VT2( LDVT2, * ),
                     34: *      $                   Z( * )
                     35: *       ..
                     36: *  
                     37: *
                     38: *> \par Purpose:
                     39: *  =============
                     40: *>
                     41: *> \verbatim
                     42: *>
                     43: *> DLASD2 merges the two sets of singular values together into a single
                     44: *> sorted set.  Then it tries to deflate the size of the problem.
                     45: *> There are two ways in which deflation can occur:  when two or more
                     46: *> singular values are close together or if there is a tiny entry in the
                     47: *> Z vector.  For each such occurrence the order of the related secular
                     48: *> equation problem is reduced by one.
                     49: *>
                     50: *> DLASD2 is called from DLASD1.
                     51: *> \endverbatim
                     52: *
                     53: *  Arguments:
                     54: *  ==========
                     55: *
                     56: *> \param[in] NL
                     57: *> \verbatim
                     58: *>          NL is INTEGER
                     59: *>         The row dimension of the upper block.  NL >= 1.
                     60: *> \endverbatim
                     61: *>
                     62: *> \param[in] NR
                     63: *> \verbatim
                     64: *>          NR is INTEGER
                     65: *>         The row dimension of the lower block.  NR >= 1.
                     66: *> \endverbatim
                     67: *>
                     68: *> \param[in] SQRE
                     69: *> \verbatim
                     70: *>          SQRE is INTEGER
                     71: *>         = 0: the lower block is an NR-by-NR square matrix.
                     72: *>         = 1: the lower block is an NR-by-(NR+1) rectangular matrix.
                     73: *>
                     74: *>         The bidiagonal matrix has N = NL + NR + 1 rows and
                     75: *>         M = N + SQRE >= N columns.
                     76: *> \endverbatim
                     77: *>
                     78: *> \param[out] K
                     79: *> \verbatim
                     80: *>          K is INTEGER
                     81: *>         Contains the dimension of the non-deflated matrix,
                     82: *>         This is the order of the related secular equation. 1 <= K <=N.
                     83: *> \endverbatim
                     84: *>
                     85: *> \param[in,out] D
                     86: *> \verbatim
                     87: *>          D is DOUBLE PRECISION array, dimension(N)
                     88: *>         On entry D contains the singular values of the two submatrices
                     89: *>         to be combined.  On exit D contains the trailing (N-K) updated
                     90: *>         singular values (those which were deflated) sorted into
                     91: *>         increasing order.
                     92: *> \endverbatim
                     93: *>
                     94: *> \param[out] Z
                     95: *> \verbatim
                     96: *>          Z is DOUBLE PRECISION array, dimension(N)
                     97: *>         On exit Z contains the updating row vector in the secular
                     98: *>         equation.
                     99: *> \endverbatim
                    100: *>
                    101: *> \param[in] ALPHA
                    102: *> \verbatim
                    103: *>          ALPHA is DOUBLE PRECISION
                    104: *>         Contains the diagonal element associated with the added row.
                    105: *> \endverbatim
                    106: *>
                    107: *> \param[in] BETA
                    108: *> \verbatim
                    109: *>          BETA is DOUBLE PRECISION
                    110: *>         Contains the off-diagonal element associated with the added
                    111: *>         row.
                    112: *> \endverbatim
                    113: *>
                    114: *> \param[in,out] U
                    115: *> \verbatim
                    116: *>          U is DOUBLE PRECISION array, dimension(LDU,N)
                    117: *>         On entry U contains the left singular vectors of two
                    118: *>         submatrices in the two square blocks with corners at (1,1),
                    119: *>         (NL, NL), and (NL+2, NL+2), (N,N).
                    120: *>         On exit U contains the trailing (N-K) updated left singular
                    121: *>         vectors (those which were deflated) in its last N-K columns.
                    122: *> \endverbatim
                    123: *>
                    124: *> \param[in] LDU
                    125: *> \verbatim
                    126: *>          LDU is INTEGER
                    127: *>         The leading dimension of the array U.  LDU >= N.
                    128: *> \endverbatim
                    129: *>
                    130: *> \param[in,out] VT
                    131: *> \verbatim
                    132: *>          VT is DOUBLE PRECISION array, dimension(LDVT,M)
                    133: *>         On entry VT**T contains the right singular vectors of two
                    134: *>         submatrices in the two square blocks with corners at (1,1),
                    135: *>         (NL+1, NL+1), and (NL+2, NL+2), (M,M).
                    136: *>         On exit VT**T contains the trailing (N-K) updated right singular
                    137: *>         vectors (those which were deflated) in its last N-K columns.
                    138: *>         In case SQRE =1, the last row of VT spans the right null
                    139: *>         space.
                    140: *> \endverbatim
                    141: *>
                    142: *> \param[in] LDVT
                    143: *> \verbatim
                    144: *>          LDVT is INTEGER
                    145: *>         The leading dimension of the array VT.  LDVT >= M.
                    146: *> \endverbatim
                    147: *>
                    148: *> \param[out] DSIGMA
                    149: *> \verbatim
                    150: *>          DSIGMA is DOUBLE PRECISION array, dimension (N)
                    151: *>         Contains a copy of the diagonal elements (K-1 singular values
                    152: *>         and one zero) in the secular equation.
                    153: *> \endverbatim
                    154: *>
                    155: *> \param[out] U2
                    156: *> \verbatim
                    157: *>          U2 is DOUBLE PRECISION array, dimension(LDU2,N)
                    158: *>         Contains a copy of the first K-1 left singular vectors which
                    159: *>         will be used by DLASD3 in a matrix multiply (DGEMM) to solve
                    160: *>         for the new left singular vectors. U2 is arranged into four
                    161: *>         blocks. The first block contains a column with 1 at NL+1 and
                    162: *>         zero everywhere else; the second block contains non-zero
                    163: *>         entries only at and above NL; the third contains non-zero
                    164: *>         entries only below NL+1; and the fourth is dense.
                    165: *> \endverbatim
                    166: *>
                    167: *> \param[in] LDU2
                    168: *> \verbatim
                    169: *>          LDU2 is INTEGER
                    170: *>         The leading dimension of the array U2.  LDU2 >= N.
                    171: *> \endverbatim
                    172: *>
                    173: *> \param[out] VT2
                    174: *> \verbatim
                    175: *>          VT2 is DOUBLE PRECISION array, dimension(LDVT2,N)
                    176: *>         VT2**T contains a copy of the first K right singular vectors
                    177: *>         which will be used by DLASD3 in a matrix multiply (DGEMM) to
                    178: *>         solve for the new right singular vectors. VT2 is arranged into
                    179: *>         three blocks. The first block contains a row that corresponds
                    180: *>         to the special 0 diagonal element in SIGMA; the second block
                    181: *>         contains non-zeros only at and before NL +1; the third block
                    182: *>         contains non-zeros only at and after  NL +2.
                    183: *> \endverbatim
                    184: *>
                    185: *> \param[in] LDVT2
                    186: *> \verbatim
                    187: *>          LDVT2 is INTEGER
                    188: *>         The leading dimension of the array VT2.  LDVT2 >= M.
                    189: *> \endverbatim
                    190: *>
                    191: *> \param[out] IDXP
                    192: *> \verbatim
                    193: *>          IDXP is INTEGER array dimension(N)
                    194: *>         This will contain the permutation used to place deflated
                    195: *>         values of D at the end of the array. On output IDXP(2:K)
                    196: *>         points to the nondeflated D-values and IDXP(K+1:N)
                    197: *>         points to the deflated singular values.
                    198: *> \endverbatim
                    199: *>
                    200: *> \param[out] IDX
                    201: *> \verbatim
                    202: *>          IDX is INTEGER array dimension(N)
                    203: *>         This will contain the permutation used to sort the contents of
                    204: *>         D into ascending order.
                    205: *> \endverbatim
                    206: *>
                    207: *> \param[out] IDXC
                    208: *> \verbatim
                    209: *>          IDXC is INTEGER array dimension(N)
                    210: *>         This will contain the permutation used to arrange the columns
                    211: *>         of the deflated U matrix into three groups:  the first group
                    212: *>         contains non-zero entries only at and above NL, the second
                    213: *>         contains non-zero entries only below NL+2, and the third is
                    214: *>         dense.
                    215: *> \endverbatim
                    216: *>
                    217: *> \param[in,out] IDXQ
                    218: *> \verbatim
                    219: *>          IDXQ is INTEGER array dimension(N)
                    220: *>         This contains the permutation which separately sorts the two
                    221: *>         sub-problems in D into ascending order.  Note that entries in
                    222: *>         the first hlaf of this permutation must first be moved one
                    223: *>         position backward; and entries in the second half
                    224: *>         must first have NL+1 added to their values.
                    225: *> \endverbatim
                    226: *>
                    227: *> \param[out] COLTYP
                    228: *> \verbatim
                    229: *>          COLTYP is INTEGER array dimension(N)
                    230: *>         As workspace, this will contain a label which will indicate
                    231: *>         which of the following types a column in the U2 matrix or a
                    232: *>         row in the VT2 matrix is:
                    233: *>         1 : non-zero in the upper half only
                    234: *>         2 : non-zero in the lower half only
                    235: *>         3 : dense
                    236: *>         4 : deflated
                    237: *>
                    238: *>         On exit, it is an array of dimension 4, with COLTYP(I) being
                    239: *>         the dimension of the I-th type columns.
                    240: *> \endverbatim
                    241: *>
                    242: *> \param[out] INFO
                    243: *> \verbatim
                    244: *>          INFO is INTEGER
                    245: *>          = 0:  successful exit.
                    246: *>          < 0:  if INFO = -i, the i-th argument had an illegal value.
                    247: *> \endverbatim
                    248: *
                    249: *  Authors:
                    250: *  ========
                    251: *
                    252: *> \author Univ. of Tennessee 
                    253: *> \author Univ. of California Berkeley 
                    254: *> \author Univ. of Colorado Denver 
                    255: *> \author NAG Ltd. 
                    256: *
                    257: *> \date November 2011
                    258: *
                    259: *> \ingroup auxOTHERauxiliary
                    260: *
                    261: *> \par Contributors:
                    262: *  ==================
                    263: *>
                    264: *>     Ming Gu and Huan Ren, Computer Science Division, University of
                    265: *>     California at Berkeley, USA
                    266: *>
                    267: *  =====================================================================
1.1       bertrand  268:       SUBROUTINE DLASD2( NL, NR, SQRE, K, D, Z, ALPHA, BETA, U, LDU, VT,
                    269:      $                   LDVT, DSIGMA, U2, LDU2, VT2, LDVT2, IDXP, IDX,
                    270:      $                   IDXC, IDXQ, COLTYP, INFO )
                    271: *
1.9       bertrand  272: *  -- LAPACK auxiliary routine (version 3.4.0) --
1.1       bertrand  273: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    274: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
1.9       bertrand  275: *     November 2011
1.1       bertrand  276: *
                    277: *     .. Scalar Arguments ..
                    278:       INTEGER            INFO, K, LDU, LDU2, LDVT, LDVT2, NL, NR, SQRE
                    279:       DOUBLE PRECISION   ALPHA, BETA
                    280: *     ..
                    281: *     .. Array Arguments ..
                    282:       INTEGER            COLTYP( * ), IDX( * ), IDXC( * ), IDXP( * ),
                    283:      $                   IDXQ( * )
                    284:       DOUBLE PRECISION   D( * ), DSIGMA( * ), U( LDU, * ),
                    285:      $                   U2( LDU2, * ), VT( LDVT, * ), VT2( LDVT2, * ),
                    286:      $                   Z( * )
                    287: *     ..
                    288: *
                    289: *  =====================================================================
                    290: *
                    291: *     .. Parameters ..
                    292:       DOUBLE PRECISION   ZERO, ONE, TWO, EIGHT
                    293:       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0,
                    294:      $                   EIGHT = 8.0D+0 )
                    295: *     ..
                    296: *     .. Local Arrays ..
                    297:       INTEGER            CTOT( 4 ), PSM( 4 )
                    298: *     ..
                    299: *     .. Local Scalars ..
                    300:       INTEGER            CT, I, IDXI, IDXJ, IDXJP, J, JP, JPREV, K2, M,
                    301:      $                   N, NLP1, NLP2
                    302:       DOUBLE PRECISION   C, EPS, HLFTOL, S, TAU, TOL, Z1
                    303: *     ..
                    304: *     .. External Functions ..
                    305:       DOUBLE PRECISION   DLAMCH, DLAPY2
                    306:       EXTERNAL           DLAMCH, DLAPY2
                    307: *     ..
                    308: *     .. External Subroutines ..
                    309:       EXTERNAL           DCOPY, DLACPY, DLAMRG, DLASET, DROT, XERBLA
                    310: *     ..
                    311: *     .. Intrinsic Functions ..
                    312:       INTRINSIC          ABS, MAX
                    313: *     ..
                    314: *     .. Executable Statements ..
                    315: *
                    316: *     Test the input parameters.
                    317: *
                    318:       INFO = 0
                    319: *
                    320:       IF( NL.LT.1 ) THEN
                    321:          INFO = -1
                    322:       ELSE IF( NR.LT.1 ) THEN
                    323:          INFO = -2
                    324:       ELSE IF( ( SQRE.NE.1 ) .AND. ( SQRE.NE.0 ) ) THEN
                    325:          INFO = -3
                    326:       END IF
                    327: *
                    328:       N = NL + NR + 1
                    329:       M = N + SQRE
                    330: *
                    331:       IF( LDU.LT.N ) THEN
                    332:          INFO = -10
                    333:       ELSE IF( LDVT.LT.M ) THEN
                    334:          INFO = -12
                    335:       ELSE IF( LDU2.LT.N ) THEN
                    336:          INFO = -15
                    337:       ELSE IF( LDVT2.LT.M ) THEN
                    338:          INFO = -17
                    339:       END IF
                    340:       IF( INFO.NE.0 ) THEN
                    341:          CALL XERBLA( 'DLASD2', -INFO )
                    342:          RETURN
                    343:       END IF
                    344: *
                    345:       NLP1 = NL + 1
                    346:       NLP2 = NL + 2
                    347: *
                    348: *     Generate the first part of the vector Z; and move the singular
                    349: *     values in the first part of D one position backward.
                    350: *
                    351:       Z1 = ALPHA*VT( NLP1, NLP1 )
                    352:       Z( 1 ) = Z1
                    353:       DO 10 I = NL, 1, -1
                    354:          Z( I+1 ) = ALPHA*VT( I, NLP1 )
                    355:          D( I+1 ) = D( I )
                    356:          IDXQ( I+1 ) = IDXQ( I ) + 1
                    357:    10 CONTINUE
                    358: *
                    359: *     Generate the second part of the vector Z.
                    360: *
                    361:       DO 20 I = NLP2, M
                    362:          Z( I ) = BETA*VT( I, NLP2 )
                    363:    20 CONTINUE
                    364: *
                    365: *     Initialize some reference arrays.
                    366: *
                    367:       DO 30 I = 2, NLP1
                    368:          COLTYP( I ) = 1
                    369:    30 CONTINUE
                    370:       DO 40 I = NLP2, N
                    371:          COLTYP( I ) = 2
                    372:    40 CONTINUE
                    373: *
                    374: *     Sort the singular values into increasing order
                    375: *
                    376:       DO 50 I = NLP2, N
                    377:          IDXQ( I ) = IDXQ( I ) + NLP1
                    378:    50 CONTINUE
                    379: *
                    380: *     DSIGMA, IDXC, IDXC, and the first column of U2
                    381: *     are used as storage space.
                    382: *
                    383:       DO 60 I = 2, N
                    384:          DSIGMA( I ) = D( IDXQ( I ) )
                    385:          U2( I, 1 ) = Z( IDXQ( I ) )
                    386:          IDXC( I ) = COLTYP( IDXQ( I ) )
                    387:    60 CONTINUE
                    388: *
                    389:       CALL DLAMRG( NL, NR, DSIGMA( 2 ), 1, 1, IDX( 2 ) )
                    390: *
                    391:       DO 70 I = 2, N
                    392:          IDXI = 1 + IDX( I )
                    393:          D( I ) = DSIGMA( IDXI )
                    394:          Z( I ) = U2( IDXI, 1 )
                    395:          COLTYP( I ) = IDXC( IDXI )
                    396:    70 CONTINUE
                    397: *
                    398: *     Calculate the allowable deflation tolerance
                    399: *
                    400:       EPS = DLAMCH( 'Epsilon' )
                    401:       TOL = MAX( ABS( ALPHA ), ABS( BETA ) )
                    402:       TOL = EIGHT*EPS*MAX( ABS( D( N ) ), TOL )
                    403: *
                    404: *     There are 2 kinds of deflation -- first a value in the z-vector
                    405: *     is small, second two (or more) singular values are very close
                    406: *     together (their difference is small).
                    407: *
                    408: *     If the value in the z-vector is small, we simply permute the
                    409: *     array so that the corresponding singular value is moved to the
                    410: *     end.
                    411: *
                    412: *     If two values in the D-vector are close, we perform a two-sided
                    413: *     rotation designed to make one of the corresponding z-vector
                    414: *     entries zero, and then permute the array so that the deflated
                    415: *     singular value is moved to the end.
                    416: *
                    417: *     If there are multiple singular values then the problem deflates.
                    418: *     Here the number of equal singular values are found.  As each equal
                    419: *     singular value is found, an elementary reflector is computed to
                    420: *     rotate the corresponding singular subspace so that the
                    421: *     corresponding components of Z are zero in this new basis.
                    422: *
                    423:       K = 1
                    424:       K2 = N + 1
                    425:       DO 80 J = 2, N
                    426:          IF( ABS( Z( J ) ).LE.TOL ) THEN
                    427: *
                    428: *           Deflate due to small z component.
                    429: *
                    430:             K2 = K2 - 1
                    431:             IDXP( K2 ) = J
                    432:             COLTYP( J ) = 4
                    433:             IF( J.EQ.N )
                    434:      $         GO TO 120
                    435:          ELSE
                    436:             JPREV = J
                    437:             GO TO 90
                    438:          END IF
                    439:    80 CONTINUE
                    440:    90 CONTINUE
                    441:       J = JPREV
                    442:   100 CONTINUE
                    443:       J = J + 1
                    444:       IF( J.GT.N )
                    445:      $   GO TO 110
                    446:       IF( ABS( Z( J ) ).LE.TOL ) THEN
                    447: *
                    448: *        Deflate due to small z component.
                    449: *
                    450:          K2 = K2 - 1
                    451:          IDXP( K2 ) = J
                    452:          COLTYP( J ) = 4
                    453:       ELSE
                    454: *
                    455: *        Check if singular values are close enough to allow deflation.
                    456: *
                    457:          IF( ABS( D( J )-D( JPREV ) ).LE.TOL ) THEN
                    458: *
                    459: *           Deflation is possible.
                    460: *
                    461:             S = Z( JPREV )
                    462:             C = Z( J )
                    463: *
                    464: *           Find sqrt(a**2+b**2) without overflow or
                    465: *           destructive underflow.
                    466: *
                    467:             TAU = DLAPY2( C, S )
                    468:             C = C / TAU
                    469:             S = -S / TAU
                    470:             Z( J ) = TAU
                    471:             Z( JPREV ) = ZERO
                    472: *
                    473: *           Apply back the Givens rotation to the left and right
                    474: *           singular vector matrices.
                    475: *
                    476:             IDXJP = IDXQ( IDX( JPREV )+1 )
                    477:             IDXJ = IDXQ( IDX( J )+1 )
                    478:             IF( IDXJP.LE.NLP1 ) THEN
                    479:                IDXJP = IDXJP - 1
                    480:             END IF
                    481:             IF( IDXJ.LE.NLP1 ) THEN
                    482:                IDXJ = IDXJ - 1
                    483:             END IF
                    484:             CALL DROT( N, U( 1, IDXJP ), 1, U( 1, IDXJ ), 1, C, S )
                    485:             CALL DROT( M, VT( IDXJP, 1 ), LDVT, VT( IDXJ, 1 ), LDVT, C,
                    486:      $                 S )
                    487:             IF( COLTYP( J ).NE.COLTYP( JPREV ) ) THEN
                    488:                COLTYP( J ) = 3
                    489:             END IF
                    490:             COLTYP( JPREV ) = 4
                    491:             K2 = K2 - 1
                    492:             IDXP( K2 ) = JPREV
                    493:             JPREV = J
                    494:          ELSE
                    495:             K = K + 1
                    496:             U2( K, 1 ) = Z( JPREV )
                    497:             DSIGMA( K ) = D( JPREV )
                    498:             IDXP( K ) = JPREV
                    499:             JPREV = J
                    500:          END IF
                    501:       END IF
                    502:       GO TO 100
                    503:   110 CONTINUE
                    504: *
                    505: *     Record the last singular value.
                    506: *
                    507:       K = K + 1
                    508:       U2( K, 1 ) = Z( JPREV )
                    509:       DSIGMA( K ) = D( JPREV )
                    510:       IDXP( K ) = JPREV
                    511: *
                    512:   120 CONTINUE
                    513: *
                    514: *     Count up the total number of the various types of columns, then
                    515: *     form a permutation which positions the four column types into
                    516: *     four groups of uniform structure (although one or more of these
                    517: *     groups may be empty).
                    518: *
                    519:       DO 130 J = 1, 4
                    520:          CTOT( J ) = 0
                    521:   130 CONTINUE
                    522:       DO 140 J = 2, N
                    523:          CT = COLTYP( J )
                    524:          CTOT( CT ) = CTOT( CT ) + 1
                    525:   140 CONTINUE
                    526: *
                    527: *     PSM(*) = Position in SubMatrix (of types 1 through 4)
                    528: *
                    529:       PSM( 1 ) = 2
                    530:       PSM( 2 ) = 2 + CTOT( 1 )
                    531:       PSM( 3 ) = PSM( 2 ) + CTOT( 2 )
                    532:       PSM( 4 ) = PSM( 3 ) + CTOT( 3 )
                    533: *
                    534: *     Fill out the IDXC array so that the permutation which it induces
                    535: *     will place all type-1 columns first, all type-2 columns next,
                    536: *     then all type-3's, and finally all type-4's, starting from the
                    537: *     second column. This applies similarly to the rows of VT.
                    538: *
                    539:       DO 150 J = 2, N
                    540:          JP = IDXP( J )
                    541:          CT = COLTYP( JP )
                    542:          IDXC( PSM( CT ) ) = J
                    543:          PSM( CT ) = PSM( CT ) + 1
                    544:   150 CONTINUE
                    545: *
                    546: *     Sort the singular values and corresponding singular vectors into
                    547: *     DSIGMA, U2, and VT2 respectively.  The singular values/vectors
                    548: *     which were not deflated go into the first K slots of DSIGMA, U2,
                    549: *     and VT2 respectively, while those which were deflated go into the
                    550: *     last N - K slots, except that the first column/row will be treated
                    551: *     separately.
                    552: *
                    553:       DO 160 J = 2, N
                    554:          JP = IDXP( J )
                    555:          DSIGMA( J ) = D( JP )
                    556:          IDXJ = IDXQ( IDX( IDXP( IDXC( J ) ) )+1 )
                    557:          IF( IDXJ.LE.NLP1 ) THEN
                    558:             IDXJ = IDXJ - 1
                    559:          END IF
                    560:          CALL DCOPY( N, U( 1, IDXJ ), 1, U2( 1, J ), 1 )
                    561:          CALL DCOPY( M, VT( IDXJ, 1 ), LDVT, VT2( J, 1 ), LDVT2 )
                    562:   160 CONTINUE
                    563: *
                    564: *     Determine DSIGMA(1), DSIGMA(2) and Z(1)
                    565: *
                    566:       DSIGMA( 1 ) = ZERO
                    567:       HLFTOL = TOL / TWO
                    568:       IF( ABS( DSIGMA( 2 ) ).LE.HLFTOL )
                    569:      $   DSIGMA( 2 ) = HLFTOL
                    570:       IF( M.GT.N ) THEN
                    571:          Z( 1 ) = DLAPY2( Z1, Z( M ) )
                    572:          IF( Z( 1 ).LE.TOL ) THEN
                    573:             C = ONE
                    574:             S = ZERO
                    575:             Z( 1 ) = TOL
                    576:          ELSE
                    577:             C = Z1 / Z( 1 )
                    578:             S = Z( M ) / Z( 1 )
                    579:          END IF
                    580:       ELSE
                    581:          IF( ABS( Z1 ).LE.TOL ) THEN
                    582:             Z( 1 ) = TOL
                    583:          ELSE
                    584:             Z( 1 ) = Z1
                    585:          END IF
                    586:       END IF
                    587: *
                    588: *     Move the rest of the updating row to Z.
                    589: *
                    590:       CALL DCOPY( K-1, U2( 2, 1 ), 1, Z( 2 ), 1 )
                    591: *
                    592: *     Determine the first column of U2, the first row of VT2 and the
                    593: *     last row of VT.
                    594: *
                    595:       CALL DLASET( 'A', N, 1, ZERO, ZERO, U2, LDU2 )
                    596:       U2( NLP1, 1 ) = ONE
                    597:       IF( M.GT.N ) THEN
                    598:          DO 170 I = 1, NLP1
                    599:             VT( M, I ) = -S*VT( NLP1, I )
                    600:             VT2( 1, I ) = C*VT( NLP1, I )
                    601:   170    CONTINUE
                    602:          DO 180 I = NLP2, M
                    603:             VT2( 1, I ) = S*VT( M, I )
                    604:             VT( M, I ) = C*VT( M, I )
                    605:   180    CONTINUE
                    606:       ELSE
                    607:          CALL DCOPY( M, VT( NLP1, 1 ), LDVT, VT2( 1, 1 ), LDVT2 )
                    608:       END IF
                    609:       IF( M.GT.N ) THEN
                    610:          CALL DCOPY( M, VT( M, 1 ), LDVT, VT2( M, 1 ), LDVT2 )
                    611:       END IF
                    612: *
                    613: *     The deflated singular values and their corresponding vectors go
                    614: *     into the back of D, U, and V respectively.
                    615: *
                    616:       IF( N.GT.K ) THEN
                    617:          CALL DCOPY( N-K, DSIGMA( K+1 ), 1, D( K+1 ), 1 )
                    618:          CALL DLACPY( 'A', N, N-K, U2( 1, K+1 ), LDU2, U( 1, K+1 ),
                    619:      $                LDU )
                    620:          CALL DLACPY( 'A', N-K, M, VT2( K+1, 1 ), LDVT2, VT( K+1, 1 ),
                    621:      $                LDVT )
                    622:       END IF
                    623: *
                    624: *     Copy CTOT into COLTYP for referencing in DLASD3.
                    625: *
                    626:       DO 190 J = 1, 4
                    627:          COLTYP( J ) = CTOT( J )
                    628:   190 CONTINUE
                    629: *
                    630:       RETURN
                    631: *
                    632: *     End of DLASD2
                    633: *
                    634:       END

CVSweb interface <joel.bertrand@systella.fr>