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


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