zungtr.c
Go to the documentation of this file.
00001 /* zungtr.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 
00021 /* Subroutine */ int zungtr_(char *uplo, integer *n, doublecomplex *a, 
00022         integer *lda, doublecomplex *tau, doublecomplex *work, integer *lwork, 
00023          integer *info)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00027 
00028     /* Local variables */
00029     integer i__, j, nb;
00030     extern logical lsame_(char *, char *);
00031     integer iinfo;
00032     logical upper;
00033     extern /* Subroutine */ int xerbla_(char *, integer *);
00034     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00035             integer *, integer *);
00036     integer lwkopt;
00037     logical lquery;
00038     extern /* Subroutine */ int zungql_(integer *, integer *, integer *, 
00039             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00040             integer *, integer *), zungqr_(integer *, integer *, integer *, 
00041             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00042             integer *, integer *);
00043 
00044 
00045 /*  -- LAPACK routine (version 3.2) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  ZUNGTR generates a complex unitary matrix Q which is defined as the */
00058 /*  product of n-1 elementary reflectors of order N, as returned by */
00059 /*  ZHETRD: */
00060 
00061 /*  if UPLO = 'U', Q = H(n-1) . . . H(2) H(1), */
00062 
00063 /*  if UPLO = 'L', Q = H(1) H(2) . . . H(n-1). */
00064 
00065 /*  Arguments */
00066 /*  ========= */
00067 
00068 /*  UPLO    (input) CHARACTER*1 */
00069 /*          = 'U': Upper triangle of A contains elementary reflectors */
00070 /*                 from ZHETRD; */
00071 /*          = 'L': Lower triangle of A contains elementary reflectors */
00072 /*                 from ZHETRD. */
00073 
00074 /*  N       (input) INTEGER */
00075 /*          The order of the matrix Q. N >= 0. */
00076 
00077 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00078 /*          On entry, the vectors which define the elementary reflectors, */
00079 /*          as returned by ZHETRD. */
00080 /*          On exit, the N-by-N unitary matrix Q. */
00081 
00082 /*  LDA     (input) INTEGER */
00083 /*          The leading dimension of the array A. LDA >= N. */
00084 
00085 /*  TAU     (input) COMPLEX*16 array, dimension (N-1) */
00086 /*          TAU(i) must contain the scalar factor of the elementary */
00087 /*          reflector H(i), as returned by ZHETRD. */
00088 
00089 /*  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */
00090 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00091 
00092 /*  LWORK   (input) INTEGER */
00093 /*          The dimension of the array WORK. LWORK >= N-1. */
00094 /*          For optimum performance LWORK >= (N-1)*NB, where NB is */
00095 /*          the optimal blocksize. */
00096 
00097 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00098 /*          only calculates the optimal size of the WORK array, returns */
00099 /*          this value as the first entry of the WORK array, and no error */
00100 /*          message related to LWORK is issued by XERBLA. */
00101 
00102 /*  INFO    (output) INTEGER */
00103 /*          = 0:  successful exit */
00104 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00105 
00106 /*  ===================================================================== */
00107 
00108 /*     .. Parameters .. */
00109 /*     .. */
00110 /*     .. Local Scalars .. */
00111 /*     .. */
00112 /*     .. External Functions .. */
00113 /*     .. */
00114 /*     .. External Subroutines .. */
00115 /*     .. */
00116 /*     .. Intrinsic Functions .. */
00117 /*     .. */
00118 /*     .. Executable Statements .. */
00119 
00120 /*     Test the input arguments */
00121 
00122     /* Parameter adjustments */
00123     a_dim1 = *lda;
00124     a_offset = 1 + a_dim1;
00125     a -= a_offset;
00126     --tau;
00127     --work;
00128 
00129     /* Function Body */
00130     *info = 0;
00131     lquery = *lwork == -1;
00132     upper = lsame_(uplo, "U");
00133     if (! upper && ! lsame_(uplo, "L")) {
00134         *info = -1;
00135     } else if (*n < 0) {
00136         *info = -2;
00137     } else if (*lda < max(1,*n)) {
00138         *info = -4;
00139     } else /* if(complicated condition) */ {
00140 /* Computing MAX */
00141         i__1 = 1, i__2 = *n - 1;
00142         if (*lwork < max(i__1,i__2) && ! lquery) {
00143             *info = -7;
00144         }
00145     }
00146 
00147     if (*info == 0) {
00148         if (upper) {
00149             i__1 = *n - 1;
00150             i__2 = *n - 1;
00151             i__3 = *n - 1;
00152             nb = ilaenv_(&c__1, "ZUNGQL", " ", &i__1, &i__2, &i__3, &c_n1);
00153         } else {
00154             i__1 = *n - 1;
00155             i__2 = *n - 1;
00156             i__3 = *n - 1;
00157             nb = ilaenv_(&c__1, "ZUNGQR", " ", &i__1, &i__2, &i__3, &c_n1);
00158         }
00159 /* Computing MAX */
00160         i__1 = 1, i__2 = *n - 1;
00161         lwkopt = max(i__1,i__2) * nb;
00162         work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00163     }
00164 
00165     if (*info != 0) {
00166         i__1 = -(*info);
00167         xerbla_("ZUNGTR", &i__1);
00168         return 0;
00169     } else if (lquery) {
00170         return 0;
00171     }
00172 
00173 /*     Quick return if possible */
00174 
00175     if (*n == 0) {
00176         work[1].r = 1., work[1].i = 0.;
00177         return 0;
00178     }
00179 
00180     if (upper) {
00181 
00182 /*        Q was determined by a call to ZHETRD with UPLO = 'U' */
00183 
00184 /*        Shift the vectors which define the elementary reflectors one */
00185 /*        column to the left, and set the last row and column of Q to */
00186 /*        those of the unit matrix */
00187 
00188         i__1 = *n - 1;
00189         for (j = 1; j <= i__1; ++j) {
00190             i__2 = j - 1;
00191             for (i__ = 1; i__ <= i__2; ++i__) {
00192                 i__3 = i__ + j * a_dim1;
00193                 i__4 = i__ + (j + 1) * a_dim1;
00194                 a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
00195 /* L10: */
00196             }
00197             i__2 = *n + j * a_dim1;
00198             a[i__2].r = 0., a[i__2].i = 0.;
00199 /* L20: */
00200         }
00201         i__1 = *n - 1;
00202         for (i__ = 1; i__ <= i__1; ++i__) {
00203             i__2 = i__ + *n * a_dim1;
00204             a[i__2].r = 0., a[i__2].i = 0.;
00205 /* L30: */
00206         }
00207         i__1 = *n + *n * a_dim1;
00208         a[i__1].r = 1., a[i__1].i = 0.;
00209 
00210 /*        Generate Q(1:n-1,1:n-1) */
00211 
00212         i__1 = *n - 1;
00213         i__2 = *n - 1;
00214         i__3 = *n - 1;
00215         zungql_(&i__1, &i__2, &i__3, &a[a_offset], lda, &tau[1], &work[1], 
00216                 lwork, &iinfo);
00217 
00218     } else {
00219 
00220 /*        Q was determined by a call to ZHETRD with UPLO = 'L'. */
00221 
00222 /*        Shift the vectors which define the elementary reflectors one */
00223 /*        column to the right, and set the first row and column of Q to */
00224 /*        those of the unit matrix */
00225 
00226         for (j = *n; j >= 2; --j) {
00227             i__1 = j * a_dim1 + 1;
00228             a[i__1].r = 0., a[i__1].i = 0.;
00229             i__1 = *n;
00230             for (i__ = j + 1; i__ <= i__1; ++i__) {
00231                 i__2 = i__ + j * a_dim1;
00232                 i__3 = i__ + (j - 1) * a_dim1;
00233                 a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
00234 /* L40: */
00235             }
00236 /* L50: */
00237         }
00238         i__1 = a_dim1 + 1;
00239         a[i__1].r = 1., a[i__1].i = 0.;
00240         i__1 = *n;
00241         for (i__ = 2; i__ <= i__1; ++i__) {
00242             i__2 = i__ + a_dim1;
00243             a[i__2].r = 0., a[i__2].i = 0.;
00244 /* L60: */
00245         }
00246         if (*n > 1) {
00247 
00248 /*           Generate Q(2:n,2:n) */
00249 
00250             i__1 = *n - 1;
00251             i__2 = *n - 1;
00252             i__3 = *n - 1;
00253             zungqr_(&i__1, &i__2, &i__3, &a[(a_dim1 << 1) + 2], lda, &tau[1], 
00254                     &work[1], lwork, &iinfo);
00255         }
00256     }
00257     work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00258     return 0;
00259 
00260 /*     End of ZUNGTR */
00261 
00262 } /* zungtr_ */


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