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