LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
cqrt17.f
Go to the documentation of this file.
1 *> \brief \b CQRT17
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * REAL FUNCTION CQRT17( 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 * COMPLEX A( LDA, * ), B( LDB, * ), C( LDB, * ),
20 * $ WORK( LWORK ), X( LDX, * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> CQRT17 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 *> = 'C': Conjugate 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 = 'C', 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 = 'C', 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 COMPLEX 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 COMPLEX array, dimension (LDX,NRHS)
94 *> If TRANS = 'N', the n-by-nrhs matrix X.
95 *> If TRANS = 'C', 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 = 'C', LDX >= M.
104 *> \endverbatim
105 *>
106 *> \param[in] B
107 *> \verbatim
108 *> B is COMPLEX array, dimension (LDB,NRHS)
109 *> If TRANS = 'N', the m-by-nrhs matrix B.
110 *> If TRANS = 'C', 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 = 'C', LDB >= N.
119 *> \endverbatim
120 *>
121 *> \param[out] C
122 *> \verbatim
123 *> C is COMPLEX array, dimension (LDB,NRHS)
124 *> \endverbatim
125 *>
126 *> \param[out] WORK
127 *> \verbatim
128 *> WORK is COMPLEX 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 December 2016
146 *
147 *> \ingroup complex_lin
148 *
149 * =====================================================================
150  REAL FUNCTION cqrt17( TRANS, IRESID, M, N, NRHS, A,
151  $ LDA, X, LDX, B, LDB, C, WORK, LWORK )
152 *
153 * -- LAPACK test routine (version 3.7.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 * December 2016
157 *
158 * .. Scalar Arguments ..
159  CHARACTER TRANS
160  INTEGER IRESID, LDA, LDB, LDX, LWORK, M, N, NRHS
161 * ..
162 * .. Array Arguments ..
163  COMPLEX A( lda, * ), B( ldb, * ), C( ldb, * ),
164  $ work( lwork ), x( ldx, * )
165 * ..
166 *
167 * =====================================================================
168 *
169 * .. Parameters ..
170  REAL ZERO, ONE
171  parameter( zero = 0.0e0, one = 1.0e0 )
172 * ..
173 * .. Local Scalars ..
174  INTEGER INFO, ISCL, NCOLS, NROWS
175  REAL BIGNUM, ERR, NORMA, NORMB, NORMRS, SMLNUM
176 * ..
177 * .. Local Arrays ..
178  REAL RWORK( 1 )
179 * ..
180 * .. External Functions ..
181  LOGICAL LSAME
182  REAL CLANGE, SLAMCH
183  EXTERNAL lsame, clange, slamch
184 * ..
185 * .. External Subroutines ..
186  EXTERNAL cgemm, clacpy, clascl, xerbla
187 * ..
188 * .. Intrinsic Functions ..
189  INTRINSIC cmplx, max, real
190 * ..
191 * .. Executable Statements ..
192 *
193  cqrt17 = zero
194 *
195  IF( lsame( trans, 'N' ) ) THEN
196  nrows = m
197  ncols = n
198  ELSE IF( lsame( trans, 'C' ) ) THEN
199  nrows = n
200  ncols = m
201  ELSE
202  CALL xerbla( 'CQRT17', 1 )
203  RETURN
204  END IF
205 *
206  IF( lwork.LT.ncols*nrhs ) THEN
207  CALL xerbla( 'CQRT17', 13 )
208  RETURN
209  END IF
210 *
211  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 )
212  $ RETURN
213 *
214  norma = clange( 'One-norm', m, n, a, lda, rwork )
215  smlnum = slamch( 'Safe minimum' ) / slamch( 'Precision' )
216  bignum = one / smlnum
217  iscl = 0
218 *
219 * compute residual and scale it
220 *
221  CALL clacpy( 'All', nrows, nrhs, b, ldb, c, ldb )
222  CALL cgemm( trans, 'No transpose', nrows, nrhs, ncols,
223  $ cmplx( -one ), a, lda, x, ldx, cmplx( one ), c, ldb )
224  normrs = clange( 'Max', nrows, nrhs, c, ldb, rwork )
225  IF( normrs.GT.smlnum ) THEN
226  iscl = 1
227  CALL clascl( 'General', 0, 0, normrs, one, nrows, nrhs, c, ldb,
228  $ info )
229  END IF
230 *
231 * compute R'*A
232 *
233  CALL cgemm( 'Conjugate transpose', trans, nrhs, ncols, nrows,
234  $ cmplx( one ), c, ldb, a, lda, cmplx( zero ), work,
235  $ nrhs )
236 *
237 * compute and properly scale error
238 *
239  err = clange( 'One-norm', nrhs, ncols, work, nrhs, rwork )
240  IF( norma.NE.zero )
241  $ err = err / norma
242 *
243  IF( iscl.EQ.1 )
244  $ err = err*normrs
245 *
246  IF( iresid.EQ.1 ) THEN
247  normb = clange( 'One-norm', nrows, nrhs, b, ldb, rwork )
248  IF( normb.NE.zero )
249  $ err = err / normb
250  ELSE
251  IF( normrs.NE.zero )
252  $ err = err / normrs
253  END IF
254 *
255  cqrt17 = err / ( slamch( 'Epsilon' )*REAL( MAX( M, N, NRHS ) ) )
256  RETURN
257 *
258 * End of CQRT17
259 *
260  END
subroutine clascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: clascl.f:145
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:105
subroutine cgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CGEMM
Definition: cgemm.f:189
real function cqrt17(TRANS, IRESID, M, N, NRHS, A, LDA, X, LDX, B, LDB, C, WORK, LWORK)
CQRT17
Definition: cqrt17.f:152