LAPACK  3.6.1 LAPACK: Linear Algebra PACKage
dqrt16.f
Go to the documentation of this file.
1 *> \brief \b DQRT16
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 DQRT16( TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB,
12 * RWORK, RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER TRANS
16 * INTEGER LDA, LDB, LDX, M, N, NRHS
17 * DOUBLE PRECISION RESID
18 * ..
19 * .. Array Arguments ..
20 * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), RWORK( * ),
21 * \$ X( LDX, * )
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> DQRT16 computes the residual for a solution of a system of linear
31 *> equations A*x = b or A'*x = b:
32 *> RESID = norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ),
33 *> where EPS is the machine epsilon.
34 *> \endverbatim
35 *
36 * Arguments:
37 * ==========
38 *
39 *> \param[in] TRANS
40 *> \verbatim
41 *> TRANS is CHARACTER*1
42 *> Specifies the form of the system of equations:
43 *> = 'N': A *x = b
44 *> = 'T': A'*x = b, where A' is the transpose of A
45 *> = 'C': A'*x = b, where A' is the transpose of A
46 *> \endverbatim
47 *>
48 *> \param[in] M
49 *> \verbatim
50 *> M is INTEGER
51 *> The number of rows of the matrix A. M >= 0.
52 *> \endverbatim
53 *>
54 *> \param[in] N
55 *> \verbatim
56 *> N is INTEGER
57 *> The number of columns of the matrix A. N >= 0.
58 *> \endverbatim
59 *>
60 *> \param[in] NRHS
61 *> \verbatim
62 *> NRHS is INTEGER
63 *> The number of columns of B, the matrix of right hand sides.
64 *> NRHS >= 0.
65 *> \endverbatim
66 *>
67 *> \param[in] A
68 *> \verbatim
69 *> A is DOUBLE PRECISION array, dimension (LDA,N)
70 *> The original M x N matrix A.
71 *> \endverbatim
72 *>
73 *> \param[in] LDA
74 *> \verbatim
75 *> LDA is INTEGER
76 *> The leading dimension of the array A. LDA >= max(1,M).
77 *> \endverbatim
78 *>
79 *> \param[in] X
80 *> \verbatim
81 *> X is DOUBLE PRECISION array, dimension (LDX,NRHS)
82 *> The computed solution vectors for the system of linear
83 *> equations.
84 *> \endverbatim
85 *>
86 *> \param[in] LDX
87 *> \verbatim
88 *> LDX is INTEGER
89 *> The leading dimension of the array X. If TRANS = 'N',
90 *> LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M).
91 *> \endverbatim
92 *>
93 *> \param[in,out] B
94 *> \verbatim
95 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
96 *> On entry, the right hand side vectors for the system of
97 *> linear equations.
98 *> On exit, B is overwritten with the difference B - A*X.
99 *> \endverbatim
100 *>
101 *> \param[in] LDB
102 *> \verbatim
103 *> LDB is INTEGER
104 *> The leading dimension of the array B. IF TRANS = 'N',
105 *> LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
106 *> \endverbatim
107 *>
108 *> \param[out] RWORK
109 *> \verbatim
110 *> RWORK is DOUBLE PRECISION array, dimension (M)
111 *> \endverbatim
112 *>
113 *> \param[out] RESID
114 *> \verbatim
115 *> RESID is DOUBLE PRECISION
116 *> The maximum over the number of right hand sides of
117 *> norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ).
118 *> \endverbatim
119 *
120 * Authors:
121 * ========
122 *
123 *> \author Univ. of Tennessee
124 *> \author Univ. of California Berkeley
125 *> \author Univ. of Colorado Denver
126 *> \author NAG Ltd.
127 *
128 *> \date November 2011
129 *
130 *> \ingroup double_lin
131 *
132 * =====================================================================
133  SUBROUTINE dqrt16( TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB,
134  \$ rwork, resid )
135 *
136 * -- LAPACK test routine (version 3.4.0) --
137 * -- LAPACK is a software package provided by Univ. of Tennessee, --
138 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
139 * November 2011
140 *
141 * .. Scalar Arguments ..
142  CHARACTER TRANS
143  INTEGER LDA, LDB, LDX, M, N, NRHS
144  DOUBLE PRECISION RESID
145 * ..
146 * .. Array Arguments ..
147  DOUBLE PRECISION A( lda, * ), B( ldb, * ), RWORK( * ),
148  \$ x( ldx, * )
149 * ..
150 *
151 * =====================================================================
152 *
153 * .. Parameters ..
154  DOUBLE PRECISION ZERO, ONE
155  parameter ( zero = 0.0d+0, one = 1.0d+0 )
156 * ..
157 * .. Local Scalars ..
158  INTEGER J, N1, N2
159  DOUBLE PRECISION ANORM, BNORM, EPS, XNORM
160 * ..
161 * .. External Functions ..
162  LOGICAL LSAME
163  DOUBLE PRECISION DASUM, DLAMCH, DLANGE
164  EXTERNAL lsame, dasum, dlamch, dlange
165 * ..
166 * .. External Subroutines ..
167  EXTERNAL dgemm
168 * ..
169 * .. Intrinsic Functions ..
170  INTRINSIC max
171 * ..
172 * .. Executable Statements ..
173 *
174 * Quick exit if M = 0 or N = 0 or NRHS = 0
175 *
176  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.EQ.0 ) THEN
177  resid = zero
178  RETURN
179  END IF
180 *
181  IF( lsame( trans, 'T' ) .OR. lsame( trans, 'C' ) ) THEN
182  anorm = dlange( 'I', m, n, a, lda, rwork )
183  n1 = n
184  n2 = m
185  ELSE
186  anorm = dlange( '1', m, n, a, lda, rwork )
187  n1 = m
188  n2 = n
189  END IF
190 *
191  eps = dlamch( 'Epsilon' )
192 *
193 * Compute B - A*X (or B - A'*X ) and store in B.
194 *
195  CALL dgemm( trans, 'No transpose', n1, nrhs, n2, -one, a, lda, x,
196  \$ ldx, one, b, ldb )
197 *
198 * Compute the maximum over the number of right hand sides of
199 * norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ) .
200 *
201  resid = zero
202  DO 10 j = 1, nrhs
203  bnorm = dasum( n1, b( 1, j ), 1 )
204  xnorm = dasum( n2, x( 1, j ), 1 )
205  IF( anorm.EQ.zero .AND. bnorm.EQ.zero ) THEN
206  resid = zero
207  ELSE IF( anorm.LE.zero .OR. xnorm.LE.zero ) THEN
208  resid = one / eps
209  ELSE
210  resid = max( resid, ( ( bnorm / anorm ) / xnorm ) /
211  \$ ( max( m, n )*eps ) )
212  END IF
213  10 CONTINUE
214 *
215  RETURN
216 *
217 * End of DQRT16
218 *
219  END
subroutine dqrt16(TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK, RESID)
DQRT16
Definition: dqrt16.f:135
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:189