LAPACK  3.10.1
LAPACK: Linear Algebra PACKage
sppt02.f
Go to the documentation of this file.
1 *> \brief \b SPPT02
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 SPPT02( UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK,
12 * RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER UPLO
16 * INTEGER LDB, LDX, N, NRHS
17 * REAL RESID
18 * ..
19 * .. Array Arguments ..
20 * REAL A( * ), B( LDB, * ), RWORK( * ), X( LDX, * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> SPPT02 computes the residual in the solution of a symmetric system
30 *> of linear equations A*x = b when packed storage is used for the
31 *> coefficient matrix. The ratio computed is
32 *>
33 *> RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS),
34 *>
35 *> where EPS is the machine precision.
36 *> \endverbatim
37 *
38 * Arguments:
39 * ==========
40 *
41 *> \param[in] UPLO
42 *> \verbatim
43 *> UPLO is CHARACTER*1
44 *> Specifies whether the upper or lower triangular part of the
45 *> symmetric matrix A is stored:
46 *> = 'U': Upper triangular
47 *> = 'L': Lower triangular
48 *> \endverbatim
49 *>
50 *> \param[in] N
51 *> \verbatim
52 *> N is INTEGER
53 *> The number of rows and columns of the matrix A. N >= 0.
54 *> \endverbatim
55 *>
56 *> \param[in] NRHS
57 *> \verbatim
58 *> NRHS is INTEGER
59 *> The number of columns of B, the matrix of right hand sides.
60 *> NRHS >= 0.
61 *> \endverbatim
62 *>
63 *> \param[in] A
64 *> \verbatim
65 *> A is REAL array, dimension (N*(N+1)/2)
66 *> The original symmetric matrix A, stored as a packed
67 *> triangular matrix.
68 *> \endverbatim
69 *>
70 *> \param[in] X
71 *> \verbatim
72 *> X is REAL array, dimension (LDX,NRHS)
73 *> The computed solution vectors for the system of linear
74 *> equations.
75 *> \endverbatim
76 *>
77 *> \param[in] LDX
78 *> \verbatim
79 *> LDX is INTEGER
80 *> The leading dimension of the array X. LDX >= max(1,N).
81 *> \endverbatim
82 *>
83 *> \param[in,out] B
84 *> \verbatim
85 *> B is REAL array, dimension (LDB,NRHS)
86 *> On entry, the right hand side vectors for the system of
87 *> linear equations.
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] RWORK
98 *> \verbatim
99 *> RWORK is REAL array, dimension (N)
100 *> \endverbatim
101 *>
102 *> \param[out] RESID
103 *> \verbatim
104 *> RESID is REAL
105 *> The maximum over the number of right hand sides of
106 *> norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
107 *> \endverbatim
108 *
109 * Authors:
110 * ========
111 *
112 *> \author Univ. of Tennessee
113 *> \author Univ. of California Berkeley
114 *> \author Univ. of Colorado Denver
115 *> \author NAG Ltd.
116 *
117 *> \ingroup single_lin
118 *
119 * =====================================================================
120  SUBROUTINE sppt02( UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK,
121  $ RESID )
122 *
123 * -- LAPACK test routine --
124 * -- LAPACK is a software package provided by Univ. of Tennessee, --
125 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
126 *
127 * .. Scalar Arguments ..
128  CHARACTER UPLO
129  INTEGER LDB, LDX, N, NRHS
130  REAL RESID
131 * ..
132 * .. Array Arguments ..
133  REAL A( * ), B( LDB, * ), RWORK( * ), X( LDX, * )
134 * ..
135 *
136 * =====================================================================
137 *
138 * .. Parameters ..
139  REAL ZERO, ONE
140  parameter( zero = 0.0e+0, one = 1.0e+0 )
141 * ..
142 * .. Local Scalars ..
143  INTEGER J
144  REAL ANORM, BNORM, EPS, XNORM
145 * ..
146 * .. External Functions ..
147  REAL SASUM, SLAMCH, SLANSP
148  EXTERNAL sasum, slamch, slansp
149 * ..
150 * .. External Subroutines ..
151  EXTERNAL sspmv
152 * ..
153 * .. Intrinsic Functions ..
154  INTRINSIC max
155 * ..
156 * .. Executable Statements ..
157 *
158 * Quick exit if N = 0 or NRHS = 0.
159 *
160  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
161  resid = zero
162  RETURN
163  END IF
164 *
165 * Exit with RESID = 1/EPS if ANORM = 0.
166 *
167  eps = slamch( 'Epsilon' )
168  anorm = slansp( '1', uplo, n, a, rwork )
169  IF( anorm.LE.zero ) THEN
170  resid = one / eps
171  RETURN
172  END IF
173 *
174 * Compute B - A*X for the matrix of right hand sides B.
175 *
176  DO 10 j = 1, nrhs
177  CALL sspmv( uplo, n, -one, a, x( 1, j ), 1, one, b( 1, j ), 1 )
178  10 CONTINUE
179 *
180 * Compute the maximum over the number of right hand sides of
181 * norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) .
182 *
183  resid = zero
184  DO 20 j = 1, nrhs
185  bnorm = sasum( n, b( 1, j ), 1 )
186  xnorm = sasum( n, x( 1, j ), 1 )
187  IF( xnorm.LE.zero ) THEN
188  resid = one / eps
189  ELSE
190  resid = max( resid, ( ( bnorm / anorm ) / xnorm ) / eps )
191  END IF
192  20 CONTINUE
193 *
194  RETURN
195 *
196 * End of SPPT02
197 *
198  END
subroutine sspmv(UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY)
SSPMV
Definition: sspmv.f:147
subroutine sppt02(UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK, RESID)
SPPT02
Definition: sppt02.f:122