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
dqrt17.f
Go to the documentation of this file.
1  DOUBLE PRECISION FUNCTION dqrt17( 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  DOUBLE PRECISION a( lda, * ), b( ldb, * ), c( ldb, * ),
14  $ work( lwork ), x( ldx, * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * DQRT17 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 * = 'T': 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 = 'T', 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 = 'T', 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) DOUBLE PRECISION 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) DOUBLE PRECISION array, dimension (LDX,NRHS)
61 * If TRANS = 'N', the n-by-nrhs matrix X.
62 * If TRANS = 'T', 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 = 'T', LDX >= M.
68 *
69 * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
70 * If TRANS = 'N', the m-by-nrhs matrix B.
71 * If TRANS = 'T', 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 = 'T', LDB >= N.
77 *
78 * C (workspace) DOUBLE PRECISION array, dimension (LDB,NRHS)
79 *
80 * WORK (workspace) DOUBLE PRECISION 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  DOUBLE PRECISION zero, one
89  parameter( zero = 0.0d0, one = 1.0d0 )
90 * ..
91 * .. Local Scalars ..
92  INTEGER info, iscl, ncols, nrows
93  DOUBLE PRECISION bignum, err, norma, normb, normrs, normx,
94  $ smlnum
95 * ..
96 * .. Local Arrays ..
97  DOUBLE PRECISION rwork( 1 )
98 * ..
99 * .. External Functions ..
100  LOGICAL lsame
101  DOUBLE PRECISION dlamch, dlange
102  EXTERNAL lsame, dlamch, dlange
103 * ..
104 * .. External Subroutines ..
105  EXTERNAL dgemm, dlacpy, dlascl, xerbla
106 * ..
107 * .. Intrinsic Functions ..
108  INTRINSIC dble, max
109 * ..
110 * .. Executable Statements ..
111 *
112  dqrt17 = zero
113 *
114  IF( lsame( trans, 'N' ) ) THEN
115  nrows = m
116  ncols = n
117  ELSE IF( lsame( trans, 'T' ) ) THEN
118  nrows = n
119  ncols = m
120  ELSE
121  CALL xerbla( 'DQRT17', 1 )
122  return
123  END IF
124 *
125  IF( lwork.LT.ncols*nrhs ) THEN
126  CALL xerbla( 'DQRT17', 13 )
127  return
128  END IF
129 *
130  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 ) THEN
131  return
132  END IF
133 *
134  norma = dlange( 'One-norm', m, n, a, lda, rwork )
135  smlnum = dlamch( 'Safe minimum' ) / dlamch( 'Precision' )
136  bignum = one / smlnum
137  iscl = 0
138 *
139 * compute residual and scale it
140 *
141  CALL dlacpy( 'All', nrows, nrhs, b, ldb, c, ldb )
142  CALL dgemm( trans, 'No transpose', nrows, nrhs, ncols, -one, a,
143  $ lda, x, ldx, one, c, ldb )
144  normrs = dlange( 'Max', nrows, nrhs, c, ldb, rwork )
145  IF( normrs.GT.smlnum ) THEN
146  iscl = 1
147  CALL dlascl( 'General', 0, 0, normrs, one, nrows, nrhs, c, ldb,
148  $ info )
149  END IF
150 *
151 * compute R'*A
152 *
153  CALL dgemm( 'Transpose', trans, nrhs, ncols, nrows, one, c, ldb,
154  $ a, lda, zero, work, nrhs )
155 *
156 * compute and properly scale error
157 *
158  err = dlange( '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 = dlange( 'One-norm', nrows, nrhs, b, ldb, rwork )
167  IF( normb.NE.zero )
168  $ err = err / normb
169  ELSE
170  normx = dlange( 'One-norm', ncols, nrhs, x, ldx, rwork )
171  IF( normx.NE.zero )
172  $ err = err / normx
173  END IF
174 *
175  dqrt17 = err / ( dlamch( 'Epsilon' )*dble( max( m, n, nrhs ) ) )
176  return
177 *
178 * End of DQRT17
179 *
180  END