zunghr.c
Go to the documentation of this file.
00001 /* zunghr.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 zunghr_(integer *n, integer *ilo, integer *ihi, 
00022         doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *
00023         work, integer *lwork, 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, nh, iinfo;
00030     extern /* Subroutine */ int xerbla_(char *, integer *);
00031     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00032             integer *, integer *);
00033     integer lwkopt;
00034     logical lquery;
00035     extern /* Subroutine */ int zungqr_(integer *, integer *, integer *, 
00036             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00037             integer *, integer *);
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 /*  ZUNGHR generates a complex unitary matrix Q which is defined as the */
00053 /*  product of IHI-ILO elementary reflectors of order N, as returned by */
00054 /*  ZGEHRD: */
00055 
00056 /*  Q = H(ilo) H(ilo+1) . . . H(ihi-1). */
00057 
00058 /*  Arguments */
00059 /*  ========= */
00060 
00061 /*  N       (input) INTEGER */
00062 /*          The order of the matrix Q. N >= 0. */
00063 
00064 /*  ILO     (input) INTEGER */
00065 /*  IHI     (input) INTEGER */
00066 /*          ILO and IHI must have the same values as in the previous call */
00067 /*          of ZGEHRD. Q is equal to the unit matrix except in the */
00068 /*          submatrix Q(ilo+1:ihi,ilo+1:ihi). */
00069 /*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
00070 
00071 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00072 /*          On entry, the vectors which define the elementary reflectors, */
00073 /*          as returned by ZGEHRD. */
00074 /*          On exit, the N-by-N unitary matrix Q. */
00075 
00076 /*  LDA     (input) INTEGER */
00077 /*          The leading dimension of the array A. LDA >= max(1,N). */
00078 
00079 /*  TAU     (input) COMPLEX*16 array, dimension (N-1) */
00080 /*          TAU(i) must contain the scalar factor of the elementary */
00081 /*          reflector H(i), as returned by ZGEHRD. */
00082 
00083 /*  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */
00084 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00085 
00086 /*  LWORK   (input) INTEGER */
00087 /*          The dimension of the array WORK. LWORK >= IHI-ILO. */
00088 /*          For optimum performance LWORK >= (IHI-ILO)*NB, where NB is */
00089 /*          the optimal blocksize. */
00090 
00091 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00092 /*          only calculates the optimal size of the WORK array, returns */
00093 /*          this value as the first entry of the WORK array, and no error */
00094 /*          message related to LWORK is issued by XERBLA. */
00095 
00096 /*  INFO    (output) INTEGER */
00097 /*          = 0:  successful exit */
00098 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00099 
00100 /*  ===================================================================== */
00101 
00102 /*     .. Parameters .. */
00103 /*     .. */
00104 /*     .. Local Scalars .. */
00105 /*     .. */
00106 /*     .. External Subroutines .. */
00107 /*     .. */
00108 /*     .. External Functions .. */
00109 /*     .. */
00110 /*     .. Intrinsic Functions .. */
00111 /*     .. */
00112 /*     .. Executable Statements .. */
00113 
00114 /*     Test the input arguments */
00115 
00116     /* Parameter adjustments */
00117     a_dim1 = *lda;
00118     a_offset = 1 + a_dim1;
00119     a -= a_offset;
00120     --tau;
00121     --work;
00122 
00123     /* Function Body */
00124     *info = 0;
00125     nh = *ihi - *ilo;
00126     lquery = *lwork == -1;
00127     if (*n < 0) {
00128         *info = -1;
00129     } else if (*ilo < 1 || *ilo > max(1,*n)) {
00130         *info = -2;
00131     } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
00132         *info = -3;
00133     } else if (*lda < max(1,*n)) {
00134         *info = -5;
00135     } else if (*lwork < max(1,nh) && ! lquery) {
00136         *info = -8;
00137     }
00138 
00139     if (*info == 0) {
00140         nb = ilaenv_(&c__1, "ZUNGQR", " ", &nh, &nh, &nh, &c_n1);
00141         lwkopt = max(1,nh) * nb;
00142         work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00143     }
00144 
00145     if (*info != 0) {
00146         i__1 = -(*info);
00147         xerbla_("ZUNGHR", &i__1);
00148         return 0;
00149     } else if (lquery) {
00150         return 0;
00151     }
00152 
00153 /*     Quick return if possible */
00154 
00155     if (*n == 0) {
00156         work[1].r = 1., work[1].i = 0.;
00157         return 0;
00158     }
00159 
00160 /*     Shift the vectors which define the elementary reflectors one */
00161 /*     column to the right, and set the first ilo and the last n-ihi */
00162 /*     rows and columns to those of the unit matrix */
00163 
00164     i__1 = *ilo + 1;
00165     for (j = *ihi; j >= i__1; --j) {
00166         i__2 = j - 1;
00167         for (i__ = 1; i__ <= i__2; ++i__) {
00168             i__3 = i__ + j * a_dim1;
00169             a[i__3].r = 0., a[i__3].i = 0.;
00170 /* L10: */
00171         }
00172         i__2 = *ihi;
00173         for (i__ = j + 1; i__ <= i__2; ++i__) {
00174             i__3 = i__ + j * a_dim1;
00175             i__4 = i__ + (j - 1) * a_dim1;
00176             a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
00177 /* L20: */
00178         }
00179         i__2 = *n;
00180         for (i__ = *ihi + 1; i__ <= i__2; ++i__) {
00181             i__3 = i__ + j * a_dim1;
00182             a[i__3].r = 0., a[i__3].i = 0.;
00183 /* L30: */
00184         }
00185 /* L40: */
00186     }
00187     i__1 = *ilo;
00188     for (j = 1; j <= i__1; ++j) {
00189         i__2 = *n;
00190         for (i__ = 1; i__ <= i__2; ++i__) {
00191             i__3 = i__ + j * a_dim1;
00192             a[i__3].r = 0., a[i__3].i = 0.;
00193 /* L50: */
00194         }
00195         i__2 = j + j * a_dim1;
00196         a[i__2].r = 1., a[i__2].i = 0.;
00197 /* L60: */
00198     }
00199     i__1 = *n;
00200     for (j = *ihi + 1; j <= i__1; ++j) {
00201         i__2 = *n;
00202         for (i__ = 1; i__ <= i__2; ++i__) {
00203             i__3 = i__ + j * a_dim1;
00204             a[i__3].r = 0., a[i__3].i = 0.;
00205 /* L70: */
00206         }
00207         i__2 = j + j * a_dim1;
00208         a[i__2].r = 1., a[i__2].i = 0.;
00209 /* L80: */
00210     }
00211 
00212     if (nh > 0) {
00213 
00214 /*        Generate Q(ilo+1:ihi,ilo+1:ihi) */
00215 
00216         zungqr_(&nh, &nh, &nh, &a[*ilo + 1 + (*ilo + 1) * a_dim1], lda, &tau[*
00217                 ilo], &work[1], lwork, &iinfo);
00218     }
00219     work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00220     return 0;
00221 
00222 /*     End of ZUNGHR */
00223 
00224 } /* zunghr_ */


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