14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
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;}
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;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
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)))
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)); }
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]);}
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);}
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)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
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];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
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];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
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];
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;
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];
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];
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]);
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]);
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;
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];
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];
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]);
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]);
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;
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];
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];
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]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
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;
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];
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];
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]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
513 /* Table of constant values */
515 static integer c__1 = 1;
516 static real c_b36 = .5f;
518 /* > \brief \b CLATBS solves a triangular banded system of equations. */
520 /* =========== DOCUMENTATION =========== */
522 /* Online html documentation available at */
523 /* http://www.netlib.org/lapack/explore-html/ */
526 /* > Download CLATBS + dependencies */
527 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clatbs.
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clatbs.
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clatbs.
541 /* SUBROUTINE CLATBS( UPLO, TRANS, DIAG, NORMIN, N, KD, AB, LDAB, X, */
542 /* SCALE, CNORM, INFO ) */
544 /* CHARACTER DIAG, NORMIN, TRANS, UPLO */
545 /* INTEGER INFO, KD, LDAB, N */
547 /* REAL CNORM( * ) */
548 /* COMPLEX AB( LDAB, * ), X( * ) */
551 /* > \par Purpose: */
556 /* > CLATBS solves one of the triangular systems */
558 /* > A * x = s*b, A**T * x = s*b, or A**H * x = s*b, */
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 CTBSV 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. */
573 /* > \param[in] UPLO */
575 /* > UPLO is CHARACTER*1 */
576 /* > Specifies whether the matrix A is upper or lower triangular. */
577 /* > = 'U': Upper triangular */
578 /* > = 'L': Lower triangular */
581 /* > \param[in] TRANS */
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) */
590 /* > \param[in] DIAG */
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 */
598 /* > \param[in] NORMIN */
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. */
610 /* > The order of the matrix A. N >= 0. */
613 /* > \param[in] KD */
615 /* > KD is INTEGER */
616 /* > The number of subdiagonals or superdiagonals in the */
617 /* > triangular matrix A. KD >= 0. */
620 /* > \param[in] AB */
622 /* > AB is COMPLEX 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). */
630 /* > \param[in] LDAB */
632 /* > LDAB is INTEGER */
633 /* > The leading dimension of the array AB. LDAB >= KD+1. */
636 /* > \param[in,out] X */
638 /* > X is COMPLEX 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. */
643 /* > \param[out] SCALE */
645 /* > SCALE is REAL */
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. */
652 /* > \param[in,out] CNORM */
654 /* > CNORM is REAL array, dimension (N) */
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. */
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 */
667 /* > \param[out] INFO */
669 /* > INFO is INTEGER */
670 /* > = 0: successful exit */
671 /* > < 0: if INFO = -k, the k-th argument had an illegal value */
677 /* > \author Univ. of Tennessee */
678 /* > \author Univ. of California Berkeley */
679 /* > \author Univ. of Colorado Denver */
680 /* > \author NAG Ltd. */
682 /* > \date December 2016 */
684 /* > \ingroup complexOTHERauxiliary */
686 /* > \par Further Details: */
687 /* ===================== */
691 /* > A rough bound on x is computed; if that is less than overflow, CTBSV */
692 /* > is called, otherwise, specific code is used which checks for possible */
693 /* > overflow or divide-by-zero at every operation. */
695 /* > A columnwise scheme is used for solving A*x = b. The basic algorithm */
696 /* > if A is lower triangular is */
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] */
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}. */
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) | ) */
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 */
717 /* > G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | ) */
721 /* > |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| ) */
724 /* > Since |x(j)| <= M(j), we use the Level 2 BLAS routine CTBSV if the */
725 /* > reciprocal of the largest M(j), j=1,..,n, is larger than */
726 /* > f2cmax(underflow, 1/overflow). */
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. */
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 */
737 /* > for j = 1, ..., n */
738 /* > x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j) */
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 */
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 */
749 /* > M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) | */
751 /* > <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| ) */
754 /* > and we can safely call CTBSV if 1/M(n) and 1/G(n) are both greater */
755 /* > than f2cmax(underflow, 1/overflow). */
758 /* ===================================================================== */
759 /* Subroutine */ int clatbs_(char *uplo, char *trans, char *diag, char *
760 normin, integer *n, integer *kd, complex *ab, integer *ldab, complex *
761 x, real *scale, real *cnorm, integer *info)
763 /* System generated locals */
764 integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5;
765 real r__1, r__2, r__3, r__4;
766 complex q__1, q__2, q__3, q__4;
768 /* Local variables */
775 integer i__, j, maind;
776 extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer
777 *, complex *, integer *);
778 extern logical lsame_(char *, char *);
779 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
783 extern /* Complex */ VOID cdotu_(complex *, integer *, complex *, integer
784 *, complex *, integer *);
786 extern /* Subroutine */ int ctbsv_(char *, char *, char *, integer *,
787 integer *, complex *, integer *, complex *, integer *), caxpy_(integer *, complex *, complex *, integer *
788 , complex *, integer *);
790 extern /* Subroutine */ int slabad_(real *, real *);
792 extern integer icamax_(integer *, complex *, integer *);
793 extern /* Complex */ VOID cladiv_(complex *, complex *, complex *);
794 extern real slamch_(char *);
795 extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer
796 *), xerbla_(char *, integer *, ftnlen);
798 extern integer isamax_(integer *, real *, integer *);
799 extern real scasum_(integer *, complex *, integer *);
807 /* -- LAPACK auxiliary routine (version 3.7.0) -- */
808 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
809 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
813 /* ===================================================================== */
816 /* Parameter adjustments */
818 ab_offset = 1 + ab_dim1 * 1;
825 upper = lsame_(uplo, "U");
826 notran = lsame_(trans, "N");
827 nounit = lsame_(diag, "N");
829 /* Test the input parameters. */
831 if (! upper && ! lsame_(uplo, "L")) {
833 } else if (! notran && ! lsame_(trans, "T") && !
834 lsame_(trans, "C")) {
836 } else if (! nounit && ! lsame_(diag, "U")) {
838 } else if (! lsame_(normin, "Y") && ! lsame_(normin,
843 } else if (*kd < 0) {
845 } else if (*ldab < *kd + 1) {
850 xerbla_("CLATBS", &i__1, (ftnlen)6);
854 /* Quick return if possible */
860 /* Determine machine dependent parameters to control overflow. */
862 smlnum = slamch_("Safe minimum");
863 bignum = 1.f / smlnum;
864 slabad_(&smlnum, &bignum);
865 smlnum /= slamch_("Precision");
866 bignum = 1.f / smlnum;
869 if (lsame_(normin, "N")) {
871 /* Compute the 1-norm of each column, not including the diagonal. */
875 /* A is upper triangular. */
878 for (j = 1; j <= i__1; ++j) {
880 i__2 = *kd, i__3 = j - 1;
881 jlen = f2cmin(i__2,i__3);
882 cnorm[j] = scasum_(&jlen, &ab[*kd + 1 - jlen + j * ab_dim1], &
888 /* A is lower triangular. */
891 for (j = 1; j <= i__1; ++j) {
893 i__2 = *kd, i__3 = *n - j;
894 jlen = f2cmin(i__2,i__3);
896 cnorm[j] = scasum_(&jlen, &ab[j * ab_dim1 + 2], &c__1);
905 /* Scale the column norms by TSCAL if the maximum element in CNORM is */
906 /* greater than BIGNUM/2. */
908 imax = isamax_(n, &cnorm[1], &c__1);
910 if (tmax <= bignum * .5f) {
913 tscal = .5f / (smlnum * tmax);
914 sscal_(n, &tscal, &cnorm[1], &c__1);
917 /* Compute a bound on the computed solution vector to see if the */
918 /* Level 2 BLAS routine CTBSV can be used. */
922 for (j = 1; j <= i__1; ++j) {
925 r__3 = xmax, r__4 = (r__1 = x[i__2].r / 2.f, abs(r__1)) + (r__2 =
926 r_imag(&x[j]) / 2.f, abs(r__2));
927 xmax = f2cmax(r__3,r__4);
933 /* Compute the growth in A * x = b. */
954 /* A is non-unit triangular. */
956 /* Compute GROW = 1/G(j) and XBND = 1/M(j). */
957 /* Initially, G(0) = f2cmax{x(i), i=1,...,n}. */
959 grow = .5f / f2cmax(xbnd,smlnum);
963 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
965 /* Exit the loop if the growth factor is too small. */
967 if (grow <= smlnum) {
971 i__3 = maind + j * ab_dim1;
972 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
973 tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
978 /* M(j) = G(j-1) / abs(A(j,j)) */
981 r__1 = xbnd, r__2 = f2cmin(1.f,tjj) * grow;
982 xbnd = f2cmin(r__1,r__2);
985 /* M(j) could overflow, set XBND to 0. */
990 if (tjj + cnorm[j] >= smlnum) {
992 /* G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) ) */
994 grow *= tjj / (tjj + cnorm[j]);
997 /* G(j) could overflow, set GROW to 0. */
1006 /* A is unit triangular. */
1008 /* Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
1011 r__1 = 1.f, r__2 = .5f / f2cmax(xbnd,smlnum);
1012 grow = f2cmin(r__1,r__2);
1015 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
1017 /* Exit the loop if the growth factor is too small. */
1019 if (grow <= smlnum) {
1023 /* G(j) = G(j-1)*( 1 + CNORM(j) ) */
1025 grow *= 1.f / (cnorm[j] + 1.f);
1034 /* Compute the growth in A**T * x = b or A**H * x = b. */
1055 /* A is non-unit triangular. */
1057 /* Compute GROW = 1/G(j) and XBND = 1/M(j). */
1058 /* Initially, M(0) = f2cmax{x(i), i=1,...,n}. */
1060 grow = .5f / f2cmax(xbnd,smlnum);
1064 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
1066 /* Exit the loop if the growth factor is too small. */
1068 if (grow <= smlnum) {
1072 /* G(j) = f2cmax( G(j-1), M(j-1)*( 1 + CNORM(j) ) ) */
1074 xj = cnorm[j] + 1.f;
1076 r__1 = grow, r__2 = xbnd / xj;
1077 grow = f2cmin(r__1,r__2);
1079 i__3 = maind + j * ab_dim1;
1080 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
1081 tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
1084 if (tjj >= smlnum) {
1086 /* M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j)) */
1093 /* M(j) could overflow, set XBND to 0. */
1099 grow = f2cmin(grow,xbnd);
1102 /* A is unit triangular. */
1104 /* Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
1107 r__1 = 1.f, r__2 = .5f / f2cmax(xbnd,smlnum);
1108 grow = f2cmin(r__1,r__2);
1111 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
1113 /* Exit the loop if the growth factor is too small. */
1115 if (grow <= smlnum) {
1119 /* G(j) = ( 1 + CNORM(j) )*G(j-1) */
1121 xj = cnorm[j] + 1.f;
1130 if (grow * tscal > smlnum) {
1132 /* Use the Level 2 BLAS solve if the reciprocal of the bound on */
1133 /* elements of X is not too small. */
1135 ctbsv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &x[1], &c__1);
1138 /* Use a Level 1 BLAS solve, scaling intermediate results. */
1140 if (xmax > bignum * .5f) {
1142 /* Scale X so that its components are less than or equal to */
1143 /* BIGNUM in absolute value. */
1145 *scale = bignum * .5f / xmax;
1146 csscal_(n, scale, &x[1], &c__1);
1154 /* Solve A * x = b */
1158 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
1160 /* Compute x(j) = b(j) / A(j,j), scaling x if necessary. */
1163 xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
1166 i__3 = maind + j * ab_dim1;
1167 q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3].i;
1168 tjjs.r = q__1.r, tjjs.i = q__1.i;
1170 tjjs.r = tscal, tjjs.i = 0.f;
1175 tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
1179 /* abs(A(j,j)) > SMLNUM: */
1182 if (xj > tjj * bignum) {
1184 /* Scale x by 1/b(j). */
1187 csscal_(n, &rec, &x[1], &c__1);
1193 cladiv_(&q__1, &x[j], &tjjs);
1194 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1196 xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
1198 } else if (tjj > 0.f) {
1200 /* 0 < abs(A(j,j)) <= SMLNUM: */
1202 if (xj > tjj * bignum) {
1204 /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM */
1205 /* to avoid overflow when dividing by A(j,j). */
1207 rec = tjj * bignum / xj;
1208 if (cnorm[j] > 1.f) {
1210 /* Scale by 1/CNORM(j) to avoid overflow when */
1211 /* multiplying x(j) times column j. */
1215 csscal_(n, &rec, &x[1], &c__1);
1220 cladiv_(&q__1, &x[j], &tjjs);
1221 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1223 xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
1227 /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
1228 /* scale = 0, and compute a solution to A*x = 0. */
1231 for (i__ = 1; i__ <= i__3; ++i__) {
1233 x[i__4].r = 0.f, x[i__4].i = 0.f;
1237 x[i__3].r = 1.f, x[i__3].i = 0.f;
1244 /* Scale x if necessary to avoid overflow when adding a */
1245 /* multiple of column j of A. */
1249 if (cnorm[j] > (bignum - xmax) * rec) {
1251 /* Scale x by 1/(2*abs(x(j))). */
1254 csscal_(n, &rec, &x[1], &c__1);
1257 } else if (xj * cnorm[j] > bignum - xmax) {
1259 /* Scale x by 1/2. */
1261 csscal_(n, &c_b36, &x[1], &c__1);
1268 /* Compute the update */
1269 /* x(f2cmax(1,j-kd):j-1) := x(f2cmax(1,j-kd):j-1) - */
1270 /* x(j)* A(f2cmax(1,j-kd):j-1,j) */
1273 i__3 = *kd, i__4 = j - 1;
1274 jlen = f2cmin(i__3,i__4);
1276 q__2.r = -x[i__3].r, q__2.i = -x[i__3].i;
1277 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
1278 caxpy_(&jlen, &q__1, &ab[*kd + 1 - jlen + j * ab_dim1]
1279 , &c__1, &x[j - jlen], &c__1);
1281 i__ = icamax_(&i__3, &x[1], &c__1);
1283 xmax = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(
1284 &x[i__]), abs(r__2));
1286 } else if (j < *n) {
1288 /* Compute the update */
1289 /* x(j+1:f2cmin(j+kd,n)) := x(j+1:f2cmin(j+kd,n)) - */
1290 /* x(j) * A(j+1:f2cmin(j+kd,n),j) */
1293 i__3 = *kd, i__4 = *n - j;
1294 jlen = f2cmin(i__3,i__4);
1297 q__2.r = -x[i__3].r, q__2.i = -x[i__3].i;
1298 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
1299 caxpy_(&jlen, &q__1, &ab[j * ab_dim1 + 2], &c__1, &x[
1303 i__ = j + icamax_(&i__3, &x[j + 1], &c__1);
1305 xmax = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[
1311 } else if (lsame_(trans, "T")) {
1313 /* Solve A**T * x = b */
1317 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
1319 /* Compute x(j) = b(j) - sum A(k,j)*x(k). */
1323 xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
1325 uscal.r = tscal, uscal.i = 0.f;
1326 rec = 1.f / f2cmax(xmax,1.f);
1327 if (cnorm[j] > (bignum - xj) * rec) {
1329 /* If x(j) could overflow, scale x by 1/(2*XMAX). */
1333 i__3 = maind + j * ab_dim1;
1334 q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3]
1336 tjjs.r = q__1.r, tjjs.i = q__1.i;
1338 tjjs.r = tscal, tjjs.i = 0.f;
1340 tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
1344 /* Divide by A(j,j) when scaling x if A(j,j) > 1. */
1347 r__1 = 1.f, r__2 = rec * tjj;
1348 rec = f2cmin(r__1,r__2);
1349 cladiv_(&q__1, &uscal, &tjjs);
1350 uscal.r = q__1.r, uscal.i = q__1.i;
1353 csscal_(n, &rec, &x[1], &c__1);
1359 csumj.r = 0.f, csumj.i = 0.f;
1360 if (uscal.r == 1.f && uscal.i == 0.f) {
1362 /* If the scaling needed for A in the dot product is 1, */
1363 /* call CDOTU to perform the dot product. */
1367 i__3 = *kd, i__4 = j - 1;
1368 jlen = f2cmin(i__3,i__4);
1369 cdotu_(&q__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
1370 , &c__1, &x[j - jlen], &c__1);
1371 csumj.r = q__1.r, csumj.i = q__1.i;
1374 i__3 = *kd, i__4 = *n - j;
1375 jlen = f2cmin(i__3,i__4);
1377 cdotu_(&q__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
1379 csumj.r = q__1.r, csumj.i = q__1.i;
1384 /* Otherwise, use in-line code for the dot product. */
1388 i__3 = *kd, i__4 = j - 1;
1389 jlen = f2cmin(i__3,i__4);
1391 for (i__ = 1; i__ <= i__3; ++i__) {
1392 i__4 = *kd + i__ - jlen + j * ab_dim1;
1393 q__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
1394 uscal.i, q__3.i = ab[i__4].r * uscal.i +
1395 ab[i__4].i * uscal.r;
1396 i__5 = j - jlen - 1 + i__;
1397 q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
1398 q__2.i = q__3.r * x[i__5].i + q__3.i * x[
1400 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
1402 csumj.r = q__1.r, csumj.i = q__1.i;
1407 i__3 = *kd, i__4 = *n - j;
1408 jlen = f2cmin(i__3,i__4);
1410 for (i__ = 1; i__ <= i__3; ++i__) {
1411 i__4 = i__ + 1 + j * ab_dim1;
1412 q__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
1413 uscal.i, q__3.i = ab[i__4].r * uscal.i +
1414 ab[i__4].i * uscal.r;
1416 q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
1417 q__2.i = q__3.r * x[i__5].i + q__3.i * x[
1419 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
1421 csumj.r = q__1.r, csumj.i = q__1.i;
1427 q__1.r = tscal, q__1.i = 0.f;
1428 if (uscal.r == q__1.r && uscal.i == q__1.i) {
1430 /* Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
1431 /* was not used to scale the dotproduct. */
1435 q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
1437 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1439 xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
1443 /* Compute x(j) = x(j) / A(j,j), scaling if necessary. */
1445 i__3 = maind + j * ab_dim1;
1446 q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3]
1448 tjjs.r = q__1.r, tjjs.i = q__1.i;
1450 tjjs.r = tscal, tjjs.i = 0.f;
1455 tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
1459 /* abs(A(j,j)) > SMLNUM: */
1462 if (xj > tjj * bignum) {
1464 /* Scale X by 1/abs(x(j)). */
1467 csscal_(n, &rec, &x[1], &c__1);
1473 cladiv_(&q__1, &x[j], &tjjs);
1474 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1475 } else if (tjj > 0.f) {
1477 /* 0 < abs(A(j,j)) <= SMLNUM: */
1479 if (xj > tjj * bignum) {
1481 /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
1483 rec = tjj * bignum / xj;
1484 csscal_(n, &rec, &x[1], &c__1);
1489 cladiv_(&q__1, &x[j], &tjjs);
1490 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1493 /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
1494 /* scale = 0 and compute a solution to A**T *x = 0. */
1497 for (i__ = 1; i__ <= i__3; ++i__) {
1499 x[i__4].r = 0.f, x[i__4].i = 0.f;
1503 x[i__3].r = 1.f, x[i__3].i = 0.f;
1511 /* Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
1512 /* product has already been divided by 1/A(j,j). */
1515 cladiv_(&q__2, &x[j], &tjjs);
1516 q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
1517 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1521 r__3 = xmax, r__4 = (r__1 = x[i__3].r, abs(r__1)) + (r__2 =
1522 r_imag(&x[j]), abs(r__2));
1523 xmax = f2cmax(r__3,r__4);
1529 /* Solve A**H * x = b */
1533 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
1535 /* Compute x(j) = b(j) - sum A(k,j)*x(k). */
1539 xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
1541 uscal.r = tscal, uscal.i = 0.f;
1542 rec = 1.f / f2cmax(xmax,1.f);
1543 if (cnorm[j] > (bignum - xj) * rec) {
1545 /* If x(j) could overflow, scale x by 1/(2*XMAX). */
1549 r_cnjg(&q__2, &ab[maind + j * ab_dim1]);
1550 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
1551 tjjs.r = q__1.r, tjjs.i = q__1.i;
1553 tjjs.r = tscal, tjjs.i = 0.f;
1555 tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
1559 /* Divide by A(j,j) when scaling x if A(j,j) > 1. */
1562 r__1 = 1.f, r__2 = rec * tjj;
1563 rec = f2cmin(r__1,r__2);
1564 cladiv_(&q__1, &uscal, &tjjs);
1565 uscal.r = q__1.r, uscal.i = q__1.i;
1568 csscal_(n, &rec, &x[1], &c__1);
1574 csumj.r = 0.f, csumj.i = 0.f;
1575 if (uscal.r == 1.f && uscal.i == 0.f) {
1577 /* If the scaling needed for A in the dot product is 1, */
1578 /* call CDOTC to perform the dot product. */
1582 i__3 = *kd, i__4 = j - 1;
1583 jlen = f2cmin(i__3,i__4);
1584 cdotc_(&q__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
1585 , &c__1, &x[j - jlen], &c__1);
1586 csumj.r = q__1.r, csumj.i = q__1.i;
1589 i__3 = *kd, i__4 = *n - j;
1590 jlen = f2cmin(i__3,i__4);
1592 cdotc_(&q__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
1594 csumj.r = q__1.r, csumj.i = q__1.i;
1599 /* Otherwise, use in-line code for the dot product. */
1603 i__3 = *kd, i__4 = j - 1;
1604 jlen = f2cmin(i__3,i__4);
1606 for (i__ = 1; i__ <= i__3; ++i__) {
1607 r_cnjg(&q__4, &ab[*kd + i__ - jlen + j * ab_dim1])
1609 q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
1610 q__3.i = q__4.r * uscal.i + q__4.i *
1612 i__4 = j - jlen - 1 + i__;
1613 q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
1614 q__2.i = q__3.r * x[i__4].i + q__3.i * x[
1616 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
1618 csumj.r = q__1.r, csumj.i = q__1.i;
1623 i__3 = *kd, i__4 = *n - j;
1624 jlen = f2cmin(i__3,i__4);
1626 for (i__ = 1; i__ <= i__3; ++i__) {
1627 r_cnjg(&q__4, &ab[i__ + 1 + j * ab_dim1]);
1628 q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
1629 q__3.i = q__4.r * uscal.i + q__4.i *
1632 q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
1633 q__2.i = q__3.r * x[i__4].i + q__3.i * x[
1635 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
1637 csumj.r = q__1.r, csumj.i = q__1.i;
1643 q__1.r = tscal, q__1.i = 0.f;
1644 if (uscal.r == q__1.r && uscal.i == q__1.i) {
1646 /* Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
1647 /* was not used to scale the dotproduct. */
1651 q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
1653 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1655 xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
1659 /* Compute x(j) = x(j) / A(j,j), scaling if necessary. */
1661 r_cnjg(&q__2, &ab[maind + j * ab_dim1]);
1662 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
1663 tjjs.r = q__1.r, tjjs.i = q__1.i;
1665 tjjs.r = tscal, tjjs.i = 0.f;
1670 tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
1674 /* abs(A(j,j)) > SMLNUM: */
1677 if (xj > tjj * bignum) {
1679 /* Scale X by 1/abs(x(j)). */
1682 csscal_(n, &rec, &x[1], &c__1);
1688 cladiv_(&q__1, &x[j], &tjjs);
1689 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1690 } else if (tjj > 0.f) {
1692 /* 0 < abs(A(j,j)) <= SMLNUM: */
1694 if (xj > tjj * bignum) {
1696 /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
1698 rec = tjj * bignum / xj;
1699 csscal_(n, &rec, &x[1], &c__1);
1704 cladiv_(&q__1, &x[j], &tjjs);
1705 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1708 /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
1709 /* scale = 0 and compute a solution to A**H *x = 0. */
1712 for (i__ = 1; i__ <= i__3; ++i__) {
1714 x[i__4].r = 0.f, x[i__4].i = 0.f;
1718 x[i__3].r = 1.f, x[i__3].i = 0.f;
1726 /* Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
1727 /* product has already been divided by 1/A(j,j). */
1730 cladiv_(&q__2, &x[j], &tjjs);
1731 q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
1732 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
1736 r__3 = xmax, r__4 = (r__1 = x[i__3].r, abs(r__1)) + (r__2 =
1737 r_imag(&x[j]), abs(r__2));
1738 xmax = f2cmax(r__3,r__4);
1745 /* Scale the column norms by 1/TSCAL for return. */
1749 sscal_(n, &r__1, &cnorm[1], &c__1);