1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
DOUBLE PRECISION FUNCTION ZQRT17( TRANS, IRESID, M, N, NRHS, A,
$ LDA, X, LDX, B, LDB, C, WORK, LWORK )
*
* -- LAPACK test routine (version 3.1) --
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
* November 2006
*
* .. Scalar Arguments ..
CHARACTER TRANS
INTEGER IRESID, LDA, LDB, LDX, LWORK, M, N, NRHS
* ..
* .. Array Arguments ..
COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDB, * ),
$ WORK( LWORK ), X( LDX, * )
* ..
*
* Purpose
* =======
*
* ZQRT17 computes the ratio
*
* || R'*op(A) ||/(||A||*alpha*max(M,N,NRHS)*eps)
*
* where R = op(A)*X - B, op(A) is A or A', and
*
* alpha = ||B|| if IRESID = 1 (zero-residual problem)
* alpha = ||R|| if IRESID = 2 (otherwise).
*
* Arguments
* =========
*
* TRANS (input) CHARACTER*1
* Specifies whether or not the transpose of A is used.
* = 'N': No transpose, op(A) = A.
* = 'C': Conjugate transpose, op(A) = A'.
*
* IRESID (input) INTEGER
* IRESID = 1 indicates zero-residual problem.
* IRESID = 2 indicates non-zero residual.
*
* M (input) INTEGER
* The number of rows of the matrix A.
* If TRANS = 'N', the number of rows of the matrix B.
* If TRANS = 'C', the number of rows of the matrix X.
*
* N (input) INTEGER
* The number of columns of the matrix A.
* If TRANS = 'N', the number of rows of the matrix X.
* If TRANS = 'C', the number of rows of the matrix B.
*
* NRHS (input) INTEGER
* The number of columns of the matrices X and B.
*
* A (input) COMPLEX*16 array, dimension (LDA,N)
* The m-by-n matrix A.
*
* LDA (input) INTEGER
* The leading dimension of the array A. LDA >= M.
*
* X (input) COMPLEX*16 array, dimension (LDX,NRHS)
* If TRANS = 'N', the n-by-nrhs matrix X.
* If TRANS = 'C', the m-by-nrhs matrix X.
*
* LDX (input) INTEGER
* The leading dimension of the array X.
* If TRANS = 'N', LDX >= N.
* If TRANS = 'C', LDX >= M.
*
* B (input) COMPLEX*16 array, dimension (LDB,NRHS)
* If TRANS = 'N', the m-by-nrhs matrix B.
* If TRANS = 'C', the n-by-nrhs matrix B.
*
* LDB (input) INTEGER
* The leading dimension of the array B.
* If TRANS = 'N', LDB >= M.
* If TRANS = 'C', LDB >= N.
*
* C (workspace) COMPLEX*16 array, dimension (LDB,NRHS)
*
* WORK (workspace) COMPLEX*16 array, dimension (LWORK)
*
* LWORK (input) INTEGER
* The length of the array WORK. LWORK >= NRHS*(M+N).
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
* ..
* .. Local Scalars ..
INTEGER INFO, ISCL, NCOLS, NROWS
DOUBLE PRECISION BIGNUM, ERR, NORMA, NORMB, NORMRS, NORMX,
$ SMLNUM
* ..
* .. Local Arrays ..
DOUBLE PRECISION RWORK( 1 )
* ..
* .. External Functions ..
LOGICAL LSAME
DOUBLE PRECISION DLAMCH, ZLANGE
EXTERNAL LSAME, DLAMCH, ZLANGE
* ..
* .. External Subroutines ..
EXTERNAL XERBLA, ZGEMM, ZLACPY, ZLASCL
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE, DCMPLX, MAX
* ..
* .. Executable Statements ..
*
ZQRT17 = ZERO
*
IF( LSAME( TRANS, 'N' ) ) THEN
NROWS = M
NCOLS = N
ELSE IF( LSAME( TRANS, 'C' ) ) THEN
NROWS = N
NCOLS = M
ELSE
CALL XERBLA( 'ZQRT17', 1 )
RETURN
END IF
*
IF( LWORK.LT.NCOLS*NRHS ) THEN
CALL XERBLA( 'ZQRT17', 13 )
RETURN
END IF
*
IF( M.LE.0 .OR. N.LE.0 .OR. NRHS.LE.0 )
$ RETURN
*
NORMA = ZLANGE( 'One-norm', M, N, A, LDA, RWORK )
SMLNUM = DLAMCH( 'Safe minimum' ) / DLAMCH( 'Precision' )
BIGNUM = ONE / SMLNUM
ISCL = 0
*
* compute residual and scale it
*
CALL ZLACPY( 'All', NROWS, NRHS, B, LDB, C, LDB )
CALL ZGEMM( TRANS, 'No transpose', NROWS, NRHS, NCOLS,
$ DCMPLX( -ONE ), A, LDA, X, LDX, DCMPLX( ONE ), C,
$ LDB )
NORMRS = ZLANGE( 'Max', NROWS, NRHS, C, LDB, RWORK )
IF( NORMRS.GT.SMLNUM ) THEN
ISCL = 1
CALL ZLASCL( 'General', 0, 0, NORMRS, ONE, NROWS, NRHS, C, LDB,
$ INFO )
END IF
*
* compute R'*A
*
CALL ZGEMM( 'Conjugate transpose', TRANS, NRHS, NCOLS, NROWS,
$ DCMPLX( ONE ), C, LDB, A, LDA, DCMPLX( ZERO ), WORK,
$ NRHS )
*
* compute and properly scale error
*
ERR = ZLANGE( 'One-norm', NRHS, NCOLS, WORK, NRHS, RWORK )
IF( NORMA.NE.ZERO )
$ ERR = ERR / NORMA
*
IF( ISCL.EQ.1 )
$ ERR = ERR*NORMRS
*
IF( IRESID.EQ.1 ) THEN
NORMB = ZLANGE( 'One-norm', NROWS, NRHS, B, LDB, RWORK )
IF( NORMB.NE.ZERO )
$ ERR = ERR / NORMB
ELSE
NORMX = ZLANGE( 'One-norm', NCOLS, NRHS, X, LDX, RWORK )
IF( NORMX.NE.ZERO )
$ ERR = ERR / NORMX
END IF
*
ZQRT17 = ERR / ( DLAMCH( 'Epsilon' )*DBLE( MAX( M, N, NRHS ) ) )
RETURN
*
* End of ZQRT17
*
END
|