LAPACK  3.8.0 LAPACK: Linear Algebra PACKage
zqrt05.f
Go to the documentation of this file.
1 *> \brief \b ZQRT05
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE ZQRT05(M,N,L,NB,RESULT)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER LWORK, M, N, L, NB, LDT
15 * .. Return values ..
16 * DOUBLE PRECISION RESULT(6)
17 *
18 *
19 *> \par Purpose:
20 * =============
21 *>
22 *> \verbatim
23 *>
24 *> ZQRT05 tests ZTPQRT and ZTPMQRT.
25 *> \endverbatim
26 *
27 * Arguments:
28 * ==========
29 *
30 *> \param[in] M
31 *> \verbatim
32 *> M is INTEGER
33 *> Number of rows in lower part of the test matrix.
34 *> \endverbatim
35 *>
36 *> \param[in] N
37 *> \verbatim
38 *> N is INTEGER
39 *> Number of columns in test matrix.
40 *> \endverbatim
41 *>
42 *> \param[in] L
43 *> \verbatim
44 *> L is INTEGER
45 *> The number of rows of the upper trapezoidal part the
46 *> lower test matrix. 0 <= L <= M.
47 *> \endverbatim
48 *>
49 *> \param[in] NB
50 *> \verbatim
51 *> NB is INTEGER
52 *> Block size of test matrix. NB <= N.
53 *> \endverbatim
54 *>
55 *> \param[out] RESULT
56 *> \verbatim
57 *> RESULT is DOUBLE PRECISION array, dimension (6)
58 *> Results of each of the six tests below.
59 *>
60 *> RESULT(1) = | A - Q R |
61 *> RESULT(2) = | I - Q^H Q |
62 *> RESULT(3) = | Q C - Q C |
63 *> RESULT(4) = | Q^H C - Q^H C |
64 *> RESULT(5) = | C Q - C Q |
65 *> RESULT(6) = | C Q^H - C Q^H |
66 *> \endverbatim
67 *
68 * Authors:
69 * ========
70 *
71 *> \author Univ. of Tennessee
72 *> \author Univ. of California Berkeley
73 *> \author Univ. of Colorado Denver
74 *> \author NAG Ltd.
75 *
76 *> \date April 2012
77 *
78 *> \ingroup complex16_lin
79 *
80 * =====================================================================
81  SUBROUTINE zqrt05(M,N,L,NB,RESULT)
82  IMPLICIT NONE
83 *
84 * -- LAPACK test routine (version 3.7.0) --
85 * -- LAPACK is a software package provided by Univ. of Tennessee, --
86 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
87 * April 2012
88 *
89 * .. Scalar Arguments ..
90  INTEGER LWORK, M, N, L, NB, LDT
91 * .. Return values ..
92  DOUBLE PRECISION RESULT(6)
93 *
94 * =====================================================================
95 *
96 * ..
97 * .. Local allocatable arrays
98  COMPLEX*16, ALLOCATABLE :: AF(:,:), Q(:,:),
99  \$ r(:,:), work( : ), t(:,:),
100  \$ cf(:,:), df(:,:), a(:,:), c(:,:), d(:,:)
101  DOUBLE PRECISION, ALLOCATABLE :: RWORK(:)
102 *
103 * .. Parameters ..
104  DOUBLE PRECISION ZERO
105  COMPLEX*16 ONE, CZERO
106  parameter( zero = 0.0, one = (1.0,0.0), czero=(0.0,0.0) )
107 * ..
108 * .. Local Scalars ..
109  INTEGER INFO, J, K, M2, NP1
110  DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
111 * ..
112 * .. Local Arrays ..
113  INTEGER ISEED( 4 )
114 * ..
115 * .. External Functions ..
116  DOUBLE PRECISION DLAMCH
117  DOUBLE PRECISION ZLANGE, ZLANSY
118  LOGICAL LSAME
119  EXTERNAL dlamch, zlange, zlansy, lsame
120 * ..
121 * .. Data statements ..
122  DATA iseed / 1988, 1989, 1990, 1991 /
123 *
124  eps = dlamch( 'Epsilon' )
125  k = n
126  m2 = m+n
127  IF( m.GT.0 ) THEN
128  np1 = n+1
129  ELSE
130  np1 = 1
131  END IF
132  lwork = m2*m2*nb
133 *
134 * Dynamically allocate all arrays
135 *
136  ALLOCATE(a(m2,n),af(m2,n),q(m2,m2),r(m2,m2),rwork(m2),
137  \$ work(lwork),t(nb,n),c(m2,n),cf(m2,n),
138  \$ d(n,m2),df(n,m2) )
139 *
140 * Put random stuff into A
141 *
142  ldt=nb
143  CALL zlaset( 'Full', m2, n, czero, czero, a, m2 )
144  CALL zlaset( 'Full', nb, n, czero, czero, t, nb )
145  DO j=1,n
146  CALL zlarnv( 2, iseed, j, a( 1, j ) )
147  END DO
148  IF( m.GT.0 ) THEN
149  DO j=1,n
150  CALL zlarnv( 2, iseed, m-l, a( min(n+m,n+1), j ) )
151  END DO
152  END IF
153  IF( l.GT.0 ) THEN
154  DO j=1,n
155  CALL zlarnv( 2, iseed, min(j,l), a( min(n+m,n+m-l+1), j ) )
156  END DO
157  END IF
158 *
159 * Copy the matrix A to the array AF.
160 *
161  CALL zlacpy( 'Full', m2, n, a, m2, af, m2 )
162 *
163 * Factor the matrix A in the array AF.
164 *
165  CALL ztpqrt( m,n,l,nb,af,m2,af(np1,1),m2,t,ldt,work,info)
166 *
167 * Generate the (M+N)-by-(M+N) matrix Q by applying H to I
168 *
169  CALL zlaset( 'Full', m2, m2, czero, one, q, m2 )
170  CALL zgemqrt( 'R', 'N', m2, m2, k, nb, af, m2, t, ldt, q, m2,
171  \$ work, info )
172 *
173 * Copy R
174 *
175  CALL zlaset( 'Full', m2, n, czero, czero, r, m2 )
176  CALL zlacpy( 'Upper', m2, n, af, m2, r, m2 )
177 *
178 * Compute |R - Q'*A| / |A| and store in RESULT(1)
179 *
180  CALL zgemm( 'C', 'N', m2, n, m2, -one, q, m2, a, m2, one, r, m2 )
181  anorm = zlange( '1', m2, n, a, m2, rwork )
182  resid = zlange( '1', m2, n, r, m2, rwork )
183  IF( anorm.GT.zero ) THEN
184  result( 1 ) = resid / (eps*anorm*max(1,m2))
185  ELSE
186  result( 1 ) = zero
187  END IF
188 *
189 * Compute |I - Q'*Q| and store in RESULT(2)
190 *
191  CALL zlaset( 'Full', m2, m2, czero, one, r, m2 )
192  CALL zherk( 'U', 'C', m2, m2, dreal(-one), q, m2, dreal(one),
193  \$ r, m2 )
194  resid = zlansy( '1', 'Upper', m2, r, m2, rwork )
195  result( 2 ) = resid / (eps*max(1,m2))
196 *
197 * Generate random m-by-n matrix C and a copy CF
198 *
199  DO j=1,n
200  CALL zlarnv( 2, iseed, m2, c( 1, j ) )
201  END DO
202  cnorm = zlange( '1', m2, n, c, m2, rwork)
203  CALL zlacpy( 'Full', m2, n, c, m2, cf, m2 )
204 *
205 * Apply Q to C as Q*C
206 *
207  CALL ztpmqrt( 'L','N', m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,m2,
208  \$ cf(np1,1),m2,work,info)
209 *
210 * Compute |Q*C - Q*C| / |C|
211 *
212  CALL zgemm( 'N', 'N', m2, n, m2, -one, q, m2, c, m2, one, cf, m2 )
213  resid = zlange( '1', m2, n, cf, m2, rwork )
214  IF( cnorm.GT.zero ) THEN
215  result( 3 ) = resid / (eps*max(1,m2)*cnorm)
216  ELSE
217  result( 3 ) = zero
218  END IF
219 *
220 * Copy C into CF again
221 *
222  CALL zlacpy( 'Full', m2, n, c, m2, cf, m2 )
223 *
224 * Apply Q to C as QT*C
225 *
226  CALL ztpmqrt( 'L','C',m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,m2,
227  \$ cf(np1,1),m2,work,info)
228 *
229 * Compute |QT*C - QT*C| / |C|
230 *
231  CALL zgemm('C','N',m2,n,m2,-one,q,m2,c,m2,one,cf,m2)
232  resid = zlange( '1', m2, n, cf, m2, rwork )
233  IF( cnorm.GT.zero ) THEN
234  result( 4 ) = resid / (eps*max(1,m2)*cnorm)
235  ELSE
236  result( 4 ) = zero
237  END IF
238 *
239 * Generate random n-by-m matrix D and a copy DF
240 *
241  DO j=1,m2
242  CALL zlarnv( 2, iseed, n, d( 1, j ) )
243  END DO
244  dnorm = zlange( '1', n, m2, d, n, rwork)
245  CALL zlacpy( 'Full', n, m2, d, n, df, n )
246 *
247 * Apply Q to D as D*Q
248 *
249  CALL ztpmqrt('R','N',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
250  \$ df(1,np1),n,work,info)
251 *
252 * Compute |D*Q - D*Q| / |D|
253 *
254  CALL zgemm('N','N',n,m2,m2,-one,d,n,q,m2,one,df,n)
255  resid = zlange('1',n, m2,df,n,rwork )
256  IF( cnorm.GT.zero ) THEN
257  result( 5 ) = resid / (eps*max(1,m2)*dnorm)
258  ELSE
259  result( 5 ) = zero
260  END IF
261 *
262 * Copy D into DF again
263 *
264  CALL zlacpy('Full',n,m2,d,n,df,n )
265 *
266 * Apply Q to D as D*QT
267 *
268  CALL ztpmqrt('R','C',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
269  \$ df(1,np1),n,work,info)
270
271 *
272 * Compute |D*QT - D*QT| / |D|
273 *
274  CALL zgemm( 'N', 'C', n, m2, m2, -one, d, n, q, m2, one, df, n )
275  resid = zlange( '1', n, m2, df, n, rwork )
276  IF( cnorm.GT.zero ) THEN
277  result( 6 ) = resid / (eps*max(1,m2)*dnorm)
278  ELSE
279  result( 6 ) = zero
280  END IF
281 *
282 * Deallocate all arrays
283 *
284  DEALLOCATE ( a, af, q, r, rwork, work, t, c, d, cf, df)
285  RETURN
286  END
287
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
Definition: zlacpy.f:105
subroutine zgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
ZGEMM
Definition: zgemm.f:189
subroutine zgemqrt(SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, C, LDC, WORK, INFO)
ZGEMQRT
Definition: zgemqrt.f:170
subroutine zlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: zlaset.f:108
subroutine zqrt05(M, N, L, NB, RESULT)
ZQRT05
Definition: zqrt05.f:82
subroutine zherk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
ZHERK
Definition: zherk.f:175
subroutine ztpmqrt(SIDE, TRANS, M, N, K, L, NB, V, LDV, T, LDT, A, LDA, B, LDB, WORK, INFO)
ZTPMQRT
Definition: ztpmqrt.f:218
subroutine zlarnv(IDIST, ISEED, N, X)
ZLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: zlarnv.f:101
subroutine ztpqrt(M, N, L, NB, A, LDA, B, LDB, T, LDT, WORK, INFO)
ZTPQRT
Definition: ztpqrt.f:191