C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / SRC / cgbbrd.c
1 #include <math.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <complex.h>
6 #ifdef complex
7 #undef complex
8 #endif
9 #ifdef I
10 #undef I
11 #endif
12
13 #if defined(_WIN64)
14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
16 #else
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
19 #endif
20
21 #ifdef LAPACK_ILP64
22 typedef BLASLONG blasint;
23 #if defined(_WIN64)
24 #define blasabs(x) llabs(x)
25 #else
26 #define blasabs(x) labs(x)
27 #endif
28 #else
29 typedef int blasint;
30 #define blasabs(x) abs(x)
31 #endif
32
33 typedef blasint integer;
34
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
38 typedef float real;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
42 #ifdef _MSC_VER
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
47 #else
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
52 #endif
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
55 typedef int logical;
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
59
60 #define TRUE_ (1)
61 #define FALSE_ (0)
62
63 /* Extern is for use with -E */
64 #ifndef Extern
65 #define Extern extern
66 #endif
67
68 /* I/O stuff */
69
70 typedef int flag;
71 typedef int ftnlen;
72 typedef int ftnint;
73
74 /*external read, write*/
75 typedef struct
76 {       flag cierr;
77         ftnint ciunit;
78         flag ciend;
79         char *cifmt;
80         ftnint cirec;
81 } cilist;
82
83 /*internal read, write*/
84 typedef struct
85 {       flag icierr;
86         char *iciunit;
87         flag iciend;
88         char *icifmt;
89         ftnint icirlen;
90         ftnint icirnum;
91 } icilist;
92
93 /*open*/
94 typedef struct
95 {       flag oerr;
96         ftnint ounit;
97         char *ofnm;
98         ftnlen ofnmlen;
99         char *osta;
100         char *oacc;
101         char *ofm;
102         ftnint orl;
103         char *oblnk;
104 } olist;
105
106 /*close*/
107 typedef struct
108 {       flag cerr;
109         ftnint cunit;
110         char *csta;
111 } cllist;
112
113 /*rewind, backspace, endfile*/
114 typedef struct
115 {       flag aerr;
116         ftnint aunit;
117 } alist;
118
119 /* inquire */
120 typedef struct
121 {       flag inerr;
122         ftnint inunit;
123         char *infile;
124         ftnlen infilen;
125         ftnint  *inex;  /*parameters in standard's order*/
126         ftnint  *inopen;
127         ftnint  *innum;
128         ftnint  *innamed;
129         char    *inname;
130         ftnlen  innamlen;
131         char    *inacc;
132         ftnlen  inacclen;
133         char    *inseq;
134         ftnlen  inseqlen;
135         char    *indir;
136         ftnlen  indirlen;
137         char    *infmt;
138         ftnlen  infmtlen;
139         char    *inform;
140         ftnint  informlen;
141         char    *inunf;
142         ftnlen  inunflen;
143         ftnint  *inrecl;
144         ftnint  *innrec;
145         char    *inblank;
146         ftnlen  inblanklen;
147 } inlist;
148
149 #define VOID void
150
151 union Multitype {       /* for multiple entry points */
152         integer1 g;
153         shortint h;
154         integer i;
155         /* longint j; */
156         real r;
157         doublereal d;
158         complex c;
159         doublecomplex z;
160         };
161
162 typedef union Multitype Multitype;
163
164 struct Vardesc {        /* for Namelist */
165         char *name;
166         char *addr;
167         ftnlen *dims;
168         int  type;
169         };
170 typedef struct Vardesc Vardesc;
171
172 struct Namelist {
173         char *name;
174         Vardesc **vars;
175         int nvars;
176         };
177 typedef struct Namelist Namelist;
178
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b)   ((a) >> (b) & 1)
186 #define bit_clear(a,b)  ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b)    ((a) |  ((uinteger)1 << (b)))
188
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
192 #ifdef _MSC_VER
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
195 #else
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
198 #endif
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) {         ftnlen i, nc, ll; char *f__rp, *lp;     ll = (llp); lp = (lpp);         for(i=0; i < (int)*(np); ++i) {                 nc = ll;                if((rnp)[i] < nc) nc = (rnp)[i];                ll -= nc;               f__rp = (rpp)[i];               while(--nc >= 0) *lp++ = *(f__rp)++;         }  while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
260
261 /* procedure parameter types for -A and -C++ */
262
263 #define F2C_proc_par_types 1
264 #ifdef __cplusplus
265 typedef logical (*L_fp)(...);
266 #else
267 typedef logical (*L_fp)();
268 #endif
269
270 static float spow_ui(float x, integer n) {
271         float pow=1.0; unsigned long int u;
272         if(n != 0) {
273                 if(n < 0) n = -n, x = 1/x;
274                 for(u = n; ; ) {
275                         if(u & 01) pow *= x;
276                         if(u >>= 1) x *= x;
277                         else break;
278                 }
279         }
280         return pow;
281 }
282 static double dpow_ui(double x, integer n) {
283         double pow=1.0; unsigned long int u;
284         if(n != 0) {
285                 if(n < 0) n = -n, x = 1/x;
286                 for(u = n; ; ) {
287                         if(u & 01) pow *= x;
288                         if(u >>= 1) x *= x;
289                         else break;
290                 }
291         }
292         return pow;
293 }
294 #ifdef _MSC_VER
295 static _Fcomplex cpow_ui(complex x, integer n) {
296         complex pow={1.0,0.0}; unsigned long int u;
297                 if(n != 0) {
298                 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
299                 for(u = n; ; ) {
300                         if(u & 01) pow.r *= x.r, pow.i *= x.i;
301                         if(u >>= 1) x.r *= x.r, x.i *= x.i;
302                         else break;
303                 }
304         }
305         _Fcomplex p={pow.r, pow.i};
306         return p;
307 }
308 #else
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310         _Complex float pow=1.0; unsigned long int u;
311         if(n != 0) {
312                 if(n < 0) n = -n, x = 1/x;
313                 for(u = n; ; ) {
314                         if(u & 01) pow *= x;
315                         if(u >>= 1) x *= x;
316                         else break;
317                 }
318         }
319         return pow;
320 }
321 #endif
322 #ifdef _MSC_VER
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324         _Dcomplex pow={1.0,0.0}; unsigned long int u;
325         if(n != 0) {
326                 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
327                 for(u = n; ; ) {
328                         if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329                         if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
330                         else break;
331                 }
332         }
333         _Dcomplex p = {pow._Val[0], pow._Val[1]};
334         return p;
335 }
336 #else
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338         _Complex double pow=1.0; unsigned long int u;
339         if(n != 0) {
340                 if(n < 0) n = -n, x = 1/x;
341                 for(u = n; ; ) {
342                         if(u & 01) pow *= x;
343                         if(u >>= 1) x *= x;
344                         else break;
345                 }
346         }
347         return pow;
348 }
349 #endif
350 static integer pow_ii(integer x, integer n) {
351         integer pow; unsigned long int u;
352         if (n <= 0) {
353                 if (n == 0 || x == 1) pow = 1;
354                 else if (x != -1) pow = x == 0 ? 1/x : 0;
355                 else n = -n;
356         }
357         if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
358                 u = n;
359                 for(pow = 1; ; ) {
360                         if(u & 01) pow *= x;
361                         if(u >>= 1) x *= x;
362                         else break;
363                 }
364         }
365         return pow;
366 }
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
368 {
369         double m; integer i, mi;
370         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371                 if (w[i-1]>m) mi=i ,m=w[i-1];
372         return mi-s+1;
373 }
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
375 {
376         float m; integer i, mi;
377         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378                 if (w[i-1]>m) mi=i ,m=w[i-1];
379         return mi-s+1;
380 }
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382         integer n = *n_, incx = *incx_, incy = *incy_, i;
383 #ifdef _MSC_VER
384         _Fcomplex zdotc = {0.0, 0.0};
385         if (incx == 1 && incy == 1) {
386                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387                         zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388                         zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
389                 }
390         } else {
391                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392                         zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393                         zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
394                 }
395         }
396         pCf(z) = zdotc;
397 }
398 #else
399         _Complex float zdotc = 0.0;
400         if (incx == 1 && incy == 1) {
401                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402                         zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
403                 }
404         } else {
405                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406                         zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
407                 }
408         }
409         pCf(z) = zdotc;
410 }
411 #endif
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413         integer n = *n_, incx = *incx_, incy = *incy_, i;
414 #ifdef _MSC_VER
415         _Dcomplex zdotc = {0.0, 0.0};
416         if (incx == 1 && incy == 1) {
417                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418                         zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419                         zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
420                 }
421         } else {
422                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423                         zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424                         zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
425                 }
426         }
427         pCd(z) = zdotc;
428 }
429 #else
430         _Complex double zdotc = 0.0;
431         if (incx == 1 && incy == 1) {
432                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433                         zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
434                 }
435         } else {
436                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437                         zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
438                 }
439         }
440         pCd(z) = zdotc;
441 }
442 #endif  
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444         integer n = *n_, incx = *incx_, incy = *incy_, i;
445 #ifdef _MSC_VER
446         _Fcomplex zdotc = {0.0, 0.0};
447         if (incx == 1 && incy == 1) {
448                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449                         zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450                         zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
451                 }
452         } else {
453                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454                         zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455                         zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
456                 }
457         }
458         pCf(z) = zdotc;
459 }
460 #else
461         _Complex float zdotc = 0.0;
462         if (incx == 1 && incy == 1) {
463                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464                         zdotc += Cf(&x[i]) * Cf(&y[i]);
465                 }
466         } else {
467                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468                         zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
469                 }
470         }
471         pCf(z) = zdotc;
472 }
473 #endif
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475         integer n = *n_, incx = *incx_, incy = *incy_, i;
476 #ifdef _MSC_VER
477         _Dcomplex zdotc = {0.0, 0.0};
478         if (incx == 1 && incy == 1) {
479                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480                         zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481                         zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
482                 }
483         } else {
484                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485                         zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486                         zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
487                 }
488         }
489         pCd(z) = zdotc;
490 }
491 #else
492         _Complex double zdotc = 0.0;
493         if (incx == 1 && incy == 1) {
494                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495                         zdotc += Cd(&x[i]) * Cd(&y[i]);
496                 }
497         } else {
498                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499                         zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
500                 }
501         }
502         pCd(z) = zdotc;
503 }
504 #endif
505 /*  -- translated by f2c (version 20000121).
506    You must link the resulting object file with the libraries:
507         -lf2c -lm   (in that order)
508 */
509
510
511 /*  -- translated by f2c (version 20000121).
512    You must link the resulting object file with the libraries:
513         -lf2c -lm   (in that order)
514 */
515
516
517
518 /* Table of constant values */
519
520 static complex c_b1 = {0.f,0.f};
521 static complex c_b2 = {1.f,0.f};
522 static integer c__1 = 1;
523
524 /* > \brief \b CGBBRD */
525
526 /*  =========== DOCUMENTATION =========== */
527
528 /* Online html documentation available at */
529 /*            http://www.netlib.org/lapack/explore-html/ */
530
531 /* > \htmlonly */
532 /* > Download CGBBRD + dependencies */
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbbrd.
534 f"> */
535 /* > [TGZ]</a> */
536 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbbrd.
537 f"> */
538 /* > [ZIP]</a> */
539 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbbrd.
540 f"> */
541 /* > [TXT]</a> */
542 /* > \endhtmlonly */
543
544 /*  Definition: */
545 /*  =========== */
546
547 /*       SUBROUTINE CGBBRD( VECT, M, N, NCC, KL, KU, AB, LDAB, D, E, Q, */
548 /*                          LDQ, PT, LDPT, C, LDC, WORK, RWORK, INFO ) */
549
550 /*       CHARACTER          VECT */
551 /*       INTEGER            INFO, KL, KU, LDAB, LDC, LDPT, LDQ, M, N, NCC */
552 /*       REAL               D( * ), E( * ), RWORK( * ) */
553 /*       COMPLEX            AB( LDAB, * ), C( LDC, * ), PT( LDPT, * ), */
554 /*      $                   Q( LDQ, * ), WORK( * ) */
555
556
557 /* > \par Purpose: */
558 /*  ============= */
559 /* > */
560 /* > \verbatim */
561 /* > */
562 /* > CGBBRD reduces a complex general m-by-n band matrix A to real upper */
563 /* > bidiagonal form B by a unitary transformation: Q**H * A * P = B. */
564 /* > */
565 /* > The routine computes B, and optionally forms Q or P**H, or computes */
566 /* > Q**H*C for a given matrix C. */
567 /* > \endverbatim */
568
569 /*  Arguments: */
570 /*  ========== */
571
572 /* > \param[in] VECT */
573 /* > \verbatim */
574 /* >          VECT is CHARACTER*1 */
575 /* >          Specifies whether or not the matrices Q and P**H are to be */
576 /* >          formed. */
577 /* >          = 'N': do not form Q or P**H; */
578 /* >          = 'Q': form Q only; */
579 /* >          = 'P': form P**H only; */
580 /* >          = 'B': form both. */
581 /* > \endverbatim */
582 /* > */
583 /* > \param[in] M */
584 /* > \verbatim */
585 /* >          M is INTEGER */
586 /* >          The number of rows of the matrix A.  M >= 0. */
587 /* > \endverbatim */
588 /* > */
589 /* > \param[in] N */
590 /* > \verbatim */
591 /* >          N is INTEGER */
592 /* >          The number of columns of the matrix A.  N >= 0. */
593 /* > \endverbatim */
594 /* > */
595 /* > \param[in] NCC */
596 /* > \verbatim */
597 /* >          NCC is INTEGER */
598 /* >          The number of columns of the matrix C.  NCC >= 0. */
599 /* > \endverbatim */
600 /* > */
601 /* > \param[in] KL */
602 /* > \verbatim */
603 /* >          KL is INTEGER */
604 /* >          The number of subdiagonals of the matrix A. KL >= 0. */
605 /* > \endverbatim */
606 /* > */
607 /* > \param[in] KU */
608 /* > \verbatim */
609 /* >          KU is INTEGER */
610 /* >          The number of superdiagonals of the matrix A. KU >= 0. */
611 /* > \endverbatim */
612 /* > */
613 /* > \param[in,out] AB */
614 /* > \verbatim */
615 /* >          AB is COMPLEX array, dimension (LDAB,N) */
616 /* >          On entry, the m-by-n band matrix A, stored in rows 1 to */
617 /* >          KL+KU+1. The j-th column of A is stored in the j-th column of */
618 /* >          the array AB as follows: */
619 /* >          AB(ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(m,j+kl). */
620 /* >          On exit, A is overwritten by values generated during the */
621 /* >          reduction. */
622 /* > \endverbatim */
623 /* > */
624 /* > \param[in] LDAB */
625 /* > \verbatim */
626 /* >          LDAB is INTEGER */
627 /* >          The leading dimension of the array A. LDAB >= KL+KU+1. */
628 /* > \endverbatim */
629 /* > */
630 /* > \param[out] D */
631 /* > \verbatim */
632 /* >          D is REAL array, dimension (f2cmin(M,N)) */
633 /* >          The diagonal elements of the bidiagonal matrix B. */
634 /* > \endverbatim */
635 /* > */
636 /* > \param[out] E */
637 /* > \verbatim */
638 /* >          E is REAL array, dimension (f2cmin(M,N)-1) */
639 /* >          The superdiagonal elements of the bidiagonal matrix B. */
640 /* > \endverbatim */
641 /* > */
642 /* > \param[out] Q */
643 /* > \verbatim */
644 /* >          Q is COMPLEX array, dimension (LDQ,M) */
645 /* >          If VECT = 'Q' or 'B', the m-by-m unitary matrix Q. */
646 /* >          If VECT = 'N' or 'P', the array Q is not referenced. */
647 /* > \endverbatim */
648 /* > */
649 /* > \param[in] LDQ */
650 /* > \verbatim */
651 /* >          LDQ is INTEGER */
652 /* >          The leading dimension of the array Q. */
653 /* >          LDQ >= f2cmax(1,M) if VECT = 'Q' or 'B'; LDQ >= 1 otherwise. */
654 /* > \endverbatim */
655 /* > */
656 /* > \param[out] PT */
657 /* > \verbatim */
658 /* >          PT is COMPLEX array, dimension (LDPT,N) */
659 /* >          If VECT = 'P' or 'B', the n-by-n unitary matrix P'. */
660 /* >          If VECT = 'N' or 'Q', the array PT is not referenced. */
661 /* > \endverbatim */
662 /* > */
663 /* > \param[in] LDPT */
664 /* > \verbatim */
665 /* >          LDPT is INTEGER */
666 /* >          The leading dimension of the array PT. */
667 /* >          LDPT >= f2cmax(1,N) if VECT = 'P' or 'B'; LDPT >= 1 otherwise. */
668 /* > \endverbatim */
669 /* > */
670 /* > \param[in,out] C */
671 /* > \verbatim */
672 /* >          C is COMPLEX array, dimension (LDC,NCC) */
673 /* >          On entry, an m-by-ncc matrix C. */
674 /* >          On exit, C is overwritten by Q**H*C. */
675 /* >          C is not referenced if NCC = 0. */
676 /* > \endverbatim */
677 /* > */
678 /* > \param[in] LDC */
679 /* > \verbatim */
680 /* >          LDC is INTEGER */
681 /* >          The leading dimension of the array C. */
682 /* >          LDC >= f2cmax(1,M) if NCC > 0; LDC >= 1 if NCC = 0. */
683 /* > \endverbatim */
684 /* > */
685 /* > \param[out] WORK */
686 /* > \verbatim */
687 /* >          WORK is COMPLEX array, dimension (f2cmax(M,N)) */
688 /* > \endverbatim */
689 /* > */
690 /* > \param[out] RWORK */
691 /* > \verbatim */
692 /* >          RWORK is REAL array, dimension (f2cmax(M,N)) */
693 /* > \endverbatim */
694 /* > */
695 /* > \param[out] INFO */
696 /* > \verbatim */
697 /* >          INFO is INTEGER */
698 /* >          = 0:  successful exit. */
699 /* >          < 0:  if INFO = -i, the i-th argument had an illegal value. */
700 /* > \endverbatim */
701
702 /*  Authors: */
703 /*  ======== */
704
705 /* > \author Univ. of Tennessee */
706 /* > \author Univ. of California Berkeley */
707 /* > \author Univ. of Colorado Denver */
708 /* > \author NAG Ltd. */
709
710 /* > \date December 2016 */
711
712 /* > \ingroup complexGBcomputational */
713
714 /*  ===================================================================== */
715 /* Subroutine */ int cgbbrd_(char *vect, integer *m, integer *n, integer *ncc,
716          integer *kl, integer *ku, complex *ab, integer *ldab, real *d__, 
717         real *e, complex *q, integer *ldq, complex *pt, integer *ldpt, 
718         complex *c__, integer *ldc, complex *work, real *rwork, integer *info)
719 {
720     /* System generated locals */
721     integer ab_dim1, ab_offset, c_dim1, c_offset, pt_dim1, pt_offset, q_dim1, 
722             q_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7;
723     complex q__1, q__2, q__3;
724
725     /* Local variables */
726     integer inca;
727     real abst;
728     extern /* Subroutine */ int crot_(integer *, complex *, integer *, 
729             complex *, integer *, real *, complex *);
730     integer i__, j, l;
731     complex t;
732     extern /* Subroutine */ int cscal_(integer *, complex *, complex *, 
733             integer *);
734     extern logical lsame_(char *, char *);
735     logical wantb, wantc;
736     integer minmn;
737     logical wantq;
738     integer j1, j2, kb;
739     complex ra;
740     real rc;
741     integer kk;
742     complex rb;
743     integer ml, nr, mu;
744     complex rs;
745     extern /* Subroutine */ int claset_(char *, integer *, integer *, complex 
746             *, complex *, complex *, integer *), clartg_(complex *, 
747             complex *, real *, complex *, complex *), xerbla_(char *, integer 
748             *, ftnlen), clargv_(integer *, complex *, integer *, complex *, 
749             integer *, real *, integer *), clartv_(integer *, complex *, 
750             integer *, complex *, integer *, real *, complex *, integer *);
751     integer kb1, ml0;
752     logical wantpt;
753     integer mu0, klm, kun, nrt, klu1;
754
755
756 /*  -- LAPACK computational routine (version 3.7.0) -- */
757 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
758 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
759 /*     December 2016 */
760
761
762 /*  ===================================================================== */
763
764
765 /*     Test the input parameters */
766
767     /* Parameter adjustments */
768     ab_dim1 = *ldab;
769     ab_offset = 1 + ab_dim1 * 1;
770     ab -= ab_offset;
771     --d__;
772     --e;
773     q_dim1 = *ldq;
774     q_offset = 1 + q_dim1 * 1;
775     q -= q_offset;
776     pt_dim1 = *ldpt;
777     pt_offset = 1 + pt_dim1 * 1;
778     pt -= pt_offset;
779     c_dim1 = *ldc;
780     c_offset = 1 + c_dim1 * 1;
781     c__ -= c_offset;
782     --work;
783     --rwork;
784
785     /* Function Body */
786     wantb = lsame_(vect, "B");
787     wantq = lsame_(vect, "Q") || wantb;
788     wantpt = lsame_(vect, "P") || wantb;
789     wantc = *ncc > 0;
790     klu1 = *kl + *ku + 1;
791     *info = 0;
792     if (! wantq && ! wantpt && ! lsame_(vect, "N")) {
793         *info = -1;
794     } else if (*m < 0) {
795         *info = -2;
796     } else if (*n < 0) {
797         *info = -3;
798     } else if (*ncc < 0) {
799         *info = -4;
800     } else if (*kl < 0) {
801         *info = -5;
802     } else if (*ku < 0) {
803         *info = -6;
804     } else if (*ldab < klu1) {
805         *info = -8;
806     } else if (*ldq < 1 || wantq && *ldq < f2cmax(1,*m)) {
807         *info = -12;
808     } else if (*ldpt < 1 || wantpt && *ldpt < f2cmax(1,*n)) {
809         *info = -14;
810     } else if (*ldc < 1 || wantc && *ldc < f2cmax(1,*m)) {
811         *info = -16;
812     }
813     if (*info != 0) {
814         i__1 = -(*info);
815         xerbla_("CGBBRD", &i__1, (ftnlen)6);
816         return 0;
817     }
818
819 /*     Initialize Q and P**H to the unit matrix, if needed */
820
821     if (wantq) {
822         claset_("Full", m, m, &c_b1, &c_b2, &q[q_offset], ldq);
823     }
824     if (wantpt) {
825         claset_("Full", n, n, &c_b1, &c_b2, &pt[pt_offset], ldpt);
826     }
827
828 /*     Quick return if possible. */
829
830     if (*m == 0 || *n == 0) {
831         return 0;
832     }
833
834     minmn = f2cmin(*m,*n);
835
836     if (*kl + *ku > 1) {
837
838 /*        Reduce to upper bidiagonal form if KU > 0; if KU = 0, reduce */
839 /*        first to lower bidiagonal form and then transform to upper */
840 /*        bidiagonal */
841
842         if (*ku > 0) {
843             ml0 = 1;
844             mu0 = 2;
845         } else {
846             ml0 = 2;
847             mu0 = 1;
848         }
849
850 /*        Wherever possible, plane rotations are generated and applied in */
851 /*        vector operations of length NR over the index set J1:J2:KLU1. */
852
853 /*        The complex sines of the plane rotations are stored in WORK, */
854 /*        and the real cosines in RWORK. */
855
856 /* Computing MIN */
857         i__1 = *m - 1;
858         klm = f2cmin(i__1,*kl);
859 /* Computing MIN */
860         i__1 = *n - 1;
861         kun = f2cmin(i__1,*ku);
862         kb = klm + kun;
863         kb1 = kb + 1;
864         inca = kb1 * *ldab;
865         nr = 0;
866         j1 = klm + 2;
867         j2 = 1 - kun;
868
869         i__1 = minmn;
870         for (i__ = 1; i__ <= i__1; ++i__) {
871
872 /*           Reduce i-th column and i-th row of matrix to bidiagonal form */
873
874             ml = klm + 1;
875             mu = kun + 1;
876             i__2 = kb;
877             for (kk = 1; kk <= i__2; ++kk) {
878                 j1 += kb;
879                 j2 += kb;
880
881 /*              generate plane rotations to annihilate nonzero elements */
882 /*              which have been created below the band */
883
884                 if (nr > 0) {
885                     clargv_(&nr, &ab[klu1 + (j1 - klm - 1) * ab_dim1], &inca, 
886                             &work[j1], &kb1, &rwork[j1], &kb1);
887                 }
888
889 /*              apply plane rotations from the left */
890
891                 i__3 = kb;
892                 for (l = 1; l <= i__3; ++l) {
893                     if (j2 - klm + l - 1 > *n) {
894                         nrt = nr - 1;
895                     } else {
896                         nrt = nr;
897                     }
898                     if (nrt > 0) {
899                         clartv_(&nrt, &ab[klu1 - l + (j1 - klm + l - 1) * 
900                                 ab_dim1], &inca, &ab[klu1 - l + 1 + (j1 - klm 
901                                 + l - 1) * ab_dim1], &inca, &rwork[j1], &work[
902                                 j1], &kb1);
903                     }
904 /* L10: */
905                 }
906
907                 if (ml > ml0) {
908                     if (ml <= *m - i__ + 1) {
909
910 /*                    generate plane rotation to annihilate a(i+ml-1,i) */
911 /*                    within the band, and apply rotation from the left */
912
913                         clartg_(&ab[*ku + ml - 1 + i__ * ab_dim1], &ab[*ku + 
914                                 ml + i__ * ab_dim1], &rwork[i__ + ml - 1], &
915                                 work[i__ + ml - 1], &ra);
916                         i__3 = *ku + ml - 1 + i__ * ab_dim1;
917                         ab[i__3].r = ra.r, ab[i__3].i = ra.i;
918                         if (i__ < *n) {
919 /* Computing MIN */
920                             i__4 = *ku + ml - 2, i__5 = *n - i__;
921                             i__3 = f2cmin(i__4,i__5);
922                             i__6 = *ldab - 1;
923                             i__7 = *ldab - 1;
924                             crot_(&i__3, &ab[*ku + ml - 2 + (i__ + 1) * 
925                                     ab_dim1], &i__6, &ab[*ku + ml - 1 + (i__ 
926                                     + 1) * ab_dim1], &i__7, &rwork[i__ + ml - 
927                                     1], &work[i__ + ml - 1]);
928                         }
929                     }
930                     ++nr;
931                     j1 -= kb1;
932                 }
933
934                 if (wantq) {
935
936 /*                 accumulate product of plane rotations in Q */
937
938                     i__3 = j2;
939                     i__4 = kb1;
940                     for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) 
941                             {
942                         r_cnjg(&q__1, &work[j]);
943                         crot_(m, &q[(j - 1) * q_dim1 + 1], &c__1, &q[j * 
944                                 q_dim1 + 1], &c__1, &rwork[j], &q__1);
945 /* L20: */
946                     }
947                 }
948
949                 if (wantc) {
950
951 /*                 apply plane rotations to C */
952
953                     i__4 = j2;
954                     i__3 = kb1;
955                     for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) 
956                             {
957                         crot_(ncc, &c__[j - 1 + c_dim1], ldc, &c__[j + c_dim1]
958                                 , ldc, &rwork[j], &work[j]);
959 /* L30: */
960                     }
961                 }
962
963                 if (j2 + kun > *n) {
964
965 /*                 adjust J2 to keep within the bounds of the matrix */
966
967                     --nr;
968                     j2 -= kb1;
969                 }
970
971                 i__3 = j2;
972                 i__4 = kb1;
973                 for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
974
975 /*                 create nonzero element a(j-1,j+ku) above the band */
976 /*                 and store it in WORK(n+1:2*n) */
977
978                     i__5 = j + kun;
979                     i__6 = j;
980                     i__7 = (j + kun) * ab_dim1 + 1;
981                     q__1.r = work[i__6].r * ab[i__7].r - work[i__6].i * ab[
982                             i__7].i, q__1.i = work[i__6].r * ab[i__7].i + 
983                             work[i__6].i * ab[i__7].r;
984                     work[i__5].r = q__1.r, work[i__5].i = q__1.i;
985                     i__5 = (j + kun) * ab_dim1 + 1;
986                     i__6 = j;
987                     i__7 = (j + kun) * ab_dim1 + 1;
988                     q__1.r = rwork[i__6] * ab[i__7].r, q__1.i = rwork[i__6] * 
989                             ab[i__7].i;
990                     ab[i__5].r = q__1.r, ab[i__5].i = q__1.i;
991 /* L40: */
992                 }
993
994 /*              generate plane rotations to annihilate nonzero elements */
995 /*              which have been generated above the band */
996
997                 if (nr > 0) {
998                     clargv_(&nr, &ab[(j1 + kun - 1) * ab_dim1 + 1], &inca, &
999                             work[j1 + kun], &kb1, &rwork[j1 + kun], &kb1);
1000                 }
1001
1002 /*              apply plane rotations from the right */
1003
1004                 i__4 = kb;
1005                 for (l = 1; l <= i__4; ++l) {
1006                     if (j2 + l - 1 > *m) {
1007                         nrt = nr - 1;
1008                     } else {
1009                         nrt = nr;
1010                     }
1011                     if (nrt > 0) {
1012                         clartv_(&nrt, &ab[l + 1 + (j1 + kun - 1) * ab_dim1], &
1013                                 inca, &ab[l + (j1 + kun) * ab_dim1], &inca, &
1014                                 rwork[j1 + kun], &work[j1 + kun], &kb1);
1015                     }
1016 /* L50: */
1017                 }
1018
1019                 if (ml == ml0 && mu > mu0) {
1020                     if (mu <= *n - i__ + 1) {
1021
1022 /*                    generate plane rotation to annihilate a(i,i+mu-1) */
1023 /*                    within the band, and apply rotation from the right */
1024
1025                         clartg_(&ab[*ku - mu + 3 + (i__ + mu - 2) * ab_dim1], 
1026                                 &ab[*ku - mu + 2 + (i__ + mu - 1) * ab_dim1], 
1027                                 &rwork[i__ + mu - 1], &work[i__ + mu - 1], &
1028                                 ra);
1029                         i__4 = *ku - mu + 3 + (i__ + mu - 2) * ab_dim1;
1030                         ab[i__4].r = ra.r, ab[i__4].i = ra.i;
1031 /* Computing MIN */
1032                         i__3 = *kl + mu - 2, i__5 = *m - i__;
1033                         i__4 = f2cmin(i__3,i__5);
1034                         crot_(&i__4, &ab[*ku - mu + 4 + (i__ + mu - 2) * 
1035                                 ab_dim1], &c__1, &ab[*ku - mu + 3 + (i__ + mu 
1036                                 - 1) * ab_dim1], &c__1, &rwork[i__ + mu - 1], 
1037                                 &work[i__ + mu - 1]);
1038                     }
1039                     ++nr;
1040                     j1 -= kb1;
1041                 }
1042
1043                 if (wantpt) {
1044
1045 /*                 accumulate product of plane rotations in P**H */
1046
1047                     i__4 = j2;
1048                     i__3 = kb1;
1049                     for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) 
1050                             {
1051                         r_cnjg(&q__1, &work[j + kun]);
1052                         crot_(n, &pt[j + kun - 1 + pt_dim1], ldpt, &pt[j + 
1053                                 kun + pt_dim1], ldpt, &rwork[j + kun], &q__1);
1054 /* L60: */
1055                     }
1056                 }
1057
1058                 if (j2 + kb > *m) {
1059
1060 /*                 adjust J2 to keep within the bounds of the matrix */
1061
1062                     --nr;
1063                     j2 -= kb1;
1064                 }
1065
1066                 i__3 = j2;
1067                 i__4 = kb1;
1068                 for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
1069
1070 /*                 create nonzero element a(j+kl+ku,j+ku-1) below the */
1071 /*                 band and store it in WORK(1:n) */
1072
1073                     i__5 = j + kb;
1074                     i__6 = j + kun;
1075                     i__7 = klu1 + (j + kun) * ab_dim1;
1076                     q__1.r = work[i__6].r * ab[i__7].r - work[i__6].i * ab[
1077                             i__7].i, q__1.i = work[i__6].r * ab[i__7].i + 
1078                             work[i__6].i * ab[i__7].r;
1079                     work[i__5].r = q__1.r, work[i__5].i = q__1.i;
1080                     i__5 = klu1 + (j + kun) * ab_dim1;
1081                     i__6 = j + kun;
1082                     i__7 = klu1 + (j + kun) * ab_dim1;
1083                     q__1.r = rwork[i__6] * ab[i__7].r, q__1.i = rwork[i__6] * 
1084                             ab[i__7].i;
1085                     ab[i__5].r = q__1.r, ab[i__5].i = q__1.i;
1086 /* L70: */
1087                 }
1088
1089                 if (ml > ml0) {
1090                     --ml;
1091                 } else {
1092                     --mu;
1093                 }
1094 /* L80: */
1095             }
1096 /* L90: */
1097         }
1098     }
1099
1100     if (*ku == 0 && *kl > 0) {
1101
1102 /*        A has been reduced to complex lower bidiagonal form */
1103
1104 /*        Transform lower bidiagonal form to upper bidiagonal by applying */
1105 /*        plane rotations from the left, overwriting superdiagonal */
1106 /*        elements on subdiagonal elements */
1107
1108 /* Computing MIN */
1109         i__2 = *m - 1;
1110         i__1 = f2cmin(i__2,*n);
1111         for (i__ = 1; i__ <= i__1; ++i__) {
1112             clartg_(&ab[i__ * ab_dim1 + 1], &ab[i__ * ab_dim1 + 2], &rc, &rs, 
1113                     &ra);
1114             i__2 = i__ * ab_dim1 + 1;
1115             ab[i__2].r = ra.r, ab[i__2].i = ra.i;
1116             if (i__ < *n) {
1117                 i__2 = i__ * ab_dim1 + 2;
1118                 i__4 = (i__ + 1) * ab_dim1 + 1;
1119                 q__1.r = rs.r * ab[i__4].r - rs.i * ab[i__4].i, q__1.i = rs.r 
1120                         * ab[i__4].i + rs.i * ab[i__4].r;
1121                 ab[i__2].r = q__1.r, ab[i__2].i = q__1.i;
1122                 i__2 = (i__ + 1) * ab_dim1 + 1;
1123                 i__4 = (i__ + 1) * ab_dim1 + 1;
1124                 q__1.r = rc * ab[i__4].r, q__1.i = rc * ab[i__4].i;
1125                 ab[i__2].r = q__1.r, ab[i__2].i = q__1.i;
1126             }
1127             if (wantq) {
1128                 r_cnjg(&q__1, &rs);
1129                 crot_(m, &q[i__ * q_dim1 + 1], &c__1, &q[(i__ + 1) * q_dim1 + 
1130                         1], &c__1, &rc, &q__1);
1131             }
1132             if (wantc) {
1133                 crot_(ncc, &c__[i__ + c_dim1], ldc, &c__[i__ + 1 + c_dim1], 
1134                         ldc, &rc, &rs);
1135             }
1136 /* L100: */
1137         }
1138     } else {
1139
1140 /*        A has been reduced to complex upper bidiagonal form or is */
1141 /*        diagonal */
1142
1143         if (*ku > 0 && *m < *n) {
1144
1145 /*           Annihilate a(m,m+1) by applying plane rotations from the */
1146 /*           right */
1147
1148             i__1 = *ku + (*m + 1) * ab_dim1;
1149             rb.r = ab[i__1].r, rb.i = ab[i__1].i;
1150             for (i__ = *m; i__ >= 1; --i__) {
1151                 clartg_(&ab[*ku + 1 + i__ * ab_dim1], &rb, &rc, &rs, &ra);
1152                 i__1 = *ku + 1 + i__ * ab_dim1;
1153                 ab[i__1].r = ra.r, ab[i__1].i = ra.i;
1154                 if (i__ > 1) {
1155                     r_cnjg(&q__3, &rs);
1156                     q__2.r = -q__3.r, q__2.i = -q__3.i;
1157                     i__1 = *ku + i__ * ab_dim1;
1158                     q__1.r = q__2.r * ab[i__1].r - q__2.i * ab[i__1].i, 
1159                             q__1.i = q__2.r * ab[i__1].i + q__2.i * ab[i__1]
1160                             .r;
1161                     rb.r = q__1.r, rb.i = q__1.i;
1162                     i__1 = *ku + i__ * ab_dim1;
1163                     i__2 = *ku + i__ * ab_dim1;
1164                     q__1.r = rc * ab[i__2].r, q__1.i = rc * ab[i__2].i;
1165                     ab[i__1].r = q__1.r, ab[i__1].i = q__1.i;
1166                 }
1167                 if (wantpt) {
1168                     r_cnjg(&q__1, &rs);
1169                     crot_(n, &pt[i__ + pt_dim1], ldpt, &pt[*m + 1 + pt_dim1], 
1170                             ldpt, &rc, &q__1);
1171                 }
1172 /* L110: */
1173             }
1174         }
1175     }
1176
1177 /*     Make diagonal and superdiagonal elements real, storing them in D */
1178 /*     and E */
1179
1180     i__1 = *ku + 1 + ab_dim1;
1181     t.r = ab[i__1].r, t.i = ab[i__1].i;
1182     i__1 = minmn;
1183     for (i__ = 1; i__ <= i__1; ++i__) {
1184         abst = c_abs(&t);
1185         d__[i__] = abst;
1186         if (abst != 0.f) {
1187             q__1.r = t.r / abst, q__1.i = t.i / abst;
1188             t.r = q__1.r, t.i = q__1.i;
1189         } else {
1190             t.r = 1.f, t.i = 0.f;
1191         }
1192         if (wantq) {
1193             cscal_(m, &t, &q[i__ * q_dim1 + 1], &c__1);
1194         }
1195         if (wantc) {
1196             r_cnjg(&q__1, &t);
1197             cscal_(ncc, &q__1, &c__[i__ + c_dim1], ldc);
1198         }
1199         if (i__ < minmn) {
1200             if (*ku == 0 && *kl == 0) {
1201                 e[i__] = 0.f;
1202                 i__2 = (i__ + 1) * ab_dim1 + 1;
1203                 t.r = ab[i__2].r, t.i = ab[i__2].i;
1204             } else {
1205                 if (*ku == 0) {
1206                     i__2 = i__ * ab_dim1 + 2;
1207                     r_cnjg(&q__2, &t);
1208                     q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i, 
1209                             q__1.i = ab[i__2].r * q__2.i + ab[i__2].i * 
1210                             q__2.r;
1211                     t.r = q__1.r, t.i = q__1.i;
1212                 } else {
1213                     i__2 = *ku + (i__ + 1) * ab_dim1;
1214                     r_cnjg(&q__2, &t);
1215                     q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i, 
1216                             q__1.i = ab[i__2].r * q__2.i + ab[i__2].i * 
1217                             q__2.r;
1218                     t.r = q__1.r, t.i = q__1.i;
1219                 }
1220                 abst = c_abs(&t);
1221                 e[i__] = abst;
1222                 if (abst != 0.f) {
1223                     q__1.r = t.r / abst, q__1.i = t.i / abst;
1224                     t.r = q__1.r, t.i = q__1.i;
1225                 } else {
1226                     t.r = 1.f, t.i = 0.f;
1227                 }
1228                 if (wantpt) {
1229                     cscal_(n, &t, &pt[i__ + 1 + pt_dim1], ldpt);
1230                 }
1231                 i__2 = *ku + 1 + (i__ + 1) * ab_dim1;
1232                 r_cnjg(&q__2, &t);
1233                 q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i, q__1.i = 
1234                         ab[i__2].r * q__2.i + ab[i__2].i * q__2.r;
1235                 t.r = q__1.r, t.i = q__1.i;
1236             }
1237         }
1238 /* L120: */
1239     }
1240     return 0;
1241
1242 /*     End of CGBBRD */
1243
1244 } /* cgbbrd_ */
1245