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


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