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


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