zupgtr.c
Go to the documentation of this file.
00001 /* zupgtr.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 zupgtr_(char *uplo, integer *n, doublecomplex *ap, 
00017         doublecomplex *tau, doublecomplex *q, integer *ldq, doublecomplex *
00018         work, integer *info)
00019 {
00020     /* System generated locals */
00021     integer q_dim1, q_offset, i__1, i__2, i__3, i__4;
00022 
00023     /* Local variables */
00024     integer i__, j, ij;
00025     extern logical lsame_(char *, char *);
00026     integer iinfo;
00027     logical upper;
00028     extern /* Subroutine */ int zung2l_(integer *, integer *, integer *, 
00029             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00030             integer *), zung2r_(integer *, integer *, integer *, 
00031             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00032             integer *), xerbla_(char *, integer *);
00033 
00034 
00035 /*  -- LAPACK routine (version 3.2) -- */
00036 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00037 /*     November 2006 */
00038 
00039 /*     .. Scalar Arguments .. */
00040 /*     .. */
00041 /*     .. Array Arguments .. */
00042 /*     .. */
00043 
00044 /*  Purpose */
00045 /*  ======= */
00046 
00047 /*  ZUPGTR generates a complex unitary matrix Q which is defined as the */
00048 /*  product of n-1 elementary reflectors H(i) of order n, as returned by */
00049 /*  ZHPTRD using packed storage: */
00050 
00051 /*  if UPLO = 'U', Q = H(n-1) . . . H(2) H(1), */
00052 
00053 /*  if UPLO = 'L', Q = H(1) H(2) . . . H(n-1). */
00054 
00055 /*  Arguments */
00056 /*  ========= */
00057 
00058 /*  UPLO    (input) CHARACTER*1 */
00059 /*          = 'U': Upper triangular packed storage used in previous */
00060 /*                 call to ZHPTRD; */
00061 /*          = 'L': Lower triangular packed storage used in previous */
00062 /*                 call to ZHPTRD. */
00063 
00064 /*  N       (input) INTEGER */
00065 /*          The order of the matrix Q. N >= 0. */
00066 
00067 /*  AP      (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00068 /*          The vectors which define the elementary reflectors, as */
00069 /*          returned by ZHPTRD. */
00070 
00071 /*  TAU     (input) COMPLEX*16 array, dimension (N-1) */
00072 /*          TAU(i) must contain the scalar factor of the elementary */
00073 /*          reflector H(i), as returned by ZHPTRD. */
00074 
00075 /*  Q       (output) COMPLEX*16 array, dimension (LDQ,N) */
00076 /*          The N-by-N unitary matrix Q. */
00077 
00078 /*  LDQ     (input) INTEGER */
00079 /*          The leading dimension of the array Q. LDQ >= max(1,N). */
00080 
00081 /*  WORK    (workspace) COMPLEX*16 array, dimension (N-1) */
00082 
00083 /*  INFO    (output) INTEGER */
00084 /*          = 0:  successful exit */
00085 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00086 
00087 /*  ===================================================================== */
00088 
00089 /*     .. Parameters .. */
00090 /*     .. */
00091 /*     .. Local Scalars .. */
00092 /*     .. */
00093 /*     .. External Functions .. */
00094 /*     .. */
00095 /*     .. External Subroutines .. */
00096 /*     .. */
00097 /*     .. Intrinsic Functions .. */
00098 /*     .. */
00099 /*     .. Executable Statements .. */
00100 
00101 /*     Test the input arguments */
00102 
00103     /* Parameter adjustments */
00104     --ap;
00105     --tau;
00106     q_dim1 = *ldq;
00107     q_offset = 1 + q_dim1;
00108     q -= q_offset;
00109     --work;
00110 
00111     /* Function Body */
00112     *info = 0;
00113     upper = lsame_(uplo, "U");
00114     if (! upper && ! lsame_(uplo, "L")) {
00115         *info = -1;
00116     } else if (*n < 0) {
00117         *info = -2;
00118     } else if (*ldq < max(1,*n)) {
00119         *info = -6;
00120     }
00121     if (*info != 0) {
00122         i__1 = -(*info);
00123         xerbla_("ZUPGTR", &i__1);
00124         return 0;
00125     }
00126 
00127 /*     Quick return if possible */
00128 
00129     if (*n == 0) {
00130         return 0;
00131     }
00132 
00133     if (upper) {
00134 
00135 /*        Q was determined by a call to ZHPTRD with UPLO = 'U' */
00136 
00137 /*        Unpack the vectors which define the elementary reflectors and */
00138 /*        set the last row and column of Q equal to those of the unit */
00139 /*        matrix */
00140 
00141         ij = 2;
00142         i__1 = *n - 1;
00143         for (j = 1; j <= i__1; ++j) {
00144             i__2 = j - 1;
00145             for (i__ = 1; i__ <= i__2; ++i__) {
00146                 i__3 = i__ + j * q_dim1;
00147                 i__4 = ij;
00148                 q[i__3].r = ap[i__4].r, q[i__3].i = ap[i__4].i;
00149                 ++ij;
00150 /* L10: */
00151             }
00152             ij += 2;
00153             i__2 = *n + j * q_dim1;
00154             q[i__2].r = 0., q[i__2].i = 0.;
00155 /* L20: */
00156         }
00157         i__1 = *n - 1;
00158         for (i__ = 1; i__ <= i__1; ++i__) {
00159             i__2 = i__ + *n * q_dim1;
00160             q[i__2].r = 0., q[i__2].i = 0.;
00161 /* L30: */
00162         }
00163         i__1 = *n + *n * q_dim1;
00164         q[i__1].r = 1., q[i__1].i = 0.;
00165 
00166 /*        Generate Q(1:n-1,1:n-1) */
00167 
00168         i__1 = *n - 1;
00169         i__2 = *n - 1;
00170         i__3 = *n - 1;
00171         zung2l_(&i__1, &i__2, &i__3, &q[q_offset], ldq, &tau[1], &work[1], &
00172                 iinfo);
00173 
00174     } else {
00175 
00176 /*        Q was determined by a call to ZHPTRD with UPLO = 'L'. */
00177 
00178 /*        Unpack the vectors which define the elementary reflectors and */
00179 /*        set the first row and column of Q equal to those of the unit */
00180 /*        matrix */
00181 
00182         i__1 = q_dim1 + 1;
00183         q[i__1].r = 1., q[i__1].i = 0.;
00184         i__1 = *n;
00185         for (i__ = 2; i__ <= i__1; ++i__) {
00186             i__2 = i__ + q_dim1;
00187             q[i__2].r = 0., q[i__2].i = 0.;
00188 /* L40: */
00189         }
00190         ij = 3;
00191         i__1 = *n;
00192         for (j = 2; j <= i__1; ++j) {
00193             i__2 = j * q_dim1 + 1;
00194             q[i__2].r = 0., q[i__2].i = 0.;
00195             i__2 = *n;
00196             for (i__ = j + 1; i__ <= i__2; ++i__) {
00197                 i__3 = i__ + j * q_dim1;
00198                 i__4 = ij;
00199                 q[i__3].r = ap[i__4].r, q[i__3].i = ap[i__4].i;
00200                 ++ij;
00201 /* L50: */
00202             }
00203             ij += 2;
00204 /* L60: */
00205         }
00206         if (*n > 1) {
00207 
00208 /*           Generate Q(2:n,2:n) */
00209 
00210             i__1 = *n - 1;
00211             i__2 = *n - 1;
00212             i__3 = *n - 1;
00213             zung2r_(&i__1, &i__2, &i__3, &q[(q_dim1 << 1) + 2], ldq, &tau[1], 
00214                     &work[1], &iinfo);
00215         }
00216     }
00217     return 0;
00218 
00219 /*     End of ZUPGTR */
00220 
00221 } /* zupgtr_ */


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