LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine zlatrs ( character  UPLO,
character  TRANS,
character  DIAG,
character  NORMIN,
integer  N,
complex*16, dimension( lda, * )  A,
integer  LDA,
complex*16, dimension( * )  X,
double precision  SCALE,
double precision, dimension( * )  CNORM,
integer  INFO 
)

ZLATRS solves a triangular system of equations with the scale factor set to prevent overflow.

Download ZLATRS + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 ZLATRS solves one of the triangular systems

    A * x = s*b,  A**T * x = s*b,  or  A**H * x = s*b,

 with scaling to prevent overflow.  Here A is an upper or lower
 triangular matrix, A**T denotes the transpose of A, A**H denotes the
 conjugate transpose of A, x and b are n-element vectors, and s is a
 scaling factor, usually less than or equal to 1, chosen so that the
 components of x will be less than the overflow threshold.  If the
 unscaled problem will not cause overflow, the Level 2 BLAS routine
 ZTRSV is called. If the matrix A is singular (A(j,j) = 0 for some j),
 then s is set to 0 and a non-trivial solution to A*x = 0 is returned.
Parameters
[in]UPLO
          UPLO is CHARACTER*1
          Specifies whether the matrix A is upper or lower triangular.
          = 'U':  Upper triangular
          = 'L':  Lower triangular
[in]TRANS
          TRANS is CHARACTER*1
          Specifies the operation applied to A.
          = 'N':  Solve A * x = s*b     (No transpose)
          = 'T':  Solve A**T * x = s*b  (Transpose)
          = 'C':  Solve A**H * x = s*b  (Conjugate transpose)
[in]DIAG
          DIAG is CHARACTER*1
          Specifies whether or not the matrix A is unit triangular.
          = 'N':  Non-unit triangular
          = 'U':  Unit triangular
[in]NORMIN
          NORMIN is CHARACTER*1
          Specifies whether CNORM has been set or not.
          = 'Y':  CNORM contains the column norms on entry
          = 'N':  CNORM is not set on entry.  On exit, the norms will
                  be computed and stored in CNORM.
[in]N
          N is INTEGER
          The order of the matrix A.  N >= 0.
[in]A
          A is COMPLEX*16 array, dimension (LDA,N)
          The triangular matrix A.  If UPLO = 'U', the leading n by n
          upper triangular part of the array A contains the upper
          triangular matrix, and the strictly lower triangular part of
          A is not referenced.  If UPLO = 'L', the leading n by n lower
          triangular part of the array A contains the lower triangular
          matrix, and the strictly upper triangular part of A is not
          referenced.  If DIAG = 'U', the diagonal elements of A are
          also not referenced and are assumed to be 1.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max (1,N).
[in,out]X
          X is COMPLEX*16 array, dimension (N)
          On entry, the right hand side b of the triangular system.
          On exit, X is overwritten by the solution vector x.
[out]SCALE
          SCALE is DOUBLE PRECISION
          The scaling factor s for the triangular system
             A * x = s*b,  A**T * x = s*b,  or  A**H * x = s*b.
          If SCALE = 0, the matrix A is singular or badly scaled, and
          the vector x is an exact or approximate solution to A*x = 0.
[in,out]CNORM
          CNORM is DOUBLE PRECISION array, dimension (N)

          If NORMIN = 'Y', CNORM is an input argument and CNORM(j)
          contains the norm of the off-diagonal part of the j-th column
          of A.  If TRANS = 'N', CNORM(j) must be greater than or equal
          to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j)
          must be greater than or equal to the 1-norm.

          If NORMIN = 'N', CNORM is an output argument and CNORM(j)
          returns the 1-norm of the offdiagonal part of the j-th column
          of A.
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -k, the k-th argument had an illegal value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012
Further Details:
  A rough bound on x is computed; if that is less than overflow, ZTRSV
  is called, otherwise, specific code is used which checks for possible
  overflow or divide-by-zero at every operation.

  A columnwise scheme is used for solving A*x = b.  The basic algorithm
  if A is lower triangular is

       x[1:n] := b[1:n]
       for j = 1, ..., n
            x(j) := x(j) / A(j,j)
            x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j]
       end

  Define bounds on the components of x after j iterations of the loop:
     M(j) = bound on x[1:j]
     G(j) = bound on x[j+1:n]
  Initially, let M(0) = 0 and G(0) = max{x(i), i=1,...,n}.

  Then for iteration j+1 we have
     M(j+1) <= G(j) / | A(j+1,j+1) |
     G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] |
            <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | )

  where CNORM(j+1) is greater than or equal to the infinity-norm of
  column j+1 of A, not counting the diagonal.  Hence

     G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | )
                  1<=i<=j
  and

     |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| )
                                   1<=i< j

  Since |x(j)| <= M(j), we use the Level 2 BLAS routine ZTRSV if the
  reciprocal of the largest M(j), j=1,..,n, is larger than
  max(underflow, 1/overflow).

  The bound on x(j) is also used to determine when a step in the
  columnwise method can be performed without fear of overflow.  If
  the computed bound is greater than a large constant, x is scaled to
  prevent overflow, but if the bound overflows, x is set to 0, x(j) to
  1, and scale to 0, and a non-trivial solution to A*x = 0 is found.

  Similarly, a row-wise scheme is used to solve A**T *x = b  or
  A**H *x = b.  The basic algorithm for A upper triangular is

       for j = 1, ..., n
            x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j)
       end

  We simultaneously compute two bounds
       G(j) = bound on ( b(i) - A[1:i-1,i]' * x[1:i-1] ), 1<=i<=j
       M(j) = bound on x(i), 1<=i<=j

  The initial values are G(0) = 0, M(0) = max{b(i), i=1,..,n}, and we
  add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1.
  Then the bound on x(j) is

       M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) |

            <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| )
                      1<=i<=j

  and we can safely call ZTRSV if 1/M(n) and 1/G(n) are both greater
  than max(underflow, 1/overflow).

Definition at line 241 of file zlatrs.f.

241 *
242 * -- LAPACK auxiliary routine (version 3.4.2) --
243 * -- LAPACK is a software package provided by Univ. of Tennessee, --
244 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
245 * September 2012
246 *
247 * .. Scalar Arguments ..
248  CHARACTER diag, normin, trans, uplo
249  INTEGER info, lda, n
250  DOUBLE PRECISION scale
251 * ..
252 * .. Array Arguments ..
253  DOUBLE PRECISION cnorm( * )
254  COMPLEX*16 a( lda, * ), x( * )
255 * ..
256 *
257 * =====================================================================
258 *
259 * .. Parameters ..
260  DOUBLE PRECISION zero, half, one, two
261  parameter ( zero = 0.0d+0, half = 0.5d+0, one = 1.0d+0,
262  $ two = 2.0d+0 )
263 * ..
264 * .. Local Scalars ..
265  LOGICAL notran, nounit, upper
266  INTEGER i, imax, j, jfirst, jinc, jlast
267  DOUBLE PRECISION bignum, grow, rec, smlnum, tjj, tmax, tscal,
268  $ xbnd, xj, xmax
269  COMPLEX*16 csumj, tjjs, uscal, zdum
270 * ..
271 * .. External Functions ..
272  LOGICAL lsame
273  INTEGER idamax, izamax
274  DOUBLE PRECISION dlamch, dzasum
275  COMPLEX*16 zdotc, zdotu, zladiv
276  EXTERNAL lsame, idamax, izamax, dlamch, dzasum, zdotc,
277  $ zdotu, zladiv
278 * ..
279 * .. External Subroutines ..
280  EXTERNAL dscal, xerbla, zaxpy, zdscal, ztrsv
281 * ..
282 * .. Intrinsic Functions ..
283  INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, min
284 * ..
285 * .. Statement Functions ..
286  DOUBLE PRECISION cabs1, cabs2
287 * ..
288 * .. Statement Function definitions ..
289  cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
290  cabs2( zdum ) = abs( dble( zdum ) / 2.d0 ) +
291  $ abs( dimag( zdum ) / 2.d0 )
292 * ..
293 * .. Executable Statements ..
294 *
295  info = 0
296  upper = lsame( uplo, 'U' )
297  notran = lsame( trans, 'N' )
298  nounit = lsame( diag, 'N' )
299 *
300 * Test the input parameters.
301 *
302  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
303  info = -1
304  ELSE IF( .NOT.notran .AND. .NOT.lsame( trans, 'T' ) .AND. .NOT.
305  $ lsame( trans, 'C' ) ) THEN
306  info = -2
307  ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag, 'U' ) ) THEN
308  info = -3
309  ELSE IF( .NOT.lsame( normin, 'Y' ) .AND. .NOT.
310  $ lsame( normin, 'N' ) ) THEN
311  info = -4
312  ELSE IF( n.LT.0 ) THEN
313  info = -5
314  ELSE IF( lda.LT.max( 1, n ) ) THEN
315  info = -7
316  END IF
317  IF( info.NE.0 ) THEN
318  CALL xerbla( 'ZLATRS', -info )
319  RETURN
320  END IF
321 *
322 * Quick return if possible
323 *
324  IF( n.EQ.0 )
325  $ RETURN
326 *
327 * Determine machine dependent parameters to control overflow.
328 *
329  smlnum = dlamch( 'Safe minimum' )
330  bignum = one / smlnum
331  CALL dlabad( smlnum, bignum )
332  smlnum = smlnum / dlamch( 'Precision' )
333  bignum = one / smlnum
334  scale = one
335 *
336  IF( lsame( normin, 'N' ) ) THEN
337 *
338 * Compute the 1-norm of each column, not including the diagonal.
339 *
340  IF( upper ) THEN
341 *
342 * A is upper triangular.
343 *
344  DO 10 j = 1, n
345  cnorm( j ) = dzasum( j-1, a( 1, j ), 1 )
346  10 CONTINUE
347  ELSE
348 *
349 * A is lower triangular.
350 *
351  DO 20 j = 1, n - 1
352  cnorm( j ) = dzasum( n-j, a( j+1, j ), 1 )
353  20 CONTINUE
354  cnorm( n ) = zero
355  END IF
356  END IF
357 *
358 * Scale the column norms by TSCAL if the maximum element in CNORM is
359 * greater than BIGNUM/2.
360 *
361  imax = idamax( n, cnorm, 1 )
362  tmax = cnorm( imax )
363  IF( tmax.LE.bignum*half ) THEN
364  tscal = one
365  ELSE
366  tscal = half / ( smlnum*tmax )
367  CALL dscal( n, tscal, cnorm, 1 )
368  END IF
369 *
370 * Compute a bound on the computed solution vector to see if the
371 * Level 2 BLAS routine ZTRSV can be used.
372 *
373  xmax = zero
374  DO 30 j = 1, n
375  xmax = max( xmax, cabs2( x( j ) ) )
376  30 CONTINUE
377  xbnd = xmax
378 *
379  IF( notran ) THEN
380 *
381 * Compute the growth in A * x = b.
382 *
383  IF( upper ) THEN
384  jfirst = n
385  jlast = 1
386  jinc = -1
387  ELSE
388  jfirst = 1
389  jlast = n
390  jinc = 1
391  END IF
392 *
393  IF( tscal.NE.one ) THEN
394  grow = zero
395  GO TO 60
396  END IF
397 *
398  IF( nounit ) THEN
399 *
400 * A is non-unit triangular.
401 *
402 * Compute GROW = 1/G(j) and XBND = 1/M(j).
403 * Initially, G(0) = max{x(i), i=1,...,n}.
404 *
405  grow = half / max( xbnd, smlnum )
406  xbnd = grow
407  DO 40 j = jfirst, jlast, jinc
408 *
409 * Exit the loop if the growth factor is too small.
410 *
411  IF( grow.LE.smlnum )
412  $ GO TO 60
413 *
414  tjjs = a( j, j )
415  tjj = cabs1( tjjs )
416 *
417  IF( tjj.GE.smlnum ) THEN
418 *
419 * M(j) = G(j-1) / abs(A(j,j))
420 *
421  xbnd = min( xbnd, min( one, tjj )*grow )
422  ELSE
423 *
424 * M(j) could overflow, set XBND to 0.
425 *
426  xbnd = zero
427  END IF
428 *
429  IF( tjj+cnorm( j ).GE.smlnum ) THEN
430 *
431 * G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) )
432 *
433  grow = grow*( tjj / ( tjj+cnorm( j ) ) )
434  ELSE
435 *
436 * G(j) could overflow, set GROW to 0.
437 *
438  grow = zero
439  END IF
440  40 CONTINUE
441  grow = xbnd
442  ELSE
443 *
444 * A is unit triangular.
445 *
446 * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}.
447 *
448  grow = min( one, half / max( xbnd, smlnum ) )
449  DO 50 j = jfirst, jlast, jinc
450 *
451 * Exit the loop if the growth factor is too small.
452 *
453  IF( grow.LE.smlnum )
454  $ GO TO 60
455 *
456 * G(j) = G(j-1)*( 1 + CNORM(j) )
457 *
458  grow = grow*( one / ( one+cnorm( j ) ) )
459  50 CONTINUE
460  END IF
461  60 CONTINUE
462 *
463  ELSE
464 *
465 * Compute the growth in A**T * x = b or A**H * x = b.
466 *
467  IF( upper ) THEN
468  jfirst = 1
469  jlast = n
470  jinc = 1
471  ELSE
472  jfirst = n
473  jlast = 1
474  jinc = -1
475  END IF
476 *
477  IF( tscal.NE.one ) THEN
478  grow = zero
479  GO TO 90
480  END IF
481 *
482  IF( nounit ) THEN
483 *
484 * A is non-unit triangular.
485 *
486 * Compute GROW = 1/G(j) and XBND = 1/M(j).
487 * Initially, M(0) = max{x(i), i=1,...,n}.
488 *
489  grow = half / max( xbnd, smlnum )
490  xbnd = grow
491  DO 70 j = jfirst, jlast, jinc
492 *
493 * Exit the loop if the growth factor is too small.
494 *
495  IF( grow.LE.smlnum )
496  $ GO TO 90
497 *
498 * G(j) = max( G(j-1), M(j-1)*( 1 + CNORM(j) ) )
499 *
500  xj = one + cnorm( j )
501  grow = min( grow, xbnd / xj )
502 *
503  tjjs = a( j, j )
504  tjj = cabs1( tjjs )
505 *
506  IF( tjj.GE.smlnum ) THEN
507 *
508 * M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j))
509 *
510  IF( xj.GT.tjj )
511  $ xbnd = xbnd*( tjj / xj )
512  ELSE
513 *
514 * M(j) could overflow, set XBND to 0.
515 *
516  xbnd = zero
517  END IF
518  70 CONTINUE
519  grow = min( grow, xbnd )
520  ELSE
521 *
522 * A is unit triangular.
523 *
524 * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}.
525 *
526  grow = min( one, half / max( xbnd, smlnum ) )
527  DO 80 j = jfirst, jlast, jinc
528 *
529 * Exit the loop if the growth factor is too small.
530 *
531  IF( grow.LE.smlnum )
532  $ GO TO 90
533 *
534 * G(j) = ( 1 + CNORM(j) )*G(j-1)
535 *
536  xj = one + cnorm( j )
537  grow = grow / xj
538  80 CONTINUE
539  END IF
540  90 CONTINUE
541  END IF
542 *
543  IF( ( grow*tscal ).GT.smlnum ) THEN
544 *
545 * Use the Level 2 BLAS solve if the reciprocal of the bound on
546 * elements of X is not too small.
547 *
548  CALL ztrsv( uplo, trans, diag, n, a, lda, x, 1 )
549  ELSE
550 *
551 * Use a Level 1 BLAS solve, scaling intermediate results.
552 *
553  IF( xmax.GT.bignum*half ) THEN
554 *
555 * Scale X so that its components are less than or equal to
556 * BIGNUM in absolute value.
557 *
558  scale = ( bignum*half ) / xmax
559  CALL zdscal( n, scale, x, 1 )
560  xmax = bignum
561  ELSE
562  xmax = xmax*two
563  END IF
564 *
565  IF( notran ) THEN
566 *
567 * Solve A * x = b
568 *
569  DO 120 j = jfirst, jlast, jinc
570 *
571 * Compute x(j) = b(j) / A(j,j), scaling x if necessary.
572 *
573  xj = cabs1( x( j ) )
574  IF( nounit ) THEN
575  tjjs = a( j, j )*tscal
576  ELSE
577  tjjs = tscal
578  IF( tscal.EQ.one )
579  $ GO TO 110
580  END IF
581  tjj = cabs1( tjjs )
582  IF( tjj.GT.smlnum ) THEN
583 *
584 * abs(A(j,j)) > SMLNUM:
585 *
586  IF( tjj.LT.one ) THEN
587  IF( xj.GT.tjj*bignum ) THEN
588 *
589 * Scale x by 1/b(j).
590 *
591  rec = one / xj
592  CALL zdscal( n, rec, x, 1 )
593  scale = scale*rec
594  xmax = xmax*rec
595  END IF
596  END IF
597  x( j ) = zladiv( x( j ), tjjs )
598  xj = cabs1( x( j ) )
599  ELSE IF( tjj.GT.zero ) THEN
600 *
601 * 0 < abs(A(j,j)) <= SMLNUM:
602 *
603  IF( xj.GT.tjj*bignum ) THEN
604 *
605 * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM
606 * to avoid overflow when dividing by A(j,j).
607 *
608  rec = ( tjj*bignum ) / xj
609  IF( cnorm( j ).GT.one ) THEN
610 *
611 * Scale by 1/CNORM(j) to avoid overflow when
612 * multiplying x(j) times column j.
613 *
614  rec = rec / cnorm( j )
615  END IF
616  CALL zdscal( n, rec, x, 1 )
617  scale = scale*rec
618  xmax = xmax*rec
619  END IF
620  x( j ) = zladiv( x( j ), tjjs )
621  xj = cabs1( x( j ) )
622  ELSE
623 *
624 * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and
625 * scale = 0, and compute a solution to A*x = 0.
626 *
627  DO 100 i = 1, n
628  x( i ) = zero
629  100 CONTINUE
630  x( j ) = one
631  xj = one
632  scale = zero
633  xmax = zero
634  END IF
635  110 CONTINUE
636 *
637 * Scale x if necessary to avoid overflow when adding a
638 * multiple of column j of A.
639 *
640  IF( xj.GT.one ) THEN
641  rec = one / xj
642  IF( cnorm( j ).GT.( bignum-xmax )*rec ) THEN
643 *
644 * Scale x by 1/(2*abs(x(j))).
645 *
646  rec = rec*half
647  CALL zdscal( n, rec, x, 1 )
648  scale = scale*rec
649  END IF
650  ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) ) THEN
651 *
652 * Scale x by 1/2.
653 *
654  CALL zdscal( n, half, x, 1 )
655  scale = scale*half
656  END IF
657 *
658  IF( upper ) THEN
659  IF( j.GT.1 ) THEN
660 *
661 * Compute the update
662 * x(1:j-1) := x(1:j-1) - x(j) * A(1:j-1,j)
663 *
664  CALL zaxpy( j-1, -x( j )*tscal, a( 1, j ), 1, x,
665  $ 1 )
666  i = izamax( j-1, x, 1 )
667  xmax = cabs1( x( i ) )
668  END IF
669  ELSE
670  IF( j.LT.n ) THEN
671 *
672 * Compute the update
673 * x(j+1:n) := x(j+1:n) - x(j) * A(j+1:n,j)
674 *
675  CALL zaxpy( n-j, -x( j )*tscal, a( j+1, j ), 1,
676  $ x( j+1 ), 1 )
677  i = j + izamax( n-j, x( j+1 ), 1 )
678  xmax = cabs1( x( i ) )
679  END IF
680  END IF
681  120 CONTINUE
682 *
683  ELSE IF( lsame( trans, 'T' ) ) THEN
684 *
685 * Solve A**T * x = b
686 *
687  DO 170 j = jfirst, jlast, jinc
688 *
689 * Compute x(j) = b(j) - sum A(k,j)*x(k).
690 * k<>j
691 *
692  xj = cabs1( x( j ) )
693  uscal = tscal
694  rec = one / max( xmax, one )
695  IF( cnorm( j ).GT.( bignum-xj )*rec ) THEN
696 *
697 * If x(j) could overflow, scale x by 1/(2*XMAX).
698 *
699  rec = rec*half
700  IF( nounit ) THEN
701  tjjs = a( j, j )*tscal
702  ELSE
703  tjjs = tscal
704  END IF
705  tjj = cabs1( tjjs )
706  IF( tjj.GT.one ) THEN
707 *
708 * Divide by A(j,j) when scaling x if A(j,j) > 1.
709 *
710  rec = min( one, rec*tjj )
711  uscal = zladiv( uscal, tjjs )
712  END IF
713  IF( rec.LT.one ) THEN
714  CALL zdscal( n, rec, x, 1 )
715  scale = scale*rec
716  xmax = xmax*rec
717  END IF
718  END IF
719 *
720  csumj = zero
721  IF( uscal.EQ.dcmplx( one ) ) THEN
722 *
723 * If the scaling needed for A in the dot product is 1,
724 * call ZDOTU to perform the dot product.
725 *
726  IF( upper ) THEN
727  csumj = zdotu( j-1, a( 1, j ), 1, x, 1 )
728  ELSE IF( j.LT.n ) THEN
729  csumj = zdotu( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
730  END IF
731  ELSE
732 *
733 * Otherwise, use in-line code for the dot product.
734 *
735  IF( upper ) THEN
736  DO 130 i = 1, j - 1
737  csumj = csumj + ( a( i, j )*uscal )*x( i )
738  130 CONTINUE
739  ELSE IF( j.LT.n ) THEN
740  DO 140 i = j + 1, n
741  csumj = csumj + ( a( i, j )*uscal )*x( i )
742  140 CONTINUE
743  END IF
744  END IF
745 *
746  IF( uscal.EQ.dcmplx( tscal ) ) THEN
747 *
748 * Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j)
749 * was not used to scale the dotproduct.
750 *
751  x( j ) = x( j ) - csumj
752  xj = cabs1( x( j ) )
753  IF( nounit ) THEN
754  tjjs = a( j, j )*tscal
755  ELSE
756  tjjs = tscal
757  IF( tscal.EQ.one )
758  $ GO TO 160
759  END IF
760 *
761 * Compute x(j) = x(j) / A(j,j), scaling if necessary.
762 *
763  tjj = cabs1( tjjs )
764  IF( tjj.GT.smlnum ) THEN
765 *
766 * abs(A(j,j)) > SMLNUM:
767 *
768  IF( tjj.LT.one ) THEN
769  IF( xj.GT.tjj*bignum ) THEN
770 *
771 * Scale X by 1/abs(x(j)).
772 *
773  rec = one / xj
774  CALL zdscal( n, rec, x, 1 )
775  scale = scale*rec
776  xmax = xmax*rec
777  END IF
778  END IF
779  x( j ) = zladiv( x( j ), tjjs )
780  ELSE IF( tjj.GT.zero ) THEN
781 *
782 * 0 < abs(A(j,j)) <= SMLNUM:
783 *
784  IF( xj.GT.tjj*bignum ) THEN
785 *
786 * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM.
787 *
788  rec = ( tjj*bignum ) / xj
789  CALL zdscal( n, rec, x, 1 )
790  scale = scale*rec
791  xmax = xmax*rec
792  END IF
793  x( j ) = zladiv( x( j ), tjjs )
794  ELSE
795 *
796 * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and
797 * scale = 0 and compute a solution to A**T *x = 0.
798 *
799  DO 150 i = 1, n
800  x( i ) = zero
801  150 CONTINUE
802  x( j ) = one
803  scale = zero
804  xmax = zero
805  END IF
806  160 CONTINUE
807  ELSE
808 *
809 * Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot
810 * product has already been divided by 1/A(j,j).
811 *
812  x( j ) = zladiv( x( j ), tjjs ) - csumj
813  END IF
814  xmax = max( xmax, cabs1( x( j ) ) )
815  170 CONTINUE
816 *
817  ELSE
818 *
819 * Solve A**H * x = b
820 *
821  DO 220 j = jfirst, jlast, jinc
822 *
823 * Compute x(j) = b(j) - sum A(k,j)*x(k).
824 * k<>j
825 *
826  xj = cabs1( x( j ) )
827  uscal = tscal
828  rec = one / max( xmax, one )
829  IF( cnorm( j ).GT.( bignum-xj )*rec ) THEN
830 *
831 * If x(j) could overflow, scale x by 1/(2*XMAX).
832 *
833  rec = rec*half
834  IF( nounit ) THEN
835  tjjs = dconjg( a( j, j ) )*tscal
836  ELSE
837  tjjs = tscal
838  END IF
839  tjj = cabs1( tjjs )
840  IF( tjj.GT.one ) THEN
841 *
842 * Divide by A(j,j) when scaling x if A(j,j) > 1.
843 *
844  rec = min( one, rec*tjj )
845  uscal = zladiv( uscal, tjjs )
846  END IF
847  IF( rec.LT.one ) THEN
848  CALL zdscal( n, rec, x, 1 )
849  scale = scale*rec
850  xmax = xmax*rec
851  END IF
852  END IF
853 *
854  csumj = zero
855  IF( uscal.EQ.dcmplx( one ) ) THEN
856 *
857 * If the scaling needed for A in the dot product is 1,
858 * call ZDOTC to perform the dot product.
859 *
860  IF( upper ) THEN
861  csumj = zdotc( j-1, a( 1, j ), 1, x, 1 )
862  ELSE IF( j.LT.n ) THEN
863  csumj = zdotc( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
864  END IF
865  ELSE
866 *
867 * Otherwise, use in-line code for the dot product.
868 *
869  IF( upper ) THEN
870  DO 180 i = 1, j - 1
871  csumj = csumj + ( dconjg( a( i, j ) )*uscal )*
872  $ x( i )
873  180 CONTINUE
874  ELSE IF( j.LT.n ) THEN
875  DO 190 i = j + 1, n
876  csumj = csumj + ( dconjg( a( i, j ) )*uscal )*
877  $ x( i )
878  190 CONTINUE
879  END IF
880  END IF
881 *
882  IF( uscal.EQ.dcmplx( tscal ) ) THEN
883 *
884 * Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j)
885 * was not used to scale the dotproduct.
886 *
887  x( j ) = x( j ) - csumj
888  xj = cabs1( x( j ) )
889  IF( nounit ) THEN
890  tjjs = dconjg( a( j, j ) )*tscal
891  ELSE
892  tjjs = tscal
893  IF( tscal.EQ.one )
894  $ GO TO 210
895  END IF
896 *
897 * Compute x(j) = x(j) / A(j,j), scaling if necessary.
898 *
899  tjj = cabs1( tjjs )
900  IF( tjj.GT.smlnum ) THEN
901 *
902 * abs(A(j,j)) > SMLNUM:
903 *
904  IF( tjj.LT.one ) THEN
905  IF( xj.GT.tjj*bignum ) THEN
906 *
907 * Scale X by 1/abs(x(j)).
908 *
909  rec = one / xj
910  CALL zdscal( n, rec, x, 1 )
911  scale = scale*rec
912  xmax = xmax*rec
913  END IF
914  END IF
915  x( j ) = zladiv( x( j ), tjjs )
916  ELSE IF( tjj.GT.zero ) THEN
917 *
918 * 0 < abs(A(j,j)) <= SMLNUM:
919 *
920  IF( xj.GT.tjj*bignum ) THEN
921 *
922 * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM.
923 *
924  rec = ( tjj*bignum ) / xj
925  CALL zdscal( n, rec, x, 1 )
926  scale = scale*rec
927  xmax = xmax*rec
928  END IF
929  x( j ) = zladiv( x( j ), tjjs )
930  ELSE
931 *
932 * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and
933 * scale = 0 and compute a solution to A**H *x = 0.
934 *
935  DO 200 i = 1, n
936  x( i ) = zero
937  200 CONTINUE
938  x( j ) = one
939  scale = zero
940  xmax = zero
941  END IF
942  210 CONTINUE
943  ELSE
944 *
945 * Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot
946 * product has already been divided by 1/A(j,j).
947 *
948  x( j ) = zladiv( x( j ), tjjs ) - csumj
949  END IF
950  xmax = max( xmax, cabs1( x( j ) ) )
951  220 CONTINUE
952  END IF
953  scale = scale / tscal
954  END IF
955 *
956 * Scale the column norms by 1/TSCAL for return.
957 *
958  IF( tscal.NE.one ) THEN
959  CALL dscal( n, one / tscal, cnorm, 1 )
960  END IF
961 *
962  RETURN
963 *
964 * End of ZLATRS
965 *
subroutine ztrsv(UPLO, TRANS, DIAG, N, A, LDA, X, INCX)
ZTRSV
Definition: ztrsv.f:151
integer function idamax(N, DX, INCX)
IDAMAX
Definition: idamax.f:53
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
complex *16 function zdotu(N, ZX, INCX, ZY, INCY)
ZDOTU
Definition: zdotu.f:54
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine dlabad(SMALL, LARGE)
DLABAD
Definition: dlabad.f:76
complex *16 function zdotc(N, ZX, INCX, ZY, INCY)
ZDOTC
Definition: zdotc.f:54
double precision function dzasum(N, ZX, INCX)
DZASUM
Definition: dzasum.f:54
integer function izamax(N, ZX, INCX)
IZAMAX
Definition: izamax.f:53
subroutine dscal(N, DA, DX, INCX)
DSCAL
Definition: dscal.f:55
subroutine zdscal(N, DA, ZX, INCX)
ZDSCAL
Definition: zdscal.f:54
complex *16 function zladiv(X, Y)
ZLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.
Definition: zladiv.f:66
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine zaxpy(N, ZA, ZX, INCX, ZY, INCY)
ZAXPY
Definition: zaxpy.f:53

Here is the call graph for this function:

Here is the caller graph for this function: