cunml2.c
Go to the documentation of this file.
00001 /* cunml2.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 /* Subroutine */ int cunml2_(char *side, char *trans, integer *m, integer *n, 
00017         integer *k, complex *a, integer *lda, complex *tau, complex *c__, 
00018         integer *ldc, complex *work, integer *info)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3;
00022     complex q__1;
00023 
00024     /* Builtin functions */
00025     void r_cnjg(complex *, complex *);
00026 
00027     /* Local variables */
00028     integer i__, i1, i2, i3, ic, jc, mi, ni, nq;
00029     complex aii;
00030     logical left;
00031     complex taui;
00032     extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex *
00033 , integer *, complex *, complex *, integer *, complex *);
00034     extern logical lsame_(char *, char *);
00035     extern /* Subroutine */ int clacgv_(integer *, complex *, integer *), 
00036             xerbla_(char *, integer *);
00037     logical notran;
00038 
00039 
00040 /*  -- LAPACK routine (version 3.2) -- */
00041 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00042 /*     November 2006 */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  CUNML2 overwrites the general complex m-by-n matrix C with */
00053 
00054 /*        Q * C  if SIDE = 'L' and TRANS = 'N', or */
00055 
00056 /*        Q'* C  if SIDE = 'L' and TRANS = 'C', or */
00057 
00058 /*        C * Q  if SIDE = 'R' and TRANS = 'N', or */
00059 
00060 /*        C * Q' if SIDE = 'R' and TRANS = 'C', */
00061 
00062 /*  where Q is a complex unitary matrix defined as the product of k */
00063 /*  elementary reflectors */
00064 
00065 /*        Q = H(k)' . . . H(2)' H(1)' */
00066 
00067 /*  as returned by CGELQF. Q is of order m if SIDE = 'L' and of order n */
00068 /*  if SIDE = 'R'. */
00069 
00070 /*  Arguments */
00071 /*  ========= */
00072 
00073 /*  SIDE    (input) CHARACTER*1 */
00074 /*          = 'L': apply Q or Q' from the Left */
00075 /*          = 'R': apply Q or Q' from the Right */
00076 
00077 /*  TRANS   (input) CHARACTER*1 */
00078 /*          = 'N': apply Q  (No transpose) */
00079 /*          = 'C': apply Q' (Conjugate transpose) */
00080 
00081 /*  M       (input) INTEGER */
00082 /*          The number of rows of the matrix C. M >= 0. */
00083 
00084 /*  N       (input) INTEGER */
00085 /*          The number of columns of the matrix C. N >= 0. */
00086 
00087 /*  K       (input) INTEGER */
00088 /*          The number of elementary reflectors whose product defines */
00089 /*          the matrix Q. */
00090 /*          If SIDE = 'L', M >= K >= 0; */
00091 /*          if SIDE = 'R', N >= K >= 0. */
00092 
00093 /*  A       (input) COMPLEX array, dimension */
00094 /*                               (LDA,M) if SIDE = 'L', */
00095 /*                               (LDA,N) if SIDE = 'R' */
00096 /*          The i-th row must contain the vector which defines the */
00097 /*          elementary reflector H(i), for i = 1,2,...,k, as returned by */
00098 /*          CGELQF in the first k rows of its array argument A. */
00099 /*          A is modified by the routine but restored on exit. */
00100 
00101 /*  LDA     (input) INTEGER */
00102 /*          The leading dimension of the array A. LDA >= max(1,K). */
00103 
00104 /*  TAU     (input) COMPLEX array, dimension (K) */
00105 /*          TAU(i) must contain the scalar factor of the elementary */
00106 /*          reflector H(i), as returned by CGELQF. */
00107 
00108 /*  C       (input/output) COMPLEX array, dimension (LDC,N) */
00109 /*          On entry, the m-by-n matrix C. */
00110 /*          On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q. */
00111 
00112 /*  LDC     (input) INTEGER */
00113 /*          The leading dimension of the array C. LDC >= max(1,M). */
00114 
00115 /*  WORK    (workspace) COMPLEX array, dimension */
00116 /*                                   (N) if SIDE = 'L', */
00117 /*                                   (M) if SIDE = 'R' */
00118 
00119 /*  INFO    (output) INTEGER */
00120 /*          = 0: successful exit */
00121 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00122 
00123 /*  ===================================================================== */
00124 
00125 /*     .. Parameters .. */
00126 /*     .. */
00127 /*     .. Local Scalars .. */
00128 /*     .. */
00129 /*     .. External Functions .. */
00130 /*     .. */
00131 /*     .. External Subroutines .. */
00132 /*     .. */
00133 /*     .. Intrinsic Functions .. */
00134 /*     .. */
00135 /*     .. Executable Statements .. */
00136 
00137 /*     Test the input arguments */
00138 
00139     /* Parameter adjustments */
00140     a_dim1 = *lda;
00141     a_offset = 1 + a_dim1;
00142     a -= a_offset;
00143     --tau;
00144     c_dim1 = *ldc;
00145     c_offset = 1 + c_dim1;
00146     c__ -= c_offset;
00147     --work;
00148 
00149     /* Function Body */
00150     *info = 0;
00151     left = lsame_(side, "L");
00152     notran = lsame_(trans, "N");
00153 
00154 /*     NQ is the order of Q */
00155 
00156     if (left) {
00157         nq = *m;
00158     } else {
00159         nq = *n;
00160     }
00161     if (! left && ! lsame_(side, "R")) {
00162         *info = -1;
00163     } else if (! notran && ! lsame_(trans, "C")) {
00164         *info = -2;
00165     } else if (*m < 0) {
00166         *info = -3;
00167     } else if (*n < 0) {
00168         *info = -4;
00169     } else if (*k < 0 || *k > nq) {
00170         *info = -5;
00171     } else if (*lda < max(1,*k)) {
00172         *info = -7;
00173     } else if (*ldc < max(1,*m)) {
00174         *info = -10;
00175     }
00176     if (*info != 0) {
00177         i__1 = -(*info);
00178         xerbla_("CUNML2", &i__1);
00179         return 0;
00180     }
00181 
00182 /*     Quick return if possible */
00183 
00184     if (*m == 0 || *n == 0 || *k == 0) {
00185         return 0;
00186     }
00187 
00188     if (left && notran || ! left && ! notran) {
00189         i1 = 1;
00190         i2 = *k;
00191         i3 = 1;
00192     } else {
00193         i1 = *k;
00194         i2 = 1;
00195         i3 = -1;
00196     }
00197 
00198     if (left) {
00199         ni = *n;
00200         jc = 1;
00201     } else {
00202         mi = *m;
00203         ic = 1;
00204     }
00205 
00206     i__1 = i2;
00207     i__2 = i3;
00208     for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00209         if (left) {
00210 
00211 /*           H(i) or H(i)' is applied to C(i:m,1:n) */
00212 
00213             mi = *m - i__ + 1;
00214             ic = i__;
00215         } else {
00216 
00217 /*           H(i) or H(i)' is applied to C(1:m,i:n) */
00218 
00219             ni = *n - i__ + 1;
00220             jc = i__;
00221         }
00222 
00223 /*        Apply H(i) or H(i)' */
00224 
00225         if (notran) {
00226             r_cnjg(&q__1, &tau[i__]);
00227             taui.r = q__1.r, taui.i = q__1.i;
00228         } else {
00229             i__3 = i__;
00230             taui.r = tau[i__3].r, taui.i = tau[i__3].i;
00231         }
00232         if (i__ < nq) {
00233             i__3 = nq - i__;
00234             clacgv_(&i__3, &a[i__ + (i__ + 1) * a_dim1], lda);
00235         }
00236         i__3 = i__ + i__ * a_dim1;
00237         aii.r = a[i__3].r, aii.i = a[i__3].i;
00238         i__3 = i__ + i__ * a_dim1;
00239         a[i__3].r = 1.f, a[i__3].i = 0.f;
00240         clarf_(side, &mi, &ni, &a[i__ + i__ * a_dim1], lda, &taui, &c__[ic + 
00241                 jc * c_dim1], ldc, &work[1]);
00242         i__3 = i__ + i__ * a_dim1;
00243         a[i__3].r = aii.r, a[i__3].i = aii.i;
00244         if (i__ < nq) {
00245             i__3 = nq - i__;
00246             clacgv_(&i__3, &a[i__ + (i__ + 1) * a_dim1], lda);
00247         }
00248 /* L10: */
00249     }
00250     return 0;
00251 
00252 /*     End of CUNML2 */
00253 
00254 } /* cunml2_ */


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