1 /* ./src_f77/zggrqf.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* Table of constant values */
9
10 static integer c__1 = 1;
11 static integer c_n1 = -1;
12
zggrqf_(integer * m,integer * p,integer * n,doublecomplex * a,integer * lda,doublecomplex * taua,doublecomplex * b,integer * ldb,doublecomplex * taub,doublecomplex * work,integer * lwork,integer * info)13 /* Subroutine */ int zggrqf_(integer *m, integer *p, integer *n,
14 doublecomplex *a, integer *lda, doublecomplex *taua, doublecomplex *b,
15 integer *ldb, doublecomplex *taub, doublecomplex *work, integer *
16 lwork, integer *info)
17 {
18 /* System generated locals */
19 integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
20
21 /* Local variables */
22 static integer nb, nb1, nb2, nb3, lopt;
23 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
24 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
25 integer *, integer *, ftnlen, ftnlen);
26 extern /* Subroutine */ int zgeqrf_(integer *, integer *, doublecomplex *,
27 integer *, doublecomplex *, doublecomplex *, integer *, integer *
28 ), zgerqf_(integer *, integer *, doublecomplex *, integer *,
29 doublecomplex *, doublecomplex *, integer *, integer *);
30 static integer lwkopt;
31 static logical lquery;
32 extern /* Subroutine */ int zunmrq_(char *, char *, integer *, integer *,
33 integer *, doublecomplex *, integer *, doublecomplex *,
34 doublecomplex *, integer *, doublecomplex *, integer *, integer *,
35 ftnlen, ftnlen);
36
37
38 /* -- LAPACK routine (version 3.0) -- */
39 /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
40 /* Courant Institute, Argonne National Lab, and Rice University */
41 /* June 30, 1999 */
42
43 /* .. Scalar Arguments .. */
44 /* .. */
45 /* .. Array Arguments .. */
46 /* .. */
47
48 /* Purpose */
49 /* ======= */
50
51 /* ZGGRQF computes a generalized RQ factorization of an M-by-N matrix A */
52 /* and a P-by-N matrix B: */
53
54 /* A = R*Q, B = Z*T*Q, */
55
56 /* where Q is an N-by-N unitary matrix, Z is a P-by-P unitary */
57 /* matrix, and R and T assume one of the forms: */
58
59 /* if M <= N, R = ( 0 R12 ) M, or if M > N, R = ( R11 ) M-N, */
60 /* N-M M ( R21 ) N */
61 /* N */
62
63 /* where R12 or R21 is upper triangular, and */
64
65 /* if P >= N, T = ( T11 ) N , or if P < N, T = ( T11 T12 ) P, */
66 /* ( 0 ) P-N P N-P */
67 /* N */
68
69 /* where T11 is upper triangular. */
70
71 /* In particular, if B is square and nonsingular, the GRQ factorization */
72 /* of A and B implicitly gives the RQ factorization of A*inv(B): */
73
74 /* A*inv(B) = (R*inv(T))*Z' */
75
76 /* where inv(B) denotes the inverse of the matrix B, and Z' denotes the */
77 /* conjugate transpose of the matrix Z. */
78
79 /* Arguments */
80 /* ========= */
81
82 /* M (input) INTEGER */
83 /* The number of rows of the matrix A. M >= 0. */
84
85 /* P (input) INTEGER */
86 /* The number of rows of the matrix B. P >= 0. */
87
88 /* N (input) INTEGER */
89 /* The number of columns of the matrices A and B. N >= 0. */
90
91 /* A (input/output) COMPLEX*16 array, dimension (LDA,N) */
92 /* On entry, the M-by-N matrix A. */
93 /* On exit, if M <= N, the upper triangle of the subarray */
94 /* A(1:M,N-M+1:N) contains the M-by-M upper triangular matrix R; */
95 /* if M > N, the elements on and above the (M-N)-th subdiagonal */
96 /* contain the M-by-N upper trapezoidal matrix R; the remaining */
97 /* elements, with the array TAUA, represent the unitary */
98 /* matrix Q as a product of elementary reflectors (see Further */
99 /* Details). */
100
101 /* LDA (input) INTEGER */
102 /* The leading dimension of the array A. LDA >= max(1,M). */
103
104 /* TAUA (output) COMPLEX*16 array, dimension (min(M,N)) */
105 /* The scalar factors of the elementary reflectors which */
106 /* represent the unitary matrix Q (see Further Details). */
107
108 /* B (input/output) COMPLEX*16 array, dimension (LDB,N) */
109 /* On entry, the P-by-N matrix B. */
110 /* On exit, the elements on and above the diagonal of the array */
111 /* contain the min(P,N)-by-N upper trapezoidal matrix T (T is */
112 /* upper triangular if P >= N); the elements below the diagonal, */
113 /* with the array TAUB, represent the unitary matrix Z as a */
114 /* product of elementary reflectors (see Further Details). */
115
116 /* LDB (input) INTEGER */
117 /* The leading dimension of the array B. LDB >= max(1,P). */
118
119 /* TAUB (output) COMPLEX*16 array, dimension (min(P,N)) */
120 /* The scalar factors of the elementary reflectors which */
121 /* represent the unitary matrix Z (see Further Details). */
122
123 /* WORK (workspace/output) COMPLEX*16 array, dimension (LWORK) */
124 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
125
126 /* LWORK (input) INTEGER */
127 /* The dimension of the array WORK. LWORK >= max(1,N,M,P). */
128 /* For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3), */
129 /* where NB1 is the optimal blocksize for the RQ factorization */
130 /* of an M-by-N matrix, NB2 is the optimal blocksize for the */
131 /* QR factorization of a P-by-N matrix, and NB3 is the optimal */
132 /* blocksize for a call of ZUNMRQ. */
133
134 /* If LWORK = -1, then a workspace query is assumed; the routine */
135 /* only calculates the optimal size of the WORK array, returns */
136 /* this value as the first entry of the WORK array, and no error */
137 /* message related to LWORK is issued by XERBLA. */
138
139 /* INFO (output) INTEGER */
140 /* = 0: successful exit */
141 /* < 0: if INFO=-i, the i-th argument had an illegal value. */
142
143 /* Further Details */
144 /* =============== */
145
146 /* The matrix Q is represented as a product of elementary reflectors */
147
148 /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */
149
150 /* Each H(i) has the form */
151
152 /* H(i) = I - taua * v * v' */
153
154 /* where taua is a complex scalar, and v is a complex vector with */
155 /* v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in */
156 /* A(m-k+i,1:n-k+i-1), and taua in TAUA(i). */
157 /* To form Q explicitly, use LAPACK subroutine ZUNGRQ. */
158 /* To use Q to update another matrix, use LAPACK subroutine ZUNMRQ. */
159
160 /* The matrix Z is represented as a product of elementary reflectors */
161
162 /* Z = H(1) H(2) . . . H(k), where k = min(p,n). */
163
164 /* Each H(i) has the form */
165
166 /* H(i) = I - taub * v * v' */
167
168 /* where taub is a complex scalar, and v is a complex vector with */
169 /* v(1:i-1) = 0 and v(i) = 1; v(i+1:p) is stored on exit in B(i+1:p,i), */
170 /* and taub in TAUB(i). */
171 /* To form Z explicitly, use LAPACK subroutine ZUNGQR. */
172 /* To use Z to update another matrix, use LAPACK subroutine ZUNMQR. */
173
174 /* ===================================================================== */
175
176 /* .. Local Scalars .. */
177 /* .. */
178 /* .. External Subroutines .. */
179 /* .. */
180 /* .. External Functions .. */
181 /* .. */
182 /* .. Intrinsic Functions .. */
183 /* .. */
184 /* .. Executable Statements .. */
185
186 /* Test the input parameters */
187
188 /* Parameter adjustments */
189 a_dim1 = *lda;
190 a_offset = 1 + a_dim1;
191 a -= a_offset;
192 --taua;
193 b_dim1 = *ldb;
194 b_offset = 1 + b_dim1;
195 b -= b_offset;
196 --taub;
197 --work;
198
199 /* Function Body */
200 *info = 0;
201 nb1 = ilaenv_(&c__1, "ZGERQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, (
202 ftnlen)1);
203 nb2 = ilaenv_(&c__1, "ZGEQRF", " ", p, n, &c_n1, &c_n1, (ftnlen)6, (
204 ftnlen)1);
205 nb3 = ilaenv_(&c__1, "ZUNMRQ", " ", m, n, p, &c_n1, (ftnlen)6, (ftnlen)1);
206 /* Computing MAX */
207 i__1 = max(nb1,nb2);
208 nb = max(i__1,nb3);
209 /* Computing MAX */
210 i__1 = max(*n,*m);
211 lwkopt = max(i__1,*p) * nb;
212 work[1].r = (doublereal) lwkopt, work[1].i = 0.;
213 lquery = *lwork == -1;
214 if (*m < 0) {
215 *info = -1;
216 } else if (*p < 0) {
217 *info = -2;
218 } else if (*n < 0) {
219 *info = -3;
220 } else if (*lda < max(1,*m)) {
221 *info = -5;
222 } else if (*ldb < max(1,*p)) {
223 *info = -8;
224 } else /* if(complicated condition) */ {
225 /* Computing MAX */
226 i__1 = max(1,*m), i__1 = max(i__1,*p);
227 if (*lwork < max(i__1,*n) && ! lquery) {
228 *info = -11;
229 }
230 }
231 if (*info != 0) {
232 i__1 = -(*info);
233 xerbla_("ZGGRQF", &i__1, (ftnlen)6);
234 return 0;
235 } else if (lquery) {
236 return 0;
237 }
238
239 /* RQ factorization of M-by-N matrix A: A = R*Q */
240
241 zgerqf_(m, n, &a[a_offset], lda, &taua[1], &work[1], lwork, info);
242 lopt = (integer) work[1].r;
243
244 /* Update B := B*Q' */
245
246 i__1 = min(*m,*n);
247 /* Computing MAX */
248 i__2 = 1, i__3 = *m - *n + 1;
249 zunmrq_("Right", "Conjugate Transpose", p, n, &i__1, &a[max(i__2,i__3) +
250 a_dim1], lda, &taua[1], &b[b_offset], ldb, &work[1], lwork, info,
251 (ftnlen)5, (ftnlen)19);
252 /* Computing MAX */
253 i__1 = lopt, i__2 = (integer) work[1].r;
254 lopt = max(i__1,i__2);
255
256 /* QR factorization of P-by-N matrix B: B = Z*T */
257
258 zgeqrf_(p, n, &b[b_offset], ldb, &taub[1], &work[1], lwork, info);
259 /* Computing MAX */
260 i__2 = lopt, i__3 = (integer) work[1].r;
261 i__1 = max(i__2,i__3);
262 work[1].r = (doublereal) i__1, work[1].i = 0.;
263
264 return 0;
265
266 /* End of ZGGRQF */
267
268 } /* zggrqf_ */
269
270