C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / SRC / zlatbs.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]/Cd(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
512
513 /* Table of constant values */
514
515 static integer c__1 = 1;
516 static doublereal c_b36 = .5;
517
518 /* > \brief \b ZLATBS solves a triangular banded system of equations. */
519
520 /*  =========== DOCUMENTATION =========== */
521
522 /* Online html documentation available at */
523 /*            http://www.netlib.org/lapack/explore-html/ */
524
525 /* > \htmlonly */
526 /* > Download ZLATBS + dependencies */
527 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlatbs.
528 f"> */
529 /* > [TGZ]</a> */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlatbs.
531 f"> */
532 /* > [ZIP]</a> */
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlatbs.
534 f"> */
535 /* > [TXT]</a> */
536 /* > \endhtmlonly */
537
538 /*  Definition: */
539 /*  =========== */
540
541 /*       SUBROUTINE ZLATBS( UPLO, TRANS, DIAG, NORMIN, N, KD, AB, LDAB, X, */
542 /*                          SCALE, CNORM, INFO ) */
543
544 /*       CHARACTER          DIAG, NORMIN, TRANS, UPLO */
545 /*       INTEGER            INFO, KD, LDAB, N */
546 /*       DOUBLE PRECISION   SCALE */
547 /*       DOUBLE PRECISION   CNORM( * ) */
548 /*       COMPLEX*16         AB( LDAB, * ), X( * ) */
549
550
551 /* > \par Purpose: */
552 /*  ============= */
553 /* > */
554 /* > \verbatim */
555 /* > */
556 /* > ZLATBS solves one of the triangular systems */
557 /* > */
558 /* >    A * x = s*b,  A**T * x = s*b,  or  A**H * x = s*b, */
559 /* > */
560 /* > with scaling to prevent overflow, where A is an upper or lower */
561 /* > triangular band matrix.  Here A**T denotes the transpose of A, x and b */
562 /* > are n-element vectors, and s is a scaling factor, usually less than */
563 /* > or equal to 1, chosen so that the components of x will be less than */
564 /* > the overflow threshold.  If the unscaled problem will not cause */
565 /* > overflow, the Level 2 BLAS routine ZTBSV is called.  If the matrix A */
566 /* > is singular (A(j,j) = 0 for some j), then s is set to 0 and a */
567 /* > non-trivial solution to A*x = 0 is returned. */
568 /* > \endverbatim */
569
570 /*  Arguments: */
571 /*  ========== */
572
573 /* > \param[in] UPLO */
574 /* > \verbatim */
575 /* >          UPLO is CHARACTER*1 */
576 /* >          Specifies whether the matrix A is upper or lower triangular. */
577 /* >          = 'U':  Upper triangular */
578 /* >          = 'L':  Lower triangular */
579 /* > \endverbatim */
580 /* > */
581 /* > \param[in] TRANS */
582 /* > \verbatim */
583 /* >          TRANS is CHARACTER*1 */
584 /* >          Specifies the operation applied to A. */
585 /* >          = 'N':  Solve A * x = s*b     (No transpose) */
586 /* >          = 'T':  Solve A**T * x = s*b  (Transpose) */
587 /* >          = 'C':  Solve A**H * x = s*b  (Conjugate transpose) */
588 /* > \endverbatim */
589 /* > */
590 /* > \param[in] DIAG */
591 /* > \verbatim */
592 /* >          DIAG is CHARACTER*1 */
593 /* >          Specifies whether or not the matrix A is unit triangular. */
594 /* >          = 'N':  Non-unit triangular */
595 /* >          = 'U':  Unit triangular */
596 /* > \endverbatim */
597 /* > */
598 /* > \param[in] NORMIN */
599 /* > \verbatim */
600 /* >          NORMIN is CHARACTER*1 */
601 /* >          Specifies whether CNORM has been set or not. */
602 /* >          = 'Y':  CNORM contains the column norms on entry */
603 /* >          = 'N':  CNORM is not set on entry.  On exit, the norms will */
604 /* >                  be computed and stored in CNORM. */
605 /* > \endverbatim */
606 /* > */
607 /* > \param[in] N */
608 /* > \verbatim */
609 /* >          N is INTEGER */
610 /* >          The order of the matrix A.  N >= 0. */
611 /* > \endverbatim */
612 /* > */
613 /* > \param[in] KD */
614 /* > \verbatim */
615 /* >          KD is INTEGER */
616 /* >          The number of subdiagonals or superdiagonals in the */
617 /* >          triangular matrix A.  KD >= 0. */
618 /* > \endverbatim */
619 /* > */
620 /* > \param[in] AB */
621 /* > \verbatim */
622 /* >          AB is COMPLEX*16 array, dimension (LDAB,N) */
623 /* >          The upper or lower triangular band matrix A, stored in the */
624 /* >          first KD+1 rows of the array. The j-th column of A is stored */
625 /* >          in the j-th column of the array AB as follows: */
626 /* >          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for f2cmax(1,j-kd)<=i<=j; */
627 /* >          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=f2cmin(n,j+kd). */
628 /* > \endverbatim */
629 /* > */
630 /* > \param[in] LDAB */
631 /* > \verbatim */
632 /* >          LDAB is INTEGER */
633 /* >          The leading dimension of the array AB.  LDAB >= KD+1. */
634 /* > \endverbatim */
635 /* > */
636 /* > \param[in,out] X */
637 /* > \verbatim */
638 /* >          X is COMPLEX*16 array, dimension (N) */
639 /* >          On entry, the right hand side b of the triangular system. */
640 /* >          On exit, X is overwritten by the solution vector x. */
641 /* > \endverbatim */
642 /* > */
643 /* > \param[out] SCALE */
644 /* > \verbatim */
645 /* >          SCALE is DOUBLE PRECISION */
646 /* >          The scaling factor s for the triangular system */
647 /* >             A * x = s*b,  A**T * x = s*b,  or  A**H * x = s*b. */
648 /* >          If SCALE = 0, the matrix A is singular or badly scaled, and */
649 /* >          the vector x is an exact or approximate solution to A*x = 0. */
650 /* > \endverbatim */
651 /* > */
652 /* > \param[in,out] CNORM */
653 /* > \verbatim */
654 /* >          CNORM is DOUBLE PRECISION array, dimension (N) */
655 /* > */
656 /* >          If NORMIN = 'Y', CNORM is an input argument and CNORM(j) */
657 /* >          contains the norm of the off-diagonal part of the j-th column */
658 /* >          of A.  If TRANS = 'N', CNORM(j) must be greater than or equal */
659 /* >          to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j) */
660 /* >          must be greater than or equal to the 1-norm. */
661 /* > */
662 /* >          If NORMIN = 'N', CNORM is an output argument and CNORM(j) */
663 /* >          returns the 1-norm of the offdiagonal part of the j-th column */
664 /* >          of A. */
665 /* > \endverbatim */
666 /* > */
667 /* > \param[out] INFO */
668 /* > \verbatim */
669 /* >          INFO is INTEGER */
670 /* >          = 0:  successful exit */
671 /* >          < 0:  if INFO = -k, the k-th argument had an illegal value */
672 /* > \endverbatim */
673
674 /*  Authors: */
675 /*  ======== */
676
677 /* > \author Univ. of Tennessee */
678 /* > \author Univ. of California Berkeley */
679 /* > \author Univ. of Colorado Denver */
680 /* > \author NAG Ltd. */
681
682 /* > \date November 2017 */
683
684 /* > \ingroup complex16OTHERauxiliary */
685
686 /* > \par Further Details: */
687 /*  ===================== */
688 /* > */
689 /* > \verbatim */
690 /* > */
691 /* >  A rough bound on x is computed; if that is less than overflow, ZTBSV */
692 /* >  is called, otherwise, specific code is used which checks for possible */
693 /* >  overflow or divide-by-zero at every operation. */
694 /* > */
695 /* >  A columnwise scheme is used for solving A*x = b.  The basic algorithm */
696 /* >  if A is lower triangular is */
697 /* > */
698 /* >       x[1:n] := b[1:n] */
699 /* >       for j = 1, ..., n */
700 /* >            x(j) := x(j) / A(j,j) */
701 /* >            x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j] */
702 /* >       end */
703 /* > */
704 /* >  Define bounds on the components of x after j iterations of the loop: */
705 /* >     M(j) = bound on x[1:j] */
706 /* >     G(j) = bound on x[j+1:n] */
707 /* >  Initially, let M(0) = 0 and G(0) = f2cmax{x(i), i=1,...,n}. */
708 /* > */
709 /* >  Then for iteration j+1 we have */
710 /* >     M(j+1) <= G(j) / | A(j+1,j+1) | */
711 /* >     G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] | */
712 /* >            <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | ) */
713 /* > */
714 /* >  where CNORM(j+1) is greater than or equal to the infinity-norm of */
715 /* >  column j+1 of A, not counting the diagonal.  Hence */
716 /* > */
717 /* >     G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | ) */
718 /* >                  1<=i<=j */
719 /* >  and */
720 /* > */
721 /* >     |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| ) */
722 /* >                                   1<=i< j */
723 /* > */
724 /* >  Since |x(j)| <= M(j), we use the Level 2 BLAS routine ZTBSV if the */
725 /* >  reciprocal of the largest M(j), j=1,..,n, is larger than */
726 /* >  f2cmax(underflow, 1/overflow). */
727 /* > */
728 /* >  The bound on x(j) is also used to determine when a step in the */
729 /* >  columnwise method can be performed without fear of overflow.  If */
730 /* >  the computed bound is greater than a large constant, x is scaled to */
731 /* >  prevent overflow, but if the bound overflows, x is set to 0, x(j) to */
732 /* >  1, and scale to 0, and a non-trivial solution to A*x = 0 is found. */
733 /* > */
734 /* >  Similarly, a row-wise scheme is used to solve A**T *x = b  or */
735 /* >  A**H *x = b.  The basic algorithm for A upper triangular is */
736 /* > */
737 /* >       for j = 1, ..., n */
738 /* >            x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j) */
739 /* >       end */
740 /* > */
741 /* >  We simultaneously compute two bounds */
742 /* >       G(j) = bound on ( b(i) - A[1:i-1,i]' * x[1:i-1] ), 1<=i<=j */
743 /* >       M(j) = bound on x(i), 1<=i<=j */
744 /* > */
745 /* >  The initial values are G(0) = 0, M(0) = f2cmax{b(i), i=1,..,n}, and we */
746 /* >  add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1. */
747 /* >  Then the bound on x(j) is */
748 /* > */
749 /* >       M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) | */
750 /* > */
751 /* >            <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| ) */
752 /* >                      1<=i<=j */
753 /* > */
754 /* >  and we can safely call ZTBSV if 1/M(n) and 1/G(n) are both greater */
755 /* >  than f2cmax(underflow, 1/overflow). */
756 /* > \endverbatim */
757 /* > */
758 /*  ===================================================================== */
759 /* Subroutine */ int zlatbs_(char *uplo, char *trans, char *diag, char *
760         normin, integer *n, integer *kd, doublecomplex *ab, integer *ldab, 
761         doublecomplex *x, doublereal *scale, doublereal *cnorm, integer *info)
762 {
763     /* System generated locals */
764     integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5;
765     doublereal d__1, d__2, d__3, d__4;
766     doublecomplex z__1, z__2, z__3, z__4;
767
768     /* Local variables */
769     integer jinc, jlen;
770     doublereal xbnd;
771     integer imax;
772     doublereal tmax;
773     doublecomplex tjjs;
774     doublereal xmax, grow;
775     integer i__, j;
776     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
777             integer *);
778     integer maind;
779     extern logical lsame_(char *, char *);
780     doublereal tscal;
781     doublecomplex uscal;
782     integer jlast;
783     doublecomplex csumj;
784     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
785             doublecomplex *, integer *, doublecomplex *, integer *);
786     logical upper;
787     extern /* Double Complex */ VOID zdotu_(doublecomplex *, integer *, 
788             doublecomplex *, integer *, doublecomplex *, integer *);
789     extern /* Subroutine */ int ztbsv_(char *, char *, char *, integer *, 
790             integer *, doublecomplex *, integer *, doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, 
791             doublecomplex *, integer *, doublecomplex *, integer *), dlabad_(
792             doublereal *, doublereal *);
793     extern doublereal dlamch_(char *);
794     doublereal xj;
795     extern integer idamax_(integer *, doublereal *, integer *);
796     extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), zdscal_(
797             integer *, doublereal *, doublecomplex *, integer *);
798     doublereal bignum;
799     extern integer izamax_(integer *, doublecomplex *, integer *);
800     extern /* Double Complex */ VOID zladiv_(doublecomplex *, doublecomplex *,
801              doublecomplex *);
802     logical notran;
803     integer jfirst;
804     extern doublereal dzasum_(integer *, doublecomplex *, integer *);
805     doublereal smlnum;
806     logical nounit;
807     doublereal rec, tjj;
808
809
810 /*  -- LAPACK auxiliary routine (version 3.8.0) -- */
811 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
812 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
813 /*     November 2017 */
814
815
816 /*  ===================================================================== */
817
818
819     /* Parameter adjustments */
820     ab_dim1 = *ldab;
821     ab_offset = 1 + ab_dim1 * 1;
822     ab -= ab_offset;
823     --x;
824     --cnorm;
825
826     /* Function Body */
827     *info = 0;
828     upper = lsame_(uplo, "U");
829     notran = lsame_(trans, "N");
830     nounit = lsame_(diag, "N");
831
832 /*     Test the input parameters. */
833
834     if (! upper && ! lsame_(uplo, "L")) {
835         *info = -1;
836     } else if (! notran && ! lsame_(trans, "T") && ! 
837             lsame_(trans, "C")) {
838         *info = -2;
839     } else if (! nounit && ! lsame_(diag, "U")) {
840         *info = -3;
841     } else if (! lsame_(normin, "Y") && ! lsame_(normin,
842              "N")) {
843         *info = -4;
844     } else if (*n < 0) {
845         *info = -5;
846     } else if (*kd < 0) {
847         *info = -6;
848     } else if (*ldab < *kd + 1) {
849         *info = -8;
850     }
851     if (*info != 0) {
852         i__1 = -(*info);
853         xerbla_("ZLATBS", &i__1, (ftnlen)6);
854         return 0;
855     }
856
857 /*     Quick return if possible */
858
859     if (*n == 0) {
860         return 0;
861     }
862
863 /*     Determine machine dependent parameters to control overflow. */
864
865     smlnum = dlamch_("Safe minimum");
866     bignum = 1. / smlnum;
867     dlabad_(&smlnum, &bignum);
868     smlnum /= dlamch_("Precision");
869     bignum = 1. / smlnum;
870     *scale = 1.;
871
872     if (lsame_(normin, "N")) {
873
874 /*        Compute the 1-norm of each column, not including the diagonal. */
875
876         if (upper) {
877
878 /*           A is upper triangular. */
879
880             i__1 = *n;
881             for (j = 1; j <= i__1; ++j) {
882 /* Computing MIN */
883                 i__2 = *kd, i__3 = j - 1;
884                 jlen = f2cmin(i__2,i__3);
885                 cnorm[j] = dzasum_(&jlen, &ab[*kd + 1 - jlen + j * ab_dim1], &
886                         c__1);
887 /* L10: */
888             }
889         } else {
890
891 /*           A is lower triangular. */
892
893             i__1 = *n;
894             for (j = 1; j <= i__1; ++j) {
895 /* Computing MIN */
896                 i__2 = *kd, i__3 = *n - j;
897                 jlen = f2cmin(i__2,i__3);
898                 if (jlen > 0) {
899                     cnorm[j] = dzasum_(&jlen, &ab[j * ab_dim1 + 2], &c__1);
900                 } else {
901                     cnorm[j] = 0.;
902                 }
903 /* L20: */
904             }
905         }
906     }
907
908 /*     Scale the column norms by TSCAL if the maximum element in CNORM is */
909 /*     greater than BIGNUM/2. */
910
911     imax = idamax_(n, &cnorm[1], &c__1);
912     tmax = cnorm[imax];
913     if (tmax <= bignum * .5) {
914         tscal = 1.;
915     } else {
916         tscal = .5 / (smlnum * tmax);
917         dscal_(n, &tscal, &cnorm[1], &c__1);
918     }
919
920 /*     Compute a bound on the computed solution vector to see if the */
921 /*     Level 2 BLAS routine ZTBSV can be used. */
922
923     xmax = 0.;
924     i__1 = *n;
925     for (j = 1; j <= i__1; ++j) {
926 /* Computing MAX */
927         i__2 = j;
928         d__3 = xmax, d__4 = (d__1 = x[i__2].r / 2., abs(d__1)) + (d__2 = 
929                 d_imag(&x[j]) / 2., abs(d__2));
930         xmax = f2cmax(d__3,d__4);
931 /* L30: */
932     }
933     xbnd = xmax;
934     if (notran) {
935
936 /*        Compute the growth in A * x = b. */
937
938         if (upper) {
939             jfirst = *n;
940             jlast = 1;
941             jinc = -1;
942             maind = *kd + 1;
943         } else {
944             jfirst = 1;
945             jlast = *n;
946             jinc = 1;
947             maind = 1;
948         }
949
950         if (tscal != 1.) {
951             grow = 0.;
952             goto L60;
953         }
954
955         if (nounit) {
956
957 /*           A is non-unit triangular. */
958
959 /*           Compute GROW = 1/G(j) and XBND = 1/M(j). */
960 /*           Initially, G(0) = f2cmax{x(i), i=1,...,n}. */
961
962             grow = .5 / f2cmax(xbnd,smlnum);
963             xbnd = grow;
964             i__1 = jlast;
965             i__2 = jinc;
966             for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
967
968 /*              Exit the loop if the growth factor is too small. */
969
970                 if (grow <= smlnum) {
971                     goto L60;
972                 }
973
974                 i__3 = maind + j * ab_dim1;
975                 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
976                 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), abs(
977                         d__2));
978
979                 if (tjj >= smlnum) {
980
981 /*                 M(j) = G(j-1) / abs(A(j,j)) */
982
983 /* Computing MIN */
984                     d__1 = xbnd, d__2 = f2cmin(1.,tjj) * grow;
985                     xbnd = f2cmin(d__1,d__2);
986                 } else {
987
988 /*                 M(j) could overflow, set XBND to 0. */
989
990                     xbnd = 0.;
991                 }
992
993                 if (tjj + cnorm[j] >= smlnum) {
994
995 /*                 G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) ) */
996
997                     grow *= tjj / (tjj + cnorm[j]);
998                 } else {
999
1000 /*                 G(j) could overflow, set GROW to 0. */
1001
1002                     grow = 0.;
1003                 }
1004 /* L40: */
1005             }
1006             grow = xbnd;
1007         } else {
1008
1009 /*           A is unit triangular. */
1010
1011 /*           Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
1012
1013 /* Computing MIN */
1014             d__1 = 1., d__2 = .5 / f2cmax(xbnd,smlnum);
1015             grow = f2cmin(d__1,d__2);
1016             i__2 = jlast;
1017             i__1 = jinc;
1018             for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
1019
1020 /*              Exit the loop if the growth factor is too small. */
1021
1022                 if (grow <= smlnum) {
1023                     goto L60;
1024                 }
1025
1026 /*              G(j) = G(j-1)*( 1 + CNORM(j) ) */
1027
1028                 grow *= 1. / (cnorm[j] + 1.);
1029 /* L50: */
1030             }
1031         }
1032 L60:
1033
1034         ;
1035     } else {
1036
1037 /*        Compute the growth in A**T * x = b  or  A**H * x = b. */
1038
1039         if (upper) {
1040             jfirst = 1;
1041             jlast = *n;
1042             jinc = 1;
1043             maind = *kd + 1;
1044         } else {
1045             jfirst = *n;
1046             jlast = 1;
1047             jinc = -1;
1048             maind = 1;
1049         }
1050
1051         if (tscal != 1.) {
1052             grow = 0.;
1053             goto L90;
1054         }
1055
1056         if (nounit) {
1057
1058 /*           A is non-unit triangular. */
1059
1060 /*           Compute GROW = 1/G(j) and XBND = 1/M(j). */
1061 /*           Initially, M(0) = f2cmax{x(i), i=1,...,n}. */
1062
1063             grow = .5 / f2cmax(xbnd,smlnum);
1064             xbnd = grow;
1065             i__1 = jlast;
1066             i__2 = jinc;
1067             for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
1068
1069 /*              Exit the loop if the growth factor is too small. */
1070
1071                 if (grow <= smlnum) {
1072                     goto L90;
1073                 }
1074
1075 /*              G(j) = f2cmax( G(j-1), M(j-1)*( 1 + CNORM(j) ) ) */
1076
1077                 xj = cnorm[j] + 1.;
1078 /* Computing MIN */
1079                 d__1 = grow, d__2 = xbnd / xj;
1080                 grow = f2cmin(d__1,d__2);
1081
1082                 i__3 = maind + j * ab_dim1;
1083                 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
1084                 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), abs(
1085                         d__2));
1086
1087                 if (tjj >= smlnum) {
1088
1089 /*                 M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j)) */
1090
1091                     if (xj > tjj) {
1092                         xbnd *= tjj / xj;
1093                     }
1094                 } else {
1095
1096 /*                 M(j) could overflow, set XBND to 0. */
1097
1098                     xbnd = 0.;
1099                 }
1100 /* L70: */
1101             }
1102             grow = f2cmin(grow,xbnd);
1103         } else {
1104
1105 /*           A is unit triangular. */
1106
1107 /*           Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
1108
1109 /* Computing MIN */
1110             d__1 = 1., d__2 = .5 / f2cmax(xbnd,smlnum);
1111             grow = f2cmin(d__1,d__2);
1112             i__2 = jlast;
1113             i__1 = jinc;
1114             for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
1115
1116 /*              Exit the loop if the growth factor is too small. */
1117
1118                 if (grow <= smlnum) {
1119                     goto L90;
1120                 }
1121
1122 /*              G(j) = ( 1 + CNORM(j) )*G(j-1) */
1123
1124                 xj = cnorm[j] + 1.;
1125                 grow /= xj;
1126 /* L80: */
1127             }
1128         }
1129 L90:
1130         ;
1131     }
1132
1133     if (grow * tscal > smlnum) {
1134
1135 /*        Use the Level 2 BLAS solve if the reciprocal of the bound on */
1136 /*        elements of X is not too small. */
1137
1138         ztbsv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &x[1], &c__1);
1139     } else {
1140
1141 /*        Use a Level 1 BLAS solve, scaling intermediate results. */
1142
1143         if (xmax > bignum * .5) {
1144
1145 /*           Scale X so that its components are less than or equal to */
1146 /*           BIGNUM in absolute value. */
1147
1148             *scale = bignum * .5 / xmax;
1149             zdscal_(n, scale, &x[1], &c__1);
1150             xmax = bignum;
1151         } else {
1152             xmax *= 2.;
1153         }
1154
1155         if (notran) {
1156
1157 /*           Solve A * x = b */
1158
1159             i__1 = jlast;
1160             i__2 = jinc;
1161             for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
1162
1163 /*              Compute x(j) = b(j) / A(j,j), scaling x if necessary. */
1164
1165                 i__3 = j;
1166                 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j]), 
1167                         abs(d__2));
1168                 if (nounit) {
1169                     i__3 = maind + j * ab_dim1;
1170                     z__1.r = tscal * ab[i__3].r, z__1.i = tscal * ab[i__3].i;
1171                     tjjs.r = z__1.r, tjjs.i = z__1.i;
1172                 } else {
1173                     tjjs.r = tscal, tjjs.i = 0.;
1174                     if (tscal == 1.) {
1175                         goto L110;
1176                     }
1177                 }
1178                 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), abs(
1179                         d__2));
1180                 if (tjj > smlnum) {
1181
1182 /*                    abs(A(j,j)) > SMLNUM: */
1183
1184                     if (tjj < 1.) {
1185                         if (xj > tjj * bignum) {
1186
1187 /*                          Scale x by 1/b(j). */
1188
1189                             rec = 1. / xj;
1190                             zdscal_(n, &rec, &x[1], &c__1);
1191                             *scale *= rec;
1192                             xmax *= rec;
1193                         }
1194                     }
1195                     i__3 = j;
1196                     zladiv_(&z__1, &x[j], &tjjs);
1197                     x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1198                     i__3 = j;
1199                     xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
1200                             , abs(d__2));
1201                 } else if (tjj > 0.) {
1202
1203 /*                    0 < abs(A(j,j)) <= SMLNUM: */
1204
1205                     if (xj > tjj * bignum) {
1206
1207 /*                       Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM */
1208 /*                       to avoid overflow when dividing by A(j,j). */
1209
1210                         rec = tjj * bignum / xj;
1211                         if (cnorm[j] > 1.) {
1212
1213 /*                          Scale by 1/CNORM(j) to avoid overflow when */
1214 /*                          multiplying x(j) times column j. */
1215
1216                             rec /= cnorm[j];
1217                         }
1218                         zdscal_(n, &rec, &x[1], &c__1);
1219                         *scale *= rec;
1220                         xmax *= rec;
1221                     }
1222                     i__3 = j;
1223                     zladiv_(&z__1, &x[j], &tjjs);
1224                     x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1225                     i__3 = j;
1226                     xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
1227                             , abs(d__2));
1228                 } else {
1229
1230 /*                    A(j,j) = 0:  Set x(1:n) = 0, x(j) = 1, and */
1231 /*                    scale = 0, and compute a solution to A*x = 0. */
1232
1233                     i__3 = *n;
1234                     for (i__ = 1; i__ <= i__3; ++i__) {
1235                         i__4 = i__;
1236                         x[i__4].r = 0., x[i__4].i = 0.;
1237 /* L100: */
1238                     }
1239                     i__3 = j;
1240                     x[i__3].r = 1., x[i__3].i = 0.;
1241                     xj = 1.;
1242                     *scale = 0.;
1243                     xmax = 0.;
1244                 }
1245 L110:
1246
1247 /*              Scale x if necessary to avoid overflow when adding a */
1248 /*              multiple of column j of A. */
1249
1250                 if (xj > 1.) {
1251                     rec = 1. / xj;
1252                     if (cnorm[j] > (bignum - xmax) * rec) {
1253
1254 /*                    Scale x by 1/(2*abs(x(j))). */
1255
1256                         rec *= .5;
1257                         zdscal_(n, &rec, &x[1], &c__1);
1258                         *scale *= rec;
1259                     }
1260                 } else if (xj * cnorm[j] > bignum - xmax) {
1261
1262 /*                 Scale x by 1/2. */
1263
1264                     zdscal_(n, &c_b36, &x[1], &c__1);
1265                     *scale *= .5;
1266                 }
1267
1268                 if (upper) {
1269                     if (j > 1) {
1270
1271 /*                    Compute the update */
1272 /*                       x(f2cmax(1,j-kd):j-1) := x(f2cmax(1,j-kd):j-1) - */
1273 /*                                             x(j)* A(f2cmax(1,j-kd):j-1,j) */
1274
1275 /* Computing MIN */
1276                         i__3 = *kd, i__4 = j - 1;
1277                         jlen = f2cmin(i__3,i__4);
1278                         i__3 = j;
1279                         z__2.r = -x[i__3].r, z__2.i = -x[i__3].i;
1280                         z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
1281                         zaxpy_(&jlen, &z__1, &ab[*kd + 1 - jlen + j * ab_dim1]
1282                                 , &c__1, &x[j - jlen], &c__1);
1283                         i__3 = j - 1;
1284                         i__ = izamax_(&i__3, &x[1], &c__1);
1285                         i__3 = i__;
1286                         xmax = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(
1287                                 &x[i__]), abs(d__2));
1288                     }
1289                 } else if (j < *n) {
1290
1291 /*                 Compute the update */
1292 /*                    x(j+1:f2cmin(j+kd,n)) := x(j+1:f2cmin(j+kd,n)) - */
1293 /*                                          x(j) * A(j+1:f2cmin(j+kd,n),j) */
1294
1295 /* Computing MIN */
1296                     i__3 = *kd, i__4 = *n - j;
1297                     jlen = f2cmin(i__3,i__4);
1298                     if (jlen > 0) {
1299                         i__3 = j;
1300                         z__2.r = -x[i__3].r, z__2.i = -x[i__3].i;
1301                         z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
1302                         zaxpy_(&jlen, &z__1, &ab[j * ab_dim1 + 2], &c__1, &x[
1303                                 j + 1], &c__1);
1304                     }
1305                     i__3 = *n - j;
1306                     i__ = j + izamax_(&i__3, &x[j + 1], &c__1);
1307                     i__3 = i__;
1308                     xmax = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[
1309                             i__]), abs(d__2));
1310                 }
1311 /* L120: */
1312             }
1313
1314         } else if (lsame_(trans, "T")) {
1315
1316 /*           Solve A**T * x = b */
1317
1318             i__2 = jlast;
1319             i__1 = jinc;
1320             for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
1321
1322 /*              Compute x(j) = b(j) - sum A(k,j)*x(k). */
1323 /*                                    k<>j */
1324
1325                 i__3 = j;
1326                 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j]), 
1327                         abs(d__2));
1328                 uscal.r = tscal, uscal.i = 0.;
1329                 rec = 1. / f2cmax(xmax,1.);
1330                 if (cnorm[j] > (bignum - xj) * rec) {
1331
1332 /*                 If x(j) could overflow, scale x by 1/(2*XMAX). */
1333
1334                     rec *= .5;
1335                     if (nounit) {
1336                         i__3 = maind + j * ab_dim1;
1337                         z__1.r = tscal * ab[i__3].r, z__1.i = tscal * ab[i__3]
1338                                 .i;
1339                         tjjs.r = z__1.r, tjjs.i = z__1.i;
1340                     } else {
1341                         tjjs.r = tscal, tjjs.i = 0.;
1342                     }
1343                     tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), 
1344                             abs(d__2));
1345                     if (tjj > 1.) {
1346
1347 /*                       Divide by A(j,j) when scaling x if A(j,j) > 1. */
1348
1349 /* Computing MIN */
1350                         d__1 = 1., d__2 = rec * tjj;
1351                         rec = f2cmin(d__1,d__2);
1352                         zladiv_(&z__1, &uscal, &tjjs);
1353                         uscal.r = z__1.r, uscal.i = z__1.i;
1354                     }
1355                     if (rec < 1.) {
1356                         zdscal_(n, &rec, &x[1], &c__1);
1357                         *scale *= rec;
1358                         xmax *= rec;
1359                     }
1360                 }
1361
1362                 csumj.r = 0., csumj.i = 0.;
1363                 if (uscal.r == 1. && uscal.i == 0.) {
1364
1365 /*                 If the scaling needed for A in the dot product is 1, */
1366 /*                 call ZDOTU to perform the dot product. */
1367
1368                     if (upper) {
1369 /* Computing MIN */
1370                         i__3 = *kd, i__4 = j - 1;
1371                         jlen = f2cmin(i__3,i__4);
1372                         zdotu_(&z__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
1373                                 , &c__1, &x[j - jlen], &c__1);
1374                         csumj.r = z__1.r, csumj.i = z__1.i;
1375                     } else {
1376 /* Computing MIN */
1377                         i__3 = *kd, i__4 = *n - j;
1378                         jlen = f2cmin(i__3,i__4);
1379                         if (jlen > 1) {
1380                             zdotu_(&z__1, &jlen, &ab[j * ab_dim1 + 2], &c__1, 
1381                                     &x[j + 1], &c__1);
1382                             csumj.r = z__1.r, csumj.i = z__1.i;
1383                         }
1384                     }
1385                 } else {
1386
1387 /*                 Otherwise, use in-line code for the dot product. */
1388
1389                     if (upper) {
1390 /* Computing MIN */
1391                         i__3 = *kd, i__4 = j - 1;
1392                         jlen = f2cmin(i__3,i__4);
1393                         i__3 = jlen;
1394                         for (i__ = 1; i__ <= i__3; ++i__) {
1395                             i__4 = *kd + i__ - jlen + j * ab_dim1;
1396                             z__3.r = ab[i__4].r * uscal.r - ab[i__4].i * 
1397                                     uscal.i, z__3.i = ab[i__4].r * uscal.i + 
1398                                     ab[i__4].i * uscal.r;
1399                             i__5 = j - jlen - 1 + i__;
1400                             z__2.r = z__3.r * x[i__5].r - z__3.i * x[i__5].i, 
1401                                     z__2.i = z__3.r * x[i__5].i + z__3.i * x[
1402                                     i__5].r;
1403                             z__1.r = csumj.r + z__2.r, z__1.i = csumj.i + 
1404                                     z__2.i;
1405                             csumj.r = z__1.r, csumj.i = z__1.i;
1406 /* L130: */
1407                         }
1408                     } else {
1409 /* Computing MIN */
1410                         i__3 = *kd, i__4 = *n - j;
1411                         jlen = f2cmin(i__3,i__4);
1412                         i__3 = jlen;
1413                         for (i__ = 1; i__ <= i__3; ++i__) {
1414                             i__4 = i__ + 1 + j * ab_dim1;
1415                             z__3.r = ab[i__4].r * uscal.r - ab[i__4].i * 
1416                                     uscal.i, z__3.i = ab[i__4].r * uscal.i + 
1417                                     ab[i__4].i * uscal.r;
1418                             i__5 = j + i__;
1419                             z__2.r = z__3.r * x[i__5].r - z__3.i * x[i__5].i, 
1420                                     z__2.i = z__3.r * x[i__5].i + z__3.i * x[
1421                                     i__5].r;
1422                             z__1.r = csumj.r + z__2.r, z__1.i = csumj.i + 
1423                                     z__2.i;
1424                             csumj.r = z__1.r, csumj.i = z__1.i;
1425 /* L140: */
1426                         }
1427                     }
1428                 }
1429
1430                 z__1.r = tscal, z__1.i = 0.;
1431                 if (uscal.r == z__1.r && uscal.i == z__1.i) {
1432
1433 /*                 Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
1434 /*                 was not used to scale the dotproduct. */
1435
1436                     i__3 = j;
1437                     i__4 = j;
1438                     z__1.r = x[i__4].r - csumj.r, z__1.i = x[i__4].i - 
1439                             csumj.i;
1440                     x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1441                     i__3 = j;
1442                     xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
1443                             , abs(d__2));
1444                     if (nounit) {
1445
1446 /*                    Compute x(j) = x(j) / A(j,j), scaling if necessary. */
1447
1448                         i__3 = maind + j * ab_dim1;
1449                         z__1.r = tscal * ab[i__3].r, z__1.i = tscal * ab[i__3]
1450                                 .i;
1451                         tjjs.r = z__1.r, tjjs.i = z__1.i;
1452                     } else {
1453                         tjjs.r = tscal, tjjs.i = 0.;
1454                         if (tscal == 1.) {
1455                             goto L160;
1456                         }
1457                     }
1458                     tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), 
1459                             abs(d__2));
1460                     if (tjj > smlnum) {
1461
1462 /*                       abs(A(j,j)) > SMLNUM: */
1463
1464                         if (tjj < 1.) {
1465                             if (xj > tjj * bignum) {
1466
1467 /*                             Scale X by 1/abs(x(j)). */
1468
1469                                 rec = 1. / xj;
1470                                 zdscal_(n, &rec, &x[1], &c__1);
1471                                 *scale *= rec;
1472                                 xmax *= rec;
1473                             }
1474                         }
1475                         i__3 = j;
1476                         zladiv_(&z__1, &x[j], &tjjs);
1477                         x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1478                     } else if (tjj > 0.) {
1479
1480 /*                       0 < abs(A(j,j)) <= SMLNUM: */
1481
1482                         if (xj > tjj * bignum) {
1483
1484 /*                          Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
1485
1486                             rec = tjj * bignum / xj;
1487                             zdscal_(n, &rec, &x[1], &c__1);
1488                             *scale *= rec;
1489                             xmax *= rec;
1490                         }
1491                         i__3 = j;
1492                         zladiv_(&z__1, &x[j], &tjjs);
1493                         x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1494                     } else {
1495
1496 /*                       A(j,j) = 0:  Set x(1:n) = 0, x(j) = 1, and */
1497 /*                       scale = 0 and compute a solution to A**T *x = 0. */
1498
1499                         i__3 = *n;
1500                         for (i__ = 1; i__ <= i__3; ++i__) {
1501                             i__4 = i__;
1502                             x[i__4].r = 0., x[i__4].i = 0.;
1503 /* L150: */
1504                         }
1505                         i__3 = j;
1506                         x[i__3].r = 1., x[i__3].i = 0.;
1507                         *scale = 0.;
1508                         xmax = 0.;
1509                     }
1510 L160:
1511                     ;
1512                 } else {
1513
1514 /*                 Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
1515 /*                 product has already been divided by 1/A(j,j). */
1516
1517                     i__3 = j;
1518                     zladiv_(&z__2, &x[j], &tjjs);
1519                     z__1.r = z__2.r - csumj.r, z__1.i = z__2.i - csumj.i;
1520                     x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1521                 }
1522 /* Computing MAX */
1523                 i__3 = j;
1524                 d__3 = xmax, d__4 = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = 
1525                         d_imag(&x[j]), abs(d__2));
1526                 xmax = f2cmax(d__3,d__4);
1527 /* L170: */
1528             }
1529
1530         } else {
1531
1532 /*           Solve A**H * x = b */
1533
1534             i__1 = jlast;
1535             i__2 = jinc;
1536             for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
1537
1538 /*              Compute x(j) = b(j) - sum A(k,j)*x(k). */
1539 /*                                    k<>j */
1540
1541                 i__3 = j;
1542                 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j]), 
1543                         abs(d__2));
1544                 uscal.r = tscal, uscal.i = 0.;
1545                 rec = 1. / f2cmax(xmax,1.);
1546                 if (cnorm[j] > (bignum - xj) * rec) {
1547
1548 /*                 If x(j) could overflow, scale x by 1/(2*XMAX). */
1549
1550                     rec *= .5;
1551                     if (nounit) {
1552                         d_cnjg(&z__2, &ab[maind + j * ab_dim1]);
1553                         z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
1554                         tjjs.r = z__1.r, tjjs.i = z__1.i;
1555                     } else {
1556                         tjjs.r = tscal, tjjs.i = 0.;
1557                     }
1558                     tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), 
1559                             abs(d__2));
1560                     if (tjj > 1.) {
1561
1562 /*                       Divide by A(j,j) when scaling x if A(j,j) > 1. */
1563
1564 /* Computing MIN */
1565                         d__1 = 1., d__2 = rec * tjj;
1566                         rec = f2cmin(d__1,d__2);
1567                         zladiv_(&z__1, &uscal, &tjjs);
1568                         uscal.r = z__1.r, uscal.i = z__1.i;
1569                     }
1570                     if (rec < 1.) {
1571                         zdscal_(n, &rec, &x[1], &c__1);
1572                         *scale *= rec;
1573                         xmax *= rec;
1574                     }
1575                 }
1576
1577                 csumj.r = 0., csumj.i = 0.;
1578                 if (uscal.r == 1. && uscal.i == 0.) {
1579
1580 /*                 If the scaling needed for A in the dot product is 1, */
1581 /*                 call ZDOTC to perform the dot product. */
1582
1583                     if (upper) {
1584 /* Computing MIN */
1585                         i__3 = *kd, i__4 = j - 1;
1586                         jlen = f2cmin(i__3,i__4);
1587                         zdotc_(&z__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
1588                                 , &c__1, &x[j - jlen], &c__1);
1589                         csumj.r = z__1.r, csumj.i = z__1.i;
1590                     } else {
1591 /* Computing MIN */
1592                         i__3 = *kd, i__4 = *n - j;
1593                         jlen = f2cmin(i__3,i__4);
1594                         if (jlen > 1) {
1595                             zdotc_(&z__1, &jlen, &ab[j * ab_dim1 + 2], &c__1, 
1596                                     &x[j + 1], &c__1);
1597                             csumj.r = z__1.r, csumj.i = z__1.i;
1598                         }
1599                     }
1600                 } else {
1601
1602 /*                 Otherwise, use in-line code for the dot product. */
1603
1604                     if (upper) {
1605 /* Computing MIN */
1606                         i__3 = *kd, i__4 = j - 1;
1607                         jlen = f2cmin(i__3,i__4);
1608                         i__3 = jlen;
1609                         for (i__ = 1; i__ <= i__3; ++i__) {
1610                             d_cnjg(&z__4, &ab[*kd + i__ - jlen + j * ab_dim1])
1611                                     ;
1612                             z__3.r = z__4.r * uscal.r - z__4.i * uscal.i, 
1613                                     z__3.i = z__4.r * uscal.i + z__4.i * 
1614                                     uscal.r;
1615                             i__4 = j - jlen - 1 + i__;
1616                             z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i, 
1617                                     z__2.i = z__3.r * x[i__4].i + z__3.i * x[
1618                                     i__4].r;
1619                             z__1.r = csumj.r + z__2.r, z__1.i = csumj.i + 
1620                                     z__2.i;
1621                             csumj.r = z__1.r, csumj.i = z__1.i;
1622 /* L180: */
1623                         }
1624                     } else {
1625 /* Computing MIN */
1626                         i__3 = *kd, i__4 = *n - j;
1627                         jlen = f2cmin(i__3,i__4);
1628                         i__3 = jlen;
1629                         for (i__ = 1; i__ <= i__3; ++i__) {
1630                             d_cnjg(&z__4, &ab[i__ + 1 + j * ab_dim1]);
1631                             z__3.r = z__4.r * uscal.r - z__4.i * uscal.i, 
1632                                     z__3.i = z__4.r * uscal.i + z__4.i * 
1633                                     uscal.r;
1634                             i__4 = j + i__;
1635                             z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i, 
1636                                     z__2.i = z__3.r * x[i__4].i + z__3.i * x[
1637                                     i__4].r;
1638                             z__1.r = csumj.r + z__2.r, z__1.i = csumj.i + 
1639                                     z__2.i;
1640                             csumj.r = z__1.r, csumj.i = z__1.i;
1641 /* L190: */
1642                         }
1643                     }
1644                 }
1645
1646                 z__1.r = tscal, z__1.i = 0.;
1647                 if (uscal.r == z__1.r && uscal.i == z__1.i) {
1648
1649 /*                 Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
1650 /*                 was not used to scale the dotproduct. */
1651
1652                     i__3 = j;
1653                     i__4 = j;
1654                     z__1.r = x[i__4].r - csumj.r, z__1.i = x[i__4].i - 
1655                             csumj.i;
1656                     x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1657                     i__3 = j;
1658                     xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
1659                             , abs(d__2));
1660                     if (nounit) {
1661
1662 /*                    Compute x(j) = x(j) / A(j,j), scaling if necessary. */
1663
1664                         d_cnjg(&z__2, &ab[maind + j * ab_dim1]);
1665                         z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
1666                         tjjs.r = z__1.r, tjjs.i = z__1.i;
1667                     } else {
1668                         tjjs.r = tscal, tjjs.i = 0.;
1669                         if (tscal == 1.) {
1670                             goto L210;
1671                         }
1672                     }
1673                     tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), 
1674                             abs(d__2));
1675                     if (tjj > smlnum) {
1676
1677 /*                       abs(A(j,j)) > SMLNUM: */
1678
1679                         if (tjj < 1.) {
1680                             if (xj > tjj * bignum) {
1681
1682 /*                             Scale X by 1/abs(x(j)). */
1683
1684                                 rec = 1. / xj;
1685                                 zdscal_(n, &rec, &x[1], &c__1);
1686                                 *scale *= rec;
1687                                 xmax *= rec;
1688                             }
1689                         }
1690                         i__3 = j;
1691                         zladiv_(&z__1, &x[j], &tjjs);
1692                         x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1693                     } else if (tjj > 0.) {
1694
1695 /*                       0 < abs(A(j,j)) <= SMLNUM: */
1696
1697                         if (xj > tjj * bignum) {
1698
1699 /*                          Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
1700
1701                             rec = tjj * bignum / xj;
1702                             zdscal_(n, &rec, &x[1], &c__1);
1703                             *scale *= rec;
1704                             xmax *= rec;
1705                         }
1706                         i__3 = j;
1707                         zladiv_(&z__1, &x[j], &tjjs);
1708                         x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1709                     } else {
1710
1711 /*                       A(j,j) = 0:  Set x(1:n) = 0, x(j) = 1, and */
1712 /*                       scale = 0 and compute a solution to A**H *x = 0. */
1713
1714                         i__3 = *n;
1715                         for (i__ = 1; i__ <= i__3; ++i__) {
1716                             i__4 = i__;
1717                             x[i__4].r = 0., x[i__4].i = 0.;
1718 /* L200: */
1719                         }
1720                         i__3 = j;
1721                         x[i__3].r = 1., x[i__3].i = 0.;
1722                         *scale = 0.;
1723                         xmax = 0.;
1724                     }
1725 L210:
1726                     ;
1727                 } else {
1728
1729 /*                 Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
1730 /*                 product has already been divided by 1/A(j,j). */
1731
1732                     i__3 = j;
1733                     zladiv_(&z__2, &x[j], &tjjs);
1734                     z__1.r = z__2.r - csumj.r, z__1.i = z__2.i - csumj.i;
1735                     x[i__3].r = z__1.r, x[i__3].i = z__1.i;
1736                 }
1737 /* Computing MAX */
1738                 i__3 = j;
1739                 d__3 = xmax, d__4 = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = 
1740                         d_imag(&x[j]), abs(d__2));
1741                 xmax = f2cmax(d__3,d__4);
1742 /* L220: */
1743             }
1744         }
1745         *scale /= tscal;
1746     }
1747
1748 /*     Scale the column norms by 1/TSCAL for return. */
1749
1750     if (tscal != 1.) {
1751         d__1 = 1. / tscal;
1752         dscal_(n, &d__1, &cnorm[1], &c__1);
1753     }
1754
1755     return 0;
1756
1757 /*     End of ZLATBS */
1758
1759 } /* zlatbs_ */
1760