LAPACK 3.3.1
Linear Algebra PACKage

slasd0.f

Go to the documentation of this file.
00001       SUBROUTINE SLASD0( N, SQRE, D, E, U, LDU, VT, LDVT, SMLSIZ, IWORK,
00002      $                   WORK, INFO )
00003 *
00004 *  -- LAPACK auxiliary routine (version 3.2.2) --
00005 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00006 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00007 *     June 2010
00008 *
00009 *     .. Scalar Arguments ..
00010       INTEGER            INFO, LDU, LDVT, N, SMLSIZ, SQRE
00011 *     ..
00012 *     .. Array Arguments ..
00013       INTEGER            IWORK( * )
00014       REAL               D( * ), E( * ), U( LDU, * ), VT( LDVT, * ),
00015      $                   WORK( * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  Using a divide and conquer approach, SLASD0 computes the singular
00022 *  value decomposition (SVD) of a real upper bidiagonal N-by-M
00023 *  matrix B with diagonal D and offdiagonal E, where M = N + SQRE.
00024 *  The algorithm computes orthogonal matrices U and VT such that
00025 *  B = U * S * VT. The singular values S are overwritten on D.
00026 *
00027 *  A related subroutine, SLASDA, computes only the singular values,
00028 *  and optionally, the singular vectors in compact form.
00029 *
00030 *  Arguments
00031 *  =========
00032 *
00033 *  N      (input) INTEGER
00034 *         On entry, the row dimension of the upper bidiagonal matrix.
00035 *         This is also the dimension of the main diagonal array D.
00036 *
00037 *  SQRE   (input) INTEGER
00038 *         Specifies the column dimension of the bidiagonal matrix.
00039 *         = 0: The bidiagonal matrix has column dimension M = N;
00040 *         = 1: The bidiagonal matrix has column dimension M = N+1;
00041 *
00042 *  D      (input/output) REAL array, dimension (N)
00043 *         On entry D contains the main diagonal of the bidiagonal
00044 *         matrix.
00045 *         On exit D, if INFO = 0, contains its singular values.
00046 *
00047 *  E      (input) REAL array, dimension (M-1)
00048 *         Contains the subdiagonal entries of the bidiagonal matrix.
00049 *         On exit, E has been destroyed.
00050 *
00051 *  U      (output) REAL array, dimension at least (LDQ, N)
00052 *         On exit, U contains the left singular vectors.
00053 *
00054 *  LDU    (input) INTEGER
00055 *         On entry, leading dimension of U.
00056 *
00057 *  VT     (output) REAL array, dimension at least (LDVT, M)
00058 *         On exit, VT**T contains the right singular vectors.
00059 *
00060 *  LDVT   (input) INTEGER
00061 *         On entry, leading dimension of VT.
00062 *
00063 *  SMLSIZ (input) INTEGER
00064 *         On entry, maximum size of the subproblems at the
00065 *         bottom of the computation tree.
00066 *
00067 *  IWORK  (workspace) INTEGER array, dimension (8*N)
00068 *
00069 *  WORK   (workspace) REAL array, dimension (3*M**2+2*M)
00070 *
00071 *  INFO   (output) INTEGER
00072 *          = 0:  successful exit.
00073 *          < 0:  if INFO = -i, the i-th argument had an illegal value.
00074 *          > 0:  if INFO = 1, a singular value did not converge
00075 *
00076 *  Further Details
00077 *  ===============
00078 *
00079 *  Based on contributions by
00080 *     Ming Gu and Huan Ren, Computer Science Division, University of
00081 *     California at Berkeley, USA
00082 *
00083 *  =====================================================================
00084 *
00085 *     .. Local Scalars ..
00086       INTEGER            I, I1, IC, IDXQ, IDXQC, IM1, INODE, ITEMP, IWK,
00087      $                   J, LF, LL, LVL, M, NCC, ND, NDB1, NDIML, NDIMR,
00088      $                   NL, NLF, NLP1, NLVL, NR, NRF, NRP1, SQREI
00089       REAL               ALPHA, BETA
00090 *     ..
00091 *     .. External Subroutines ..
00092       EXTERNAL           SLASD1, SLASDQ, SLASDT, XERBLA
00093 *     ..
00094 *     .. Executable Statements ..
00095 *
00096 *     Test the input parameters.
00097 *
00098       INFO = 0
00099 *
00100       IF( N.LT.0 ) THEN
00101          INFO = -1
00102       ELSE IF( ( SQRE.LT.0 ) .OR. ( SQRE.GT.1 ) ) THEN
00103          INFO = -2
00104       END IF
00105 *
00106       M = N + SQRE
00107 *
00108       IF( LDU.LT.N ) THEN
00109          INFO = -6
00110       ELSE IF( LDVT.LT.M ) THEN
00111          INFO = -8
00112       ELSE IF( SMLSIZ.LT.3 ) THEN
00113          INFO = -9
00114       END IF
00115       IF( INFO.NE.0 ) THEN
00116          CALL XERBLA( 'SLASD0', -INFO )
00117          RETURN
00118       END IF
00119 *
00120 *     If the input matrix is too small, call SLASDQ to find the SVD.
00121 *
00122       IF( N.LE.SMLSIZ ) THEN
00123          CALL SLASDQ( 'U', SQRE, N, M, N, 0, D, E, VT, LDVT, U, LDU, U,
00124      $                LDU, WORK, INFO )
00125          RETURN
00126       END IF
00127 *
00128 *     Set up the computation tree.
00129 *
00130       INODE = 1
00131       NDIML = INODE + N
00132       NDIMR = NDIML + N
00133       IDXQ = NDIMR + N
00134       IWK = IDXQ + N
00135       CALL SLASDT( N, NLVL, ND, IWORK( INODE ), IWORK( NDIML ),
00136      $             IWORK( NDIMR ), SMLSIZ )
00137 *
00138 *     For the nodes on bottom level of the tree, solve
00139 *     their subproblems by SLASDQ.
00140 *
00141       NDB1 = ( ND+1 ) / 2
00142       NCC = 0
00143       DO 30 I = NDB1, ND
00144 *
00145 *     IC : center row of each node
00146 *     NL : number of rows of left  subproblem
00147 *     NR : number of rows of right subproblem
00148 *     NLF: starting row of the left   subproblem
00149 *     NRF: starting row of the right  subproblem
00150 *
00151          I1 = I - 1
00152          IC = IWORK( INODE+I1 )
00153          NL = IWORK( NDIML+I1 )
00154          NLP1 = NL + 1
00155          NR = IWORK( NDIMR+I1 )
00156          NRP1 = NR + 1
00157          NLF = IC - NL
00158          NRF = IC + 1
00159          SQREI = 1
00160          CALL SLASDQ( 'U', SQREI, NL, NLP1, NL, NCC, D( NLF ), E( NLF ),
00161      $                VT( NLF, NLF ), LDVT, U( NLF, NLF ), LDU,
00162      $                U( NLF, NLF ), LDU, WORK, INFO )
00163          IF( INFO.NE.0 ) THEN
00164             RETURN
00165          END IF
00166          ITEMP = IDXQ + NLF - 2
00167          DO 10 J = 1, NL
00168             IWORK( ITEMP+J ) = J
00169    10    CONTINUE
00170          IF( I.EQ.ND ) THEN
00171             SQREI = SQRE
00172          ELSE
00173             SQREI = 1
00174          END IF
00175          NRP1 = NR + SQREI
00176          CALL SLASDQ( 'U', SQREI, NR, NRP1, NR, NCC, D( NRF ), E( NRF ),
00177      $                VT( NRF, NRF ), LDVT, U( NRF, NRF ), LDU,
00178      $                U( NRF, NRF ), LDU, WORK, INFO )
00179          IF( INFO.NE.0 ) THEN
00180             RETURN
00181          END IF
00182          ITEMP = IDXQ + IC
00183          DO 20 J = 1, NR
00184             IWORK( ITEMP+J-1 ) = J
00185    20    CONTINUE
00186    30 CONTINUE
00187 *
00188 *     Now conquer each subproblem bottom-up.
00189 *
00190       DO 50 LVL = NLVL, 1, -1
00191 *
00192 *        Find the first node LF and last node LL on the
00193 *        current level LVL.
00194 *
00195          IF( LVL.EQ.1 ) THEN
00196             LF = 1
00197             LL = 1
00198          ELSE
00199             LF = 2**( LVL-1 )
00200             LL = 2*LF - 1
00201          END IF
00202          DO 40 I = LF, LL
00203             IM1 = I - 1
00204             IC = IWORK( INODE+IM1 )
00205             NL = IWORK( NDIML+IM1 )
00206             NR = IWORK( NDIMR+IM1 )
00207             NLF = IC - NL
00208             IF( ( SQRE.EQ.0 ) .AND. ( I.EQ.LL ) ) THEN
00209                SQREI = SQRE
00210             ELSE
00211                SQREI = 1
00212             END IF
00213             IDXQC = IDXQ + NLF - 1
00214             ALPHA = D( IC )
00215             BETA = E( IC )
00216             CALL SLASD1( NL, NR, SQREI, D( NLF ), ALPHA, BETA,
00217      $                   U( NLF, NLF ), LDU, VT( NLF, NLF ), LDVT,
00218      $                   IWORK( IDXQC ), IWORK( IWK ), WORK, INFO )
00219             IF( INFO.NE.0 ) THEN
00220                RETURN
00221             END IF
00222    40    CONTINUE
00223    50 CONTINUE
00224 *
00225       RETURN
00226 *
00227 *     End of SLASD0
00228 *
00229       END
 All Files Functions