zgebd2.c
Go to the documentation of this file.
00001 /* zgebd2.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 zgebd2_(integer *m, integer *n, doublecomplex *a, 
00021         integer *lda, doublereal *d__, doublereal *e, doublecomplex *tauq, 
00022         doublecomplex *taup, doublecomplex *work, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2, i__3;
00026     doublecomplex z__1;
00027 
00028     /* Builtin functions */
00029     void d_cnjg(doublecomplex *, doublecomplex *);
00030 
00031     /* Local variables */
00032     integer i__;
00033     doublecomplex alpha;
00034     extern /* Subroutine */ int zlarf_(char *, integer *, integer *, 
00035             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00036             integer *, doublecomplex *), xerbla_(char *, integer *), zlarfg_(integer *, doublecomplex *, doublecomplex *, 
00037             integer *, doublecomplex *), zlacgv_(integer *, doublecomplex *, 
00038             integer *);
00039 
00040 
00041 /*  -- LAPACK routine (version 3.2) -- */
00042 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00043 /*     November 2006 */
00044 
00045 /*     .. Scalar Arguments .. */
00046 /*     .. */
00047 /*     .. Array Arguments .. */
00048 /*     .. */
00049 
00050 /*  Purpose */
00051 /*  ======= */
00052 
00053 /*  ZGEBD2 reduces a complex general m by n matrix A to upper or lower */
00054 /*  real bidiagonal form B by a unitary transformation: Q' * A * P = B. */
00055 
00056 /*  If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */
00057 
00058 /*  Arguments */
00059 /*  ========= */
00060 
00061 /*  M       (input) INTEGER */
00062 /*          The number of rows in the matrix A.  M >= 0. */
00063 
00064 /*  N       (input) INTEGER */
00065 /*          The number of columns in the matrix A.  N >= 0. */
00066 
00067 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00068 /*          On entry, the m by n general matrix to be reduced. */
00069 /*          On exit, */
00070 /*          if m >= n, the diagonal and the first superdiagonal are */
00071 /*            overwritten with the upper bidiagonal matrix B; the */
00072 /*            elements below the diagonal, with the array TAUQ, represent */
00073 /*            the unitary matrix Q as a product of elementary */
00074 /*            reflectors, and the elements above the first superdiagonal, */
00075 /*            with the array TAUP, represent the unitary matrix P as */
00076 /*            a product of elementary reflectors; */
00077 /*          if m < n, the diagonal and the first subdiagonal are */
00078 /*            overwritten with the lower bidiagonal matrix B; the */
00079 /*            elements below the first subdiagonal, with the array TAUQ, */
00080 /*            represent the unitary matrix Q as a product of */
00081 /*            elementary reflectors, and the elements above the diagonal, */
00082 /*            with the array TAUP, represent the unitary matrix P as */
00083 /*            a product of elementary reflectors. */
00084 /*          See Further Details. */
00085 
00086 /*  LDA     (input) INTEGER */
00087 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00088 
00089 /*  D       (output) DOUBLE PRECISION array, dimension (min(M,N)) */
00090 /*          The diagonal elements of the bidiagonal matrix B: */
00091 /*          D(i) = A(i,i). */
00092 
00093 /*  E       (output) DOUBLE PRECISION array, dimension (min(M,N)-1) */
00094 /*          The off-diagonal elements of the bidiagonal matrix B: */
00095 /*          if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */
00096 /*          if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */
00097 
00098 /*  TAUQ    (output) COMPLEX*16 array dimension (min(M,N)) */
00099 /*          The scalar factors of the elementary reflectors which */
00100 /*          represent the unitary matrix Q. See Further Details. */
00101 
00102 /*  TAUP    (output) COMPLEX*16 array, dimension (min(M,N)) */
00103 /*          The scalar factors of the elementary reflectors which */
00104 /*          represent the unitary matrix P. See Further Details. */
00105 
00106 /*  WORK    (workspace) COMPLEX*16 array, dimension (max(M,N)) */
00107 
00108 /*  INFO    (output) INTEGER */
00109 /*          = 0: successful exit */
00110 /*          < 0: if INFO = -i, the i-th argument had an illegal value. */
00111 
00112 /*  Further Details */
00113 /*  =============== */
00114 
00115 /*  The matrices Q and P are represented as products of elementary */
00116 /*  reflectors: */
00117 
00118 /*  If m >= n, */
00119 
00120 /*     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1) */
00121 
00122 /*  Each H(i) and G(i) has the form: */
00123 
00124 /*     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u' */
00125 
00126 /*  where tauq and taup are complex scalars, and v and u are complex */
00127 /*  vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in */
00128 /*  A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in */
00129 /*  A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */
00130 
00131 /*  If m < n, */
00132 
00133 /*     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m) */
00134 
00135 /*  Each H(i) and G(i) has the form: */
00136 
00137 /*     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u' */
00138 
00139 /*  where tauq and taup are complex scalars, v and u are complex vectors; */
00140 /*  v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */
00141 /*  u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */
00142 /*  tauq is stored in TAUQ(i) and taup in TAUP(i). */
00143 
00144 /*  The contents of A on exit are illustrated by the following examples: */
00145 
00146 /*  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n): */
00147 
00148 /*    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 ) */
00149 /*    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 ) */
00150 /*    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 ) */
00151 /*    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 ) */
00152 /*    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 ) */
00153 /*    (  v1  v2  v3  v4  v5 ) */
00154 
00155 /*  where d and e denote diagonal and off-diagonal elements of B, vi */
00156 /*  denotes an element of the vector defining H(i), and ui an element of */
00157 /*  the vector defining G(i). */
00158 
00159 /*  ===================================================================== */
00160 
00161 /*     .. Parameters .. */
00162 /*     .. */
00163 /*     .. Local Scalars .. */
00164 /*     .. */
00165 /*     .. External Subroutines .. */
00166 /*     .. */
00167 /*     .. Intrinsic Functions .. */
00168 /*     .. */
00169 /*     .. Executable Statements .. */
00170 
00171 /*     Test the input parameters */
00172 
00173     /* Parameter adjustments */
00174     a_dim1 = *lda;
00175     a_offset = 1 + a_dim1;
00176     a -= a_offset;
00177     --d__;
00178     --e;
00179     --tauq;
00180     --taup;
00181     --work;
00182 
00183     /* Function Body */
00184     *info = 0;
00185     if (*m < 0) {
00186         *info = -1;
00187     } else if (*n < 0) {
00188         *info = -2;
00189     } else if (*lda < max(1,*m)) {
00190         *info = -4;
00191     }
00192     if (*info < 0) {
00193         i__1 = -(*info);
00194         xerbla_("ZGEBD2", &i__1);
00195         return 0;
00196     }
00197 
00198     if (*m >= *n) {
00199 
00200 /*        Reduce to upper bidiagonal form */
00201 
00202         i__1 = *n;
00203         for (i__ = 1; i__ <= i__1; ++i__) {
00204 
00205 /*           Generate elementary reflector H(i) to annihilate A(i+1:m,i) */
00206 
00207             i__2 = i__ + i__ * a_dim1;
00208             alpha.r = a[i__2].r, alpha.i = a[i__2].i;
00209             i__2 = *m - i__ + 1;
00210 /* Computing MIN */
00211             i__3 = i__ + 1;
00212             zlarfg_(&i__2, &alpha, &a[min(i__3, *m)+ i__ * a_dim1], &c__1, &
00213                     tauq[i__]);
00214             i__2 = i__;
00215             d__[i__2] = alpha.r;
00216             i__2 = i__ + i__ * a_dim1;
00217             a[i__2].r = 1., a[i__2].i = 0.;
00218 
00219 /*           Apply H(i)' to A(i:m,i+1:n) from the left */
00220 
00221             if (i__ < *n) {
00222                 i__2 = *m - i__ + 1;
00223                 i__3 = *n - i__;
00224                 d_cnjg(&z__1, &tauq[i__]);
00225                 zlarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &
00226                         z__1, &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]);
00227             }
00228             i__2 = i__ + i__ * a_dim1;
00229             i__3 = i__;
00230             a[i__2].r = d__[i__3], a[i__2].i = 0.;
00231 
00232             if (i__ < *n) {
00233 
00234 /*              Generate elementary reflector G(i) to annihilate */
00235 /*              A(i,i+2:n) */
00236 
00237                 i__2 = *n - i__;
00238                 zlacgv_(&i__2, &a[i__ + (i__ + 1) * a_dim1], lda);
00239                 i__2 = i__ + (i__ + 1) * a_dim1;
00240                 alpha.r = a[i__2].r, alpha.i = a[i__2].i;
00241                 i__2 = *n - i__;
00242 /* Computing MIN */
00243                 i__3 = i__ + 2;
00244                 zlarfg_(&i__2, &alpha, &a[i__ + min(i__3, *n)* a_dim1], lda, &
00245                         taup[i__]);
00246                 i__2 = i__;
00247                 e[i__2] = alpha.r;
00248                 i__2 = i__ + (i__ + 1) * a_dim1;
00249                 a[i__2].r = 1., a[i__2].i = 0.;
00250 
00251 /*              Apply G(i) to A(i+1:m,i+1:n) from the right */
00252 
00253                 i__2 = *m - i__;
00254                 i__3 = *n - i__;
00255                 zlarf_("Right", &i__2, &i__3, &a[i__ + (i__ + 1) * a_dim1], 
00256                         lda, &taup[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], 
00257                         lda, &work[1]);
00258                 i__2 = *n - i__;
00259                 zlacgv_(&i__2, &a[i__ + (i__ + 1) * a_dim1], lda);
00260                 i__2 = i__ + (i__ + 1) * a_dim1;
00261                 i__3 = i__;
00262                 a[i__2].r = e[i__3], a[i__2].i = 0.;
00263             } else {
00264                 i__2 = i__;
00265                 taup[i__2].r = 0., taup[i__2].i = 0.;
00266             }
00267 /* L10: */
00268         }
00269     } else {
00270 
00271 /*        Reduce to lower bidiagonal form */
00272 
00273         i__1 = *m;
00274         for (i__ = 1; i__ <= i__1; ++i__) {
00275 
00276 /*           Generate elementary reflector G(i) to annihilate A(i,i+1:n) */
00277 
00278             i__2 = *n - i__ + 1;
00279             zlacgv_(&i__2, &a[i__ + i__ * a_dim1], lda);
00280             i__2 = i__ + i__ * a_dim1;
00281             alpha.r = a[i__2].r, alpha.i = a[i__2].i;
00282             i__2 = *n - i__ + 1;
00283 /* Computing MIN */
00284             i__3 = i__ + 1;
00285             zlarfg_(&i__2, &alpha, &a[i__ + min(i__3, *n)* a_dim1], lda, &
00286                     taup[i__]);
00287             i__2 = i__;
00288             d__[i__2] = alpha.r;
00289             i__2 = i__ + i__ * a_dim1;
00290             a[i__2].r = 1., a[i__2].i = 0.;
00291 
00292 /*           Apply G(i) to A(i+1:m,i:n) from the right */
00293 
00294             if (i__ < *m) {
00295                 i__2 = *m - i__;
00296                 i__3 = *n - i__ + 1;
00297                 zlarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &
00298                         taup[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
00299             }
00300             i__2 = *n - i__ + 1;
00301             zlacgv_(&i__2, &a[i__ + i__ * a_dim1], lda);
00302             i__2 = i__ + i__ * a_dim1;
00303             i__3 = i__;
00304             a[i__2].r = d__[i__3], a[i__2].i = 0.;
00305 
00306             if (i__ < *m) {
00307 
00308 /*              Generate elementary reflector H(i) to annihilate */
00309 /*              A(i+2:m,i) */
00310 
00311                 i__2 = i__ + 1 + i__ * a_dim1;
00312                 alpha.r = a[i__2].r, alpha.i = a[i__2].i;
00313                 i__2 = *m - i__;
00314 /* Computing MIN */
00315                 i__3 = i__ + 2;
00316                 zlarfg_(&i__2, &alpha, &a[min(i__3, *m)+ i__ * a_dim1], &c__1, 
00317                          &tauq[i__]);
00318                 i__2 = i__;
00319                 e[i__2] = alpha.r;
00320                 i__2 = i__ + 1 + i__ * a_dim1;
00321                 a[i__2].r = 1., a[i__2].i = 0.;
00322 
00323 /*              Apply H(i)' to A(i+1:m,i+1:n) from the left */
00324 
00325                 i__2 = *m - i__;
00326                 i__3 = *n - i__;
00327                 d_cnjg(&z__1, &tauq[i__]);
00328                 zlarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &
00329                         c__1, &z__1, &a[i__ + 1 + (i__ + 1) * a_dim1], lda, &
00330                         work[1]);
00331                 i__2 = i__ + 1 + i__ * a_dim1;
00332                 i__3 = i__;
00333                 a[i__2].r = e[i__3], a[i__2].i = 0.;
00334             } else {
00335                 i__2 = i__;
00336                 tauq[i__2].r = 0., tauq[i__2].i = 0.;
00337             }
00338 /* L20: */
00339         }
00340     }
00341     return 0;
00342 
00343 /*     End of ZGEBD2 */
00344 
00345 } /* zgebd2_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:31