LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine sla_porfsx_extended ( integer  PREC_TYPE,
character  UPLO,
integer  N,
integer  NRHS,
real, dimension( lda, * )  A,
integer  LDA,
real, dimension( ldaf, * )  AF,
integer  LDAF,
logical  COLEQU,
real, dimension( * )  C,
real, dimension( ldb, * )  B,
integer  LDB,
real, dimension( ldy, * )  Y,
integer  LDY,
real, dimension( * )  BERR_OUT,
integer  N_NORMS,
real, dimension( nrhs, * )  ERR_BNDS_NORM,
real, dimension( nrhs, * )  ERR_BNDS_COMP,
real, dimension( * )  RES,
real, dimension(*)  AYB,
real, dimension( * )  DY,
real, dimension( * )  Y_TAIL,
real  RCOND,
integer  ITHRESH,
real  RTHRESH,
real  DZ_UB,
logical  IGNORE_CWISE,
integer  INFO 
)

SLA_PORFSX_EXTENDED improves the computed solution to a system of linear equations for symmetric or Hermitian positive-definite matrices by performing extra-precise iterative refinement and provides error bounds and backward error estimates for the solution.

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

Purpose:
 SLA_PORFSX_EXTENDED improves the computed solution to a system of
 linear equations by performing extra-precise iterative refinement
 and provides error bounds and backward error estimates for the solution.
 This subroutine is called by SPORFSX to perform iterative refinement.
 In addition to normwise error bound, the code provides maximum
 componentwise error bound if possible. See comments for ERR_BNDS_NORM
 and ERR_BNDS_COMP for details of the error bounds. Note that this
 subroutine is only resonsible for setting the second fields of
 ERR_BNDS_NORM and ERR_BNDS_COMP.
Parameters
[in]PREC_TYPE
          PREC_TYPE is INTEGER
     Specifies the intermediate precision to be used in refinement.
     The value is defined by ILAPREC(P) where P is a CHARACTER and
     P    = 'S':  Single
          = 'D':  Double
          = 'I':  Indigenous
          = 'X', 'E':  Extra
[in]UPLO
          UPLO is CHARACTER*1
       = 'U':  Upper triangle of A is stored;
       = 'L':  Lower triangle of A is stored.
[in]N
          N is INTEGER
     The number of linear equations, i.e., the order of the
     matrix A.  N >= 0.
[in]NRHS
          NRHS is INTEGER
     The number of right-hand-sides, i.e., the number of columns of the
     matrix B.
[in]A
          A is REAL array, dimension (LDA,N)
     On entry, the N-by-N matrix A.
[in]LDA
          LDA is INTEGER
     The leading dimension of the array A.  LDA >= max(1,N).
[in]AF
          AF is REAL array, dimension (LDAF,N)
     The triangular factor U or L from the Cholesky factorization
     A = U**T*U or A = L*L**T, as computed by SPOTRF.
[in]LDAF
          LDAF is INTEGER
     The leading dimension of the array AF.  LDAF >= max(1,N).
[in]COLEQU
          COLEQU is LOGICAL
     If .TRUE. then column equilibration was done to A before calling
     this routine. This is needed to compute the solution and error
     bounds correctly.
[in]C
          C is REAL array, dimension (N)
     The column scale factors for A. If COLEQU = .FALSE., C
     is not accessed. If C is input, each element of C should be a power
     of the radix to ensure a reliable solution and error estimates.
     Scaling by powers of the radix does not cause rounding errors unless
     the result underflows or overflows. Rounding errors during scaling
     lead to refining with a matrix that is not equivalent to the
     input matrix, producing error estimates that may not be
     reliable.
[in]B
          B is REAL array, dimension (LDB,NRHS)
     The right-hand-side matrix B.
[in]LDB
          LDB is INTEGER
     The leading dimension of the array B.  LDB >= max(1,N).
[in,out]Y
          Y is REAL array, dimension (LDY,NRHS)
     On entry, the solution matrix X, as computed by SPOTRS.
     On exit, the improved solution matrix Y.
[in]LDY
          LDY is INTEGER
     The leading dimension of the array Y.  LDY >= max(1,N).
[out]BERR_OUT
          BERR_OUT is REAL array, dimension (NRHS)
     On exit, BERR_OUT(j) contains the componentwise relative backward
     error for right-hand-side j from the formula
         max(i) ( abs(RES(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
     where abs(Z) is the componentwise absolute value of the matrix
     or vector Z. This is computed by SLA_LIN_BERR.
[in]N_NORMS
          N_NORMS is INTEGER
     Determines which error bounds to return (see ERR_BNDS_NORM
     and ERR_BNDS_COMP).
     If N_NORMS >= 1 return normwise error bounds.
     If N_NORMS >= 2 return componentwise error bounds.
[in,out]ERR_BNDS_NORM
          ERR_BNDS_NORM is REAL array, dimension (NRHS, N_ERR_BNDS)
     For each right-hand side, this array contains information about
     various error bounds and condition numbers corresponding to the
     normwise relative error, which is defined as follows:

     Normwise relative error in the ith solution vector:
             max_j (abs(XTRUE(j,i) - X(j,i)))
            ------------------------------
                  max_j abs(X(j,i))

     The array is indexed by the type of error information as described
     below. There currently are up to three pieces of information
     returned.

     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith
     right-hand side.

     The second index in ERR_BNDS_NORM(:,err) contains the following
     three fields:
     err = 1 "Trust/don't trust" boolean. Trust the answer if the
              reciprocal condition number is less than the threshold
              sqrt(n) * slamch('Epsilon').

     err = 2 "Guaranteed" error bound: The estimated forward error,
              almost certainly within a factor of 10 of the true error
              so long as the next entry is greater than the threshold
              sqrt(n) * slamch('Epsilon'). This error bound should only
              be trusted if the previous boolean is true.

     err = 3  Reciprocal condition number: Estimated normwise
              reciprocal condition number.  Compared with the threshold
              sqrt(n) * slamch('Epsilon') to determine if the error
              estimate is "guaranteed". These reciprocal condition
              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
              appropriately scaled matrix Z.
              Let Z = S*A, where S scales each row by a power of the
              radix so all absolute row sums of Z are approximately 1.

     This subroutine is only responsible for setting the second field
     above.
     See Lapack Working Note 165 for further details and extra
     cautions.
[in,out]ERR_BNDS_COMP
          ERR_BNDS_COMP is REAL array, dimension (NRHS, N_ERR_BNDS)
     For each right-hand side, this array contains information about
     various error bounds and condition numbers corresponding to the
     componentwise relative error, which is defined as follows:

     Componentwise relative error in the ith solution vector:
                    abs(XTRUE(j,i) - X(j,i))
             max_j ----------------------
                         abs(X(j,i))

     The array is indexed by the right-hand side i (on which the
     componentwise relative error depends), and the type of error
     information as described below. There currently are up to three
     pieces of information returned for each right-hand side. If
     componentwise accuracy is not requested (PARAMS(3) = 0.0), then
     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most
     the first (:,N_ERR_BNDS) entries are returned.

     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith
     right-hand side.

     The second index in ERR_BNDS_COMP(:,err) contains the following
     three fields:
     err = 1 "Trust/don't trust" boolean. Trust the answer if the
              reciprocal condition number is less than the threshold
              sqrt(n) * slamch('Epsilon').

     err = 2 "Guaranteed" error bound: The estimated forward error,
              almost certainly within a factor of 10 of the true error
              so long as the next entry is greater than the threshold
              sqrt(n) * slamch('Epsilon'). This error bound should only
              be trusted if the previous boolean is true.

     err = 3  Reciprocal condition number: Estimated componentwise
              reciprocal condition number.  Compared with the threshold
              sqrt(n) * slamch('Epsilon') to determine if the error
              estimate is "guaranteed". These reciprocal condition
              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some
              appropriately scaled matrix Z.
              Let Z = S*(A*diag(x)), where x is the solution for the
              current right-hand side and S scales each row of
              A*diag(x) by a power of the radix so all absolute row
              sums of Z are approximately 1.

     This subroutine is only responsible for setting the second field
     above.
     See Lapack Working Note 165 for further details and extra
     cautions.
[in]RES
          RES is REAL array, dimension (N)
     Workspace to hold the intermediate residual.
[in]AYB
          AYB is REAL array, dimension (N)
     Workspace. This can be the same workspace passed for Y_TAIL.
[in]DY
          DY is REAL array, dimension (N)
     Workspace to hold the intermediate solution.
[in]Y_TAIL
          Y_TAIL is REAL array, dimension (N)
     Workspace to hold the trailing bits of the intermediate solution.
[in]RCOND
          RCOND is REAL
     Reciprocal scaled condition number.  This is an estimate of the
     reciprocal Skeel condition number of the matrix A after
     equilibration (if done).  If this is less than the machine
     precision (in particular, if it is zero), the matrix is singular
     to working precision.  Note that the error may still be small even
     if this number is very small and the matrix appears ill-
     conditioned.
[in]ITHRESH
          ITHRESH is INTEGER
     The maximum number of residual computations allowed for
     refinement. The default is 10. For 'aggressive' set to 100 to
     permit convergence using approximate factorizations or
     factorizations other than LU. If the factorization uses a
     technique other than Gaussian elimination, the guarantees in
     ERR_BNDS_NORM and ERR_BNDS_COMP may no longer be trustworthy.
[in]RTHRESH
          RTHRESH is REAL
     Determines when to stop refinement if the error estimate stops
     decreasing. Refinement will stop when the next solution no longer
     satisfies norm(dx_{i+1}) < RTHRESH * norm(dx_i) where norm(Z) is
     the infinity norm of Z. RTHRESH satisfies 0 < RTHRESH <= 1. The
     default value is 0.5. For 'aggressive' set to 0.9 to permit
     convergence on extremely ill-conditioned matrices. See LAWN 165
     for more details.
[in]DZ_UB
          DZ_UB is REAL
     Determines when to start considering componentwise convergence.
     Componentwise convergence is only considered after each component
     of the solution Y is stable, which we definte as the relative
     change in each component being less than DZ_UB. The default value
     is 0.25, requiring the first bit to be stable. See LAWN 165 for
     more details.
[in]IGNORE_CWISE
          IGNORE_CWISE is LOGICAL
     If .TRUE. then ignore componentwise convergence. Default value
     is .FALSE..
[out]INFO
          INFO is INTEGER
       = 0:  Successful exit.
       < 0:  if INFO = -i, the ith argument to SPOTRS had an illegal
             value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
September 2012

Definition at line 389 of file sla_porfsx_extended.f.

389 *
390 * -- LAPACK computational routine (version 3.4.2) --
391 * -- LAPACK is a software package provided by Univ. of Tennessee, --
392 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
393 * September 2012
394 *
395 * .. Scalar Arguments ..
396  INTEGER info, lda, ldaf, ldb, ldy, n, nrhs, prec_type,
397  $ n_norms, ithresh
398  CHARACTER uplo
399  LOGICAL colequ, ignore_cwise
400  REAL rthresh, dz_ub
401 * ..
402 * .. Array Arguments ..
403  REAL a( lda, * ), af( ldaf, * ), b( ldb, * ),
404  $ y( ldy, * ), res( * ), dy( * ), y_tail( * )
405  REAL c( * ), ayb(*), rcond, berr_out( * ),
406  $ err_bnds_norm( nrhs, * ),
407  $ err_bnds_comp( nrhs, * )
408 * ..
409 *
410 * =====================================================================
411 *
412 * .. Local Scalars ..
413  INTEGER uplo2, cnt, i, j, x_state, z_state
414  REAL yk, dyk, ymin, normy, normx, normdx, dxrat,
415  $ dzrat, prevnormdx, prev_dz_z, dxratmax,
416  $ dzratmax, dx_x, dz_z, final_dx_x, final_dz_z,
417  $ eps, hugeval, incr_thresh
418  LOGICAL incr_prec
419 * ..
420 * .. Parameters ..
421  INTEGER unstable_state, working_state, conv_state,
422  $ noprog_state, y_prec_state, base_residual,
423  $ extra_residual, extra_y
424  parameter ( unstable_state = 0, working_state = 1,
425  $ conv_state = 2, noprog_state = 3 )
426  parameter ( base_residual = 0, extra_residual = 1,
427  $ extra_y = 2 )
428  INTEGER final_nrm_err_i, final_cmp_err_i, berr_i
429  INTEGER rcond_i, nrm_rcond_i, nrm_err_i, cmp_rcond_i
430  INTEGER cmp_err_i, piv_growth_i
431  parameter ( final_nrm_err_i = 1, final_cmp_err_i = 2,
432  $ berr_i = 3 )
433  parameter ( rcond_i = 4, nrm_rcond_i = 5, nrm_err_i = 6 )
434  parameter ( cmp_rcond_i = 7, cmp_err_i = 8,
435  $ piv_growth_i = 9 )
436  INTEGER la_linrx_itref_i, la_linrx_ithresh_i,
437  $ la_linrx_cwise_i
438  parameter ( la_linrx_itref_i = 1,
439  $ la_linrx_ithresh_i = 2 )
440  parameter ( la_linrx_cwise_i = 3 )
441  INTEGER la_linrx_trust_i, la_linrx_err_i,
442  $ la_linrx_rcond_i
443  parameter ( la_linrx_trust_i = 1, la_linrx_err_i = 2 )
444  parameter ( la_linrx_rcond_i = 3 )
445 * ..
446 * .. External Functions ..
447  LOGICAL lsame
448  EXTERNAL ilauplo
449  INTEGER ilauplo
450 * ..
451 * .. External Subroutines ..
452  EXTERNAL saxpy, scopy, spotrs, ssymv, blas_ssymv_x,
453  $ blas_ssymv2_x, sla_syamv, sla_wwaddw,
454  $ sla_lin_berr
455  REAL slamch
456 * ..
457 * .. Intrinsic Functions ..
458  INTRINSIC abs, max, min
459 * ..
460 * .. Executable Statements ..
461 *
462  IF (info.NE.0) RETURN
463  eps = slamch( 'Epsilon' )
464  hugeval = slamch( 'Overflow' )
465 * Force HUGEVAL to Inf
466  hugeval = hugeval * hugeval
467 * Using HUGEVAL may lead to spurious underflows.
468  incr_thresh = REAL( N ) * eps
469 
470  IF ( lsame( uplo, 'L' ) ) THEN
471  uplo2 = ilauplo( 'L' )
472  ELSE
473  uplo2 = ilauplo( 'U' )
474  ENDIF
475 
476  DO j = 1, nrhs
477  y_prec_state = extra_residual
478  IF ( y_prec_state .EQ. extra_y ) THEN
479  DO i = 1, n
480  y_tail( i ) = 0.0
481  END DO
482  END IF
483 
484  dxrat = 0.0
485  dxratmax = 0.0
486  dzrat = 0.0
487  dzratmax = 0.0
488  final_dx_x = hugeval
489  final_dz_z = hugeval
490  prevnormdx = hugeval
491  prev_dz_z = hugeval
492  dz_z = hugeval
493  dx_x = hugeval
494 
495  x_state = working_state
496  z_state = unstable_state
497  incr_prec = .false.
498 
499  DO cnt = 1, ithresh
500 *
501 * Compute residual RES = B_s - op(A_s) * Y,
502 * op(A) = A, A**T, or A**H depending on TRANS (and type).
503 *
504  CALL scopy( n, b( 1, j ), 1, res, 1 )
505  IF ( y_prec_state .EQ. base_residual ) THEN
506  CALL ssymv( uplo, n, -1.0, a, lda, y(1,j), 1,
507  $ 1.0, res, 1 )
508  ELSE IF ( y_prec_state .EQ. extra_residual ) THEN
509  CALL blas_ssymv_x( uplo2, n, -1.0, a, lda,
510  $ y( 1, j ), 1, 1.0, res, 1, prec_type )
511  ELSE
512  CALL blas_ssymv2_x(uplo2, n, -1.0, a, lda,
513  $ y(1, j), y_tail, 1, 1.0, res, 1, prec_type)
514  END IF
515 
516 ! XXX: RES is no longer needed.
517  CALL scopy( n, res, 1, dy, 1 )
518  CALL spotrs( uplo, n, 1, af, ldaf, dy, n, info )
519 *
520 * Calculate relative changes DX_X, DZ_Z and ratios DXRAT, DZRAT.
521 *
522  normx = 0.0
523  normy = 0.0
524  normdx = 0.0
525  dz_z = 0.0
526  ymin = hugeval
527 
528  DO i = 1, n
529  yk = abs( y( i, j ) )
530  dyk = abs( dy( i ) )
531 
532  IF ( yk .NE. 0.0 ) THEN
533  dz_z = max( dz_z, dyk / yk )
534  ELSE IF ( dyk .NE. 0.0 ) THEN
535  dz_z = hugeval
536  END IF
537 
538  ymin = min( ymin, yk )
539 
540  normy = max( normy, yk )
541 
542  IF ( colequ ) THEN
543  normx = max( normx, yk * c( i ) )
544  normdx = max( normdx, dyk * c( i ) )
545  ELSE
546  normx = normy
547  normdx = max( normdx, dyk )
548  END IF
549  END DO
550 
551  IF ( normx .NE. 0.0 ) THEN
552  dx_x = normdx / normx
553  ELSE IF ( normdx .EQ. 0.0 ) THEN
554  dx_x = 0.0
555  ELSE
556  dx_x = hugeval
557  END IF
558 
559  dxrat = normdx / prevnormdx
560  dzrat = dz_z / prev_dz_z
561 *
562 * Check termination criteria.
563 *
564  IF ( ymin*rcond .LT. incr_thresh*normy
565  $ .AND. y_prec_state .LT. extra_y )
566  $ incr_prec = .true.
567 
568  IF ( x_state .EQ. noprog_state .AND. dxrat .LE. rthresh )
569  $ x_state = working_state
570  IF ( x_state .EQ. working_state ) THEN
571  IF ( dx_x .LE. eps ) THEN
572  x_state = conv_state
573  ELSE IF ( dxrat .GT. rthresh ) THEN
574  IF ( y_prec_state .NE. extra_y ) THEN
575  incr_prec = .true.
576  ELSE
577  x_state = noprog_state
578  END IF
579  ELSE
580  IF ( dxrat .GT. dxratmax ) dxratmax = dxrat
581  END IF
582  IF ( x_state .GT. working_state ) final_dx_x = dx_x
583  END IF
584 
585  IF ( z_state .EQ. unstable_state .AND. dz_z .LE. dz_ub )
586  $ z_state = working_state
587  IF ( z_state .EQ. noprog_state .AND. dzrat .LE. rthresh )
588  $ z_state = working_state
589  IF ( z_state .EQ. working_state ) THEN
590  IF ( dz_z .LE. eps ) THEN
591  z_state = conv_state
592  ELSE IF ( dz_z .GT. dz_ub ) THEN
593  z_state = unstable_state
594  dzratmax = 0.0
595  final_dz_z = hugeval
596  ELSE IF ( dzrat .GT. rthresh ) THEN
597  IF ( y_prec_state .NE. extra_y ) THEN
598  incr_prec = .true.
599  ELSE
600  z_state = noprog_state
601  END IF
602  ELSE
603  IF ( dzrat .GT. dzratmax ) dzratmax = dzrat
604  END IF
605  IF ( z_state .GT. working_state ) final_dz_z = dz_z
606  END IF
607 
608  IF ( x_state.NE.working_state.AND.
609  $ ( ignore_cwise.OR.z_state.NE.working_state ) )
610  $ GOTO 666
611 
612  IF ( incr_prec ) THEN
613  incr_prec = .false.
614  y_prec_state = y_prec_state + 1
615  DO i = 1, n
616  y_tail( i ) = 0.0
617  END DO
618  END IF
619 
620  prevnormdx = normdx
621  prev_dz_z = dz_z
622 *
623 * Update soluton.
624 *
625  IF (y_prec_state .LT. extra_y) THEN
626  CALL saxpy( n, 1.0, dy, 1, y(1,j), 1 )
627  ELSE
628  CALL sla_wwaddw( n, y( 1, j ), y_tail, dy )
629  END IF
630 
631  END DO
632 * Target of "IF (Z_STOP .AND. X_STOP)". Sun's f77 won't EXIT.
633  666 CONTINUE
634 *
635 * Set final_* when cnt hits ithresh.
636 *
637  IF ( x_state .EQ. working_state ) final_dx_x = dx_x
638  IF ( z_state .EQ. working_state ) final_dz_z = dz_z
639 *
640 * Compute error bounds.
641 *
642  IF ( n_norms .GE. 1 ) THEN
643  err_bnds_norm( j, la_linrx_err_i ) =
644  $ final_dx_x / (1 - dxratmax)
645  END IF
646  IF ( n_norms .GE. 2 ) THEN
647  err_bnds_comp( j, la_linrx_err_i ) =
648  $ final_dz_z / (1 - dzratmax)
649  END IF
650 *
651 * Compute componentwise relative backward error from formula
652 * max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) )
653 * where abs(Z) is the componentwise absolute value of the matrix
654 * or vector Z.
655 *
656 * Compute residual RES = B_s - op(A_s) * Y,
657 * op(A) = A, A**T, or A**H depending on TRANS (and type).
658 *
659  CALL scopy( n, b( 1, j ), 1, res, 1 )
660  CALL ssymv( uplo, n, -1.0, a, lda, y(1,j), 1, 1.0, res, 1 )
661 
662  DO i = 1, n
663  ayb( i ) = abs( b( i, j ) )
664  END DO
665 *
666 * Compute abs(op(A_s))*abs(Y) + abs(B_s).
667 *
668  CALL sla_syamv( uplo2, n, 1.0,
669  $ a, lda, y(1, j), 1, 1.0, ayb, 1 )
670 
671  CALL sla_lin_berr( n, n, 1, res, ayb, berr_out( j ) )
672 *
673 * End of loop for each RHS.
674 *
675  END DO
676 *
677  RETURN
subroutine sla_syamv(UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
SLA_SYAMV computes a matrix-vector product using a symmetric indefinite matrix to calculate error bou...
Definition: sla_syamv.f:179
integer function ilauplo(UPLO)
ILAUPLO
Definition: ilauplo.f:60
subroutine spotrs(UPLO, N, NRHS, A, LDA, B, LDB, INFO)
SPOTRS
Definition: spotrs.f:112
subroutine saxpy(N, SA, SX, INCX, SY, INCY)
SAXPY
Definition: saxpy.f:54
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69
subroutine sla_lin_berr(N, NZ, NRHS, RES, AYB, BERR)
SLA_LIN_BERR computes a component-wise relative backward error.
Definition: sla_lin_berr.f:103
subroutine sla_wwaddw(N, X, Y, W)
SLA_WWADDW adds a vector into a doubled-single vector.
Definition: sla_wwaddw.f:83
subroutine ssymv(UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
SSYMV
Definition: ssymv.f:154
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine scopy(N, SX, INCX, SY, INCY)
SCOPY
Definition: scopy.f:53

Here is the call graph for this function:

Here is the caller graph for this function: