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