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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
*> \brief \b DLQT04
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE ZLQT04(M,N,NB,RESULT)
*
* .. Scalar Arguments ..
* INTEGER M, N, NB
* .. Return values ..
* DOUBLE PRECISION RESULT(6)
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ZLQT04 tests ZGELQT and ZUNMLQT.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> Number of rows in test matrix.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> Number of columns in test matrix.
*> \endverbatim
*>
*> \param[in] NB
*> \verbatim
*> NB is INTEGER
*> Block size of test matrix. NB <= Min(M,N).
*> \endverbatim
*>
*> \param[out] RESULT
*> \verbatim
*> RESULT is DOUBLE PRECISION array, dimension (6)
*> Results of each of the six tests below.
*>
*> RESULT(1) = | A - L Q |
*> RESULT(2) = | I - Q Q^H |
*> RESULT(3) = | Q C - Q C |
*> RESULT(4) = | Q^H C - Q^H C |
*> RESULT(5) = | C Q - C Q |
*> RESULT(6) = | C Q^H - C Q^H |
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date April 2012
*
*> \ingroup double_lin
*
* =====================================================================
SUBROUTINE ZLQT04(M,N,NB,RESULT)
IMPLICIT NONE
*
* -- LAPACK test routine (version 3.4.1) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* April 2012
*
* .. Scalar Arguments ..
INTEGER M, N, NB
* .. Return values ..
DOUBLE PRECISION RESULT(6)
*
* =====================================================================
*
* ..
* .. Local allocatable arrays
COMPLEX*16, ALLOCATABLE :: AF(:,:), Q(:,:),
$ L(:,:), RWORK(:), WORK( : ), T(:,:),
$ CF(:,:), DF(:,:), A(:,:), C(:,:), D(:,:)
*
* .. Parameters ..
DOUBLE PRECISION ZERO
COMPLEX*16 ONE, CZERO
PARAMETER( ZERO = 0.0)
PARAMETER( ONE = (1.0,0.0), CZERO=(0.0,0.0) )
* ..
* .. Local Scalars ..
INTEGER INFO, J, K, LL, LWORK, LDT
DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
* ..
* .. Local Arrays ..
INTEGER ISEED( 4 )
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH
DOUBLE PRECISION ZLANGE, ZLANSY
LOGICAL LSAME
EXTERNAL DLAMCH, ZLANGE, ZLANSY, LSAME
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN
* ..
* .. Data statements ..
DATA ISEED / 1988, 1989, 1990, 1991 /
*
EPS = DLAMCH( 'Epsilon' )
K = MIN(M,N)
LL = MAX(M,N)
LWORK = MAX(2,LL)*MAX(2,LL)*NB
*
* Dynamically allocate local arrays
*
ALLOCATE ( A(M,N), AF(M,N), Q(N,N), L(LL,N), RWORK(LL),
$ WORK(LWORK), T(NB,N), C(M,N), CF(M,N),
$ D(N,M), DF(N,M) )
*
* Put random numbers into A and copy to AF
*
LDT=NB
DO J=1,N
CALL ZLARNV( 2, ISEED, M, A( 1, J ) )
END DO
CALL ZLACPY( 'Full', M, N, A, M, AF, M )
*
* Factor the matrix A in the array AF.
*
CALL ZGELQT( M, N, NB, AF, M, T, LDT, WORK, INFO )
*
* Generate the n-by-n matrix Q
*
CALL ZLASET( 'Full', N, N, CZERO, ONE, Q, N )
CALL ZGEMLQT( 'R', 'N', N, N, K, NB, AF, M, T, LDT, Q, N,
$ WORK, INFO )
*
* Copy L
*
CALL ZLASET( 'Full', LL, N, CZERO, CZERO, L, LL )
CALL ZLACPY( 'Lower', M, N, AF, M, L, LL )
*
* Compute |L - A*Q'| / |A| and store in RESULT(1)
*
CALL ZGEMM( 'N', 'C', M, N, N, -ONE, A, M, Q, N, ONE, L, LL )
ANORM = ZLANGE( '1', M, N, A, M, RWORK )
RESID = ZLANGE( '1', M, N, L, LL, RWORK )
IF( ANORM.GT.ZERO ) THEN
RESULT( 1 ) = RESID / (EPS*MAX(1,M)*ANORM)
ELSE
RESULT( 1 ) = ZERO
END IF
*
* Compute |I - Q'*Q| and store in RESULT(2)
*
CALL ZLASET( 'Full', N, N, CZERO, ONE, L, LL )
CALL ZHERK( 'U', 'C', N, N, DREAL(-ONE), Q, N, DREAL(ONE), L, LL)
RESID = ZLANSY( '1', 'Upper', N, L, LL, RWORK )
RESULT( 2 ) = RESID / (EPS*MAX(1,N))
*
* Generate random m-by-n matrix C and a copy CF
*
DO J=1,M
CALL ZLARNV( 2, ISEED, N, D( 1, J ) )
END DO
DNORM = ZLANGE( '1', N, M, D, N, RWORK)
CALL ZLACPY( 'Full', N, M, D, N, DF, N )
*
* Apply Q to C as Q*C
*
CALL ZGEMLQT( 'L', 'N', N, M, K, NB, AF, M, T, NB, DF, N,
$ WORK, INFO)
*
* Compute |Q*D - Q*D| / |D|
*
CALL ZGEMM( 'N', 'N', N, M, N, -ONE, Q, N, D, N, ONE, DF, N )
RESID = ZLANGE( '1', N, M, DF, N, RWORK )
IF( DNORM.GT.ZERO ) THEN
RESULT( 3 ) = RESID / (EPS*MAX(1,M)*DNORM)
ELSE
RESULT( 3 ) = ZERO
END IF
*
* Copy D into DF again
*
CALL ZLACPY( 'Full', N, M, D, N, DF, N )
*
* Apply Q to D as QT*D
*
CALL ZGEMLQT( 'L', 'C', N, M, K, NB, AF, M, T, NB, DF, N,
$ WORK, INFO)
*
* Compute |QT*D - QT*D| / |D|
*
CALL ZGEMM( 'C', 'N', N, M, N, -ONE, Q, N, D, N, ONE, DF, N )
RESID = ZLANGE( '1', N, M, DF, N, RWORK )
IF( DNORM.GT.ZERO ) THEN
RESULT( 4 ) = RESID / (EPS*MAX(1,M)*DNORM)
ELSE
RESULT( 4 ) = ZERO
END IF
*
* Generate random n-by-m matrix D and a copy DF
*
DO J=1,N
CALL ZLARNV( 2, ISEED, M, C( 1, J ) )
END DO
CNORM = ZLANGE( '1', M, N, C, M, RWORK)
CALL ZLACPY( 'Full', M, N, C, M, CF, M )
*
* Apply Q to C as C*Q
*
CALL ZGEMLQT( 'R', 'N', M, N, K, NB, AF, M, T, NB, CF, M,
$ WORK, INFO)
*
* Compute |C*Q - C*Q| / |C|
*
CALL ZGEMM( 'N', 'N', M, N, N, -ONE, C, M, Q, N, ONE, CF, M )
RESID = ZLANGE( '1', N, M, DF, N, RWORK )
IF( CNORM.GT.ZERO ) THEN
RESULT( 5 ) = RESID / (EPS*MAX(1,M)*DNORM)
ELSE
RESULT( 5 ) = ZERO
END IF
*
* Copy C into CF again
*
CALL ZLACPY( 'Full', M, N, C, M, CF, M )
*
* Apply Q to D as D*QT
*
CALL ZGEMLQT( 'R', 'C', M, N, K, NB, AF, M, T, NB, CF, M,
$ WORK, INFO)
*
* Compute |C*QT - C*QT| / |C|
*
CALL ZGEMM( 'N', 'C', M, N, N, -ONE, C, M, Q, N, ONE, CF, M )
RESID = ZLANGE( '1', M, N, CF, M, RWORK )
IF( CNORM.GT.ZERO ) THEN
RESULT( 6 ) = RESID / (EPS*MAX(1,M)*DNORM)
ELSE
RESULT( 6 ) = ZERO
END IF
*
* Deallocate all arrays
*
DEALLOCATE ( A, AF, Q, L, RWORK, WORK, T, C, D, CF, DF)
*
RETURN
END
|