LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dgebrd.f
Go to the documentation of this file.
00001 *> \brief \b DGEBRD
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download DGEBRD + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgebrd.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgebrd.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgebrd.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE DGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK,
00022 *                          INFO )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       INTEGER            INFO, LDA, LWORK, M, N
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       DOUBLE PRECISION   A( LDA, * ), D( * ), E( * ), TAUP( * ),
00029 *      $                   TAUQ( * ), WORK( * )
00030 *       ..
00031 *  
00032 *
00033 *> \par Purpose:
00034 *  =============
00035 *>
00036 *> \verbatim
00037 *>
00038 *> DGEBRD reduces a general real M-by-N matrix A to upper or lower
00039 *> bidiagonal form B by an orthogonal transformation: Q**T * A * P = B.
00040 *>
00041 *> If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
00042 *> \endverbatim
00043 *
00044 *  Arguments:
00045 *  ==========
00046 *
00047 *> \param[in] M
00048 *> \verbatim
00049 *>          M is INTEGER
00050 *>          The number of rows in the matrix A.  M >= 0.
00051 *> \endverbatim
00052 *>
00053 *> \param[in] N
00054 *> \verbatim
00055 *>          N is INTEGER
00056 *>          The number of columns in the matrix A.  N >= 0.
00057 *> \endverbatim
00058 *>
00059 *> \param[in,out] A
00060 *> \verbatim
00061 *>          A is DOUBLE PRECISION array, dimension (LDA,N)
00062 *>          On entry, the M-by-N general matrix to be reduced.
00063 *>          On exit,
00064 *>          if m >= n, the diagonal and the first superdiagonal are
00065 *>            overwritten with the upper bidiagonal matrix B; the
00066 *>            elements below the diagonal, with the array TAUQ, represent
00067 *>            the orthogonal matrix Q as a product of elementary
00068 *>            reflectors, and the elements above the first superdiagonal,
00069 *>            with the array TAUP, represent the orthogonal matrix P as
00070 *>            a product of elementary reflectors;
00071 *>          if m < n, the diagonal and the first subdiagonal are
00072 *>            overwritten with the lower bidiagonal matrix B; the
00073 *>            elements below the first subdiagonal, with the array TAUQ,
00074 *>            represent the orthogonal matrix Q as a product of
00075 *>            elementary reflectors, and the elements above the diagonal,
00076 *>            with the array TAUP, represent the orthogonal matrix P as
00077 *>            a product of elementary reflectors.
00078 *>          See Further Details.
00079 *> \endverbatim
00080 *>
00081 *> \param[in] LDA
00082 *> \verbatim
00083 *>          LDA is INTEGER
00084 *>          The leading dimension of the array A.  LDA >= max(1,M).
00085 *> \endverbatim
00086 *>
00087 *> \param[out] D
00088 *> \verbatim
00089 *>          D is DOUBLE PRECISION array, dimension (min(M,N))
00090 *>          The diagonal elements of the bidiagonal matrix B:
00091 *>          D(i) = A(i,i).
00092 *> \endverbatim
00093 *>
00094 *> \param[out] E
00095 *> \verbatim
00096 *>          E is DOUBLE PRECISION array, dimension (min(M,N)-1)
00097 *>          The off-diagonal elements of the bidiagonal matrix B:
00098 *>          if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
00099 *>          if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
00100 *> \endverbatim
00101 *>
00102 *> \param[out] TAUQ
00103 *> \verbatim
00104 *>          TAUQ is DOUBLE PRECISION array dimension (min(M,N))
00105 *>          The scalar factors of the elementary reflectors which
00106 *>          represent the orthogonal matrix Q. See Further Details.
00107 *> \endverbatim
00108 *>
00109 *> \param[out] TAUP
00110 *> \verbatim
00111 *>          TAUP is DOUBLE PRECISION array, dimension (min(M,N))
00112 *>          The scalar factors of the elementary reflectors which
00113 *>          represent the orthogonal matrix P. See Further Details.
00114 *> \endverbatim
00115 *>
00116 *> \param[out] WORK
00117 *> \verbatim
00118 *>          WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
00119 *>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
00120 *> \endverbatim
00121 *>
00122 *> \param[in] LWORK
00123 *> \verbatim
00124 *>          LWORK is INTEGER
00125 *>          The length of the array WORK.  LWORK >= max(1,M,N).
00126 *>          For optimum performance LWORK >= (M+N)*NB, where NB
00127 *>          is the optimal blocksize.
00128 *>
00129 *>          If LWORK = -1, then a workspace query is assumed; the routine
00130 *>          only calculates the optimal size of the WORK array, returns
00131 *>          this value as the first entry of the WORK array, and no error
00132 *>          message related to LWORK is issued by XERBLA.
00133 *> \endverbatim
00134 *>
00135 *> \param[out] INFO
00136 *> \verbatim
00137 *>          INFO is INTEGER
00138 *>          = 0:  successful exit
00139 *>          < 0:  if INFO = -i, the i-th argument had an illegal value.
00140 *> \endverbatim
00141 *
00142 *  Authors:
00143 *  ========
00144 *
00145 *> \author Univ. of Tennessee 
00146 *> \author Univ. of California Berkeley 
00147 *> \author Univ. of Colorado Denver 
00148 *> \author NAG Ltd. 
00149 *
00150 *> \date November 2011
00151 *
00152 *> \ingroup doubleGEcomputational
00153 *
00154 *> \par Further Details:
00155 *  =====================
00156 *>
00157 *> \verbatim
00158 *>
00159 *>  The matrices Q and P are represented as products of elementary
00160 *>  reflectors:
00161 *>
00162 *>  If m >= n,
00163 *>
00164 *>     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1)
00165 *>
00166 *>  Each H(i) and G(i) has the form:
00167 *>
00168 *>     H(i) = I - tauq * v * v**T  and G(i) = I - taup * u * u**T
00169 *>
00170 *>  where tauq and taup are real scalars, and v and u are real vectors;
00171 *>  v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
00172 *>  u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
00173 *>  tauq is stored in TAUQ(i) and taup in TAUP(i).
00174 *>
00175 *>  If m < n,
00176 *>
00177 *>     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m)
00178 *>
00179 *>  Each H(i) and G(i) has the form:
00180 *>
00181 *>     H(i) = I - tauq * v * v**T  and G(i) = I - taup * u * u**T
00182 *>
00183 *>  where tauq and taup are real scalars, and v and u are real vectors;
00184 *>  v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
00185 *>  u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
00186 *>  tauq is stored in TAUQ(i) and taup in TAUP(i).
00187 *>
00188 *>  The contents of A on exit are illustrated by the following examples:
00189 *>
00190 *>  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n):
00191 *>
00192 *>    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 )
00193 *>    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 )
00194 *>    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 )
00195 *>    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 )
00196 *>    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 )
00197 *>    (  v1  v2  v3  v4  v5 )
00198 *>
00199 *>  where d and e denote diagonal and off-diagonal elements of B, vi
00200 *>  denotes an element of the vector defining H(i), and ui an element of
00201 *>  the vector defining G(i).
00202 *> \endverbatim
00203 *>
00204 *  =====================================================================
00205       SUBROUTINE DGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK,
00206      $                   INFO )
00207 *
00208 *  -- LAPACK computational routine (version 3.4.0) --
00209 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00210 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00211 *     November 2011
00212 *
00213 *     .. Scalar Arguments ..
00214       INTEGER            INFO, LDA, LWORK, M, N
00215 *     ..
00216 *     .. Array Arguments ..
00217       DOUBLE PRECISION   A( LDA, * ), D( * ), E( * ), TAUP( * ),
00218      $                   TAUQ( * ), WORK( * )
00219 *     ..
00220 *
00221 *  =====================================================================
00222 *
00223 *     .. Parameters ..
00224       DOUBLE PRECISION   ONE
00225       PARAMETER          ( ONE = 1.0D+0 )
00226 *     ..
00227 *     .. Local Scalars ..
00228       LOGICAL            LQUERY
00229       INTEGER            I, IINFO, J, LDWRKX, LDWRKY, LWKOPT, MINMN, NB,
00230      $                   NBMIN, NX
00231       DOUBLE PRECISION   WS
00232 *     ..
00233 *     .. External Subroutines ..
00234       EXTERNAL           DGEBD2, DGEMM, DLABRD, XERBLA
00235 *     ..
00236 *     .. Intrinsic Functions ..
00237       INTRINSIC          DBLE, MAX, MIN
00238 *     ..
00239 *     .. External Functions ..
00240       INTEGER            ILAENV
00241       EXTERNAL           ILAENV
00242 *     ..
00243 *     .. Executable Statements ..
00244 *
00245 *     Test the input parameters
00246 *
00247       INFO = 0
00248       NB = MAX( 1, ILAENV( 1, 'DGEBRD', ' ', M, N, -1, -1 ) )
00249       LWKOPT = ( M+N )*NB
00250       WORK( 1 ) = DBLE( LWKOPT )
00251       LQUERY = ( LWORK.EQ.-1 )
00252       IF( M.LT.0 ) THEN
00253          INFO = -1
00254       ELSE IF( N.LT.0 ) THEN
00255          INFO = -2
00256       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00257          INFO = -4
00258       ELSE IF( LWORK.LT.MAX( 1, M, N ) .AND. .NOT.LQUERY ) THEN
00259          INFO = -10
00260       END IF
00261       IF( INFO.LT.0 ) THEN
00262          CALL XERBLA( 'DGEBRD', -INFO )
00263          RETURN
00264       ELSE IF( LQUERY ) THEN
00265          RETURN
00266       END IF
00267 *
00268 *     Quick return if possible
00269 *
00270       MINMN = MIN( M, N )
00271       IF( MINMN.EQ.0 ) THEN
00272          WORK( 1 ) = 1
00273          RETURN
00274       END IF
00275 *
00276       WS = MAX( M, N )
00277       LDWRKX = M
00278       LDWRKY = N
00279 *
00280       IF( NB.GT.1 .AND. NB.LT.MINMN ) THEN
00281 *
00282 *        Set the crossover point NX.
00283 *
00284          NX = MAX( NB, ILAENV( 3, 'DGEBRD', ' ', M, N, -1, -1 ) )
00285 *
00286 *        Determine when to switch from blocked to unblocked code.
00287 *
00288          IF( NX.LT.MINMN ) THEN
00289             WS = ( M+N )*NB
00290             IF( LWORK.LT.WS ) THEN
00291 *
00292 *              Not enough work space for the optimal NB, consider using
00293 *              a smaller block size.
00294 *
00295                NBMIN = ILAENV( 2, 'DGEBRD', ' ', M, N, -1, -1 )
00296                IF( LWORK.GE.( M+N )*NBMIN ) THEN
00297                   NB = LWORK / ( M+N )
00298                ELSE
00299                   NB = 1
00300                   NX = MINMN
00301                END IF
00302             END IF
00303          END IF
00304       ELSE
00305          NX = MINMN
00306       END IF
00307 *
00308       DO 30 I = 1, MINMN - NX, NB
00309 *
00310 *        Reduce rows and columns i:i+nb-1 to bidiagonal form and return
00311 *        the matrices X and Y which are needed to update the unreduced
00312 *        part of the matrix
00313 *
00314          CALL DLABRD( M-I+1, N-I+1, NB, A( I, I ), LDA, D( I ), E( I ),
00315      $                TAUQ( I ), TAUP( I ), WORK, LDWRKX,
00316      $                WORK( LDWRKX*NB+1 ), LDWRKY )
00317 *
00318 *        Update the trailing submatrix A(i+nb:m,i+nb:n), using an update
00319 *        of the form  A := A - V*Y**T - X*U**T
00320 *
00321          CALL DGEMM( 'No transpose', 'Transpose', M-I-NB+1, N-I-NB+1,
00322      $               NB, -ONE, A( I+NB, I ), LDA,
00323      $               WORK( LDWRKX*NB+NB+1 ), LDWRKY, ONE,
00324      $               A( I+NB, I+NB ), LDA )
00325          CALL DGEMM( 'No transpose', 'No transpose', M-I-NB+1, N-I-NB+1,
00326      $               NB, -ONE, WORK( NB+1 ), LDWRKX, A( I, I+NB ), LDA,
00327      $               ONE, A( I+NB, I+NB ), LDA )
00328 *
00329 *        Copy diagonal and off-diagonal elements of B back into A
00330 *
00331          IF( M.GE.N ) THEN
00332             DO 10 J = I, I + NB - 1
00333                A( J, J ) = D( J )
00334                A( J, J+1 ) = E( J )
00335    10       CONTINUE
00336          ELSE
00337             DO 20 J = I, I + NB - 1
00338                A( J, J ) = D( J )
00339                A( J+1, J ) = E( J )
00340    20       CONTINUE
00341          END IF
00342    30 CONTINUE
00343 *
00344 *     Use unblocked code to reduce the remainder of the matrix
00345 *
00346       CALL DGEBD2( M-I+1, N-I+1, A( I, I ), LDA, D( I ), E( I ),
00347      $             TAUQ( I ), TAUP( I ), WORK, IINFO )
00348       WORK( 1 ) = WS
00349       RETURN
00350 *
00351 *     End of DGEBRD
00352 *
00353       END
 All Files Functions