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