ctzrzf.c
Go to the documentation of this file.
00001 /* ctzrzf.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 static integer c__3 = 3;
00021 static integer c__2 = 2;
00022 
00023 /* Subroutine */ int ctzrzf_(integer *m, integer *n, complex *a, integer *lda, 
00024          complex *tau, complex *work, integer *lwork, integer *info)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
00028 
00029     /* Local variables */
00030     integer i__, m1, ib, nb, ki, kk, mu, nx, iws, nbmin;
00031     extern /* Subroutine */ int clarzb_(char *, char *, char *, char *, 
00032             integer *, integer *, integer *, integer *, complex *, integer *, 
00033             complex *, integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *);
00034     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00035             integer *, integer *);
00036     extern /* Subroutine */ int clarzt_(char *, char *, integer *, integer *, 
00037             complex *, integer *, complex *, complex *, integer *), clatrz_(integer *, integer *, integer *, complex *, 
00038             integer *, complex *, complex *);
00039     integer ldwork, lwkopt;
00040     logical lquery;
00041 
00042 
00043 /*  -- LAPACK routine (version 3.2) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  CTZRZF reduces the M-by-N ( M<=N ) complex upper trapezoidal matrix A */
00056 /*  to upper triangular form by means of unitary transformations. */
00057 
00058 /*  The upper trapezoidal matrix A is factored as */
00059 
00060 /*     A = ( R  0 ) * Z, */
00061 
00062 /*  where Z is an N-by-N unitary matrix and R is an M-by-M upper */
00063 /*  triangular matrix. */
00064 
00065 /*  Arguments */
00066 /*  ========= */
00067 
00068 /*  M       (input) INTEGER */
00069 /*          The number of rows of the matrix A.  M >= 0. */
00070 
00071 /*  N       (input) INTEGER */
00072 /*          The number of columns of the matrix A.  N >= M. */
00073 
00074 /*  A       (input/output) COMPLEX array, dimension (LDA,N) */
00075 /*          On entry, the leading M-by-N upper trapezoidal part of the */
00076 /*          array A must contain the matrix to be factorized. */
00077 /*          On exit, the leading M-by-M upper triangular part of A */
00078 /*          contains the upper triangular matrix R, and elements M+1 to */
00079 /*          N of the first M rows of A, with the array TAU, represent the */
00080 /*          unitary matrix Z as a product of M elementary reflectors. */
00081 
00082 /*  LDA     (input) INTEGER */
00083 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00084 
00085 /*  TAU     (output) COMPLEX array, dimension (M) */
00086 /*          The scalar factors of the elementary reflectors. */
00087 
00088 /*  WORK    (workspace/output) COMPLEX array, dimension (MAX(1,LWORK)) */
00089 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00090 
00091 /*  LWORK   (input) INTEGER */
00092 /*          The dimension of the array WORK.  LWORK >= max(1,M). */
00093 /*          For optimum performance LWORK >= M*NB, where NB is */
00094 /*          the optimal blocksize. */
00095 
00096 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00097 /*          only calculates the optimal size of the WORK array, returns */
00098 /*          this value as the first entry of the WORK array, and no error */
00099 /*          message related to LWORK is issued by XERBLA. */
00100 
00101 /*  INFO    (output) INTEGER */
00102 /*          = 0:  successful exit */
00103 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00104 
00105 /*  Further Details */
00106 /*  =============== */
00107 
00108 /*  Based on contributions by */
00109 /*    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */
00110 
00111 /*  The factorization is obtained by Householder's method.  The kth */
00112 /*  transformation matrix, Z( k ), which is used to introduce zeros into */
00113 /*  the ( m - k + 1 )th row of A, is given in the form */
00114 
00115 /*     Z( k ) = ( I     0   ), */
00116 /*              ( 0  T( k ) ) */
00117 
00118 /*  where */
00119 
00120 /*     T( k ) = I - tau*u( k )*u( k )',   u( k ) = (   1    ), */
00121 /*                                                 (   0    ) */
00122 /*                                                 ( z( k ) ) */
00123 
00124 /*  tau is a scalar and z( k ) is an ( n - m ) element vector. */
00125 /*  tau and z( k ) are chosen to annihilate the elements of the kth row */
00126 /*  of X. */
00127 
00128 /*  The scalar tau is returned in the kth element of TAU and the vector */
00129 /*  u( k ) in the kth row of A, such that the elements of z( k ) are */
00130 /*  in  a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in */
00131 /*  the upper triangular part of A. */
00132 
00133 /*  Z is given by */
00134 
00135 /*     Z =  Z( 1 ) * Z( 2 ) * ... * Z( m ). */
00136 
00137 /*  ===================================================================== */
00138 
00139 /*     .. Parameters .. */
00140 /*     .. */
00141 /*     .. Local Scalars .. */
00142 /*     .. */
00143 /*     .. External Subroutines .. */
00144 /*     .. */
00145 /*     .. Intrinsic Functions .. */
00146 /*     .. */
00147 /*     .. External Functions .. */
00148 /*     .. */
00149 /*     .. Executable Statements .. */
00150 
00151 /*     Test the input arguments */
00152 
00153     /* Parameter adjustments */
00154     a_dim1 = *lda;
00155     a_offset = 1 + a_dim1;
00156     a -= a_offset;
00157     --tau;
00158     --work;
00159 
00160     /* Function Body */
00161     *info = 0;
00162     lquery = *lwork == -1;
00163     if (*m < 0) {
00164         *info = -1;
00165     } else if (*n < *m) {
00166         *info = -2;
00167     } else if (*lda < max(1,*m)) {
00168         *info = -4;
00169     } else if (*lwork < max(1,*m) && ! lquery) {
00170         *info = -7;
00171     }
00172 
00173     if (*info == 0) {
00174         if (*m == 0 || *m == *n) {
00175             lwkopt = 1;
00176         } else {
00177 
00178 /*           Determine the block size. */
00179 
00180             nb = ilaenv_(&c__1, "CGERQF", " ", m, n, &c_n1, &c_n1);
00181             lwkopt = *m * nb;
00182         }
00183         work[1].r = (real) lwkopt, work[1].i = 0.f;
00184 
00185         if (*lwork < max(1,*m) && ! lquery) {
00186             *info = -7;
00187         }
00188     }
00189 
00190     if (*info != 0) {
00191         i__1 = -(*info);
00192         xerbla_("CTZRZF", &i__1);
00193         return 0;
00194     } else if (lquery) {
00195         return 0;
00196     }
00197 
00198 /*     Quick return if possible */
00199 
00200     if (*m == 0) {
00201         return 0;
00202     } else if (*m == *n) {
00203         i__1 = *n;
00204         for (i__ = 1; i__ <= i__1; ++i__) {
00205             i__2 = i__;
00206             tau[i__2].r = 0.f, tau[i__2].i = 0.f;
00207 /* L10: */
00208         }
00209         return 0;
00210     }
00211 
00212     nbmin = 2;
00213     nx = 1;
00214     iws = *m;
00215     if (nb > 1 && nb < *m) {
00216 
00217 /*        Determine when to cross over from blocked to unblocked code. */
00218 
00219 /* Computing MAX */
00220         i__1 = 0, i__2 = ilaenv_(&c__3, "CGERQF", " ", m, n, &c_n1, &c_n1);
00221         nx = max(i__1,i__2);
00222         if (nx < *m) {
00223 
00224 /*           Determine if workspace is large enough for blocked code. */
00225 
00226             ldwork = *m;
00227             iws = ldwork * nb;
00228             if (*lwork < iws) {
00229 
00230 /*              Not enough workspace to use optimal NB:  reduce NB and */
00231 /*              determine the minimum value of NB. */
00232 
00233                 nb = *lwork / ldwork;
00234 /* Computing MAX */
00235                 i__1 = 2, i__2 = ilaenv_(&c__2, "CGERQF", " ", m, n, &c_n1, &
00236                         c_n1);
00237                 nbmin = max(i__1,i__2);
00238             }
00239         }
00240     }
00241 
00242     if (nb >= nbmin && nb < *m && nx < *m) {
00243 
00244 /*        Use blocked code initially. */
00245 /*        The last kk rows are handled by the block method. */
00246 
00247 /* Computing MIN */
00248         i__1 = *m + 1;
00249         m1 = min(i__1,*n);
00250         ki = (*m - nx - 1) / nb * nb;
00251 /* Computing MIN */
00252         i__1 = *m, i__2 = ki + nb;
00253         kk = min(i__1,i__2);
00254 
00255         i__1 = *m - kk + 1;
00256         i__2 = -nb;
00257         for (i__ = *m - kk + ki + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; 
00258                 i__ += i__2) {
00259 /* Computing MIN */
00260             i__3 = *m - i__ + 1;
00261             ib = min(i__3,nb);
00262 
00263 /*           Compute the TZ factorization of the current block */
00264 /*           A(i:i+ib-1,i:n) */
00265 
00266             i__3 = *n - i__ + 1;
00267             i__4 = *n - *m;
00268             clatrz_(&ib, &i__3, &i__4, &a[i__ + i__ * a_dim1], lda, &tau[i__], 
00269                      &work[1]);
00270             if (i__ > 1) {
00271 
00272 /*              Form the triangular factor of the block reflector */
00273 /*              H = H(i+ib-1) . . . H(i+1) H(i) */
00274 
00275                 i__3 = *n - *m;
00276                 clarzt_("Backward", "Rowwise", &i__3, &ib, &a[i__ + m1 * 
00277                         a_dim1], lda, &tau[i__], &work[1], &ldwork);
00278 
00279 /*              Apply H to A(1:i-1,i:n) from the right */
00280 
00281                 i__3 = i__ - 1;
00282                 i__4 = *n - i__ + 1;
00283                 i__5 = *n - *m;
00284                 clarzb_("Right", "No transpose", "Backward", "Rowwise", &i__3, 
00285                          &i__4, &ib, &i__5, &a[i__ + m1 * a_dim1], lda, &work[
00286                         1], &ldwork, &a[i__ * a_dim1 + 1], lda, &work[ib + 1], 
00287                          &ldwork)
00288                         ;
00289             }
00290 /* L20: */
00291         }
00292         mu = i__ + nb - 1;
00293     } else {
00294         mu = *m;
00295     }
00296 
00297 /*     Use unblocked code to factor the last or only block */
00298 
00299     if (mu > 0) {
00300         i__2 = *n - *m;
00301         clatrz_(&mu, n, &i__2, &a[a_offset], lda, &tau[1], &work[1]);
00302     }
00303 
00304     work[1].r = (real) lwkopt, work[1].i = 0.f;
00305 
00306     return 0;
00307 
00308 /*     End of CTZRZF */
00309 
00310 } /* ctzrzf_ */


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