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


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