dgebd2.c
Go to the documentation of this file.
00001 /* dgebd2.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 /* Subroutine */ int dgebd2_(integer *m, integer *n, doublereal *a, integer *
00021         lda, doublereal *d__, doublereal *e, doublereal *tauq, doublereal *
00022         taup, doublereal *work, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2, i__3;
00026 
00027     /* Local variables */
00028     integer i__;
00029     extern /* Subroutine */ int dlarf_(char *, integer *, integer *, 
00030             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00031             doublereal *), dlarfg_(integer *, doublereal *, 
00032             doublereal *, integer *, doublereal *), xerbla_(char *, integer *);
00033 
00034 
00035 /*  -- LAPACK routine (version 3.2) -- */
00036 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00037 /*     November 2006 */
00038 
00039 /*     .. Scalar Arguments .. */
00040 /*     .. */
00041 /*     .. Array Arguments .. */
00042 /*     .. */
00043 
00044 /*  Purpose */
00045 /*  ======= */
00046 
00047 /*  DGEBD2 reduces a real general m by n matrix A to upper or lower */
00048 /*  bidiagonal form B by an orthogonal transformation: Q' * A * P = B. */
00049 
00050 /*  If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */
00051 
00052 /*  Arguments */
00053 /*  ========= */
00054 
00055 /*  M       (input) INTEGER */
00056 /*          The number of rows in the matrix A.  M >= 0. */
00057 
00058 /*  N       (input) INTEGER */
00059 /*          The number of columns in the matrix A.  N >= 0. */
00060 
00061 /*  A       (input/output) 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 
00080 /*  LDA     (input) INTEGER */
00081 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00082 
00083 /*  D       (output) DOUBLE PRECISION array, dimension (min(M,N)) */
00084 /*          The diagonal elements of the bidiagonal matrix B: */
00085 /*          D(i) = A(i,i). */
00086 
00087 /*  E       (output) DOUBLE PRECISION array, dimension (min(M,N)-1) */
00088 /*          The off-diagonal elements of the bidiagonal matrix B: */
00089 /*          if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */
00090 /*          if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */
00091 
00092 /*  TAUQ    (output) DOUBLE PRECISION array dimension (min(M,N)) */
00093 /*          The scalar factors of the elementary reflectors which */
00094 /*          represent the orthogonal matrix Q. See Further Details. */
00095 
00096 /*  TAUP    (output) DOUBLE PRECISION array, dimension (min(M,N)) */
00097 /*          The scalar factors of the elementary reflectors which */
00098 /*          represent the orthogonal matrix P. See Further Details. */
00099 
00100 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (max(M,N)) */
00101 
00102 /*  INFO    (output) INTEGER */
00103 /*          = 0: successful exit. */
00104 /*          < 0: if INFO = -i, the i-th argument had an illegal value. */
00105 
00106 /*  Further Details */
00107 /*  =============== */
00108 
00109 /*  The matrices Q and P are represented as products of elementary */
00110 /*  reflectors: */
00111 
00112 /*  If m >= n, */
00113 
00114 /*     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1) */
00115 
00116 /*  Each H(i) and G(i) has the form: */
00117 
00118 /*     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u' */
00119 
00120 /*  where tauq and taup are real scalars, and v and u are real vectors; */
00121 /*  v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); */
00122 /*  u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); */
00123 /*  tauq is stored in TAUQ(i) and taup in TAUP(i). */
00124 
00125 /*  If m < n, */
00126 
00127 /*     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m) */
00128 
00129 /*  Each H(i) and G(i) has the form: */
00130 
00131 /*     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u' */
00132 
00133 /*  where tauq and taup are real scalars, and v and u are real vectors; */
00134 /*  v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */
00135 /*  u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */
00136 /*  tauq is stored in TAUQ(i) and taup in TAUP(i). */
00137 
00138 /*  The contents of A on exit are illustrated by the following examples: */
00139 
00140 /*  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n): */
00141 
00142 /*    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 ) */
00143 /*    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 ) */
00144 /*    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 ) */
00145 /*    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 ) */
00146 /*    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 ) */
00147 /*    (  v1  v2  v3  v4  v5 ) */
00148 
00149 /*  where d and e denote diagonal and off-diagonal elements of B, vi */
00150 /*  denotes an element of the vector defining H(i), and ui an element of */
00151 /*  the vector defining G(i). */
00152 
00153 /*  ===================================================================== */
00154 
00155 /*     .. Parameters .. */
00156 /*     .. */
00157 /*     .. Local Scalars .. */
00158 /*     .. */
00159 /*     .. External Subroutines .. */
00160 /*     .. */
00161 /*     .. Intrinsic Functions .. */
00162 /*     .. */
00163 /*     .. Executable Statements .. */
00164 
00165 /*     Test the input parameters */
00166 
00167     /* Parameter adjustments */
00168     a_dim1 = *lda;
00169     a_offset = 1 + a_dim1;
00170     a -= a_offset;
00171     --d__;
00172     --e;
00173     --tauq;
00174     --taup;
00175     --work;
00176 
00177     /* Function Body */
00178     *info = 0;
00179     if (*m < 0) {
00180         *info = -1;
00181     } else if (*n < 0) {
00182         *info = -2;
00183     } else if (*lda < max(1,*m)) {
00184         *info = -4;
00185     }
00186     if (*info < 0) {
00187         i__1 = -(*info);
00188         xerbla_("DGEBD2", &i__1);
00189         return 0;
00190     }
00191 
00192     if (*m >= *n) {
00193 
00194 /*        Reduce to upper bidiagonal form */
00195 
00196         i__1 = *n;
00197         for (i__ = 1; i__ <= i__1; ++i__) {
00198 
00199 /*           Generate elementary reflector H(i) to annihilate A(i+1:m,i) */
00200 
00201             i__2 = *m - i__ + 1;
00202 /* Computing MIN */
00203             i__3 = i__ + 1;
00204             dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[min(i__3, *m)+ i__ * 
00205                     a_dim1], &c__1, &tauq[i__]);
00206             d__[i__] = a[i__ + i__ * a_dim1];
00207             a[i__ + i__ * a_dim1] = 1.;
00208 
00209 /*           Apply H(i) to A(i:m,i+1:n) from the left */
00210 
00211             if (i__ < *n) {
00212                 i__2 = *m - i__ + 1;
00213                 i__3 = *n - i__;
00214                 dlarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &
00215                         tauq[i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]
00216 );
00217             }
00218             a[i__ + i__ * a_dim1] = d__[i__];
00219 
00220             if (i__ < *n) {
00221 
00222 /*              Generate elementary reflector G(i) to annihilate */
00223 /*              A(i,i+2:n) */
00224 
00225                 i__2 = *n - i__;
00226 /* Computing MIN */
00227                 i__3 = i__ + 2;
00228                 dlarfg_(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + min(
00229                         i__3, *n)* a_dim1], lda, &taup[i__]);
00230                 e[i__] = a[i__ + (i__ + 1) * a_dim1];
00231                 a[i__ + (i__ + 1) * a_dim1] = 1.;
00232 
00233 /*              Apply G(i) to A(i+1:m,i+1:n) from the right */
00234 
00235                 i__2 = *m - i__;
00236                 i__3 = *n - i__;
00237                 dlarf_("Right", &i__2, &i__3, &a[i__ + (i__ + 1) * a_dim1], 
00238                         lda, &taup[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], 
00239                         lda, &work[1]);
00240                 a[i__ + (i__ + 1) * a_dim1] = e[i__];
00241             } else {
00242                 taup[i__] = 0.;
00243             }
00244 /* L10: */
00245         }
00246     } else {
00247 
00248 /*        Reduce to lower bidiagonal form */
00249 
00250         i__1 = *m;
00251         for (i__ = 1; i__ <= i__1; ++i__) {
00252 
00253 /*           Generate elementary reflector G(i) to annihilate A(i,i+1:n) */
00254 
00255             i__2 = *n - i__ + 1;
00256 /* Computing MIN */
00257             i__3 = i__ + 1;
00258             dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)* 
00259                     a_dim1], lda, &taup[i__]);
00260             d__[i__] = a[i__ + i__ * a_dim1];
00261             a[i__ + i__ * a_dim1] = 1.;
00262 
00263 /*           Apply G(i) to A(i+1:m,i:n) from the right */
00264 
00265             if (i__ < *m) {
00266                 i__2 = *m - i__;
00267                 i__3 = *n - i__ + 1;
00268                 dlarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &
00269                         taup[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
00270             }
00271             a[i__ + i__ * a_dim1] = d__[i__];
00272 
00273             if (i__ < *m) {
00274 
00275 /*              Generate elementary reflector H(i) to annihilate */
00276 /*              A(i+2:m,i) */
00277 
00278                 i__2 = *m - i__;
00279 /* Computing MIN */
00280                 i__3 = i__ + 2;
00281                 dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *m)+ 
00282                         i__ * a_dim1], &c__1, &tauq[i__]);
00283                 e[i__] = a[i__ + 1 + i__ * a_dim1];
00284                 a[i__ + 1 + i__ * a_dim1] = 1.;
00285 
00286 /*              Apply H(i) to A(i+1:m,i+1:n) from the left */
00287 
00288                 i__2 = *m - i__;
00289                 i__3 = *n - i__;
00290                 dlarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &
00291                         c__1, &tauq[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], 
00292                         lda, &work[1]);
00293                 a[i__ + 1 + i__ * a_dim1] = e[i__];
00294             } else {
00295                 tauq[i__] = 0.;
00296             }
00297 /* L20: */
00298         }
00299     }
00300     return 0;
00301 
00302 /*     End of DGEBD2 */
00303 
00304 } /* dgebd2_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:43