cunmtr.c
Go to the documentation of this file.
00001 /* cunmtr.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 integer c_n1 = -1;
00020 static integer c__2 = 2;
00021 
00022 /* Subroutine */ int cunmtr_(char *side, char *uplo, char *trans, integer *m, 
00023         integer *n, complex *a, integer *lda, complex *tau, complex *c__, 
00024         integer *ldc, complex *work, integer *lwork, integer *info)
00025 {
00026     /* System generated locals */
00027     address a__1[2];
00028     integer a_dim1, a_offset, c_dim1, c_offset, i__1[2], i__2, i__3;
00029     char ch__1[2];
00030 
00031     /* Builtin functions */
00032     /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
00033 
00034     /* Local variables */
00035     integer i1, i2, nb, mi, ni, nq, nw;
00036     logical left;
00037     extern logical lsame_(char *, char *);
00038     integer iinfo;
00039     logical upper;
00040     extern /* Subroutine */ int xerbla_(char *, integer *);
00041     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00042             integer *, integer *);
00043     extern /* Subroutine */ int cunmql_(char *, char *, integer *, integer *, 
00044             integer *, complex *, integer *, complex *, complex *, integer *, 
00045             complex *, integer *, integer *), cunmqr_(char *, 
00046             char *, integer *, integer *, integer *, complex *, integer *, 
00047             complex *, complex *, integer *, complex *, integer *, integer *);
00048     integer lwkopt;
00049     logical lquery;
00050 
00051 
00052 /*  -- LAPACK routine (version 3.2) -- */
00053 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00054 /*     November 2006 */
00055 
00056 /*     .. Scalar Arguments .. */
00057 /*     .. */
00058 /*     .. Array Arguments .. */
00059 /*     .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  CUNMTR overwrites the general complex M-by-N matrix C with */
00065 
00066 /*                  SIDE = 'L'     SIDE = 'R' */
00067 /*  TRANS = 'N':      Q * C          C * Q */
00068 /*  TRANS = 'C':      Q**H * C       C * Q**H */
00069 
00070 /*  where Q is a complex unitary matrix of order nq, with nq = m if */
00071 /*  SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of */
00072 /*  nq-1 elementary reflectors, as returned by CHETRD: */
00073 
00074 /*  if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1); */
00075 
00076 /*  if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1). */
00077 
00078 /*  Arguments */
00079 /*  ========= */
00080 
00081 /*  SIDE    (input) CHARACTER*1 */
00082 /*          = 'L': apply Q or Q**H from the Left; */
00083 /*          = 'R': apply Q or Q**H from the Right. */
00084 
00085 /*  UPLO    (input) CHARACTER*1 */
00086 /*          = 'U': Upper triangle of A contains elementary reflectors */
00087 /*                 from CHETRD; */
00088 /*          = 'L': Lower triangle of A contains elementary reflectors */
00089 /*                 from CHETRD. */
00090 
00091 /*  TRANS   (input) CHARACTER*1 */
00092 /*          = 'N':  No transpose, apply Q; */
00093 /*          = 'C':  Conjugate transpose, apply Q**H. */
00094 
00095 /*  M       (input) INTEGER */
00096 /*          The number of rows of the matrix C. M >= 0. */
00097 
00098 /*  N       (input) INTEGER */
00099 /*          The number of columns of the matrix C. N >= 0. */
00100 
00101 /*  A       (input) COMPLEX array, dimension */
00102 /*                               (LDA,M) if SIDE = 'L' */
00103 /*                               (LDA,N) if SIDE = 'R' */
00104 /*          The vectors which define the elementary reflectors, as */
00105 /*          returned by CHETRD. */
00106 
00107 /*  LDA     (input) INTEGER */
00108 /*          The leading dimension of the array A. */
00109 /*          LDA >= max(1,M) if SIDE = 'L'; LDA >= max(1,N) if SIDE = 'R'. */
00110 
00111 /*  TAU     (input) COMPLEX array, dimension */
00112 /*                               (M-1) if SIDE = 'L' */
00113 /*                               (N-1) if SIDE = 'R' */
00114 /*          TAU(i) must contain the scalar factor of the elementary */
00115 /*          reflector H(i), as returned by CHETRD. */
00116 
00117 /*  C       (input/output) COMPLEX array, dimension (LDC,N) */
00118 /*          On entry, the M-by-N matrix C. */
00119 /*          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q. */
00120 
00121 /*  LDC     (input) INTEGER */
00122 /*          The leading dimension of the array C. LDC >= max(1,M). */
00123 
00124 /*  WORK    (workspace/output) COMPLEX array, dimension (MAX(1,LWORK)) */
00125 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00126 
00127 /*  LWORK   (input) INTEGER */
00128 /*          The dimension of the array WORK. */
00129 /*          If SIDE = 'L', LWORK >= max(1,N); */
00130 /*          if SIDE = 'R', LWORK >= max(1,M). */
00131 /*          For optimum performance LWORK >= N*NB if SIDE = 'L', and */
00132 /*          LWORK >=M*NB if SIDE = 'R', where NB is the optimal */
00133 /*          blocksize. */
00134 
00135 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00136 /*          only calculates the optimal size of the WORK array, returns */
00137 /*          this value as the first entry of the WORK array, and no error */
00138 /*          message related to LWORK is issued by XERBLA. */
00139 
00140 /*  INFO    (output) INTEGER */
00141 /*          = 0:  successful exit */
00142 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00143 
00144 /*  ===================================================================== */
00145 
00146 /*     .. Local Scalars .. */
00147 /*     .. */
00148 /*     .. External Functions .. */
00149 /*     .. */
00150 /*     .. External Subroutines .. */
00151 /*     .. */
00152 /*     .. Intrinsic Functions .. */
00153 /*     .. */
00154 /*     .. Executable Statements .. */
00155 
00156 /*     Test the input arguments */
00157 
00158     /* Parameter adjustments */
00159     a_dim1 = *lda;
00160     a_offset = 1 + a_dim1;
00161     a -= a_offset;
00162     --tau;
00163     c_dim1 = *ldc;
00164     c_offset = 1 + c_dim1;
00165     c__ -= c_offset;
00166     --work;
00167 
00168     /* Function Body */
00169     *info = 0;
00170     left = lsame_(side, "L");
00171     upper = lsame_(uplo, "U");
00172     lquery = *lwork == -1;
00173 
00174 /*     NQ is the order of Q and NW is the minimum dimension of WORK */
00175 
00176     if (left) {
00177         nq = *m;
00178         nw = *n;
00179     } else {
00180         nq = *n;
00181         nw = *m;
00182     }
00183     if (! left && ! lsame_(side, "R")) {
00184         *info = -1;
00185     } else if (! upper && ! lsame_(uplo, "L")) {
00186         *info = -2;
00187     } else if (! lsame_(trans, "N") && ! lsame_(trans, 
00188             "C")) {
00189         *info = -3;
00190     } else if (*m < 0) {
00191         *info = -4;
00192     } else if (*n < 0) {
00193         *info = -5;
00194     } else if (*lda < max(1,nq)) {
00195         *info = -7;
00196     } else if (*ldc < max(1,*m)) {
00197         *info = -10;
00198     } else if (*lwork < max(1,nw) && ! lquery) {
00199         *info = -12;
00200     }
00201 
00202     if (*info == 0) {
00203         if (upper) {
00204             if (left) {
00205 /* Writing concatenation */
00206                 i__1[0] = 1, a__1[0] = side;
00207                 i__1[1] = 1, a__1[1] = trans;
00208                 s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
00209                 i__2 = *m - 1;
00210                 i__3 = *m - 1;
00211                 nb = ilaenv_(&c__1, "CUNMQL", ch__1, &i__2, n, &i__3, &c_n1);
00212             } else {
00213 /* Writing concatenation */
00214                 i__1[0] = 1, a__1[0] = side;
00215                 i__1[1] = 1, a__1[1] = trans;
00216                 s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
00217                 i__2 = *n - 1;
00218                 i__3 = *n - 1;
00219                 nb = ilaenv_(&c__1, "CUNMQL", ch__1, m, &i__2, &i__3, &c_n1);
00220             }
00221         } else {
00222             if (left) {
00223 /* Writing concatenation */
00224                 i__1[0] = 1, a__1[0] = side;
00225                 i__1[1] = 1, a__1[1] = trans;
00226                 s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
00227                 i__2 = *m - 1;
00228                 i__3 = *m - 1;
00229                 nb = ilaenv_(&c__1, "CUNMQR", ch__1, &i__2, n, &i__3, &c_n1);
00230             } else {
00231 /* Writing concatenation */
00232                 i__1[0] = 1, a__1[0] = side;
00233                 i__1[1] = 1, a__1[1] = trans;
00234                 s_cat(ch__1, a__1, i__1, &c__2, (ftnlen)2);
00235                 i__2 = *n - 1;
00236                 i__3 = *n - 1;
00237                 nb = ilaenv_(&c__1, "CUNMQR", ch__1, m, &i__2, &i__3, &c_n1);
00238             }
00239         }
00240         lwkopt = max(1,nw) * nb;
00241         work[1].r = (real) lwkopt, work[1].i = 0.f;
00242     }
00243 
00244     if (*info != 0) {
00245         i__2 = -(*info);
00246         xerbla_("CUNMTR", &i__2);
00247         return 0;
00248     } else if (lquery) {
00249         return 0;
00250     }
00251 
00252 /*     Quick return if possible */
00253 
00254     if (*m == 0 || *n == 0 || nq == 1) {
00255         work[1].r = 1.f, work[1].i = 0.f;
00256         return 0;
00257     }
00258 
00259     if (left) {
00260         mi = *m - 1;
00261         ni = *n;
00262     } else {
00263         mi = *m;
00264         ni = *n - 1;
00265     }
00266 
00267     if (upper) {
00268 
00269 /*        Q was determined by a call to CHETRD with UPLO = 'U' */
00270 
00271         i__2 = nq - 1;
00272         cunmql_(side, trans, &mi, &ni, &i__2, &a[(a_dim1 << 1) + 1], lda, &
00273                 tau[1], &c__[c_offset], ldc, &work[1], lwork, &iinfo);
00274     } else {
00275 
00276 /*        Q was determined by a call to CHETRD with UPLO = 'L' */
00277 
00278         if (left) {
00279             i1 = 2;
00280             i2 = 1;
00281         } else {
00282             i1 = 1;
00283             i2 = 2;
00284         }
00285         i__2 = nq - 1;
00286         cunmqr_(side, trans, &mi, &ni, &i__2, &a[a_dim1 + 2], lda, &tau[1], &
00287                 c__[i1 + i2 * c_dim1], ldc, &work[1], lwork, &iinfo);
00288     }
00289     work[1].r = (real) lwkopt, work[1].i = 0.f;
00290     return 0;
00291 
00292 /*     End of CUNMTR */
00293 
00294 } /* cunmtr_ */


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