LAPACK  3.9.1
LAPACK: Linear Algebra PACKage
dtpt02.f
Go to the documentation of this file.
1 *> \brief \b DTPT02
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 DTPT02( UPLO, TRANS, DIAG, N, NRHS, AP, X, LDX, B, LDB,
12 * WORK, RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER DIAG, TRANS, UPLO
16 * INTEGER LDB, LDX, N, NRHS
17 * DOUBLE PRECISION RESID
18 * ..
19 * .. Array Arguments ..
20 * DOUBLE PRECISION AP( * ), B( LDB, * ), WORK( * ), X( LDX, * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> DTPT02 computes the residual for the computed solution to a
30 *> triangular system of linear equations A*x = b or A'*x = b when
31 *> the triangular matrix A is stored in packed format. Here A' is the
32 *> transpose of A and x and b are N by NRHS matrices. The test ratio is
33 *> the maximum over the number of right hand sides of
34 *> norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ),
35 *> where op(A) denotes A or A' and EPS is the machine epsilon.
36 *> \endverbatim
37 *
38 * Arguments:
39 * ==========
40 *
41 *> \param[in] UPLO
42 *> \verbatim
43 *> UPLO is CHARACTER*1
44 *> Specifies whether the matrix A is upper or lower triangular.
45 *> = 'U': Upper triangular
46 *> = 'L': Lower triangular
47 *> \endverbatim
48 *>
49 *> \param[in] TRANS
50 *> \verbatim
51 *> TRANS is CHARACTER*1
52 *> Specifies the operation applied to A.
53 *> = 'N': A *x = b (No transpose)
54 *> = 'T': A'*x = b (Transpose)
55 *> = 'C': A'*x = b (Conjugate transpose = Transpose)
56 *> \endverbatim
57 *>
58 *> \param[in] DIAG
59 *> \verbatim
60 *> DIAG is CHARACTER*1
61 *> Specifies whether or not the matrix A is unit triangular.
62 *> = 'N': Non-unit triangular
63 *> = 'U': Unit triangular
64 *> \endverbatim
65 *>
66 *> \param[in] N
67 *> \verbatim
68 *> N is INTEGER
69 *> The order of the matrix A. N >= 0.
70 *> \endverbatim
71 *>
72 *> \param[in] NRHS
73 *> \verbatim
74 *> NRHS is INTEGER
75 *> The number of right hand sides, i.e., the number of columns
76 *> of the matrices X and B. NRHS >= 0.
77 *> \endverbatim
78 *>
79 *> \param[in] AP
80 *> \verbatim
81 *> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
82 *> The upper or lower triangular matrix A, packed columnwise in
83 *> a linear array. The j-th column of A is stored in the array
84 *> AP as follows:
85 *> if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j;
86 *> if UPLO = 'L',
87 *> AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n.
88 *> \endverbatim
89 *>
90 *> \param[in] X
91 *> \verbatim
92 *> X is DOUBLE PRECISION array, dimension (LDX,NRHS)
93 *> The computed solution vectors for the system of linear
94 *> equations.
95 *> \endverbatim
96 *>
97 *> \param[in] LDX
98 *> \verbatim
99 *> LDX is INTEGER
100 *> The leading dimension of the array X. LDX >= max(1,N).
101 *> \endverbatim
102 *>
103 *> \param[in] B
104 *> \verbatim
105 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
106 *> The right hand side vectors for the system of linear
107 *> equations.
108 *> \endverbatim
109 *>
110 *> \param[in] LDB
111 *> \verbatim
112 *> LDB is INTEGER
113 *> The leading dimension of the array B. LDB >= max(1,N).
114 *> \endverbatim
115 *>
116 *> \param[out] WORK
117 *> \verbatim
118 *> WORK is DOUBLE PRECISION array, dimension (N)
119 *> \endverbatim
120 *>
121 *> \param[out] RESID
122 *> \verbatim
123 *> RESID is DOUBLE PRECISION
124 *> The maximum over the number of right hand sides of
125 *> norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
126 *> \endverbatim
127 *
128 * Authors:
129 * ========
130 *
131 *> \author Univ. of Tennessee
132 *> \author Univ. of California Berkeley
133 *> \author Univ. of Colorado Denver
134 *> \author NAG Ltd.
135 *
136 *> \ingroup double_lin
137 *
138 * =====================================================================
139  SUBROUTINE dtpt02( UPLO, TRANS, DIAG, N, NRHS, AP, X, LDX, B, LDB,
140  $ WORK, RESID )
141 *
142 * -- LAPACK test routine --
143 * -- LAPACK is a software package provided by Univ. of Tennessee, --
144 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
145 *
146 * .. Scalar Arguments ..
147  CHARACTER DIAG, TRANS, UPLO
148  INTEGER LDB, LDX, N, NRHS
149  DOUBLE PRECISION RESID
150 * ..
151 * .. Array Arguments ..
152  DOUBLE PRECISION AP( * ), B( LDB, * ), WORK( * ), X( LDX, * )
153 * ..
154 *
155 * =====================================================================
156 *
157 * .. Parameters ..
158  DOUBLE PRECISION ZERO, ONE
159  parameter( zero = 0.0d+0, one = 1.0d+0 )
160 * ..
161 * .. Local Scalars ..
162  INTEGER J
163  DOUBLE PRECISION ANORM, BNORM, EPS, XNORM
164 * ..
165 * .. External Functions ..
166  LOGICAL LSAME
167  DOUBLE PRECISION DASUM, DLAMCH, DLANTP
168  EXTERNAL lsame, dasum, dlamch, dlantp
169 * ..
170 * .. External Subroutines ..
171  EXTERNAL daxpy, dcopy, dtpmv
172 * ..
173 * .. Intrinsic Functions ..
174  INTRINSIC max
175 * ..
176 * .. Executable Statements ..
177 *
178 * Quick exit if N = 0 or NRHS = 0
179 *
180  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
181  resid = zero
182  RETURN
183  END IF
184 *
185 * Compute the 1-norm of A or A'.
186 *
187  IF( lsame( trans, 'N' ) ) THEN
188  anorm = dlantp( '1', uplo, diag, n, ap, work )
189  ELSE
190  anorm = dlantp( 'I', uplo, diag, n, ap, work )
191  END IF
192 *
193 * Exit with RESID = 1/EPS if ANORM = 0.
194 *
195  eps = dlamch( 'Epsilon' )
196  IF( anorm.LE.zero ) THEN
197  resid = one / eps
198  RETURN
199  END IF
200 *
201 * Compute the maximum over the number of right hand sides of
202 * norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
203 *
204  resid = zero
205  DO 10 j = 1, nrhs
206  CALL dcopy( n, x( 1, j ), 1, work, 1 )
207  CALL dtpmv( uplo, trans, diag, n, ap, work, 1 )
208  CALL daxpy( n, -one, b( 1, j ), 1, work, 1 )
209  bnorm = dasum( n, work, 1 )
210  xnorm = dasum( n, x( 1, j ), 1 )
211  IF( xnorm.LE.zero ) THEN
212  resid = one / eps
213  ELSE
214  resid = max( resid, ( ( bnorm / anorm ) / xnorm ) / eps )
215  END IF
216  10 CONTINUE
217 *
218  RETURN
219 *
220 * End of DTPT02
221 *
222  END
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 dtpmv(UPLO, TRANS, DIAG, N, AP, X, INCX)
DTPMV
Definition: dtpmv.f:142
subroutine dtpt02(UPLO, TRANS, DIAG, N, NRHS, AP, X, LDX, B, LDB, WORK, RESID)
DTPT02
Definition: dtpt02.f:141