LAPACK 3.3.1
Linear Algebra PACKage

zgebd2.f

Go to the documentation of this file.
00001       SUBROUTINE ZGEBD2( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO )
00002 *
00003 *  -- LAPACK routine (version 3.3.1) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *  -- April 2011                                                      --
00007 *
00008 *     .. Scalar Arguments ..
00009       INTEGER            INFO, LDA, M, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       DOUBLE PRECISION   D( * ), E( * )
00013       COMPLEX*16         A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  ZGEBD2 reduces a complex general m by n matrix A to upper or lower
00020 *  real bidiagonal form B by a unitary transformation: Q**H * A * P = B.
00021 *
00022 *  If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
00023 *
00024 *  Arguments
00025 *  =========
00026 *
00027 *  M       (input) INTEGER
00028 *          The number of rows in the matrix A.  M >= 0.
00029 *
00030 *  N       (input) INTEGER
00031 *          The number of columns in the matrix A.  N >= 0.
00032 *
00033 *  A       (input/output) COMPLEX*16 array, dimension (LDA,N)
00034 *          On entry, the m by n general matrix to be reduced.
00035 *          On exit,
00036 *          if m >= n, the diagonal and the first superdiagonal are
00037 *            overwritten with the upper bidiagonal matrix B; the
00038 *            elements below the diagonal, with the array TAUQ, represent
00039 *            the unitary matrix Q as a product of elementary
00040 *            reflectors, and the elements above the first superdiagonal,
00041 *            with the array TAUP, represent the unitary matrix P as
00042 *            a product of elementary reflectors;
00043 *          if m < n, the diagonal and the first subdiagonal are
00044 *            overwritten with the lower bidiagonal matrix B; the
00045 *            elements below the first subdiagonal, with the array TAUQ,
00046 *            represent the unitary matrix Q as a product of
00047 *            elementary reflectors, and the elements above the diagonal,
00048 *            with the array TAUP, represent the unitary matrix P as
00049 *            a product of elementary reflectors.
00050 *          See Further Details.
00051 *
00052 *  LDA     (input) INTEGER
00053 *          The leading dimension of the array A.  LDA >= max(1,M).
00054 *
00055 *  D       (output) DOUBLE PRECISION array, dimension (min(M,N))
00056 *          The diagonal elements of the bidiagonal matrix B:
00057 *          D(i) = A(i,i).
00058 *
00059 *  E       (output) DOUBLE PRECISION array, dimension (min(M,N)-1)
00060 *          The off-diagonal elements of the bidiagonal matrix B:
00061 *          if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
00062 *          if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
00063 *
00064 *  TAUQ    (output) COMPLEX*16 array dimension (min(M,N))
00065 *          The scalar factors of the elementary reflectors which
00066 *          represent the unitary matrix Q. See Further Details.
00067 *
00068 *  TAUP    (output) COMPLEX*16 array, dimension (min(M,N))
00069 *          The scalar factors of the elementary reflectors which
00070 *          represent the unitary matrix P. See Further Details.
00071 *
00072 *  WORK    (workspace) COMPLEX*16 array, dimension (max(M,N))
00073 *
00074 *  INFO    (output) INTEGER
00075 *          = 0: successful exit
00076 *          < 0: if INFO = -i, the i-th argument had an illegal value.
00077 *
00078 *  Further Details
00079 *  ===============
00080 *
00081 *  The matrices Q and P are represented as products of elementary
00082 *  reflectors:
00083 *
00084 *  If m >= n,
00085 *
00086 *     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1)
00087 *
00088 *  Each H(i) and G(i) has the form:
00089 *
00090 *     H(i) = I - tauq * v * v**H  and G(i) = I - taup * u * u**H
00091 *
00092 *  where tauq and taup are complex scalars, and v and u are complex
00093 *  vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in
00094 *  A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in
00095 *  A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
00096 *
00097 *  If m < n,
00098 *
00099 *     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m)
00100 *
00101 *  Each H(i) and G(i) has the form:
00102 *
00103 *     H(i) = I - tauq * v * v**H  and G(i) = I - taup * u * u**H
00104 *
00105 *  where tauq and taup are complex scalars, v and u are complex vectors;
00106 *  v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
00107 *  u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
00108 *  tauq is stored in TAUQ(i) and taup in TAUP(i).
00109 *
00110 *  The contents of A on exit are illustrated by the following examples:
00111 *
00112 *  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n):
00113 *
00114 *    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 )
00115 *    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 )
00116 *    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 )
00117 *    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 )
00118 *    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 )
00119 *    (  v1  v2  v3  v4  v5 )
00120 *
00121 *  where d and e denote diagonal and off-diagonal elements of B, vi
00122 *  denotes an element of the vector defining H(i), and ui an element of
00123 *  the vector defining G(i).
00124 *
00125 *  =====================================================================
00126 *
00127 *     .. Parameters ..
00128       COMPLEX*16         ZERO, ONE
00129       PARAMETER          ( ZERO = ( 0.0D+0, 0.0D+0 ),
00130      $                   ONE = ( 1.0D+0, 0.0D+0 ) )
00131 *     ..
00132 *     .. Local Scalars ..
00133       INTEGER            I
00134       COMPLEX*16         ALPHA
00135 *     ..
00136 *     .. External Subroutines ..
00137       EXTERNAL           XERBLA, ZLACGV, ZLARF, ZLARFG
00138 *     ..
00139 *     .. Intrinsic Functions ..
00140       INTRINSIC          DCONJG, MAX, MIN
00141 *     ..
00142 *     .. Executable Statements ..
00143 *
00144 *     Test the input parameters
00145 *
00146       INFO = 0
00147       IF( M.LT.0 ) THEN
00148          INFO = -1
00149       ELSE IF( N.LT.0 ) THEN
00150          INFO = -2
00151       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00152          INFO = -4
00153       END IF
00154       IF( INFO.LT.0 ) THEN
00155          CALL XERBLA( 'ZGEBD2', -INFO )
00156          RETURN
00157       END IF
00158 *
00159       IF( M.GE.N ) THEN
00160 *
00161 *        Reduce to upper bidiagonal form
00162 *
00163          DO 10 I = 1, N
00164 *
00165 *           Generate elementary reflector H(i) to annihilate A(i+1:m,i)
00166 *
00167             ALPHA = A( I, I )
00168             CALL ZLARFG( M-I+1, ALPHA, A( MIN( I+1, M ), I ), 1,
00169      $                   TAUQ( I ) )
00170             D( I ) = ALPHA
00171             A( I, I ) = ONE
00172 *
00173 *           Apply H(i)**H to A(i:m,i+1:n) from the left
00174 *
00175             IF( I.LT.N )
00176      $         CALL ZLARF( 'Left', M-I+1, N-I, A( I, I ), 1,
00177      $                     DCONJG( TAUQ( I ) ), A( I, I+1 ), LDA, WORK )
00178             A( I, I ) = D( I )
00179 *
00180             IF( I.LT.N ) THEN
00181 *
00182 *              Generate elementary reflector G(i) to annihilate
00183 *              A(i,i+2:n)
00184 *
00185                CALL ZLACGV( N-I, A( I, I+1 ), LDA )
00186                ALPHA = A( I, I+1 )
00187                CALL ZLARFG( N-I, ALPHA, A( I, MIN( I+2, N ) ), LDA,
00188      $                      TAUP( I ) )
00189                E( I ) = ALPHA
00190                A( I, I+1 ) = ONE
00191 *
00192 *              Apply G(i) to A(i+1:m,i+1:n) from the right
00193 *
00194                CALL ZLARF( 'Right', M-I, N-I, A( I, I+1 ), LDA,
00195      $                     TAUP( I ), A( I+1, I+1 ), LDA, WORK )
00196                CALL ZLACGV( N-I, A( I, I+1 ), LDA )
00197                A( I, I+1 ) = E( I )
00198             ELSE
00199                TAUP( I ) = ZERO
00200             END IF
00201    10    CONTINUE
00202       ELSE
00203 *
00204 *        Reduce to lower bidiagonal form
00205 *
00206          DO 20 I = 1, M
00207 *
00208 *           Generate elementary reflector G(i) to annihilate A(i,i+1:n)
00209 *
00210             CALL ZLACGV( N-I+1, A( I, I ), LDA )
00211             ALPHA = A( I, I )
00212             CALL ZLARFG( N-I+1, ALPHA, A( I, MIN( I+1, N ) ), LDA,
00213      $                   TAUP( I ) )
00214             D( I ) = ALPHA
00215             A( I, I ) = ONE
00216 *
00217 *           Apply G(i) to A(i+1:m,i:n) from the right
00218 *
00219             IF( I.LT.M )
00220      $         CALL ZLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
00221      $                     TAUP( I ), A( I+1, I ), LDA, WORK )
00222             CALL ZLACGV( N-I+1, A( I, I ), LDA )
00223             A( I, I ) = D( I )
00224 *
00225             IF( I.LT.M ) THEN
00226 *
00227 *              Generate elementary reflector H(i) to annihilate
00228 *              A(i+2:m,i)
00229 *
00230                ALPHA = A( I+1, I )
00231                CALL ZLARFG( M-I, ALPHA, A( MIN( I+2, M ), I ), 1,
00232      $                      TAUQ( I ) )
00233                E( I ) = ALPHA
00234                A( I+1, I ) = ONE
00235 *
00236 *              Apply H(i)**H to A(i+1:m,i+1:n) from the left
00237 *
00238                CALL ZLARF( 'Left', M-I, N-I, A( I+1, I ), 1,
00239      $                     DCONJG( TAUQ( I ) ), A( I+1, I+1 ), LDA,
00240      $                     WORK )
00241                A( I+1, I ) = E( I )
00242             ELSE
00243                TAUQ( I ) = ZERO
00244             END IF
00245    20    CONTINUE
00246       END IF
00247       RETURN
00248 *
00249 *     End of ZGEBD2
00250 *
00251       END
 All Files Functions