LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine dtprfs ( character  UPLO,
character  TRANS,
character  DIAG,
integer  N,
integer  NRHS,
double precision, dimension( * )  AP,
double precision, dimension( ldb, * )  B,
integer  LDB,
double precision, dimension( ldx, * )  X,
integer  LDX,
double precision, dimension( * )  FERR,
double precision, dimension( * )  BERR,
double precision, dimension( * )  WORK,
integer, dimension( * )  IWORK,
integer  INFO 
)

DTPRFS

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

Purpose:
 DTPRFS provides error bounds and backward error estimates for the
 solution to a system of linear equations with a triangular packed
 coefficient matrix.

 The solution matrix X must be computed by DTPTRS or some other
 means before entering this routine.  DTPRFS does not do iterative
 refinement because doing so cannot improve the backward error.
Parameters
[in]UPLO
          UPLO is CHARACTER*1
          = 'U':  A is upper triangular;
          = 'L':  A is lower triangular.
[in]TRANS
          TRANS is CHARACTER*1
          Specifies the form of the system of equations:
          = 'N':  A * X = B  (No transpose)
          = 'T':  A**T * X = B  (Transpose)
          = 'C':  A**H * X = B  (Conjugate transpose = Transpose)
[in]DIAG
          DIAG is CHARACTER*1
          = 'N':  A is non-unit triangular;
          = 'U':  A is unit triangular.
[in]N
          N is INTEGER
          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 matrices B and X.  NRHS >= 0.
[in]AP
          AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
          The upper or lower triangular matrix A, packed columnwise in
          a linear array.  The j-th column of A is stored in the array
          AP as follows:
          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
          If DIAG = 'U', the diagonal elements of A are not referenced
          and are assumed to be 1.
[in]B
          B is DOUBLE PRECISION 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]X
          X is DOUBLE PRECISION array, dimension (LDX,NRHS)
          The solution matrix X.
[in]LDX
          LDX is INTEGER
          The leading dimension of the array X.  LDX >= max(1,N).
[out]FERR
          FERR is DOUBLE PRECISION array, dimension (NRHS)
          The estimated forward error bound for each solution vector
          X(j) (the j-th column of the solution matrix X).
          If XTRUE is the true solution corresponding to X(j), FERR(j)
          is an estimated upper bound for the magnitude of the largest
          element in (X(j) - XTRUE) divided by the magnitude of the
          largest element in X(j).  The estimate is as reliable as
          the estimate for RCOND, and is almost always a slight
          overestimate of the true error.
[out]BERR
          BERR is DOUBLE PRECISION array, dimension (NRHS)
          The componentwise relative backward error of each solution
          vector X(j) (i.e., the smallest relative change in
          any element of A or B that makes X(j) an exact solution).
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (3*N)
[out]IWORK
          IWORK is INTEGER array, dimension (N)
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011

Definition at line 177 of file dtprfs.f.

177 *
178 * -- LAPACK computational routine (version 3.4.0) --
179 * -- LAPACK is a software package provided by Univ. of Tennessee, --
180 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
181 * November 2011
182 *
183 * .. Scalar Arguments ..
184  CHARACTER diag, trans, uplo
185  INTEGER info, ldb, ldx, n, nrhs
186 * ..
187 * .. Array Arguments ..
188  INTEGER iwork( * )
189  DOUBLE PRECISION ap( * ), b( ldb, * ), berr( * ), ferr( * ),
190  $ work( * ), x( ldx, * )
191 * ..
192 *
193 * =====================================================================
194 *
195 * .. Parameters ..
196  DOUBLE PRECISION zero
197  parameter ( zero = 0.0d+0 )
198  DOUBLE PRECISION one
199  parameter ( one = 1.0d+0 )
200 * ..
201 * .. Local Scalars ..
202  LOGICAL notran, nounit, upper
203  CHARACTER transt
204  INTEGER i, j, k, kase, kc, nz
205  DOUBLE PRECISION eps, lstres, s, safe1, safe2, safmin, xk
206 * ..
207 * .. Local Arrays ..
208  INTEGER isave( 3 )
209 * ..
210 * .. External Subroutines ..
211  EXTERNAL daxpy, dcopy, dlacn2, dtpmv, dtpsv, xerbla
212 * ..
213 * .. Intrinsic Functions ..
214  INTRINSIC abs, max
215 * ..
216 * .. External Functions ..
217  LOGICAL lsame
218  DOUBLE PRECISION dlamch
219  EXTERNAL lsame, dlamch
220 * ..
221 * .. Executable Statements ..
222 *
223 * Test the input parameters.
224 *
225  info = 0
226  upper = lsame( uplo, 'U' )
227  notran = lsame( trans, 'N' )
228  nounit = lsame( diag, 'N' )
229 *
230  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
231  info = -1
232  ELSE IF( .NOT.notran .AND. .NOT.lsame( trans, 'T' ) .AND. .NOT.
233  $ lsame( trans, 'C' ) ) THEN
234  info = -2
235  ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag, 'U' ) ) THEN
236  info = -3
237  ELSE IF( n.LT.0 ) THEN
238  info = -4
239  ELSE IF( nrhs.LT.0 ) THEN
240  info = -5
241  ELSE IF( ldb.LT.max( 1, n ) ) THEN
242  info = -8
243  ELSE IF( ldx.LT.max( 1, n ) ) THEN
244  info = -10
245  END IF
246  IF( info.NE.0 ) THEN
247  CALL xerbla( 'DTPRFS', -info )
248  RETURN
249  END IF
250 *
251 * Quick return if possible
252 *
253  IF( n.EQ.0 .OR. nrhs.EQ.0 ) THEN
254  DO 10 j = 1, nrhs
255  ferr( j ) = zero
256  berr( j ) = zero
257  10 CONTINUE
258  RETURN
259  END IF
260 *
261  IF( notran ) THEN
262  transt = 'T'
263  ELSE
264  transt = 'N'
265  END IF
266 *
267 * NZ = maximum number of nonzero elements in each row of A, plus 1
268 *
269  nz = n + 1
270  eps = dlamch( 'Epsilon' )
271  safmin = dlamch( 'Safe minimum' )
272  safe1 = nz*safmin
273  safe2 = safe1 / eps
274 *
275 * Do for each right hand side
276 *
277  DO 250 j = 1, nrhs
278 *
279 * Compute residual R = B - op(A) * X,
280 * where op(A) = A or A**T, depending on TRANS.
281 *
282  CALL dcopy( n, x( 1, j ), 1, work( n+1 ), 1 )
283  CALL dtpmv( uplo, trans, diag, n, ap, work( n+1 ), 1 )
284  CALL daxpy( n, -one, b( 1, j ), 1, work( n+1 ), 1 )
285 *
286 * Compute componentwise relative backward error from formula
287 *
288 * max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) )
289 *
290 * where abs(Z) is the componentwise absolute value of the matrix
291 * or vector Z. If the i-th component of the denominator is less
292 * than SAFE2, then SAFE1 is added to the i-th components of the
293 * numerator and denominator before dividing.
294 *
295  DO 20 i = 1, n
296  work( i ) = abs( b( i, j ) )
297  20 CONTINUE
298 *
299  IF( notran ) THEN
300 *
301 * Compute abs(A)*abs(X) + abs(B).
302 *
303  IF( upper ) THEN
304  kc = 1
305  IF( nounit ) THEN
306  DO 40 k = 1, n
307  xk = abs( x( k, j ) )
308  DO 30 i = 1, k
309  work( i ) = work( i ) + abs( ap( kc+i-1 ) )*xk
310  30 CONTINUE
311  kc = kc + k
312  40 CONTINUE
313  ELSE
314  DO 60 k = 1, n
315  xk = abs( x( k, j ) )
316  DO 50 i = 1, k - 1
317  work( i ) = work( i ) + abs( ap( kc+i-1 ) )*xk
318  50 CONTINUE
319  work( k ) = work( k ) + xk
320  kc = kc + k
321  60 CONTINUE
322  END IF
323  ELSE
324  kc = 1
325  IF( nounit ) THEN
326  DO 80 k = 1, n
327  xk = abs( x( k, j ) )
328  DO 70 i = k, n
329  work( i ) = work( i ) + abs( ap( kc+i-k ) )*xk
330  70 CONTINUE
331  kc = kc + n - k + 1
332  80 CONTINUE
333  ELSE
334  DO 100 k = 1, n
335  xk = abs( x( k, j ) )
336  DO 90 i = k + 1, n
337  work( i ) = work( i ) + abs( ap( kc+i-k ) )*xk
338  90 CONTINUE
339  work( k ) = work( k ) + xk
340  kc = kc + n - k + 1
341  100 CONTINUE
342  END IF
343  END IF
344  ELSE
345 *
346 * Compute abs(A**T)*abs(X) + abs(B).
347 *
348  IF( upper ) THEN
349  kc = 1
350  IF( nounit ) THEN
351  DO 120 k = 1, n
352  s = zero
353  DO 110 i = 1, k
354  s = s + abs( ap( kc+i-1 ) )*abs( x( i, j ) )
355  110 CONTINUE
356  work( k ) = work( k ) + s
357  kc = kc + k
358  120 CONTINUE
359  ELSE
360  DO 140 k = 1, n
361  s = abs( x( k, j ) )
362  DO 130 i = 1, k - 1
363  s = s + abs( ap( kc+i-1 ) )*abs( x( i, j ) )
364  130 CONTINUE
365  work( k ) = work( k ) + s
366  kc = kc + k
367  140 CONTINUE
368  END IF
369  ELSE
370  kc = 1
371  IF( nounit ) THEN
372  DO 160 k = 1, n
373  s = zero
374  DO 150 i = k, n
375  s = s + abs( ap( kc+i-k ) )*abs( x( i, j ) )
376  150 CONTINUE
377  work( k ) = work( k ) + s
378  kc = kc + n - k + 1
379  160 CONTINUE
380  ELSE
381  DO 180 k = 1, n
382  s = abs( x( k, j ) )
383  DO 170 i = k + 1, n
384  s = s + abs( ap( kc+i-k ) )*abs( x( i, j ) )
385  170 CONTINUE
386  work( k ) = work( k ) + s
387  kc = kc + n - k + 1
388  180 CONTINUE
389  END IF
390  END IF
391  END IF
392  s = zero
393  DO 190 i = 1, n
394  IF( work( i ).GT.safe2 ) THEN
395  s = max( s, abs( work( n+i ) ) / work( i ) )
396  ELSE
397  s = max( s, ( abs( work( n+i ) )+safe1 ) /
398  $ ( work( i )+safe1 ) )
399  END IF
400  190 CONTINUE
401  berr( j ) = s
402 *
403 * Bound error from formula
404 *
405 * norm(X - XTRUE) / norm(X) .le. FERR =
406 * norm( abs(inv(op(A)))*
407 * ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X)
408 *
409 * where
410 * norm(Z) is the magnitude of the largest component of Z
411 * inv(op(A)) is the inverse of op(A)
412 * abs(Z) is the componentwise absolute value of the matrix or
413 * vector Z
414 * NZ is the maximum number of nonzeros in any row of A, plus 1
415 * EPS is machine epsilon
416 *
417 * The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B))
418 * is incremented by SAFE1 if the i-th component of
419 * abs(op(A))*abs(X) + abs(B) is less than SAFE2.
420 *
421 * Use DLACN2 to estimate the infinity-norm of the matrix
422 * inv(op(A)) * diag(W),
423 * where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) )))
424 *
425  DO 200 i = 1, n
426  IF( work( i ).GT.safe2 ) THEN
427  work( i ) = abs( work( n+i ) ) + nz*eps*work( i )
428  ELSE
429  work( i ) = abs( work( n+i ) ) + nz*eps*work( i ) + safe1
430  END IF
431  200 CONTINUE
432 *
433  kase = 0
434  210 CONTINUE
435  CALL dlacn2( n, work( 2*n+1 ), work( n+1 ), iwork, ferr( j ),
436  $ kase, isave )
437  IF( kase.NE.0 ) THEN
438  IF( kase.EQ.1 ) THEN
439 *
440 * Multiply by diag(W)*inv(op(A)**T).
441 *
442  CALL dtpsv( uplo, transt, diag, n, ap, work( n+1 ), 1 )
443  DO 220 i = 1, n
444  work( n+i ) = work( i )*work( n+i )
445  220 CONTINUE
446  ELSE
447 *
448 * Multiply by inv(op(A))*diag(W).
449 *
450  DO 230 i = 1, n
451  work( n+i ) = work( i )*work( n+i )
452  230 CONTINUE
453  CALL dtpsv( uplo, trans, diag, n, ap, work( n+1 ), 1 )
454  END IF
455  GO TO 210
456  END IF
457 *
458 * Normalize error.
459 *
460  lstres = zero
461  DO 240 i = 1, n
462  lstres = max( lstres, abs( x( i, j ) ) )
463  240 CONTINUE
464  IF( lstres.NE.zero )
465  $ ferr( j ) = ferr( j ) / lstres
466 *
467  250 CONTINUE
468 *
469  RETURN
470 *
471 * End of DTPRFS
472 *
subroutine dcopy(N, DX, INCX, DY, INCY)
DCOPY
Definition: dcopy.f:53
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
subroutine daxpy(N, DA, DX, INCX, DY, INCY)
DAXPY
Definition: daxpy.f:54
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine dtpsv(UPLO, TRANS, DIAG, N, AP, X, INCX)
DTPSV
Definition: dtpsv.f:146
subroutine dtpmv(UPLO, TRANS, DIAG, N, AP, X, INCX)
DTPMV
Definition: dtpmv.f:144
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine dlacn2(N, V, X, ISGN, EST, KASE, ISAVE)
DLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition: dlacn2.f:138

Here is the call graph for this function:

Here is the caller graph for this function: