LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
zqrt04.f
Go to the documentation of this file.
1 *> \brief \b ZQRT04
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 ZQRT04(M,N,NB,RESULT)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER M, N, NB, LDT
15 * .. Return values ..
16 * DOUBLE PRECISION RESULT(6)
17 *
18 *
19 *> \par Purpose:
20 * =============
21 *>
22 *> \verbatim
23 *>
24 *> ZQRT04 tests ZGEQRT and ZGEMQRT.
25 *> \endverbatim
26 *
27 * Arguments:
28 * ==========
29 *
30 *> \param[in] M
31 *> \verbatim
32 *> M is INTEGER
33 *> Number of rows in 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] NB
43 *> \verbatim
44 *> NB is INTEGER
45 *> Block size of test matrix. NB <= Min(M,N).
46 *> \endverbatim
47 *>
48 *> \param[out] RESULT
49 *> \verbatim
50 *> RESULT is DOUBLE PRECISION array, dimension (6)
51 *> Results of each of the six tests below.
52 *>
53 *> RESULT(1) = | A - Q R |
54 *> RESULT(2) = | I - Q^H Q |
55 *> RESULT(3) = | Q C - Q C |
56 *> RESULT(4) = | Q^H C - Q^H C |
57 *> RESULT(5) = | C Q - C Q |
58 *> RESULT(6) = | C Q^H - C Q^H |
59 *> \endverbatim
60 *
61 * Authors:
62 * ========
63 *
64 *> \author Univ. of Tennessee
65 *> \author Univ. of California Berkeley
66 *> \author Univ. of Colorado Denver
67 *> \author NAG Ltd.
68 *
69 *> \date April 2012
70 *
71 *> \ingroup complex16_lin
72 *
73 * =====================================================================
74  SUBROUTINE zqrt04(M,N,NB,RESULT)
75  IMPLICIT NONE
76 *
77 * -- LAPACK test routine (version 3.4.1) --
78 * -- LAPACK is a software package provided by Univ. of Tennessee, --
79 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
80 * April 2012
81 *
82 * .. Scalar Arguments ..
83  INTEGER m, n, nb, ldt
84 * .. Return values ..
85  DOUBLE PRECISION result(6)
86 *
87 * =====================================================================
88 *
89 * ..
90 * .. Local allocatable arrays
91  COMPLEX*16, ALLOCATABLE :: af(:,:), q(:,:),
92  $ r(:,:), rwork(:), work( : ), t(:,:),
93  $ cf(:,:), df(:,:), a(:,:), c(:,:), d(:,:)
94 *
95 * .. Parameters ..
96  DOUBLE PRECISION zero
97  COMPLEX*16 one, czero
98  parameter( zero = 0.0, one = (1.0,0.0), czero=(0.0,0.0) )
99 * ..
100 * .. Local Scalars ..
101  INTEGER info, j, k, l, lwork
102  DOUBLE PRECISION anorm, eps, resid, cnorm, dnorm
103 * ..
104 * .. Local Arrays ..
105  INTEGER iseed( 4 )
106 * ..
107 * .. External Functions ..
108  DOUBLE PRECISION dlamch
109  DOUBLE PRECISION zlange, zlansy
110  LOGICAL lsame
111  EXTERNAL dlamch, zlange, zlansy, lsame
112 * ..
113 * .. Intrinsic Functions ..
114  INTRINSIC max, min
115 * ..
116 * .. Data statements ..
117  DATA iseed / 1988, 1989, 1990, 1991 /
118 *
119  eps = dlamch( 'Epsilon' )
120  k = min(m,n)
121  l = max(m,n)
122  lwork = max(2,l)*max(2,l)*nb
123 *
124 * Dynamically allocate local arrays
125 *
126  ALLOCATE ( a(m,n), af(m,n), q(m,m), r(m,l), rwork(l),
127  $ work(lwork), t(nb,n), c(m,n), cf(m,n),
128  $ d(n,m), df(n,m) )
129 *
130 * Put random numbers into A and copy to AF
131 *
132  ldt=nb
133  DO j=1,n
134  CALL zlarnv( 2, iseed, m, a( 1, j ) )
135  END DO
136  CALL zlacpy( 'Full', m, n, a, m, af, m )
137 *
138 * Factor the matrix A in the array AF.
139 *
140  CALL zgeqrt( m, n, nb, af, m, t, ldt, work, info )
141 *
142 * Generate the m-by-m matrix Q
143 *
144  CALL zlaset( 'Full', m, m, czero, one, q, m )
145  CALL zgemqrt( 'R', 'N', m, m, k, nb, af, m, t, ldt, q, m,
146  $ work, info )
147 *
148 * Copy R
149 *
150  CALL zlaset( 'Full', m, n, czero, czero, r, m )
151  CALL zlacpy( 'Upper', m, n, af, m, r, m )
152 *
153 * Compute |R - Q'*A| / |A| and store in RESULT(1)
154 *
155  CALL zgemm( 'C', 'N', m, n, m, -one, q, m, a, m, one, r, m )
156  anorm = zlange( '1', m, n, a, m, rwork )
157  resid = zlange( '1', m, n, r, m, rwork )
158  IF( anorm.GT.zero ) THEN
159  result( 1 ) = resid / (eps*max(1,m)*anorm)
160  ELSE
161  result( 1 ) = zero
162  END IF
163 *
164 * Compute |I - Q'*Q| and store in RESULT(2)
165 *
166  CALL zlaset( 'Full', m, m, czero, one, r, m )
167  CALL zherk( 'U', 'C', m, m, dreal(-one), q, m, dreal(one), r, m )
168  resid = zlansy( '1', 'Upper', m, r, m, rwork )
169  result( 2 ) = resid / (eps*max(1,m))
170 *
171 * Generate random m-by-n matrix C and a copy CF
172 *
173  DO j=1,n
174  CALL zlarnv( 2, iseed, m, c( 1, j ) )
175  END DO
176  cnorm = zlange( '1', m, n, c, m, rwork)
177  CALL zlacpy( 'Full', m, n, c, m, cf, m )
178 *
179 * Apply Q to C as Q*C
180 *
181  CALL zgemqrt( 'L', 'N', m, n, k, nb, af, m, t, nb, cf, m,
182  $ work, info)
183 *
184 * Compute |Q*C - Q*C| / |C|
185 *
186  CALL zgemm( 'N', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
187  resid = zlange( '1', m, n, cf, m, rwork )
188  IF( cnorm.GT.zero ) THEN
189  result( 3 ) = resid / (eps*max(1,m)*cnorm)
190  ELSE
191  result( 3 ) = zero
192  END IF
193 *
194 * Copy C into CF again
195 *
196  CALL zlacpy( 'Full', m, n, c, m, cf, m )
197 *
198 * Apply Q to C as QT*C
199 *
200  CALL zgemqrt( 'L', 'C', m, n, k, nb, af, m, t, nb, cf, m,
201  $ work, info)
202 *
203 * Compute |QT*C - QT*C| / |C|
204 *
205  CALL zgemm( 'C', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
206  resid = zlange( '1', m, n, cf, m, rwork )
207  IF( cnorm.GT.zero ) THEN
208  result( 4 ) = resid / (eps*max(1,m)*cnorm)
209  ELSE
210  result( 4 ) = zero
211  END IF
212 *
213 * Generate random n-by-m matrix D and a copy DF
214 *
215  DO j=1,m
216  CALL zlarnv( 2, iseed, n, d( 1, j ) )
217  END DO
218  dnorm = zlange( '1', n, m, d, n, rwork)
219  CALL zlacpy( 'Full', n, m, d, n, df, n )
220 *
221 * Apply Q to D as D*Q
222 *
223  CALL zgemqrt( 'R', 'N', n, m, k, nb, af, m, t, nb, df, n,
224  $ work, info)
225 *
226 * Compute |D*Q - D*Q| / |D|
227 *
228  CALL zgemm( 'N', 'N', n, m, m, -one, d, n, q, m, one, df, n )
229  resid = zlange( '1', n, m, df, n, rwork )
230  IF( cnorm.GT.zero ) THEN
231  result( 5 ) = resid / (eps*max(1,m)*dnorm)
232  ELSE
233  result( 5 ) = zero
234  END IF
235 *
236 * Copy D into DF again
237 *
238  CALL zlacpy( 'Full', n, m, d, n, df, n )
239 *
240 * Apply Q to D as D*QT
241 *
242  CALL zgemqrt( 'R', 'C', n, m, k, nb, af, m, t, nb, df, n,
243  $ work, info)
244 *
245 * Compute |D*QT - D*QT| / |D|
246 *
247  CALL zgemm( 'N', 'C', n, m, m, -one, d, n, q, m, one, df, n )
248  resid = zlange( '1', n, m, df, n, rwork )
249  IF( cnorm.GT.zero ) THEN
250  result( 6 ) = resid / (eps*max(1,m)*dnorm)
251  ELSE
252  result( 6 ) = zero
253  END IF
254 *
255 * Deallocate all arrays
256 *
257  DEALLOCATE ( a, af, q, r, rwork, work, t, c, d, cf, df)
258 *
259  return
260  END
261