MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
cppt05.f
Go to the documentation of this file.
1  SUBROUTINE cppt05( UPLO, N, NRHS, AP, B, LDB, X, LDX, XACT,
2  $ ldxact, ferr, berr, reslts )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  CHARACTER uplo
10  INTEGER ldb, ldx, ldxact, n, nrhs
11 * ..
12 * .. Array Arguments ..
13  REAL berr( * ), ferr( * ), reslts( * )
14  COMPLEX ap( * ), b( ldb, * ), x( ldx, * ),
15  $ xact( ldxact, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * CPPT05 tests the error bounds from iterative refinement for the
22 * computed solution to a system of equations A*X = B, where A is a
23 * Hermitian matrix in packed storage format.
24 *
25 * RESLTS(1) = test of the error bound
26 * = norm(X - XACT) / ( norm(X) * FERR )
27 *
28 * A large value is returned if this ratio is not less than one.
29 *
30 * RESLTS(2) = residual from the iterative refinement routine
31 * = the maximum of BERR / ( (n+1)*EPS + (*) ), where
32 * (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
33 *
34 * Arguments
35 * =========
36 *
37 * UPLO (input) CHARACTER*1
38 * Specifies whether the upper or lower triangular part of the
39 * Hermitian matrix A is stored.
40 * = 'U': Upper triangular
41 * = 'L': Lower triangular
42 *
43 * N (input) INTEGER
44 * The number of rows of the matrices X, B, and XACT, and the
45 * order of the matrix A. N >= 0.
46 *
47 * NRHS (input) INTEGER
48 * The number of columns of the matrices X, B, and XACT.
49 * NRHS >= 0.
50 *
51 * AP (input) COMPLEX array, dimension (N*(N+1)/2)
52 * The upper or lower triangle of the Hermitian matrix A, packed
53 * columnwise in a linear array. The j-th column of A is stored
54 * in the array AP as follows:
55 * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
56 * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
57 *
58 * B (input) COMPLEX array, dimension (LDB,NRHS)
59 * The right hand side vectors for the system of linear
60 * equations.
61 *
62 * LDB (input) INTEGER
63 * The leading dimension of the array B. LDB >= max(1,N).
64 *
65 * X (input) COMPLEX array, dimension (LDX,NRHS)
66 * The computed solution vectors. Each vector is stored as a
67 * column of the matrix X.
68 *
69 * LDX (input) INTEGER
70 * The leading dimension of the array X. LDX >= max(1,N).
71 *
72 * XACT (input) COMPLEX array, dimension (LDX,NRHS)
73 * The exact solution vectors. Each vector is stored as a
74 * column of the matrix XACT.
75 *
76 * LDXACT (input) INTEGER
77 * The leading dimension of the array XACT. LDXACT >= max(1,N).
78 *
79 * FERR (input) REAL array, dimension (NRHS)
80 * The estimated forward error bounds for each solution vector
81 * X. If XTRUE is the true solution, FERR bounds the magnitude
82 * of the largest entry in (X - XTRUE) divided by the magnitude
83 * of the largest entry in X.
84 *
85 * BERR (input) REAL array, dimension (NRHS)
86 * The componentwise relative backward error of each solution
87 * vector (i.e., the smallest relative change in any entry of A
88 * or B that makes X an exact solution).
89 *
90 * RESLTS (output) REAL array, dimension (2)
91 * The maximum over the NRHS solution vectors of the ratios:
92 * RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
93 * RESLTS(2) = BERR / ( (n+1)*EPS + (*) )
94 *
95 * =====================================================================
96 *
97 * .. Parameters ..
98  REAL zero, one
99  parameter( zero = 0.0e+0, one = 1.0e+0 )
100 * ..
101 * .. Local Scalars ..
102  LOGICAL upper
103  INTEGER i, imax, j, jc, k
104  REAL axbi, diff, eps, errbnd, ovfl, tmp, unfl, xnorm
105  COMPLEX zdum
106 * ..
107 * .. External Functions ..
108  LOGICAL lsame
109  INTEGER icamax
110  REAL slamch
111  EXTERNAL lsame, icamax, slamch
112 * ..
113 * .. Intrinsic Functions ..
114  INTRINSIC abs, aimag, max, min, real
115 * ..
116 * .. Statement Functions ..
117  REAL cabs1
118 * ..
119 * .. Statement Function definitions ..
120  cabs1( zdum ) = abs( REAL( ZDUM ) ) + abs( aimag( zdum ) )
121 * ..
122 * .. Executable Statements ..
123 *
124 * Quick exit if N = 0 or NRHS = 0.
125 *
126  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
127  reslts( 1 ) = zero
128  reslts( 2 ) = zero
129  return
130  END IF
131 *
132  eps = slamch( 'Epsilon' )
133  unfl = slamch( 'Safe minimum' )
134  ovfl = one / unfl
135  upper = lsame( uplo, 'U' )
136 *
137 * Test 1: Compute the maximum of
138 * norm(X - XACT) / ( norm(X) * FERR )
139 * over all the vectors X and XACT using the infinity-norm.
140 *
141  errbnd = zero
142  DO 30 j = 1, nrhs
143  imax = icamax( n, x( 1, j ), 1 )
144  xnorm = max( cabs1( x( imax, j ) ), unfl )
145  diff = zero
146  DO 10 i = 1, n
147  diff = max( diff, cabs1( x( i, j )-xact( i, j ) ) )
148  10 continue
149 *
150  IF( xnorm.GT.one ) THEN
151  go to 20
152  ELSE IF( diff.LE.ovfl*xnorm ) THEN
153  go to 20
154  ELSE
155  errbnd = one / eps
156  go to 30
157  END IF
158 *
159  20 continue
160  IF( diff / xnorm.LE.ferr( j ) ) THEN
161  errbnd = max( errbnd, ( diff / xnorm ) / ferr( j ) )
162  ELSE
163  errbnd = one / eps
164  END IF
165  30 continue
166  reslts( 1 ) = errbnd
167 *
168 * Test 2: Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where
169 * (*) = (n+1)*UNFL / (min_i (abs(A)*abs(X) +abs(b))_i )
170 *
171  DO 90 k = 1, nrhs
172  DO 80 i = 1, n
173  tmp = cabs1( b( i, k ) )
174  IF( upper ) THEN
175  jc = ( ( i-1 )*i ) / 2
176  DO 40 j = 1, i - 1
177  tmp = tmp + cabs1( ap( jc+j ) )*cabs1( x( j, k ) )
178  40 continue
179  tmp = tmp + abs( REAL( AP( JC+I ) ) )*cabs1( x( i, k ) )
180  jc = jc + i + i
181  DO 50 j = i + 1, n
182  tmp = tmp + cabs1( ap( jc ) )*cabs1( x( j, k ) )
183  jc = jc + j
184  50 continue
185  ELSE
186  jc = i
187  DO 60 j = 1, i - 1
188  tmp = tmp + cabs1( ap( jc ) )*cabs1( x( j, k ) )
189  jc = jc + n - j
190  60 continue
191  tmp = tmp + abs( REAL( AP( JC ) ) )*cabs1( x( i, k ) )
192  DO 70 j = i + 1, n
193  tmp = tmp + cabs1( ap( jc+j-i ) )*cabs1( x( j, k ) )
194  70 continue
195  END IF
196  IF( i.EQ.1 ) THEN
197  axbi = tmp
198  ELSE
199  axbi = min( axbi, tmp )
200  END IF
201  80 continue
202  tmp = berr( k ) / ( ( n+1 )*eps+( n+1 )*unfl /
203  $ max( axbi, ( n+1 )*unfl ) )
204  IF( k.EQ.1 ) THEN
205  reslts( 2 ) = tmp
206  ELSE
207  reslts( 2 ) = max( reslts( 2 ), tmp )
208  END IF
209  90 continue
210 *
211  return
212 *
213 * End of CPPT05
214 *
215  END