zggqrf.c
Go to the documentation of this file.
00001 /* zggqrf.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 
00021 /* Subroutine */ int zggqrf_(integer *n, integer *m, integer *p, 
00022         doublecomplex *a, integer *lda, doublecomplex *taua, doublecomplex *b, 
00023          integer *ldb, doublecomplex *taub, doublecomplex *work, integer *
00024         lwork, integer *info)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
00028 
00029     /* Local variables */
00030     integer nb, nb1, nb2, nb3, lopt;
00031     extern /* Subroutine */ int xerbla_(char *, integer *);
00032     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00033             integer *, integer *);
00034     extern /* Subroutine */ int zgeqrf_(integer *, integer *, doublecomplex *, 
00035              integer *, doublecomplex *, doublecomplex *, integer *, integer *
00036 ), zgerqf_(integer *, integer *, doublecomplex *, integer *, 
00037             doublecomplex *, doublecomplex *, integer *, integer *);
00038     integer lwkopt;
00039     logical lquery;
00040     extern /* Subroutine */ int zunmqr_(char *, char *, integer *, integer *, 
00041             integer *, doublecomplex *, integer *, doublecomplex *, 
00042             doublecomplex *, integer *, doublecomplex *, integer *, integer *);
00043 
00044 
00045 /*  -- LAPACK routine (version 3.2) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  ZGGQRF computes a generalized QR factorization of an N-by-M matrix A */
00058 /*  and an N-by-P matrix B: */
00059 
00060 /*              A = Q*R,        B = Q*T*Z, */
00061 
00062 /*  where Q is an N-by-N unitary matrix, Z is a P-by-P unitary matrix, */
00063 /*  and R and T assume one of the forms: */
00064 
00065 /*  if N >= M,  R = ( R11 ) M  ,   or if N < M,  R = ( R11  R12 ) N, */
00066 /*                  (  0  ) N-M                         N   M-N */
00067 /*                     M */
00068 
00069 /*  where R11 is upper triangular, and */
00070 
00071 /*  if N <= P,  T = ( 0  T12 ) N,   or if N > P,  T = ( T11 ) N-P, */
00072 /*                   P-N  N                           ( T21 ) P */
00073 /*                                                       P */
00074 
00075 /*  where T12 or T21 is upper triangular. */
00076 
00077 /*  In particular, if B is square and nonsingular, the GQR factorization */
00078 /*  of A and B implicitly gives the QR factorization of inv(B)*A: */
00079 
00080 /*               inv(B)*A = Z'*(inv(T)*R) */
00081 
00082 /*  where inv(B) denotes the inverse of the matrix B, and Z' denotes the */
00083 /*  conjugate transpose of matrix Z. */
00084 
00085 /*  Arguments */
00086 /*  ========= */
00087 
00088 /*  N       (input) INTEGER */
00089 /*          The number of rows of the matrices A and B. N >= 0. */
00090 
00091 /*  M       (input) INTEGER */
00092 /*          The number of columns of the matrix A.  M >= 0. */
00093 
00094 /*  P       (input) INTEGER */
00095 /*          The number of columns of the matrix B.  P >= 0. */
00096 
00097 /*  A       (input/output) COMPLEX*16 array, dimension (LDA,M) */
00098 /*          On entry, the N-by-M matrix A. */
00099 /*          On exit, the elements on and above the diagonal of the array */
00100 /*          contain the min(N,M)-by-M upper trapezoidal matrix R (R is */
00101 /*          upper triangular if N >= M); the elements below the diagonal, */
00102 /*          with the array TAUA, represent the unitary matrix Q as a */
00103 /*          product of min(N,M) elementary reflectors (see Further */
00104 /*          Details). */
00105 
00106 /*  LDA     (input) INTEGER */
00107 /*          The leading dimension of the array A. LDA >= max(1,N). */
00108 
00109 /*  TAUA    (output) COMPLEX*16 array, dimension (min(N,M)) */
00110 /*          The scalar factors of the elementary reflectors which */
00111 /*          represent the unitary matrix Q (see Further Details). */
00112 
00113 /*  B       (input/output) COMPLEX*16 array, dimension (LDB,P) */
00114 /*          On entry, the N-by-P matrix B. */
00115 /*          On exit, if N <= P, the upper triangle of the subarray */
00116 /*          B(1:N,P-N+1:P) contains the N-by-N upper triangular matrix T; */
00117 /*          if N > P, the elements on and above the (N-P)-th subdiagonal */
00118 /*          contain the N-by-P upper trapezoidal matrix T; the remaining */
00119 /*          elements, with the array TAUB, represent the unitary */
00120 /*          matrix Z as a product of elementary reflectors (see Further */
00121 /*          Details). */
00122 
00123 /*  LDB     (input) INTEGER */
00124 /*          The leading dimension of the array B. LDB >= max(1,N). */
00125 
00126 /*  TAUB    (output) COMPLEX*16 array, dimension (min(N,P)) */
00127 /*          The scalar factors of the elementary reflectors which */
00128 /*          represent the unitary matrix Z (see Further Details). */
00129 
00130 /*  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */
00131 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00132 
00133 /*  LWORK   (input) INTEGER */
00134 /*          The dimension of the array WORK. LWORK >= max(1,N,M,P). */
00135 /*          For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3), */
00136 /*          where NB1 is the optimal blocksize for the QR factorization */
00137 /*          of an N-by-M matrix, NB2 is the optimal blocksize for the */
00138 /*          RQ factorization of an N-by-P matrix, and NB3 is the optimal */
00139 /*          blocksize for a call of ZUNMQR. */
00140 
00141 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00142 /*          only calculates the optimal size of the WORK array, returns */
00143 /*          this value as the first entry of the WORK array, and no error */
00144 /*          message related to LWORK is issued by XERBLA. */
00145 
00146 /*  INFO    (output) INTEGER */
00147 /*           = 0:  successful exit */
00148 /*           < 0:  if INFO = -i, the i-th argument had an illegal value. */
00149 
00150 /*  Further Details */
00151 /*  =============== */
00152 
00153 /*  The matrix Q is represented as a product of elementary reflectors */
00154 
00155 /*     Q = H(1) H(2) . . . H(k), where k = min(n,m). */
00156 
00157 /*  Each H(i) has the form */
00158 
00159 /*     H(i) = I - taua * v * v' */
00160 
00161 /*  where taua is a complex scalar, and v is a complex vector with */
00162 /*  v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i+1:n,i), */
00163 /*  and taua in TAUA(i). */
00164 /*  To form Q explicitly, use LAPACK subroutine ZUNGQR. */
00165 /*  To use Q to update another matrix, use LAPACK subroutine ZUNMQR. */
00166 
00167 /*  The matrix Z is represented as a product of elementary reflectors */
00168 
00169 /*     Z = H(1) H(2) . . . H(k), where k = min(n,p). */
00170 
00171 /*  Each H(i) has the form */
00172 
00173 /*     H(i) = I - taub * v * v' */
00174 
00175 /*  where taub is a complex scalar, and v is a complex vector with */
00176 /*  v(p-k+i+1:p) = 0 and v(p-k+i) = 1; v(1:p-k+i-1) is stored on exit in */
00177 /*  B(n-k+i,1:p-k+i-1), and taub in TAUB(i). */
00178 /*  To form Z explicitly, use LAPACK subroutine ZUNGRQ. */
00179 /*  To use Z to update another matrix, use LAPACK subroutine ZUNMRQ. */
00180 
00181 /*  ===================================================================== */
00182 
00183 /*     .. Local Scalars .. */
00184 /*     .. */
00185 /*     .. External Subroutines .. */
00186 /*     .. */
00187 /*     .. External Functions .. */
00188 /*     .. */
00189 /*     .. Intrinsic Functions .. */
00190 /*     .. */
00191 /*     .. Executable Statements .. */
00192 
00193 /*     Test the input parameters */
00194 
00195     /* Parameter adjustments */
00196     a_dim1 = *lda;
00197     a_offset = 1 + a_dim1;
00198     a -= a_offset;
00199     --taua;
00200     b_dim1 = *ldb;
00201     b_offset = 1 + b_dim1;
00202     b -= b_offset;
00203     --taub;
00204     --work;
00205 
00206     /* Function Body */
00207     *info = 0;
00208     nb1 = ilaenv_(&c__1, "ZGEQRF", " ", n, m, &c_n1, &c_n1);
00209     nb2 = ilaenv_(&c__1, "ZGERQF", " ", n, p, &c_n1, &c_n1);
00210     nb3 = ilaenv_(&c__1, "ZUNMQR", " ", n, m, p, &c_n1);
00211 /* Computing MAX */
00212     i__1 = max(nb1,nb2);
00213     nb = max(i__1,nb3);
00214 /* Computing MAX */
00215     i__1 = max(*n,*m);
00216     lwkopt = max(i__1,*p) * nb;
00217     work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00218     lquery = *lwork == -1;
00219     if (*n < 0) {
00220         *info = -1;
00221     } else if (*m < 0) {
00222         *info = -2;
00223     } else if (*p < 0) {
00224         *info = -3;
00225     } else if (*lda < max(1,*n)) {
00226         *info = -5;
00227     } else if (*ldb < max(1,*n)) {
00228         *info = -8;
00229     } else /* if(complicated condition) */ {
00230 /* Computing MAX */
00231         i__1 = max(1,*n), i__1 = max(i__1,*m);
00232         if (*lwork < max(i__1,*p) && ! lquery) {
00233             *info = -11;
00234         }
00235     }
00236     if (*info != 0) {
00237         i__1 = -(*info);
00238         xerbla_("ZGGQRF", &i__1);
00239         return 0;
00240     } else if (lquery) {
00241         return 0;
00242     }
00243 
00244 /*     QR factorization of N-by-M matrix A: A = Q*R */
00245 
00246     zgeqrf_(n, m, &a[a_offset], lda, &taua[1], &work[1], lwork, info);
00247     lopt = (integer) work[1].r;
00248 
00249 /*     Update B := Q'*B. */
00250 
00251     i__1 = min(*n,*m);
00252     zunmqr_("Left", "Conjugate Transpose", n, p, &i__1, &a[a_offset], lda, &
00253             taua[1], &b[b_offset], ldb, &work[1], lwork, info);
00254 /* Computing MAX */
00255     i__1 = lopt, i__2 = (integer) work[1].r;
00256     lopt = max(i__1,i__2);
00257 
00258 /*     RQ factorization of N-by-P matrix B: B = T*Z. */
00259 
00260     zgerqf_(n, p, &b[b_offset], ldb, &taub[1], &work[1], lwork, info);
00261 /* Computing MAX */
00262     i__2 = lopt, i__3 = (integer) work[1].r;
00263     i__1 = max(i__2,i__3);
00264     work[1].r = (doublereal) i__1, work[1].i = 0.;
00265 
00266     return 0;
00267 
00268 /*     End of ZGGQRF */
00269 
00270 } /* zggqrf_ */


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