PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
cqrt17.f
Go to the documentation of this file.
1  REAL FUNCTION cqrt17( TRANS, IRESID, M, N, NRHS, A,
2  $ lda, x, ldx, b, ldb, c, work, lwork )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  CHARACTER trans
10  INTEGER iresid, lda, ldb, ldx, lwork, m, n, nrhs
11 * ..
12 * .. Array Arguments ..
13  COMPLEX a( lda, * ), b( ldb, * ), c( ldb, * ),
14  $ work( lwork ), x( ldx, * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * CQRT17 computes the ratio
21 *
22 * || R'*op(A) ||/(||A||*alpha*max(M,N,NRHS)*eps)
23 *
24 * where R = op(A)*X - B, op(A) is A or A', and
25 *
26 * alpha = ||B|| if IRESID = 1 (zero-residual problem)
27 * alpha = ||R|| if IRESID = 2 (otherwise).
28 *
29 * Arguments
30 * =========
31 *
32 * TRANS (input) CHARACTER*1
33 * Specifies whether or not the transpose of A is used.
34 * = 'N': No transpose, op(A) = A.
35 * = 'C': Conjugate transpose, op(A) = A'.
36 *
37 * IRESID (input) INTEGER
38 * IRESID = 1 indicates zero-residual problem.
39 * IRESID = 2 indicates non-zero residual.
40 *
41 * M (input) INTEGER
42 * The number of rows of the matrix A.
43 * If TRANS = 'N', the number of rows of the matrix B.
44 * If TRANS = 'C', the number of rows of the matrix X.
45 *
46 * N (input) INTEGER
47 * The number of columns of the matrix A.
48 * If TRANS = 'N', the number of rows of the matrix X.
49 * If TRANS = 'C', the number of rows of the matrix B.
50 *
51 * NRHS (input) INTEGER
52 * The number of columns of the matrices X and B.
53 *
54 * A (input) COMPLEX array, dimension (LDA,N)
55 * The m-by-n matrix A.
56 *
57 * LDA (input) INTEGER
58 * The leading dimension of the array A. LDA >= M.
59 *
60 * X (input) COMPLEX array, dimension (LDX,NRHS)
61 * If TRANS = 'N', the n-by-nrhs matrix X.
62 * If TRANS = 'C', the m-by-nrhs matrix X.
63 *
64 * LDX (input) INTEGER
65 * The leading dimension of the array X.
66 * If TRANS = 'N', LDX >= N.
67 * If TRANS = 'C', LDX >= M.
68 *
69 * B (input) COMPLEX array, dimension (LDB,NRHS)
70 * If TRANS = 'N', the m-by-nrhs matrix B.
71 * If TRANS = 'C', the n-by-nrhs matrix B.
72 *
73 * LDB (input) INTEGER
74 * The leading dimension of the array B.
75 * If TRANS = 'N', LDB >= M.
76 * If TRANS = 'C', LDB >= N.
77 *
78 * C (workspace) COMPLEX array, dimension (LDB,NRHS)
79 *
80 * WORK (workspace) COMPLEX array, dimension (LWORK)
81 *
82 * LWORK (input) INTEGER
83 * The length of the array WORK. LWORK >= NRHS*(M+N).
84 *
85 * =====================================================================
86 *
87 * .. Parameters ..
88  REAL zero, one
89  parameter( zero = 0.0e0, one = 1.0e0 )
90 * ..
91 * .. Local Scalars ..
92  INTEGER info, iscl, ncols, nrows
93  REAL bignum, err, norma, normb, normrs, normx,
94  $ smlnum
95 * ..
96 * .. Local Arrays ..
97  REAL rwork( 1 )
98 * ..
99 * .. External Functions ..
100  LOGICAL lsame
101  REAL clange, slamch
102  EXTERNAL lsame, clange, slamch
103 * ..
104 * .. External Subroutines ..
105  EXTERNAL cgemm, clacpy, clascl, xerbla
106 * ..
107 * .. Intrinsic Functions ..
108  INTRINSIC cmplx, max, real
109 * ..
110 * .. Executable Statements ..
111 *
112  cqrt17 = zero
113 *
114  IF( lsame( trans, 'N' ) ) THEN
115  nrows = m
116  ncols = n
117  ELSE IF( lsame( trans, 'C' ) ) THEN
118  nrows = n
119  ncols = m
120  ELSE
121  CALL xerbla( 'CQRT17', 1 )
122  return
123  END IF
124 *
125  IF( lwork.LT.ncols*nrhs ) THEN
126  CALL xerbla( 'CQRT17', 13 )
127  return
128  END IF
129 *
130  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 )
131  $ return
132 *
133  norma = clange( 'One-norm', m, n, a, lda, rwork )
134  smlnum = slamch( 'Safe minimum' ) / slamch( 'Precision' )
135  bignum = one / smlnum
136  iscl = 0
137 *
138 * compute residual and scale it
139 *
140  CALL clacpy( 'All', nrows, nrhs, b, ldb, c, ldb )
141  CALL cgemm( trans, 'No transpose', nrows, nrhs, ncols,
142  $ cmplx( -one ), a, lda, x, ldx, cmplx( one ), c, ldb )
143  normrs = clange( 'Max', nrows, nrhs, c, ldb, rwork )
144  IF( normrs.GT.smlnum ) THEN
145  iscl = 1
146  CALL clascl( 'General', 0, 0, normrs, one, nrows, nrhs, c, ldb,
147  $ info )
148  END IF
149 *
150 * compute R'*A
151 *
152  CALL cgemm( 'Conjugate transpose', trans, nrhs, ncols, nrows,
153  $ cmplx( one ), c, ldb, a, lda, cmplx( zero ), work,
154  $ nrhs )
155 *
156 * compute and properly scale error
157 *
158  err = clange( 'One-norm', nrhs, ncols, work, nrhs, rwork )
159  IF( norma.NE.zero )
160  $ err = err / norma
161 *
162  IF( iscl.EQ.1 )
163  $ err = err*normrs
164 *
165  IF( iresid.EQ.1 ) THEN
166  normb = clange( 'One-norm', nrows, nrhs, b, ldb, rwork )
167  IF( normb.NE.zero )
168  $ err = err / normb
169  ELSE
170  normx = clange( 'One-norm', ncols, nrhs, x, ldx, rwork )
171  IF( normx.NE.zero )
172  $ err = err / normx
173  END IF
174 *
175  cqrt17 = err / ( slamch( 'Epsilon' )*REAL( MAX( M, N, NRHS ) ) )
176  return
177 *
178 * End of CQRT17
179 *
180  END