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


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