LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
cptt02.f
Go to the documentation of this file.
1 *> \brief \b CPTT02
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE CPTT02( UPLO, N, NRHS, D, E, X, LDX, B, LDB, RESID )
12 *
13 * .. Scalar Arguments ..
14 * CHARACTER UPLO
15 * INTEGER LDB, LDX, N, NRHS
16 * REAL RESID
17 * ..
18 * .. Array Arguments ..
19 * REAL D( * )
20 * COMPLEX B( LDB, * ), E( * ), X( LDX, * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> CPTT02 computes the residual for the solution to a symmetric
30 *> tridiagonal system of equations:
31 *> RESID = norm(B - A*X) / (norm(A) * norm(X) * EPS),
32 *> where EPS is the machine epsilon.
33 *> \endverbatim
34 *
35 * Arguments:
36 * ==========
37 *
38 *> \param[in] UPLO
39 *> \verbatim
40 *> UPLO is CHARACTER*1
41 *> Specifies whether the superdiagonal or the subdiagonal of the
42 *> tridiagonal matrix A is stored.
43 *> = 'U': E is the superdiagonal of A
44 *> = 'L': E is the subdiagonal of A
45 *> \endverbatim
46 *>
47 *> \param[in] N
48 *> \verbatim
49 *> N is INTEGTER
50 *> The order of the matrix A.
51 *> \endverbatim
52 *>
53 *> \param[in] NRHS
54 *> \verbatim
55 *> NRHS is INTEGER
56 *> The number of right hand sides, i.e., the number of columns
57 *> of the matrices B and X. NRHS >= 0.
58 *> \endverbatim
59 *>
60 *> \param[in] D
61 *> \verbatim
62 *> D is REAL array, dimension (N)
63 *> The n diagonal elements of the tridiagonal matrix A.
64 *> \endverbatim
65 *>
66 *> \param[in] E
67 *> \verbatim
68 *> E is COMPLEX array, dimension (N-1)
69 *> The (n-1) subdiagonal elements of the tridiagonal matrix A.
70 *> \endverbatim
71 *>
72 *> \param[in] X
73 *> \verbatim
74 *> X is COMPLEX array, dimension (LDX,NRHS)
75 *> The n by nrhs matrix of solution vectors X.
76 *> \endverbatim
77 *>
78 *> \param[in] LDX
79 *> \verbatim
80 *> LDX is INTEGER
81 *> The leading dimension of the array X. LDX >= max(1,N).
82 *> \endverbatim
83 *>
84 *> \param[in,out] B
85 *> \verbatim
86 *> B is COMPLEX array, dimension (LDB,NRHS)
87 *> On entry, the n by nrhs matrix of right hand side vectors B.
88 *> On exit, B is overwritten with the difference B - A*X.
89 *> \endverbatim
90 *>
91 *> \param[in] LDB
92 *> \verbatim
93 *> LDB is INTEGER
94 *> The leading dimension of the array B. LDB >= max(1,N).
95 *> \endverbatim
96 *>
97 *> \param[out] RESID
98 *> \verbatim
99 *> RESID is REAL
100 *> norm(B - A*X) / (norm(A) * norm(X) * EPS)
101 *> \endverbatim
102 *
103 * Authors:
104 * ========
105 *
106 *> \author Univ. of Tennessee
107 *> \author Univ. of California Berkeley
108 *> \author Univ. of Colorado Denver
109 *> \author NAG Ltd.
110 *
111 *> \date November 2011
112 *
113 *> \ingroup complex_lin
114 *
115 * =====================================================================
116  SUBROUTINE cptt02( UPLO, N, NRHS, D, E, X, LDX, B, LDB, RESID )
117 *
118 * -- LAPACK test routine (version 3.4.0) --
119 * -- LAPACK is a software package provided by Univ. of Tennessee, --
120 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
121 * November 2011
122 *
123 * .. Scalar Arguments ..
124  CHARACTER uplo
125  INTEGER ldb, ldx, n, nrhs
126  REAL resid
127 * ..
128 * .. Array Arguments ..
129  REAL d( * )
130  COMPLEX b( ldb, * ), e( * ), x( ldx, * )
131 * ..
132 *
133 * =====================================================================
134 *
135 * .. Parameters ..
136  REAL one, zero
137  parameter( one = 1.0e+0, zero = 0.0e+0 )
138 * ..
139 * .. Local Scalars ..
140  INTEGER j
141  REAL anorm, bnorm, eps, xnorm
142 * ..
143 * .. External Functions ..
144  REAL clanht, scasum, slamch
145  EXTERNAL clanht, scasum, slamch
146 * ..
147 * .. Intrinsic Functions ..
148  INTRINSIC max
149 * ..
150 * .. External Subroutines ..
151  EXTERNAL claptm
152 * ..
153 * .. Executable Statements ..
154 *
155 * Quick return if possible
156 *
157  IF( n.LE.0 ) THEN
158  resid = zero
159  return
160  END IF
161 *
162 * Compute the 1-norm of the tridiagonal matrix A.
163 *
164  anorm = clanht( '1', n, d, e )
165 *
166 * Exit with RESID = 1/EPS if ANORM = 0.
167 *
168  eps = slamch( 'Epsilon' )
169  IF( anorm.LE.zero ) THEN
170  resid = one / eps
171  return
172  END IF
173 *
174 * Compute B - A*X.
175 *
176  CALL claptm( uplo, n, nrhs, -one, d, e, x, ldx, one, b, ldb )
177 *
178 * Compute the maximum over the number of right hand sides of
179 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
180 *
181  resid = zero
182  DO 10 j = 1, nrhs
183  bnorm = scasum( n, b( 1, j ), 1 )
184  xnorm = scasum( n, x( 1, j ), 1 )
185  IF( xnorm.LE.zero ) THEN
186  resid = one / eps
187  ELSE
188  resid = max( resid, ( ( bnorm / anorm ) / xnorm ) / eps )
189  END IF
190  10 continue
191 *
192  return
193 *
194 * End of CPTT02
195 *
196  END