cupmtr.c
Go to the documentation of this file.
00001 /* cupmtr.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 
00020 /* Subroutine */ int cupmtr_(char *side, char *uplo, char *trans, integer *m, 
00021         integer *n, complex *ap, complex *tau, complex *c__, integer *ldc, 
00022         complex *work, integer *info)
00023 {
00024     /* System generated locals */
00025     integer c_dim1, c_offset, i__1, i__2, i__3;
00026     complex q__1;
00027 
00028     /* Builtin functions */
00029     void r_cnjg(complex *, complex *);
00030 
00031     /* Local variables */
00032     integer i__, i1, i2, i3, ic, jc, ii, mi, ni, nq;
00033     complex aii;
00034     logical left;
00035     complex taui;
00036     extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex *
00037 , integer *, complex *, complex *, integer *, complex *);
00038     extern logical lsame_(char *, char *);
00039     logical upper;
00040     extern /* Subroutine */ int xerbla_(char *, integer *);
00041     logical notran, forwrd;
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 /*  CUPMTR overwrites the general complex M-by-N matrix C with */
00057 
00058 /*                  SIDE = 'L'     SIDE = 'R' */
00059 /*  TRANS = 'N':      Q * C          C * Q */
00060 /*  TRANS = 'C':      Q**H * C       C * Q**H */
00061 
00062 /*  where Q is a complex unitary matrix of order nq, with nq = m if */
00063 /*  SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of */
00064 /*  nq-1 elementary reflectors, as returned by CHPTRD using packed */
00065 /*  storage: */
00066 
00067 /*  if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1); */
00068 
00069 /*  if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1). */
00070 
00071 /*  Arguments */
00072 /*  ========= */
00073 
00074 /*  SIDE    (input) CHARACTER*1 */
00075 /*          = 'L': apply Q or Q**H from the Left; */
00076 /*          = 'R': apply Q or Q**H from the Right. */
00077 
00078 /*  UPLO    (input) CHARACTER*1 */
00079 /*          = 'U': Upper triangular packed storage used in previous */
00080 /*                 call to CHPTRD; */
00081 /*          = 'L': Lower triangular packed storage used in previous */
00082 /*                 call to CHPTRD. */
00083 
00084 /*  TRANS   (input) CHARACTER*1 */
00085 /*          = 'N':  No transpose, apply Q; */
00086 /*          = 'C':  Conjugate transpose, apply Q**H. */
00087 
00088 /*  M       (input) INTEGER */
00089 /*          The number of rows of the matrix C. M >= 0. */
00090 
00091 /*  N       (input) INTEGER */
00092 /*          The number of columns of the matrix C. N >= 0. */
00093 
00094 /*  AP      (input) COMPLEX array, dimension */
00095 /*                               (M*(M+1)/2) if SIDE = 'L' */
00096 /*                               (N*(N+1)/2) if SIDE = 'R' */
00097 /*          The vectors which define the elementary reflectors, as */
00098 /*          returned by CHPTRD.  AP is modified by the routine but */
00099 /*          restored on exit. */
00100 
00101 /*  TAU     (input) COMPLEX array, dimension (M-1) if SIDE = 'L' */
00102 /*                                     or (N-1) if SIDE = 'R' */
00103 /*          TAU(i) must contain the scalar factor of the elementary */
00104 /*          reflector H(i), as returned by CHPTRD. */
00105 
00106 /*  C       (input/output) COMPLEX array, dimension (LDC,N) */
00107 /*          On entry, the M-by-N matrix C. */
00108 /*          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q. */
00109 
00110 /*  LDC     (input) INTEGER */
00111 /*          The leading dimension of the array C. LDC >= max(1,M). */
00112 
00113 /*  WORK    (workspace) COMPLEX array, dimension */
00114 /*                                   (N) if SIDE = 'L' */
00115 /*                                   (M) if SIDE = 'R' */
00116 
00117 /*  INFO    (output) INTEGER */
00118 /*          = 0:  successful exit */
00119 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00120 
00121 /*  ===================================================================== */
00122 
00123 /*     .. Parameters .. */
00124 /*     .. */
00125 /*     .. Local Scalars .. */
00126 /*     .. */
00127 /*     .. External Functions .. */
00128 /*     .. */
00129 /*     .. External Subroutines .. */
00130 /*     .. */
00131 /*     .. Intrinsic Functions .. */
00132 /*     .. */
00133 /*     .. Executable Statements .. */
00134 
00135 /*     Test the input arguments */
00136 
00137     /* Parameter adjustments */
00138     --ap;
00139     --tau;
00140     c_dim1 = *ldc;
00141     c_offset = 1 + c_dim1;
00142     c__ -= c_offset;
00143     --work;
00144 
00145     /* Function Body */
00146     *info = 0;
00147     left = lsame_(side, "L");
00148     notran = lsame_(trans, "N");
00149     upper = lsame_(uplo, "U");
00150 
00151 /*     NQ is the order of Q */
00152 
00153     if (left) {
00154         nq = *m;
00155     } else {
00156         nq = *n;
00157     }
00158     if (! left && ! lsame_(side, "R")) {
00159         *info = -1;
00160     } else if (! upper && ! lsame_(uplo, "L")) {
00161         *info = -2;
00162     } else if (! notran && ! lsame_(trans, "C")) {
00163         *info = -3;
00164     } else if (*m < 0) {
00165         *info = -4;
00166     } else if (*n < 0) {
00167         *info = -5;
00168     } else if (*ldc < max(1,*m)) {
00169         *info = -9;
00170     }
00171     if (*info != 0) {
00172         i__1 = -(*info);
00173         xerbla_("CUPMTR", &i__1);
00174         return 0;
00175     }
00176 
00177 /*     Quick return if possible */
00178 
00179     if (*m == 0 || *n == 0) {
00180         return 0;
00181     }
00182 
00183     if (upper) {
00184 
00185 /*        Q was determined by a call to CHPTRD with UPLO = 'U' */
00186 
00187         forwrd = left && notran || ! left && ! notran;
00188 
00189         if (forwrd) {
00190             i1 = 1;
00191             i2 = nq - 1;
00192             i3 = 1;
00193             ii = 2;
00194         } else {
00195             i1 = nq - 1;
00196             i2 = 1;
00197             i3 = -1;
00198             ii = nq * (nq + 1) / 2 - 1;
00199         }
00200 
00201         if (left) {
00202             ni = *n;
00203         } else {
00204             mi = *m;
00205         }
00206 
00207         i__1 = i2;
00208         i__2 = i3;
00209         for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00210             if (left) {
00211 
00212 /*              H(i) or H(i)' is applied to C(1:i,1:n) */
00213 
00214                 mi = i__;
00215             } else {
00216 
00217 /*              H(i) or H(i)' is applied to C(1:m,1:i) */
00218 
00219                 ni = i__;
00220             }
00221 
00222 /*           Apply H(i) or H(i)' */
00223 
00224             if (notran) {
00225                 i__3 = i__;
00226                 taui.r = tau[i__3].r, taui.i = tau[i__3].i;
00227             } else {
00228                 r_cnjg(&q__1, &tau[i__]);
00229                 taui.r = q__1.r, taui.i = q__1.i;
00230             }
00231             i__3 = ii;
00232             aii.r = ap[i__3].r, aii.i = ap[i__3].i;
00233             i__3 = ii;
00234             ap[i__3].r = 1.f, ap[i__3].i = 0.f;
00235             clarf_(side, &mi, &ni, &ap[ii - i__ + 1], &c__1, &taui, &c__[
00236                     c_offset], ldc, &work[1]);
00237             i__3 = ii;
00238             ap[i__3].r = aii.r, ap[i__3].i = aii.i;
00239 
00240             if (forwrd) {
00241                 ii = ii + i__ + 2;
00242             } else {
00243                 ii = ii - i__ - 1;
00244             }
00245 /* L10: */
00246         }
00247     } else {
00248 
00249 /*        Q was determined by a call to CHPTRD with UPLO = 'L'. */
00250 
00251         forwrd = left && ! notran || ! left && notran;
00252 
00253         if (forwrd) {
00254             i1 = 1;
00255             i2 = nq - 1;
00256             i3 = 1;
00257             ii = 2;
00258         } else {
00259             i1 = nq - 1;
00260             i2 = 1;
00261             i3 = -1;
00262             ii = nq * (nq + 1) / 2 - 1;
00263         }
00264 
00265         if (left) {
00266             ni = *n;
00267             jc = 1;
00268         } else {
00269             mi = *m;
00270             ic = 1;
00271         }
00272 
00273         i__2 = i2;
00274         i__1 = i3;
00275         for (i__ = i1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) {
00276             i__3 = ii;
00277             aii.r = ap[i__3].r, aii.i = ap[i__3].i;
00278             i__3 = ii;
00279             ap[i__3].r = 1.f, ap[i__3].i = 0.f;
00280             if (left) {
00281 
00282 /*              H(i) or H(i)' is applied to C(i+1:m,1:n) */
00283 
00284                 mi = *m - i__;
00285                 ic = i__ + 1;
00286             } else {
00287 
00288 /*              H(i) or H(i)' is applied to C(1:m,i+1:n) */
00289 
00290                 ni = *n - i__;
00291                 jc = i__ + 1;
00292             }
00293 
00294 /*           Apply H(i) or H(i)' */
00295 
00296             if (notran) {
00297                 i__3 = i__;
00298                 taui.r = tau[i__3].r, taui.i = tau[i__3].i;
00299             } else {
00300                 r_cnjg(&q__1, &tau[i__]);
00301                 taui.r = q__1.r, taui.i = q__1.i;
00302             }
00303             clarf_(side, &mi, &ni, &ap[ii], &c__1, &taui, &c__[ic + jc * 
00304                     c_dim1], ldc, &work[1]);
00305             i__3 = ii;
00306             ap[i__3].r = aii.r, ap[i__3].i = aii.i;
00307 
00308             if (forwrd) {
00309                 ii = ii + nq - i__ + 1;
00310             } else {
00311                 ii = ii - nq + i__ - 2;
00312             }
00313 /* L20: */
00314         }
00315     }
00316     return 0;
00317 
00318 /*     End of CUPMTR */
00319 
00320 } /* cupmtr_ */


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