LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
cqrt04.f
Go to the documentation of this file.
1 *> \brief \b CQRT04
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 CQRT04(M,N,NB,RESULT)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER M, N, NB, LDT
15 * .. Return values ..
16 * REAL RESULT(6)
17 *
18 *
19 *> \par Purpose:
20 * =============
21 *>
22 *> \verbatim
23 *>
24 *> CQRT04 tests CGEQRT and CGEMQRT.
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 REAL 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 complex_lin
72 *
73 * =====================================================================
74  SUBROUTINE cqrt04(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  REAL result(6)
86 *
87 * =====================================================================
88 *
89 * ..
90 * .. Local allocatable arrays
91  COMPLEX, ALLOCATABLE :: af(:,:), q(:,:),
92  $ r(:,:), rwork(:), work( : ), t(:,:),
93  $ cf(:,:), df(:,:), a(:,:), c(:,:), d(:,:)
94 *
95 * .. Parameters ..
96  REAL zero
97  COMPLEX 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  REAL anorm, eps, resid, cnorm, dnorm
103 * ..
104 * .. Local Arrays ..
105  INTEGER iseed( 4 )
106 * ..
107 * .. External Functions ..
108  REAL slamch
109  REAL clange, clansy
110  LOGICAL lsame
111  EXTERNAL slamch, clange, clansy, lsame
112 * ..
113 * .. Intrinsic Functions ..
114  INTRINSIC max, min
115 * ..
116 * .. Data statements ..
117  DATA iseed / 1988, 1989, 1990, 1991 /
118 *
119  eps = slamch( '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 clarnv( 2, iseed, m, a( 1, j ) )
135  END DO
136  CALL clacpy( 'Full', m, n, a, m, af, m )
137 *
138 * Factor the matrix A in the array AF.
139 *
140  CALL cgeqrt( m, n, nb, af, m, t, ldt, work, info )
141 *
142 * Generate the m-by-m matrix Q
143 *
144  CALL claset( 'Full', m, m, czero, one, q, m )
145  CALL cgemqrt( 'R', 'N', m, m, k, nb, af, m, t, ldt, q, m,
146  $ work, info )
147 *
148 * Copy R
149 *
150  CALL claset( 'Full', m, n, czero, czero, r, m )
151  CALL clacpy( 'Upper', m, n, af, m, r, m )
152 *
153 * Compute |R - Q'*A| / |A| and store in RESULT(1)
154 *
155  CALL cgemm( 'C', 'N', m, n, m, -one, q, m, a, m, one, r, m )
156  anorm = clange( '1', m, n, a, m, rwork )
157  resid = clange( '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 claset( 'Full', m, m, czero, one, r, m )
167  CALL cherk( 'U', 'C', m, m, REAL(-ONE), q, m, REAL(ONE), r, m )
168  resid = clansy( '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 clarnv( 2, iseed, m, c( 1, j ) )
175  END DO
176  cnorm = clange( '1', m, n, c, m, rwork)
177  CALL clacpy( 'Full', m, n, c, m, cf, m )
178 *
179 * Apply Q to C as Q*C
180 *
181  CALL cgemqrt( '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 cgemm( 'N', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
187  resid = clange( '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 clacpy( 'Full', m, n, c, m, cf, m )
197 *
198 * Apply Q to C as QT*C
199 *
200  CALL cgemqrt( '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 cgemm( 'C', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
206  resid = clange( '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 clarnv( 2, iseed, n, d( 1, j ) )
217  END DO
218  dnorm = clange( '1', n, m, d, n, rwork)
219  CALL clacpy( 'Full', n, m, d, n, df, n )
220 *
221 * Apply Q to D as D*Q
222 *
223  CALL cgemqrt( '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 cgemm( 'N', 'N', n, m, m, -one, d, n, q, m, one, df, n )
229  resid = clange( '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 clacpy( 'Full', n, m, d, n, df, n )
239 *
240 * Apply Q to D as D*QT
241 *
242  CALL cgemqrt( '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 cgemm( 'N', 'C', n, m, m, -one, d, n, q, m, one, df, n )
248  resid = clange( '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