LAPACK  3.4.2 LAPACK: Linear Algebra PACKage
dqrt17.f
Go to the documentation of this file.
1 *> \brief \b DQRT17
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * DOUBLE PRECISION FUNCTION DQRT17( TRANS, IRESID, M, N, NRHS, A,
12 * LDA, X, LDX, B, LDB, C, WORK, LWORK )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER TRANS
16 * INTEGER IRESID, LDA, LDB, LDX, LWORK, M, N, NRHS
17 * ..
18 * .. Array Arguments ..
19 * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDB, * ),
20 * \$ WORK( LWORK ), X( LDX, * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> DQRT17 computes the ratio
30 *>
31 *> || R'*op(A) ||/(||A||*alpha*max(M,N,NRHS)*eps)
32 *>
33 *> where R = op(A)*X - B, op(A) is A or A', and
34 *>
35 *> alpha = ||B|| if IRESID = 1 (zero-residual problem)
36 *> alpha = ||R|| if IRESID = 2 (otherwise).
37 *> \endverbatim
38 *
39 * Arguments:
40 * ==========
41 *
42 *> \param[in] TRANS
43 *> \verbatim
44 *> TRANS is CHARACTER*1
45 *> Specifies whether or not the transpose of A is used.
46 *> = 'N': No transpose, op(A) = A.
47 *> = 'T': Transpose, op(A) = A'.
48 *> \endverbatim
49 *>
50 *> \param[in] IRESID
51 *> \verbatim
52 *> IRESID is INTEGER
53 *> IRESID = 1 indicates zero-residual problem.
54 *> IRESID = 2 indicates non-zero residual.
55 *> \endverbatim
56 *>
57 *> \param[in] M
58 *> \verbatim
59 *> M is INTEGER
60 *> The number of rows of the matrix A.
61 *> If TRANS = 'N', the number of rows of the matrix B.
62 *> If TRANS = 'T', the number of rows of the matrix X.
63 *> \endverbatim
64 *>
65 *> \param[in] N
66 *> \verbatim
67 *> N is INTEGER
68 *> The number of columns of the matrix A.
69 *> If TRANS = 'N', the number of rows of the matrix X.
70 *> If TRANS = 'T', the number of rows of the matrix B.
71 *> \endverbatim
72 *>
73 *> \param[in] NRHS
74 *> \verbatim
75 *> NRHS is INTEGER
76 *> The number of columns of the matrices X and B.
77 *> \endverbatim
78 *>
79 *> \param[in] A
80 *> \verbatim
81 *> A is DOUBLE PRECISION array, dimension (LDA,N)
82 *> The m-by-n matrix A.
83 *> \endverbatim
84 *>
85 *> \param[in] LDA
86 *> \verbatim
87 *> LDA is INTEGER
88 *> The leading dimension of the array A. LDA >= M.
89 *> \endverbatim
90 *>
91 *> \param[in] X
92 *> \verbatim
93 *> X is DOUBLE PRECISION array, dimension (LDX,NRHS)
94 *> If TRANS = 'N', the n-by-nrhs matrix X.
95 *> If TRANS = 'T', the m-by-nrhs matrix X.
96 *> \endverbatim
97 *>
98 *> \param[in] LDX
99 *> \verbatim
100 *> LDX is INTEGER
101 *> The leading dimension of the array X.
102 *> If TRANS = 'N', LDX >= N.
103 *> If TRANS = 'T', LDX >= M.
104 *> \endverbatim
105 *>
106 *> \param[in] B
107 *> \verbatim
108 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
109 *> If TRANS = 'N', the m-by-nrhs matrix B.
110 *> If TRANS = 'T', the n-by-nrhs matrix B.
111 *> \endverbatim
112 *>
113 *> \param[in] LDB
114 *> \verbatim
115 *> LDB is INTEGER
116 *> The leading dimension of the array B.
117 *> If TRANS = 'N', LDB >= M.
118 *> If TRANS = 'T', LDB >= N.
119 *> \endverbatim
120 *>
121 *> \param[out] C
122 *> \verbatim
123 *> C is DOUBLE PRECISION array, dimension (LDB,NRHS)
124 *> \endverbatim
125 *>
126 *> \param[out] WORK
127 *> \verbatim
128 *> WORK is DOUBLE PRECISION array, dimension (LWORK)
129 *> \endverbatim
130 *>
131 *> \param[in] LWORK
132 *> \verbatim
133 *> LWORK is INTEGER
134 *> The length of the array WORK. LWORK >= NRHS*(M+N).
135 *> \endverbatim
136 *
137 * Authors:
138 * ========
139 *
140 *> \author Univ. of Tennessee
141 *> \author Univ. of California Berkeley
142 *> \author Univ. of Colorado Denver
143 *> \author NAG Ltd.
144 *
145 *> \date November 2011
146 *
147 *> \ingroup double_lin
148 *
149 * =====================================================================
150  DOUBLE PRECISION FUNCTION dqrt17( TRANS, IRESID, M, N, NRHS, A,
151  \$ lda, x, ldx, b, ldb, c, work, lwork )
152 *
153 * -- LAPACK test routine (version 3.4.0) --
154 * -- LAPACK is a software package provided by Univ. of Tennessee, --
155 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
156 * November 2011
157 *
158 * .. Scalar Arguments ..
159  CHARACTER trans
160  INTEGER iresid, lda, ldb, ldx, lwork, m, n, nrhs
161 * ..
162 * .. Array Arguments ..
163  DOUBLE PRECISION a( lda, * ), b( ldb, * ), c( ldb, * ),
164  \$ work( lwork ), x( ldx, * )
165 * ..
166 *
167 * =====================================================================
168 *
169 * .. Parameters ..
170  DOUBLE PRECISION zero, one
171  parameter( zero = 0.0d0, one = 1.0d0 )
172 * ..
173 * .. Local Scalars ..
174  INTEGER info, iscl, ncols, nrows
175  DOUBLE PRECISION bignum, err, norma, normb, normrs, normx,
176  \$ smlnum
177 * ..
178 * .. Local Arrays ..
179  DOUBLE PRECISION rwork( 1 )
180 * ..
181 * .. External Functions ..
182  LOGICAL lsame
183  DOUBLE PRECISION dlamch, dlange
184  EXTERNAL lsame, dlamch, dlange
185 * ..
186 * .. External Subroutines ..
187  EXTERNAL dgemm, dlacpy, dlascl, xerbla
188 * ..
189 * .. Intrinsic Functions ..
190  INTRINSIC dble, max
191 * ..
192 * .. Executable Statements ..
193 *
194  dqrt17 = zero
195 *
196  IF( lsame( trans, 'N' ) ) THEN
197  nrows = m
198  ncols = n
199  ELSE IF( lsame( trans, 'T' ) ) THEN
200  nrows = n
201  ncols = m
202  ELSE
203  CALL xerbla( 'DQRT17', 1 )
204  return
205  END IF
206 *
207  IF( lwork.LT.ncols*nrhs ) THEN
208  CALL xerbla( 'DQRT17', 13 )
209  return
210  END IF
211 *
212  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 ) THEN
213  return
214  END IF
215 *
216  norma = dlange( 'One-norm', m, n, a, lda, rwork )
217  smlnum = dlamch( 'Safe minimum' ) / dlamch( 'Precision' )
218  bignum = one / smlnum
219  iscl = 0
220 *
221 * compute residual and scale it
222 *
223  CALL dlacpy( 'All', nrows, nrhs, b, ldb, c, ldb )
224  CALL dgemm( trans, 'No transpose', nrows, nrhs, ncols, -one, a,
225  \$ lda, x, ldx, one, c, ldb )
226  normrs = dlange( 'Max', nrows, nrhs, c, ldb, rwork )
227  IF( normrs.GT.smlnum ) THEN
228  iscl = 1
229  CALL dlascl( 'General', 0, 0, normrs, one, nrows, nrhs, c, ldb,
230  \$ info )
231  END IF
232 *
233 * compute R'*A
234 *
235  CALL dgemm( 'Transpose', trans, nrhs, ncols, nrows, one, c, ldb,
236  \$ a, lda, zero, work, nrhs )
237 *
238 * compute and properly scale error
239 *
240  err = dlange( 'One-norm', nrhs, ncols, work, nrhs, rwork )
241  IF( norma.NE.zero )
242  \$ err = err / norma
243 *
244  IF( iscl.EQ.1 )
245  \$ err = err*normrs
246 *
247  IF( iresid.EQ.1 ) THEN
248  normb = dlange( 'One-norm', nrows, nrhs, b, ldb, rwork )
249  IF( normb.NE.zero )
250  \$ err = err / normb
251  ELSE
252  normx = dlange( 'One-norm', ncols, nrhs, x, ldx, rwork )
253  IF( normx.NE.zero )
254  \$ err = err / normx
255  END IF
256 *
257  dqrt17 = err / ( dlamch( 'Epsilon' )*dble( max( m, n, nrhs ) ) )
258  return
259 *
260 * End of DQRT17
261 *
262  END