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


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