slahrd.c
Go to the documentation of this file.
00001 /* slahrd.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_b38 = 0.f;
00022 
00023 /* Subroutine */ int slahrd_(integer *n, integer *k, integer *nb, real *a, 
00024         integer *lda, real *tau, real *t, integer *ldt, real *y, integer *ldy)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, 
00028             i__3;
00029     real r__1;
00030 
00031     /* Local variables */
00032     integer i__;
00033     real ei;
00034     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), 
00035             sgemv_(char *, integer *, integer *, real *, real *, integer *, 
00036             real *, integer *, real *, real *, integer *), scopy_(
00037             integer *, real *, integer *, real *, integer *), saxpy_(integer *
00038 , real *, real *, integer *, real *, integer *), strmv_(char *, 
00039             char *, char *, integer *, real *, integer *, real *, integer *), slarfg_(integer *, real *, real *, 
00040             integer *, real *);
00041 
00042 
00043 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  SLAHRD reduces the first NB columns of a real general n-by-(n-k+1) */
00056 /*  matrix A so that elements below the k-th subdiagonal are zero. The */
00057 /*  reduction is performed by an orthogonal similarity transformation */
00058 /*  Q' * A * Q. The routine returns the matrices V and T which determine */
00059 /*  Q as a block reflector I - V*T*V', and also the matrix Y = A * V * T. */
00060 
00061 /*  This is an OBSOLETE auxiliary routine. */
00062 /*  This routine will be 'deprecated' in a  future release. */
00063 /*  Please use the new routine SLAHR2 instead. */
00064 
00065 /*  Arguments */
00066 /*  ========= */
00067 
00068 /*  N       (input) INTEGER */
00069 /*          The order of the matrix A. */
00070 
00071 /*  K       (input) INTEGER */
00072 /*          The offset for the reduction. Elements below the k-th */
00073 /*          subdiagonal in the first NB columns are reduced to zero. */
00074 
00075 /*  NB      (input) INTEGER */
00076 /*          The number of columns to be reduced. */
00077 
00078 /*  A       (input/output) REAL array, dimension (LDA,N-K+1) */
00079 /*          On entry, the n-by-(n-k+1) general matrix A. */
00080 /*          On exit, the elements on and above the k-th subdiagonal in */
00081 /*          the first NB columns are overwritten with the corresponding */
00082 /*          elements of the reduced matrix; the elements below the k-th */
00083 /*          subdiagonal, with the array TAU, represent the matrix Q as a */
00084 /*          product of elementary reflectors. The other columns of A are */
00085 /*          unchanged. See Further Details. */
00086 
00087 /*  LDA     (input) INTEGER */
00088 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00089 
00090 /*  TAU     (output) REAL array, dimension (NB) */
00091 /*          The scalar factors of the elementary reflectors. See Further */
00092 /*          Details. */
00093 
00094 /*  T       (output) REAL array, dimension (LDT,NB) */
00095 /*          The upper triangular matrix T. */
00096 
00097 /*  LDT     (input) INTEGER */
00098 /*          The leading dimension of the array T.  LDT >= NB. */
00099 
00100 /*  Y       (output) REAL array, dimension (LDY,NB) */
00101 /*          The n-by-nb matrix Y. */
00102 
00103 /*  LDY     (input) INTEGER */
00104 /*          The leading dimension of the array Y. LDY >= N. */
00105 
00106 /*  Further Details */
00107 /*  =============== */
00108 
00109 /*  The matrix Q is represented as a product of nb elementary reflectors */
00110 
00111 /*     Q = H(1) H(2) . . . H(nb). */
00112 
00113 /*  Each H(i) has the form */
00114 
00115 /*     H(i) = I - tau * v * v' */
00116 
00117 /*  where tau is a real scalar, and v is a real vector with */
00118 /*  v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */
00119 /*  A(i+k+1:n,i), and tau in TAU(i). */
00120 
00121 /*  The elements of the vectors v together form the (n-k+1)-by-nb matrix */
00122 /*  V which is needed, with T and Y, to apply the transformation to the */
00123 /*  unreduced part of the matrix, using an update of the form: */
00124 /*  A := (I - V*T*V') * (A - Y*V'). */
00125 
00126 /*  The contents of A on exit are illustrated by the following example */
00127 /*  with n = 7, k = 3 and nb = 2: */
00128 
00129 /*     ( a   h   a   a   a ) */
00130 /*     ( a   h   a   a   a ) */
00131 /*     ( a   h   a   a   a ) */
00132 /*     ( h   h   a   a   a ) */
00133 /*     ( v1  h   a   a   a ) */
00134 /*     ( v1  v2  a   a   a ) */
00135 /*     ( v1  v2  a   a   a ) */
00136 
00137 /*  where a denotes an element of the original matrix A, h denotes a */
00138 /*  modified element of the upper Hessenberg matrix H, and vi denotes an */
00139 /*  element of the vector defining H(i). */
00140 
00141 /*  ===================================================================== */
00142 
00143 /*     .. Parameters .. */
00144 /*     .. */
00145 /*     .. Local Scalars .. */
00146 /*     .. */
00147 /*     .. External Subroutines .. */
00148 /*     .. */
00149 /*     .. Intrinsic Functions .. */
00150 /*     .. */
00151 /*     .. Executable Statements .. */
00152 
00153 /*     Quick return if possible */
00154 
00155     /* Parameter adjustments */
00156     --tau;
00157     a_dim1 = *lda;
00158     a_offset = 1 + a_dim1;
00159     a -= a_offset;
00160     t_dim1 = *ldt;
00161     t_offset = 1 + t_dim1;
00162     t -= t_offset;
00163     y_dim1 = *ldy;
00164     y_offset = 1 + y_dim1;
00165     y -= y_offset;
00166 
00167     /* Function Body */
00168     if (*n <= 1) {
00169         return 0;
00170     }
00171 
00172     i__1 = *nb;
00173     for (i__ = 1; i__ <= i__1; ++i__) {
00174         if (i__ > 1) {
00175 
00176 /*           Update A(1:n,i) */
00177 
00178 /*           Compute i-th column of A - Y * V' */
00179 
00180             i__2 = i__ - 1;
00181             sgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &a[*k 
00182                     + i__ - 1 + a_dim1], lda, &c_b5, &a[i__ * a_dim1 + 1], &
00183                     c__1);
00184 
00185 /*           Apply I - V * T' * V' to this column (call it b) from the */
00186 /*           left, using the last column of T as workspace */
00187 
00188 /*           Let  V = ( V1 )   and   b = ( b1 )   (first I-1 rows) */
00189 /*                    ( V2 )             ( b2 ) */
00190 
00191 /*           where V1 is unit lower triangular */
00192 
00193 /*           w := V1' * b1 */
00194 
00195             i__2 = i__ - 1;
00196             scopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + 
00197                     1], &c__1);
00198             i__2 = i__ - 1;
00199             strmv_("Lower", "Transpose", "Unit", &i__2, &a[*k + 1 + a_dim1], 
00200                     lda, &t[*nb * t_dim1 + 1], &c__1);
00201 
00202 /*           w := w + V2'*b2 */
00203 
00204             i__2 = *n - *k - i__ + 1;
00205             i__3 = i__ - 1;
00206             sgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], 
00207                     lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b5, &t[*nb * 
00208                     t_dim1 + 1], &c__1);
00209 
00210 /*           w := T'*w */
00211 
00212             i__2 = i__ - 1;
00213             strmv_("Upper", "Transpose", "Non-unit", &i__2, &t[t_offset], ldt, 
00214                      &t[*nb * t_dim1 + 1], &c__1);
00215 
00216 /*           b2 := b2 - V2*w */
00217 
00218             i__2 = *n - *k - i__ + 1;
00219             i__3 = i__ - 1;
00220             sgemv_("No transpose", &i__2, &i__3, &c_b4, &a[*k + i__ + a_dim1], 
00221                      lda, &t[*nb * t_dim1 + 1], &c__1, &c_b5, &a[*k + i__ + 
00222                     i__ * a_dim1], &c__1);
00223 
00224 /*           b1 := b1 - V1*w */
00225 
00226             i__2 = i__ - 1;
00227             strmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1]
00228 , lda, &t[*nb * t_dim1 + 1], &c__1);
00229             i__2 = i__ - 1;
00230             saxpy_(&i__2, &c_b4, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ 
00231                     * a_dim1], &c__1);
00232 
00233             a[*k + i__ - 1 + (i__ - 1) * a_dim1] = ei;
00234         }
00235 
00236 /*        Generate the elementary reflector H(i) to annihilate */
00237 /*        A(k+i+1:n,i) */
00238 
00239         i__2 = *n - *k - i__ + 1;
00240 /* Computing MIN */
00241         i__3 = *k + i__ + 1;
00242         slarfg_(&i__2, &a[*k + i__ + i__ * a_dim1], &a[min(i__3, *n)+ i__ * 
00243                 a_dim1], &c__1, &tau[i__]);
00244         ei = a[*k + i__ + i__ * a_dim1];
00245         a[*k + i__ + i__ * a_dim1] = 1.f;
00246 
00247 /*        Compute  Y(1:n,i) */
00248 
00249         i__2 = *n - *k - i__ + 1;
00250         sgemv_("No transpose", n, &i__2, &c_b5, &a[(i__ + 1) * a_dim1 + 1], 
00251                 lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &y[i__ * 
00252                 y_dim1 + 1], &c__1);
00253         i__2 = *n - *k - i__ + 1;
00254         i__3 = i__ - 1;
00255         sgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], lda, &
00256                 a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &t[i__ * t_dim1 + 
00257                 1], &c__1);
00258         i__2 = i__ - 1;
00259         sgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &t[i__ * 
00260                 t_dim1 + 1], &c__1, &c_b5, &y[i__ * y_dim1 + 1], &c__1);
00261         sscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1);
00262 
00263 /*        Compute T(1:i,i) */
00264 
00265         i__2 = i__ - 1;
00266         r__1 = -tau[i__];
00267         sscal_(&i__2, &r__1, &t[i__ * t_dim1 + 1], &c__1);
00268         i__2 = i__ - 1;
00269         strmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt, 
00270                 &t[i__ * t_dim1 + 1], &c__1)
00271                 ;
00272         t[i__ + i__ * t_dim1] = tau[i__];
00273 
00274 /* L10: */
00275     }
00276     a[*k + *nb + *nb * a_dim1] = ei;
00277 
00278     return 0;
00279 
00280 /*     End of SLAHRD */
00281 
00282 } /* slahrd_ */


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