dlabrd.c
Go to the documentation of this file.
00001 /* dlabrd.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 doublereal c_b4 = -1.;
00019 static doublereal c_b5 = 1.;
00020 static integer c__1 = 1;
00021 static doublereal c_b16 = 0.;
00022 
00023 /* Subroutine */ int dlabrd_(integer *m, integer *n, integer *nb, doublereal *
00024         a, integer *lda, doublereal *d__, doublereal *e, doublereal *tauq, 
00025         doublereal *taup, doublereal *x, integer *ldx, doublereal *y, integer 
00026         *ldy)
00027 {
00028     /* System generated locals */
00029     integer a_dim1, a_offset, x_dim1, x_offset, y_dim1, y_offset, i__1, i__2, 
00030             i__3;
00031 
00032     /* Local variables */
00033     integer i__;
00034     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
00035             integer *), dgemv_(char *, integer *, integer *, doublereal *, 
00036             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00037             doublereal *, integer *), dlarfg_(integer *, doublereal *, 
00038              doublereal *, integer *, doublereal *);
00039 
00040 
00041 /*  -- LAPACK auxiliary 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 /*  DLABRD reduces the first NB rows and columns of a real general */
00054 /*  m by n matrix A to upper or lower bidiagonal form by an orthogonal */
00055 /*  transformation Q' * A * P, and returns the matrices X and Y which */
00056 /*  are needed to apply the transformation to the unreduced part of A. */
00057 
00058 /*  If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower */
00059 /*  bidiagonal form. */
00060 
00061 /*  This is an auxiliary routine called by DGEBRD */
00062 
00063 /*  Arguments */
00064 /*  ========= */
00065 
00066 /*  M       (input) INTEGER */
00067 /*          The number of rows in the matrix A. */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The number of columns in the matrix A. */
00071 
00072 /*  NB      (input) INTEGER */
00073 /*          The number of leading rows and columns of A to be reduced. */
00074 
00075 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
00076 /*          On entry, the m by n general matrix to be reduced. */
00077 /*          On exit, the first NB rows and columns of the matrix are */
00078 /*          overwritten; the rest of the array is unchanged. */
00079 /*          If m >= n, elements on and below the diagonal in the first NB */
00080 /*            columns, with the array TAUQ, represent the orthogonal */
00081 /*            matrix Q as a product of elementary reflectors; and */
00082 /*            elements above the diagonal in the first NB rows, with the */
00083 /*            array TAUP, represent the orthogonal matrix P as a product */
00084 /*            of elementary reflectors. */
00085 /*          If m < n, elements below the diagonal in the first NB */
00086 /*            columns, with the array TAUQ, represent the orthogonal */
00087 /*            matrix Q as a product of elementary reflectors, and */
00088 /*            elements on and above the diagonal in the first NB rows, */
00089 /*            with the array TAUP, represent the orthogonal matrix P as */
00090 /*            a product of elementary reflectors. */
00091 /*          See Further Details. */
00092 
00093 /*  LDA     (input) INTEGER */
00094 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00095 
00096 /*  D       (output) DOUBLE PRECISION array, dimension (NB) */
00097 /*          The diagonal elements of the first NB rows and columns of */
00098 /*          the reduced matrix.  D(i) = A(i,i). */
00099 
00100 /*  E       (output) DOUBLE PRECISION array, dimension (NB) */
00101 /*          The off-diagonal elements of the first NB rows and columns of */
00102 /*          the reduced matrix. */
00103 
00104 /*  TAUQ    (output) DOUBLE PRECISION array dimension (NB) */
00105 /*          The scalar factors of the elementary reflectors which */
00106 /*          represent the orthogonal matrix Q. See Further Details. */
00107 
00108 /*  TAUP    (output) DOUBLE PRECISION array, dimension (NB) */
00109 /*          The scalar factors of the elementary reflectors which */
00110 /*          represent the orthogonal matrix P. See Further Details. */
00111 
00112 /*  X       (output) DOUBLE PRECISION array, dimension (LDX,NB) */
00113 /*          The m-by-nb matrix X required to update the unreduced part */
00114 /*          of A. */
00115 
00116 /*  LDX     (input) INTEGER */
00117 /*          The leading dimension of the array X. LDX >= M. */
00118 
00119 /*  Y       (output) DOUBLE PRECISION array, dimension (LDY,NB) */
00120 /*          The n-by-nb matrix Y required to update the unreduced part */
00121 /*          of A. */
00122 
00123 /*  LDY     (input) INTEGER */
00124 /*          The leading dimension of the array Y. LDY >= N. */
00125 
00126 /*  Further Details */
00127 /*  =============== */
00128 
00129 /*  The matrices Q and P are represented as products of elementary */
00130 /*  reflectors: */
00131 
00132 /*     Q = H(1) H(2) . . . H(nb)  and  P = G(1) G(2) . . . G(nb) */
00133 
00134 /*  Each H(i) and G(i) has the form: */
00135 
00136 /*     H(i) = I - tauq * v * v'  and G(i) = I - taup * u * u' */
00137 
00138 /*  where tauq and taup are real scalars, and v and u are real vectors. */
00139 
00140 /*  If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in */
00141 /*  A(i:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+1:n) is stored on exit in */
00142 /*  A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */
00143 
00144 /*  If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in */
00145 /*  A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in */
00146 /*  A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */
00147 
00148 /*  The elements of the vectors v and u together form the m-by-nb matrix */
00149 /*  V and the nb-by-n matrix U' which are needed, with X and Y, to apply */
00150 /*  the transformation to the unreduced part of the matrix, using a block */
00151 /*  update of the form:  A := A - V*Y' - X*U'. */
00152 
00153 /*  The contents of A on exit are illustrated by the following examples */
00154 /*  with nb = 2: */
00155 
00156 /*  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n): */
00157 
00158 /*    (  1   1   u1  u1  u1 )           (  1   u1  u1  u1  u1  u1 ) */
00159 /*    (  v1  1   1   u2  u2 )           (  1   1   u2  u2  u2  u2 ) */
00160 /*    (  v1  v2  a   a   a  )           (  v1  1   a   a   a   a  ) */
00161 /*    (  v1  v2  a   a   a  )           (  v1  v2  a   a   a   a  ) */
00162 /*    (  v1  v2  a   a   a  )           (  v1  v2  a   a   a   a  ) */
00163 /*    (  v1  v2  a   a   a  ) */
00164 
00165 /*  where a denotes an element of the original matrix which is unchanged, */
00166 /*  vi denotes an element of the vector defining H(i), and ui an element */
00167 /*  of the vector defining G(i). */
00168 
00169 /*  ===================================================================== */
00170 
00171 /*     .. Parameters .. */
00172 /*     .. */
00173 /*     .. Local Scalars .. */
00174 /*     .. */
00175 /*     .. External Subroutines .. */
00176 /*     .. */
00177 /*     .. Intrinsic Functions .. */
00178 /*     .. */
00179 /*     .. Executable Statements .. */
00180 
00181 /*     Quick return if possible */
00182 
00183     /* Parameter adjustments */
00184     a_dim1 = *lda;
00185     a_offset = 1 + a_dim1;
00186     a -= a_offset;
00187     --d__;
00188     --e;
00189     --tauq;
00190     --taup;
00191     x_dim1 = *ldx;
00192     x_offset = 1 + x_dim1;
00193     x -= x_offset;
00194     y_dim1 = *ldy;
00195     y_offset = 1 + y_dim1;
00196     y -= y_offset;
00197 
00198     /* Function Body */
00199     if (*m <= 0 || *n <= 0) {
00200         return 0;
00201     }
00202 
00203     if (*m >= *n) {
00204 
00205 /*        Reduce to upper bidiagonal form */
00206 
00207         i__1 = *nb;
00208         for (i__ = 1; i__ <= i__1; ++i__) {
00209 
00210 /*           Update A(i:m,i) */
00211 
00212             i__2 = *m - i__ + 1;
00213             i__3 = i__ - 1;
00214             dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + a_dim1], lda, 
00215                      &y[i__ + y_dim1], ldy, &c_b5, &a[i__ + i__ * a_dim1], &
00216                     c__1);
00217             i__2 = *m - i__ + 1;
00218             i__3 = i__ - 1;
00219             dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + x_dim1], ldx, 
00220                      &a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[i__ + i__ * 
00221                     a_dim1], &c__1);
00222 
00223 /*           Generate reflection Q(i) to annihilate A(i+1:m,i) */
00224 
00225             i__2 = *m - i__ + 1;
00226 /* Computing MIN */
00227             i__3 = i__ + 1;
00228             dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[min(i__3, *m)+ i__ * 
00229                     a_dim1], &c__1, &tauq[i__]);
00230             d__[i__] = a[i__ + i__ * a_dim1];
00231             if (i__ < *n) {
00232                 a[i__ + i__ * a_dim1] = 1.;
00233 
00234 /*              Compute Y(i+1:n,i) */
00235 
00236                 i__2 = *m - i__ + 1;
00237                 i__3 = *n - i__;
00238                 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + (i__ + 1) * 
00239                         a_dim1], lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &
00240                         y[i__ + 1 + i__ * y_dim1], &c__1);
00241                 i__2 = *m - i__ + 1;
00242                 i__3 = i__ - 1;
00243                 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + a_dim1], 
00244                         lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ * 
00245                         y_dim1 + 1], &c__1);
00246                 i__2 = *n - i__;
00247                 i__3 = i__ - 1;
00248                 dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 + 
00249                         y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[
00250                         i__ + 1 + i__ * y_dim1], &c__1);
00251                 i__2 = *m - i__ + 1;
00252                 i__3 = i__ - 1;
00253                 dgemv_("Transpose", &i__2, &i__3, &c_b5, &x[i__ + x_dim1], 
00254                         ldx, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ * 
00255                         y_dim1 + 1], &c__1);
00256                 i__2 = i__ - 1;
00257                 i__3 = *n - i__;
00258                 dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) * 
00259                         a_dim1 + 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5, 
00260                         &y[i__ + 1 + i__ * y_dim1], &c__1);
00261                 i__2 = *n - i__;
00262                 dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1);
00263 
00264 /*              Update A(i,i+1:n) */
00265 
00266                 i__2 = *n - i__;
00267                 dgemv_("No transpose", &i__2, &i__, &c_b4, &y[i__ + 1 + 
00268                         y_dim1], ldy, &a[i__ + a_dim1], lda, &c_b5, &a[i__ + (
00269                         i__ + 1) * a_dim1], lda);
00270                 i__2 = i__ - 1;
00271                 i__3 = *n - i__;
00272                 dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) * 
00273                         a_dim1 + 1], lda, &x[i__ + x_dim1], ldx, &c_b5, &a[
00274                         i__ + (i__ + 1) * a_dim1], lda);
00275 
00276 /*              Generate reflection P(i) to annihilate A(i,i+2:n) */
00277 
00278                 i__2 = *n - i__;
00279 /* Computing MIN */
00280                 i__3 = i__ + 2;
00281                 dlarfg_(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + min(
00282                         i__3, *n)* a_dim1], lda, &taup[i__]);
00283                 e[i__] = a[i__ + (i__ + 1) * a_dim1];
00284                 a[i__ + (i__ + 1) * a_dim1] = 1.;
00285 
00286 /*              Compute X(i+1:m,i) */
00287 
00288                 i__2 = *m - i__;
00289                 i__3 = *n - i__;
00290                 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__ 
00291                         + 1) * a_dim1], lda, &a[i__ + (i__ + 1) * a_dim1], 
00292                         lda, &c_b16, &x[i__ + 1 + i__ * x_dim1], &c__1);
00293                 i__2 = *n - i__;
00294                 dgemv_("Transpose", &i__2, &i__, &c_b5, &y[i__ + 1 + y_dim1], 
00295                         ldy, &a[i__ + (i__ + 1) * a_dim1], lda, &c_b16, &x[
00296                         i__ * x_dim1 + 1], &c__1);
00297                 i__2 = *m - i__;
00298                 dgemv_("No transpose", &i__2, &i__, &c_b4, &a[i__ + 1 + 
00299                         a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
00300                         i__ + 1 + i__ * x_dim1], &c__1);
00301                 i__2 = i__ - 1;
00302                 i__3 = *n - i__;
00303                 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[(i__ + 1) * 
00304                         a_dim1 + 1], lda, &a[i__ + (i__ + 1) * a_dim1], lda, &
00305                         c_b16, &x[i__ * x_dim1 + 1], &c__1);
00306                 i__2 = *m - i__;
00307                 i__3 = i__ - 1;
00308                 dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 + 
00309                         x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
00310                         i__ + 1 + i__ * x_dim1], &c__1);
00311                 i__2 = *m - i__;
00312                 dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1);
00313             }
00314 /* L10: */
00315         }
00316     } else {
00317 
00318 /*        Reduce to lower bidiagonal form */
00319 
00320         i__1 = *nb;
00321         for (i__ = 1; i__ <= i__1; ++i__) {
00322 
00323 /*           Update A(i,i:n) */
00324 
00325             i__2 = *n - i__ + 1;
00326             i__3 = i__ - 1;
00327             dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + y_dim1], ldy, 
00328                      &a[i__ + a_dim1], lda, &c_b5, &a[i__ + i__ * a_dim1], 
00329                     lda);
00330             i__2 = i__ - 1;
00331             i__3 = *n - i__ + 1;
00332             dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[i__ * a_dim1 + 1], 
00333                     lda, &x[i__ + x_dim1], ldx, &c_b5, &a[i__ + i__ * a_dim1], 
00334                      lda);
00335 
00336 /*           Generate reflection P(i) to annihilate A(i,i+1:n) */
00337 
00338             i__2 = *n - i__ + 1;
00339 /* Computing MIN */
00340             i__3 = i__ + 1;
00341             dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)* 
00342                     a_dim1], lda, &taup[i__]);
00343             d__[i__] = a[i__ + i__ * a_dim1];
00344             if (i__ < *m) {
00345                 a[i__ + i__ * a_dim1] = 1.;
00346 
00347 /*              Compute X(i+1:m,i) */
00348 
00349                 i__2 = *m - i__;
00350                 i__3 = *n - i__ + 1;
00351                 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + i__ *
00352                          a_dim1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, &
00353                         x[i__ + 1 + i__ * x_dim1], &c__1);
00354                 i__2 = *n - i__ + 1;
00355                 i__3 = i__ - 1;
00356                 dgemv_("Transpose", &i__2, &i__3, &c_b5, &y[i__ + y_dim1], 
00357                         ldy, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ * 
00358                         x_dim1 + 1], &c__1);
00359                 i__2 = *m - i__;
00360                 i__3 = i__ - 1;
00361                 dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 + 
00362                         a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
00363                         i__ + 1 + i__ * x_dim1], &c__1);
00364                 i__2 = i__ - 1;
00365                 i__3 = *n - i__ + 1;
00366                 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ * a_dim1 + 
00367                         1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ *
00368                          x_dim1 + 1], &c__1);
00369                 i__2 = *m - i__;
00370                 i__3 = i__ - 1;
00371                 dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 + 
00372                         x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
00373                         i__ + 1 + i__ * x_dim1], &c__1);
00374                 i__2 = *m - i__;
00375                 dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1);
00376 
00377 /*              Update A(i+1:m,i) */
00378 
00379                 i__2 = *m - i__;
00380                 i__3 = i__ - 1;
00381                 dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 + 
00382                         a_dim1], lda, &y[i__ + y_dim1], ldy, &c_b5, &a[i__ + 
00383                         1 + i__ * a_dim1], &c__1);
00384                 i__2 = *m - i__;
00385                 dgemv_("No transpose", &i__2, &i__, &c_b4, &x[i__ + 1 + 
00386                         x_dim1], ldx, &a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[
00387                         i__ + 1 + i__ * a_dim1], &c__1);
00388 
00389 /*              Generate reflection Q(i) to annihilate A(i+2:m,i) */
00390 
00391                 i__2 = *m - i__;
00392 /* Computing MIN */
00393                 i__3 = i__ + 2;
00394                 dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *m)+ 
00395                         i__ * a_dim1], &c__1, &tauq[i__]);
00396                 e[i__] = a[i__ + 1 + i__ * a_dim1];
00397                 a[i__ + 1 + i__ * a_dim1] = 1.;
00398 
00399 /*              Compute Y(i+1:n,i) */
00400 
00401                 i__2 = *m - i__;
00402                 i__3 = *n - i__;
00403                 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__ + 
00404                         1) * a_dim1], lda, &a[i__ + 1 + i__ * a_dim1], &c__1, 
00405                         &c_b16, &y[i__ + 1 + i__ * y_dim1], &c__1);
00406                 i__2 = *m - i__;
00407                 i__3 = i__ - 1;
00408                 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + a_dim1], 
00409                          lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[
00410                         i__ * y_dim1 + 1], &c__1);
00411                 i__2 = *n - i__;
00412                 i__3 = i__ - 1;
00413                 dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 + 
00414                         y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[
00415                         i__ + 1 + i__ * y_dim1], &c__1);
00416                 i__2 = *m - i__;
00417                 dgemv_("Transpose", &i__2, &i__, &c_b5, &x[i__ + 1 + x_dim1], 
00418                         ldx, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[
00419                         i__ * y_dim1 + 1], &c__1);
00420                 i__2 = *n - i__;
00421                 dgemv_("Transpose", &i__, &i__2, &c_b4, &a[(i__ + 1) * a_dim1 
00422                         + 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[i__ 
00423                         + 1 + i__ * y_dim1], &c__1);
00424                 i__2 = *n - i__;
00425                 dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1);
00426             }
00427 /* L20: */
00428         }
00429     }
00430     return 0;
00431 
00432 /*     End of DLABRD */
00433 
00434 } /* dlabrd_ */


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