slarzb.c
Go to the documentation of this file.
00001 /* slarzb.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_b13 = 1.f;
00020 static real c_b23 = -1.f;
00021 
00022 /* Subroutine */ int slarzb_(char *side, char *trans, char *direct, char *
00023         storev, integer *m, integer *n, integer *k, integer *l, real *v, 
00024         integer *ldv, real *t, integer *ldt, real *c__, integer *ldc, real *
00025         work, integer *ldwork)
00026 {
00027     /* System generated locals */
00028     integer c_dim1, c_offset, t_dim1, t_offset, v_dim1, v_offset, work_dim1, 
00029             work_offset, i__1, i__2;
00030 
00031     /* Local variables */
00032     integer i__, j, info;
00033     extern logical lsame_(char *, char *);
00034     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, 
00035             integer *, real *, real *, integer *, real *, integer *, real *, 
00036             real *, integer *), scopy_(integer *, real *, 
00037             integer *, real *, integer *), strmm_(char *, char *, char *, 
00038             char *, integer *, integer *, real *, real *, integer *, real *, 
00039             integer *), xerbla_(char *, 
00040             integer *);
00041     char transt[1];
00042 
00043 
00044 /*  -- LAPACK routine (version 3.2) -- */
00045 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00046 /*     November 2006 */
00047 
00048 /*     .. Scalar Arguments .. */
00049 /*     .. */
00050 /*     .. Array Arguments .. */
00051 /*     .. */
00052 
00053 /*  Purpose */
00054 /*  ======= */
00055 
00056 /*  SLARZB applies a real block reflector H or its transpose H**T to */
00057 /*  a real distributed M-by-N  C from the left or the right. */
00058 
00059 /*  Currently, only STOREV = 'R' and DIRECT = 'B' are supported. */
00060 
00061 /*  Arguments */
00062 /*  ========= */
00063 
00064 /*  SIDE    (input) CHARACTER*1 */
00065 /*          = 'L': apply H or H' from the Left */
00066 /*          = 'R': apply H or H' from the Right */
00067 
00068 /*  TRANS   (input) CHARACTER*1 */
00069 /*          = 'N': apply H (No transpose) */
00070 /*          = 'C': apply H' (Transpose) */
00071 
00072 /*  DIRECT  (input) CHARACTER*1 */
00073 /*          Indicates how H is formed from a product of elementary */
00074 /*          reflectors */
00075 /*          = 'F': H = H(1) H(2) . . . H(k) (Forward, not supported yet) */
00076 /*          = 'B': H = H(k) . . . H(2) H(1) (Backward) */
00077 
00078 /*  STOREV  (input) CHARACTER*1 */
00079 /*          Indicates how the vectors which define the elementary */
00080 /*          reflectors are stored: */
00081 /*          = 'C': Columnwise                        (not supported yet) */
00082 /*          = 'R': Rowwise */
00083 
00084 /*  M       (input) INTEGER */
00085 /*          The number of rows of the matrix C. */
00086 
00087 /*  N       (input) INTEGER */
00088 /*          The number of columns of the matrix C. */
00089 
00090 /*  K       (input) INTEGER */
00091 /*          The order of the matrix T (= the number of elementary */
00092 /*          reflectors whose product defines the block reflector). */
00093 
00094 /*  L       (input) INTEGER */
00095 /*          The number of columns of the matrix V containing the */
00096 /*          meaningful part of the Householder reflectors. */
00097 /*          If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0. */
00098 
00099 /*  V       (input) REAL array, dimension (LDV,NV). */
00100 /*          If STOREV = 'C', NV = K; if STOREV = 'R', NV = L. */
00101 
00102 /*  LDV     (input) INTEGER */
00103 /*          The leading dimension of the array V. */
00104 /*          If STOREV = 'C', LDV >= L; if STOREV = 'R', LDV >= K. */
00105 
00106 /*  T       (input) REAL array, dimension (LDT,K) */
00107 /*          The triangular K-by-K matrix T in the representation of the */
00108 /*          block reflector. */
00109 
00110 /*  LDT     (input) INTEGER */
00111 /*          The leading dimension of the array T. LDT >= K. */
00112 
00113 /*  C       (input/output) REAL array, dimension (LDC,N) */
00114 /*          On entry, the M-by-N matrix C. */
00115 /*          On exit, C is overwritten by H*C or H'*C or C*H or C*H'. */
00116 
00117 /*  LDC     (input) INTEGER */
00118 /*          The leading dimension of the array C. LDC >= max(1,M). */
00119 
00120 /*  WORK    (workspace) REAL array, dimension (LDWORK,K) */
00121 
00122 /*  LDWORK  (input) INTEGER */
00123 /*          The leading dimension of the array WORK. */
00124 /*          If SIDE = 'L', LDWORK >= max(1,N); */
00125 /*          if SIDE = 'R', LDWORK >= max(1,M). */
00126 
00127 /*  Further Details */
00128 /*  =============== */
00129 
00130 /*  Based on contributions by */
00131 /*    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */
00132 
00133 /*  ===================================================================== */
00134 
00135 /*     .. Parameters .. */
00136 /*     .. */
00137 /*     .. Local Scalars .. */
00138 /*     .. */
00139 /*     .. External Functions .. */
00140 /*     .. */
00141 /*     .. External Subroutines .. */
00142 /*     .. */
00143 /*     .. Executable Statements .. */
00144 
00145 /*     Quick return if possible */
00146 
00147     /* Parameter adjustments */
00148     v_dim1 = *ldv;
00149     v_offset = 1 + v_dim1;
00150     v -= v_offset;
00151     t_dim1 = *ldt;
00152     t_offset = 1 + t_dim1;
00153     t -= t_offset;
00154     c_dim1 = *ldc;
00155     c_offset = 1 + c_dim1;
00156     c__ -= c_offset;
00157     work_dim1 = *ldwork;
00158     work_offset = 1 + work_dim1;
00159     work -= work_offset;
00160 
00161     /* Function Body */
00162     if (*m <= 0 || *n <= 0) {
00163         return 0;
00164     }
00165 
00166 /*     Check for currently supported options */
00167 
00168     info = 0;
00169     if (! lsame_(direct, "B")) {
00170         info = -3;
00171     } else if (! lsame_(storev, "R")) {
00172         info = -4;
00173     }
00174     if (info != 0) {
00175         i__1 = -info;
00176         xerbla_("SLARZB", &i__1);
00177         return 0;
00178     }
00179 
00180     if (lsame_(trans, "N")) {
00181         *(unsigned char *)transt = 'T';
00182     } else {
00183         *(unsigned char *)transt = 'N';
00184     }
00185 
00186     if (lsame_(side, "L")) {
00187 
00188 /*        Form  H * C  or  H' * C */
00189 
00190 /*        W( 1:n, 1:k ) = C( 1:k, 1:n )' */
00191 
00192         i__1 = *k;
00193         for (j = 1; j <= i__1; ++j) {
00194             scopy_(n, &c__[j + c_dim1], ldc, &work[j * work_dim1 + 1], &c__1);
00195 /* L10: */
00196         }
00197 
00198 /*        W( 1:n, 1:k ) = W( 1:n, 1:k ) + ... */
00199 /*                        C( m-l+1:m, 1:n )' * V( 1:k, 1:l )' */
00200 
00201         if (*l > 0) {
00202             sgemm_("Transpose", "Transpose", n, k, l, &c_b13, &c__[*m - *l + 
00203                     1 + c_dim1], ldc, &v[v_offset], ldv, &c_b13, &work[
00204                     work_offset], ldwork);
00205         }
00206 
00207 /*        W( 1:n, 1:k ) = W( 1:n, 1:k ) * T'  or  W( 1:m, 1:k ) * T */
00208 
00209         strmm_("Right", "Lower", transt, "Non-unit", n, k, &c_b13, &t[
00210                 t_offset], ldt, &work[work_offset], ldwork);
00211 
00212 /*        C( 1:k, 1:n ) = C( 1:k, 1:n ) - W( 1:n, 1:k )' */
00213 
00214         i__1 = *n;
00215         for (j = 1; j <= i__1; ++j) {
00216             i__2 = *k;
00217             for (i__ = 1; i__ <= i__2; ++i__) {
00218                 c__[i__ + j * c_dim1] -= work[j + i__ * work_dim1];
00219 /* L20: */
00220             }
00221 /* L30: */
00222         }
00223 
00224 /*        C( m-l+1:m, 1:n ) = C( m-l+1:m, 1:n ) - ... */
00225 /*                            V( 1:k, 1:l )' * W( 1:n, 1:k )' */
00226 
00227         if (*l > 0) {
00228             sgemm_("Transpose", "Transpose", l, n, k, &c_b23, &v[v_offset], 
00229                     ldv, &work[work_offset], ldwork, &c_b13, &c__[*m - *l + 1 
00230                     + c_dim1], ldc);
00231         }
00232 
00233     } else if (lsame_(side, "R")) {
00234 
00235 /*        Form  C * H  or  C * H' */
00236 
00237 /*        W( 1:m, 1:k ) = C( 1:m, 1:k ) */
00238 
00239         i__1 = *k;
00240         for (j = 1; j <= i__1; ++j) {
00241             scopy_(m, &c__[j * c_dim1 + 1], &c__1, &work[j * work_dim1 + 1], &
00242                     c__1);
00243 /* L40: */
00244         }
00245 
00246 /*        W( 1:m, 1:k ) = W( 1:m, 1:k ) + ... */
00247 /*                        C( 1:m, n-l+1:n ) * V( 1:k, 1:l )' */
00248 
00249         if (*l > 0) {
00250             sgemm_("No transpose", "Transpose", m, k, l, &c_b13, &c__[(*n - *
00251                     l + 1) * c_dim1 + 1], ldc, &v[v_offset], ldv, &c_b13, &
00252                     work[work_offset], ldwork);
00253         }
00254 
00255 /*        W( 1:m, 1:k ) = W( 1:m, 1:k ) * T  or  W( 1:m, 1:k ) * T' */
00256 
00257         strmm_("Right", "Lower", trans, "Non-unit", m, k, &c_b13, &t[t_offset]
00258 , ldt, &work[work_offset], ldwork);
00259 
00260 /*        C( 1:m, 1:k ) = C( 1:m, 1:k ) - W( 1:m, 1:k ) */
00261 
00262         i__1 = *k;
00263         for (j = 1; j <= i__1; ++j) {
00264             i__2 = *m;
00265             for (i__ = 1; i__ <= i__2; ++i__) {
00266                 c__[i__ + j * c_dim1] -= work[i__ + j * work_dim1];
00267 /* L50: */
00268             }
00269 /* L60: */
00270         }
00271 
00272 /*        C( 1:m, n-l+1:n ) = C( 1:m, n-l+1:n ) - ... */
00273 /*                            W( 1:m, 1:k ) * V( 1:k, 1:l ) */
00274 
00275         if (*l > 0) {
00276             sgemm_("No transpose", "No transpose", m, l, k, &c_b23, &work[
00277                     work_offset], ldwork, &v[v_offset], ldv, &c_b13, &c__[(*n 
00278                     - *l + 1) * c_dim1 + 1], ldc);
00279         }
00280 
00281     }
00282 
00283     return 0;
00284 
00285 /*     End of SLARZB */
00286 
00287 } /* slarzb_ */


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