zungl2.c
Go to the documentation of this file.
00001 /* zungl2.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 zungl2_(integer *m, integer *n, integer *k, 
00017         doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *
00018         work, integer *info)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, i__1, i__2, i__3;
00022     doublecomplex z__1, z__2;
00023 
00024     /* Builtin functions */
00025     void d_cnjg(doublecomplex *, doublecomplex *);
00026 
00027     /* Local variables */
00028     integer i__, j, l;
00029     extern /* Subroutine */ int zscal_(integer *, doublecomplex *, 
00030             doublecomplex *, integer *), zlarf_(char *, integer *, integer *, 
00031             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00032             integer *, doublecomplex *), xerbla_(char *, integer *), zlacgv_(integer *, doublecomplex *, 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 /*  ZUNGL2 generates an m-by-n complex matrix Q with orthonormal rows, */
00048 /*  which is defined as the first m rows of a product of k elementary */
00049 /*  reflectors of order n */
00050 
00051 /*        Q  =  H(k)' . . . H(2)' H(1)' */
00052 
00053 /*  as returned by ZGELQF. */
00054 
00055 /*  Arguments */
00056 /*  ========= */
00057 
00058 /*  M       (input) INTEGER */
00059 /*          The number of rows of the matrix Q. M >= 0. */
00060 
00061 /*  N       (input) INTEGER */
00062 /*          The number of columns of the matrix Q. N >= M. */
00063 
00064 /*  K       (input) INTEGER */
00065 /*          The number of elementary reflectors whose product defines the */
00066 /*          matrix Q. M >= K >= 0. */
00067 
00068 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,N) */
00069 /*          On entry, the i-th row must contain the vector which defines */
00070 /*          the elementary reflector H(i), for i = 1,2,...,k, as returned */
00071 /*          by ZGELQF in the first k rows of its array argument A. */
00072 /*          On exit, the m by n matrix Q. */
00073 
00074 /*  LDA     (input) INTEGER */
00075 /*          The first dimension of the array A. LDA >= max(1,M). */
00076 
00077 /*  TAU     (input) COMPLEX*16 array, dimension (K) */
00078 /*          TAU(i) must contain the scalar factor of the elementary */
00079 /*          reflector H(i), as returned by ZGELQF. */
00080 
00081 /*  WORK    (workspace) COMPLEX*16 array, dimension (M) */
00082 
00083 /*  INFO    (output) INTEGER */
00084 /*          = 0: successful exit */
00085 /*          < 0: if INFO = -i, the i-th argument has an illegal value */
00086 
00087 /*  ===================================================================== */
00088 
00089 /*     .. Parameters .. */
00090 /*     .. */
00091 /*     .. Local Scalars .. */
00092 /*     .. */
00093 /*     .. External Subroutines .. */
00094 /*     .. */
00095 /*     .. Intrinsic Functions .. */
00096 /*     .. */
00097 /*     .. Executable Statements .. */
00098 
00099 /*     Test the input arguments */
00100 
00101     /* Parameter adjustments */
00102     a_dim1 = *lda;
00103     a_offset = 1 + a_dim1;
00104     a -= a_offset;
00105     --tau;
00106     --work;
00107 
00108     /* Function Body */
00109     *info = 0;
00110     if (*m < 0) {
00111         *info = -1;
00112     } else if (*n < *m) {
00113         *info = -2;
00114     } else if (*k < 0 || *k > *m) {
00115         *info = -3;
00116     } else if (*lda < max(1,*m)) {
00117         *info = -5;
00118     }
00119     if (*info != 0) {
00120         i__1 = -(*info);
00121         xerbla_("ZUNGL2", &i__1);
00122         return 0;
00123     }
00124 
00125 /*     Quick return if possible */
00126 
00127     if (*m <= 0) {
00128         return 0;
00129     }
00130 
00131     if (*k < *m) {
00132 
00133 /*        Initialise rows k+1:m to rows of the unit matrix */
00134 
00135         i__1 = *n;
00136         for (j = 1; j <= i__1; ++j) {
00137             i__2 = *m;
00138             for (l = *k + 1; l <= i__2; ++l) {
00139                 i__3 = l + j * a_dim1;
00140                 a[i__3].r = 0., a[i__3].i = 0.;
00141 /* L10: */
00142             }
00143             if (j > *k && j <= *m) {
00144                 i__2 = j + j * a_dim1;
00145                 a[i__2].r = 1., a[i__2].i = 0.;
00146             }
00147 /* L20: */
00148         }
00149     }
00150 
00151     for (i__ = *k; i__ >= 1; --i__) {
00152 
00153 /*        Apply H(i)' to A(i:m,i:n) from the right */
00154 
00155         if (i__ < *n) {
00156             i__1 = *n - i__;
00157             zlacgv_(&i__1, &a[i__ + (i__ + 1) * a_dim1], lda);
00158             if (i__ < *m) {
00159                 i__1 = i__ + i__ * a_dim1;
00160                 a[i__1].r = 1., a[i__1].i = 0.;
00161                 i__1 = *m - i__;
00162                 i__2 = *n - i__ + 1;
00163                 d_cnjg(&z__1, &tau[i__]);
00164                 zlarf_("Right", &i__1, &i__2, &a[i__ + i__ * a_dim1], lda, &
00165                         z__1, &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
00166             }
00167             i__1 = *n - i__;
00168             i__2 = i__;
00169             z__1.r = -tau[i__2].r, z__1.i = -tau[i__2].i;
00170             zscal_(&i__1, &z__1, &a[i__ + (i__ + 1) * a_dim1], lda);
00171             i__1 = *n - i__;
00172             zlacgv_(&i__1, &a[i__ + (i__ + 1) * a_dim1], lda);
00173         }
00174         i__1 = i__ + i__ * a_dim1;
00175         d_cnjg(&z__2, &tau[i__]);
00176         z__1.r = 1. - z__2.r, z__1.i = 0. - z__2.i;
00177         a[i__1].r = z__1.r, a[i__1].i = z__1.i;
00178 
00179 /*        Set A(i,1:i-1) to zero */
00180 
00181         i__1 = i__ - 1;
00182         for (l = 1; l <= i__1; ++l) {
00183             i__2 = i__ + l * a_dim1;
00184             a[i__2].r = 0., a[i__2].i = 0.;
00185 /* L30: */
00186         }
00187 /* L40: */
00188     }
00189     return 0;
00190 
00191 /*     End of ZUNGL2 */
00192 
00193 } /* zungl2_ */


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