LAPACK 3.3.1
Linear Algebra PACKage

dgebd2.f

Go to the documentation of this file.
00001       SUBROUTINE DGEBD2( 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   A( LDA, * ), D( * ), E( * ), TAUP( * ),
00013      $                   TAUQ( * ), WORK( * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  DGEBD2 reduces a real general m by n matrix A to upper or lower
00020 *  bidiagonal form B by an orthogonal transformation: Q**T * 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) DOUBLE PRECISION 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 orthogonal matrix Q as a product of elementary
00040 *            reflectors, and the elements above the first superdiagonal,
00041 *            with the array TAUP, represent the orthogonal 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 orthogonal matrix Q as a product of
00047 *            elementary reflectors, and the elements above the diagonal,
00048 *            with the array TAUP, represent the orthogonal 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) DOUBLE PRECISION array dimension (min(M,N))
00065 *          The scalar factors of the elementary reflectors which
00066 *          represent the orthogonal matrix Q. See Further Details.
00067 *
00068 *  TAUP    (output) DOUBLE PRECISION array, dimension (min(M,N))
00069 *          The scalar factors of the elementary reflectors which
00070 *          represent the orthogonal matrix P. See Further Details.
00071 *
00072 *  WORK    (workspace) DOUBLE PRECISION 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**T  and G(i) = I - taup * u * u**T
00091 *
00092 *  where tauq and taup are real scalars, and v and u are real vectors;
00093 *  v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
00094 *  u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
00095 *  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**T  and G(i) = I - taup * u * u**T
00104 *
00105 *  where tauq and taup are real scalars, and v and u are real 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       DOUBLE PRECISION   ZERO, ONE
00129       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00130 *     ..
00131 *     .. Local Scalars ..
00132       INTEGER            I
00133 *     ..
00134 *     .. External Subroutines ..
00135       EXTERNAL           DLARF, DLARFG, XERBLA
00136 *     ..
00137 *     .. Intrinsic Functions ..
00138       INTRINSIC          MAX, MIN
00139 *     ..
00140 *     .. Executable Statements ..
00141 *
00142 *     Test the input parameters
00143 *
00144       INFO = 0
00145       IF( M.LT.0 ) THEN
00146          INFO = -1
00147       ELSE IF( N.LT.0 ) THEN
00148          INFO = -2
00149       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00150          INFO = -4
00151       END IF
00152       IF( INFO.LT.0 ) THEN
00153          CALL XERBLA( 'DGEBD2', -INFO )
00154          RETURN
00155       END IF
00156 *
00157       IF( M.GE.N ) THEN
00158 *
00159 *        Reduce to upper bidiagonal form
00160 *
00161          DO 10 I = 1, N
00162 *
00163 *           Generate elementary reflector H(i) to annihilate A(i+1:m,i)
00164 *
00165             CALL DLARFG( M-I+1, A( I, I ), A( MIN( I+1, M ), I ), 1,
00166      $                   TAUQ( I ) )
00167             D( I ) = A( I, I )
00168             A( I, I ) = ONE
00169 *
00170 *           Apply H(i) to A(i:m,i+1:n) from the left
00171 *
00172             IF( I.LT.N )
00173      $         CALL DLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAUQ( I ),
00174      $                     A( I, I+1 ), LDA, WORK )
00175             A( I, I ) = D( I )
00176 *
00177             IF( I.LT.N ) THEN
00178 *
00179 *              Generate elementary reflector G(i) to annihilate
00180 *              A(i,i+2:n)
00181 *
00182                CALL DLARFG( N-I, A( I, I+1 ), A( I, MIN( I+2, N ) ),
00183      $                      LDA, TAUP( I ) )
00184                E( I ) = A( I, I+1 )
00185                A( I, I+1 ) = ONE
00186 *
00187 *              Apply G(i) to A(i+1:m,i+1:n) from the right
00188 *
00189                CALL DLARF( 'Right', M-I, N-I, A( I, I+1 ), LDA,
00190      $                     TAUP( I ), A( I+1, I+1 ), LDA, WORK )
00191                A( I, I+1 ) = E( I )
00192             ELSE
00193                TAUP( I ) = ZERO
00194             END IF
00195    10    CONTINUE
00196       ELSE
00197 *
00198 *        Reduce to lower bidiagonal form
00199 *
00200          DO 20 I = 1, M
00201 *
00202 *           Generate elementary reflector G(i) to annihilate A(i,i+1:n)
00203 *
00204             CALL DLARFG( N-I+1, A( I, I ), A( I, MIN( I+1, N ) ), LDA,
00205      $                   TAUP( I ) )
00206             D( I ) = A( I, I )
00207             A( I, I ) = ONE
00208 *
00209 *           Apply G(i) to A(i+1:m,i:n) from the right
00210 *
00211             IF( I.LT.M )
00212      $         CALL DLARF( 'Right', M-I, N-I+1, A( I, I ), LDA,
00213      $                     TAUP( I ), A( I+1, I ), LDA, WORK )
00214             A( I, I ) = D( I )
00215 *
00216             IF( I.LT.M ) THEN
00217 *
00218 *              Generate elementary reflector H(i) to annihilate
00219 *              A(i+2:m,i)
00220 *
00221                CALL DLARFG( M-I, A( I+1, I ), A( MIN( I+2, M ), I ), 1,
00222      $                      TAUQ( I ) )
00223                E( I ) = A( I+1, I )
00224                A( I+1, I ) = ONE
00225 *
00226 *              Apply H(i) to A(i+1:m,i+1:n) from the left
00227 *
00228                CALL DLARF( 'Left', M-I, N-I, A( I+1, I ), 1, TAUQ( I ),
00229      $                     A( I+1, I+1 ), LDA, WORK )
00230                A( I+1, I ) = E( I )
00231             ELSE
00232                TAUQ( I ) = ZERO
00233             END IF
00234    20    CONTINUE
00235       END IF
00236       RETURN
00237 *
00238 *     End of DGEBD2
00239 *
00240       END
 All Files Functions