LAPACK  3.10.1
LAPACK: Linear Algebra PACKage

◆ dtprfs()

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.

Definition at line 173 of file dtprfs.f.

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