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
cqrt16.f
Go to the documentation of this file.
1  SUBROUTINE cqrt16( TRANS, M, N, NRHS, A, LDA, X, LDX, B, LDB,
2  $ rwork, resid )
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 lda, ldb, ldx, m, n, nrhs
11  REAL resid
12 * ..
13 * .. Array Arguments ..
14  REAL rwork( * )
15  COMPLEX a( lda, * ), b( ldb, * ), x( ldx, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * CQRT16 computes the residual for a solution of a system of linear
22 * equations A*x = b or A'*x = b:
23 * RESID = norm(B - A*X) / ( max(m,n) * (norm(A) * norm(X)+ nnorm (RHS)) * EPS ) .
24 * where EPS is the machine epsilon.
25 *
26 * Arguments
27 * =========
28 *
29 * TRANS (input) CHARACTER*1
30 * Specifies the form of the system of equations:
31 * = 'N': A *x = b
32 * = 'T': A^T*x = b, where A^T is the transpose of A
33 * = 'C': A^H*x = b, where A^H is the conjugate transpose of A
34 *
35 * M (input) INTEGER
36 * The number of rows of the matrix A. M >= 0.
37 *
38 * N (input) INTEGER
39 * The number of columns of the matrix A. N >= 0.
40 *
41 * NRHS (input) INTEGER
42 * The number of columns of B, the matrix of right hand sides.
43 * NRHS >= 0.
44 *
45 * A (input) COMPLEX array, dimension (LDA,N)
46 * The original M x N matrix A.
47 *
48 * LDA (input) INTEGER
49 * The leading dimension of the array A. LDA >= max(1,M).
50 *
51 * X (input) COMPLEX array, dimension (LDX,NRHS)
52 * The computed solution vectors for the system of linear
53 * equations.
54 *
55 * LDX (input) INTEGER
56 * The leading dimension of the array X. If TRANS = 'N',
57 * LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M).
58 *
59 * B (input/output) COMPLEX array, dimension (LDB,NRHS)
60 * On entry, the right hand side vectors for the system of
61 * linear equations.
62 * On exit, B is overwritten with the difference B - A*X.
63 *
64 * LDB (input) INTEGER
65 * The leading dimension of the array B. IF TRANS = 'N',
66 * LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
67 *
68 * RWORK (workspace) REAL array, dimension (M)
69 *
70 * RESID (output) REAL
71 * The maximum over the number of right hand sides of
72 * norm(B - A*X) / ( max(m,n) * (norm(A) * norm(X)+ nnorm (RHS)) * EPS ) .
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77  REAL zero, one
78  parameter( zero = 0.0e+0, one = 1.0e+0 )
79  COMPLEX cone
80  parameter( cone = ( 1.0e+0, 0.0e+0 ) )
81 * ..
82 * .. Local Scalars ..
83  INTEGER j, n1, n2
84  REAL anorm, bnorm, eps, xnorm, rhsnorm
85 * ..
86 * .. External Functions ..
87  LOGICAL lsame
88  REAL clange, scasum, slamch
89  EXTERNAL lsame, clange, scasum, slamch
90 * ..
91 * .. External Subroutines ..
92  EXTERNAL cgemm
93 * ..
94 * .. Intrinsic Functions ..
95  INTRINSIC max
96 * ..
97 * .. Executable Statements ..
98 *
99 * Quick exit if M = 0 or N = 0 or NRHS = 0
100 *
101  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.EQ.0 ) THEN
102  resid = zero
103  return
104  END IF
105 *
106  IF( lsame( trans, 'T' ) .OR. lsame( trans, 'C' ) ) THEN
107  anorm = clange( 'I', m, n, a, lda, rwork )
108  n1 = n
109  n2 = m
110  ELSE
111  anorm = clange( '1', m, n, a, lda, rwork )
112  n1 = m
113  n2 = n
114  END IF
115  rhsnorm = clange( 'I', n, nrhs, b, ldb, rwork )
116 *
117  eps = slamch( 'Epsilon' )
118 *
119 * Compute B - A*X (or B - A'*X ) and store in B.
120 *
121  CALL cgemm( trans, 'No transpose', n1, nrhs, n2, -cone, a, lda, x,
122  $ ldx, cone, b, ldb )
123 *
124 * Compute the maximum over the number of right hand sides of
125 * norm(B - A*X) / ( max(m,n) * (norm(A) * norm(X)+ nnorm (RHS)) * EPS ) .
126 *
127  resid = zero
128  DO 10 j = 1, nrhs
129  bnorm = scasum( n1, b( 1, j ), 1 )
130  xnorm = scasum( n2, x( 1, j ), 1 )
131  IF( anorm.EQ.zero .AND. bnorm.EQ.zero ) THEN
132  resid = zero
133  ELSE IF( anorm.LE.zero .OR. xnorm.LE.zero ) THEN
134  resid = one / eps
135  ELSE
136  resid = max( resid, ( bnorm )/ (anorm *xnorm + rhsnorm ) *
137  $ ( max( m, n )*eps ) )
138  END IF
139  10 continue
140 *
141  return
142 *
143 * End of CQRT16
144 *
145  END