dlarft.c
Go to the documentation of this file.
00001 /* dlarft.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 static doublereal c_b8 = 0.;
00020 
00021 /* Subroutine */ int dlarft_(char *direct, char *storev, integer *n, integer *
00022         k, doublereal *v, integer *ldv, doublereal *tau, doublereal *t, 
00023         integer *ldt)
00024 {
00025     /* System generated locals */
00026     integer t_dim1, t_offset, v_dim1, v_offset, i__1, i__2, i__3;
00027     doublereal d__1;
00028 
00029     /* Local variables */
00030     integer i__, j, prevlastv;
00031     doublereal vii;
00032     extern logical lsame_(char *, char *);
00033     extern /* Subroutine */ int dgemv_(char *, integer *, integer *, 
00034             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00035             doublereal *, doublereal *, integer *);
00036     integer lastv;
00037     extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *, 
00038             doublereal *, integer *, doublereal *, integer *);
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 /*  DLARFT forms the triangular factor T of a real block reflector H */
00054 /*  of order n, which is defined as a product of k elementary reflectors. */
00055 
00056 /*  If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular; */
00057 
00058 /*  If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular. */
00059 
00060 /*  If STOREV = 'C', the vector which defines the elementary reflector */
00061 /*  H(i) is stored in the i-th column of the array V, and */
00062 
00063 /*     H  =  I - V * T * V' */
00064 
00065 /*  If STOREV = 'R', the vector which defines the elementary reflector */
00066 /*  H(i) is stored in the i-th row of the array V, and */
00067 
00068 /*     H  =  I - V' * T * V */
00069 
00070 /*  Arguments */
00071 /*  ========= */
00072 
00073 /*  DIRECT  (input) CHARACTER*1 */
00074 /*          Specifies the order in which the elementary reflectors are */
00075 /*          multiplied to form the block reflector: */
00076 /*          = 'F': H = H(1) H(2) . . . H(k) (Forward) */
00077 /*          = 'B': H = H(k) . . . H(2) H(1) (Backward) */
00078 
00079 /*  STOREV  (input) CHARACTER*1 */
00080 /*          Specifies how the vectors which define the elementary */
00081 /*          reflectors are stored (see also Further Details): */
00082 /*          = 'C': columnwise */
00083 /*          = 'R': rowwise */
00084 
00085 /*  N       (input) INTEGER */
00086 /*          The order of the block reflector H. N >= 0. */
00087 
00088 /*  K       (input) INTEGER */
00089 /*          The order of the triangular factor T (= the number of */
00090 /*          elementary reflectors). K >= 1. */
00091 
00092 /*  V       (input/output) DOUBLE PRECISION array, dimension */
00093 /*                               (LDV,K) if STOREV = 'C' */
00094 /*                               (LDV,N) if STOREV = 'R' */
00095 /*          The matrix V. See further details. */
00096 
00097 /*  LDV     (input) INTEGER */
00098 /*          The leading dimension of the array V. */
00099 /*          If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K. */
00100 
00101 /*  TAU     (input) DOUBLE PRECISION array, dimension (K) */
00102 /*          TAU(i) must contain the scalar factor of the elementary */
00103 /*          reflector H(i). */
00104 
00105 /*  T       (output) DOUBLE PRECISION array, dimension (LDT,K) */
00106 /*          The k by k triangular factor T of the block reflector. */
00107 /*          If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is */
00108 /*          lower triangular. The rest of the array is not used. */
00109 
00110 /*  LDT     (input) INTEGER */
00111 /*          The leading dimension of the array T. LDT >= K. */
00112 
00113 /*  Further Details */
00114 /*  =============== */
00115 
00116 /*  The shape of the matrix V and the storage of the vectors which define */
00117 /*  the H(i) is best illustrated by the following example with n = 5 and */
00118 /*  k = 3. The elements equal to 1 are not stored; the corresponding */
00119 /*  array elements are modified but restored on exit. The rest of the */
00120 /*  array is not used. */
00121 
00122 /*  DIRECT = 'F' and STOREV = 'C':         DIRECT = 'F' and STOREV = 'R': */
00123 
00124 /*               V = (  1       )                 V = (  1 v1 v1 v1 v1 ) */
00125 /*                   ( v1  1    )                     (     1 v2 v2 v2 ) */
00126 /*                   ( v1 v2  1 )                     (        1 v3 v3 ) */
00127 /*                   ( v1 v2 v3 ) */
00128 /*                   ( v1 v2 v3 ) */
00129 
00130 /*  DIRECT = 'B' and STOREV = 'C':         DIRECT = 'B' and STOREV = 'R': */
00131 
00132 /*               V = ( v1 v2 v3 )                 V = ( v1 v1  1       ) */
00133 /*                   ( v1 v2 v3 )                     ( v2 v2 v2  1    ) */
00134 /*                   (  1 v2 v3 )                     ( v3 v3 v3 v3  1 ) */
00135 /*                   (     1 v3 ) */
00136 /*                   (        1 ) */
00137 
00138 /*  ===================================================================== */
00139 
00140 /*     .. Parameters .. */
00141 /*     .. */
00142 /*     .. Local Scalars .. */
00143 /*     .. */
00144 /*     .. External Subroutines .. */
00145 /*     .. */
00146 /*     .. External Functions .. */
00147 /*     .. */
00148 /*     .. Executable Statements .. */
00149 
00150 /*     Quick return if possible */
00151 
00152     /* Parameter adjustments */
00153     v_dim1 = *ldv;
00154     v_offset = 1 + v_dim1;
00155     v -= v_offset;
00156     --tau;
00157     t_dim1 = *ldt;
00158     t_offset = 1 + t_dim1;
00159     t -= t_offset;
00160 
00161     /* Function Body */
00162     if (*n == 0) {
00163         return 0;
00164     }
00165 
00166     if (lsame_(direct, "F")) {
00167         prevlastv = *n;
00168         i__1 = *k;
00169         for (i__ = 1; i__ <= i__1; ++i__) {
00170             prevlastv = max(i__,prevlastv);
00171             if (tau[i__] == 0.) {
00172 
00173 /*              H(i)  =  I */
00174 
00175                 i__2 = i__;
00176                 for (j = 1; j <= i__2; ++j) {
00177                     t[j + i__ * t_dim1] = 0.;
00178 /* L10: */
00179                 }
00180             } else {
00181 
00182 /*              general case */
00183 
00184                 vii = v[i__ + i__ * v_dim1];
00185                 v[i__ + i__ * v_dim1] = 1.;
00186                 if (lsame_(storev, "C")) {
00187 /*                 Skip any trailing zeros. */
00188                     i__2 = i__ + 1;
00189                     for (lastv = *n; lastv >= i__2; --lastv) {
00190                         if (v[lastv + i__ * v_dim1] != 0.) {
00191                             break;
00192                         }
00193                     }
00194                     j = min(lastv,prevlastv);
00195 
00196 /*                 T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)' * V(i:j,i) */
00197 
00198                     i__2 = j - i__ + 1;
00199                     i__3 = i__ - 1;
00200                     d__1 = -tau[i__];
00201                     dgemv_("Transpose", &i__2, &i__3, &d__1, &v[i__ + v_dim1], 
00202                              ldv, &v[i__ + i__ * v_dim1], &c__1, &c_b8, &t[
00203                             i__ * t_dim1 + 1], &c__1);
00204                 } else {
00205 /*                 Skip any trailing zeros. */
00206                     i__2 = i__ + 1;
00207                     for (lastv = *n; lastv >= i__2; --lastv) {
00208                         if (v[i__ + lastv * v_dim1] != 0.) {
00209                             break;
00210                         }
00211                     }
00212                     j = min(lastv,prevlastv);
00213 
00214 /*                 T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)' */
00215 
00216                     i__2 = i__ - 1;
00217                     i__3 = j - i__ + 1;
00218                     d__1 = -tau[i__];
00219                     dgemv_("No transpose", &i__2, &i__3, &d__1, &v[i__ * 
00220                             v_dim1 + 1], ldv, &v[i__ + i__ * v_dim1], ldv, &
00221                             c_b8, &t[i__ * t_dim1 + 1], &c__1);
00222                 }
00223                 v[i__ + i__ * v_dim1] = vii;
00224 
00225 /*              T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i) */
00226 
00227                 i__2 = i__ - 1;
00228                 dtrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[
00229                         t_offset], ldt, &t[i__ * t_dim1 + 1], &c__1);
00230                 t[i__ + i__ * t_dim1] = tau[i__];
00231                 if (i__ > 1) {
00232                     prevlastv = max(prevlastv,lastv);
00233                 } else {
00234                     prevlastv = lastv;
00235                 }
00236             }
00237 /* L20: */
00238         }
00239     } else {
00240         prevlastv = 1;
00241         for (i__ = *k; i__ >= 1; --i__) {
00242             if (tau[i__] == 0.) {
00243 
00244 /*              H(i)  =  I */
00245 
00246                 i__1 = *k;
00247                 for (j = i__; j <= i__1; ++j) {
00248                     t[j + i__ * t_dim1] = 0.;
00249 /* L30: */
00250                 }
00251             } else {
00252 
00253 /*              general case */
00254 
00255                 if (i__ < *k) {
00256                     if (lsame_(storev, "C")) {
00257                         vii = v[*n - *k + i__ + i__ * v_dim1];
00258                         v[*n - *k + i__ + i__ * v_dim1] = 1.;
00259 /*                    Skip any leading zeros. */
00260                         i__1 = i__ - 1;
00261                         for (lastv = 1; lastv <= i__1; ++lastv) {
00262                             if (v[lastv + i__ * v_dim1] != 0.) {
00263                                 break;
00264                             }
00265                         }
00266                         j = max(lastv,prevlastv);
00267 
00268 /*                    T(i+1:k,i) := */
00269 /*                            - tau(i) * V(j:n-k+i,i+1:k)' * V(j:n-k+i,i) */
00270 
00271                         i__1 = *n - *k + i__ - j + 1;
00272                         i__2 = *k - i__;
00273                         d__1 = -tau[i__];
00274                         dgemv_("Transpose", &i__1, &i__2, &d__1, &v[j + (i__ 
00275                                 + 1) * v_dim1], ldv, &v[j + i__ * v_dim1], &
00276                                 c__1, &c_b8, &t[i__ + 1 + i__ * t_dim1], &
00277                                 c__1);
00278                         v[*n - *k + i__ + i__ * v_dim1] = vii;
00279                     } else {
00280                         vii = v[i__ + (*n - *k + i__) * v_dim1];
00281                         v[i__ + (*n - *k + i__) * v_dim1] = 1.;
00282 /*                    Skip any leading zeros. */
00283                         i__1 = i__ - 1;
00284                         for (lastv = 1; lastv <= i__1; ++lastv) {
00285                             if (v[i__ + lastv * v_dim1] != 0.) {
00286                                 break;
00287                             }
00288                         }
00289                         j = max(lastv,prevlastv);
00290 
00291 /*                    T(i+1:k,i) := */
00292 /*                            - tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)' */
00293 
00294                         i__1 = *k - i__;
00295                         i__2 = *n - *k + i__ - j + 1;
00296                         d__1 = -tau[i__];
00297                         dgemv_("No transpose", &i__1, &i__2, &d__1, &v[i__ + 
00298                                 1 + j * v_dim1], ldv, &v[i__ + j * v_dim1], 
00299                                 ldv, &c_b8, &t[i__ + 1 + i__ * t_dim1], &c__1);
00300                         v[i__ + (*n - *k + i__) * v_dim1] = vii;
00301                     }
00302 
00303 /*                 T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i) */
00304 
00305                     i__1 = *k - i__;
00306                     dtrmv_("Lower", "No transpose", "Non-unit", &i__1, &t[i__ 
00307                             + 1 + (i__ + 1) * t_dim1], ldt, &t[i__ + 1 + i__ *
00308                              t_dim1], &c__1)
00309                             ;
00310                     if (i__ > 1) {
00311                         prevlastv = min(prevlastv,lastv);
00312                     } else {
00313                         prevlastv = lastv;
00314                     }
00315                 }
00316                 t[i__ + i__ * t_dim1] = tau[i__];
00317             }
00318 /* L40: */
00319         }
00320     }
00321     return 0;
00322 
00323 /*     End of DLARFT */
00324 
00325 } /* dlarft_ */


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