LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
cqrt05.f
Go to the documentation of this file.
1 *> \brief \b CQRT05
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 CQRT05(M,N,L,NB,RESULT)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER LWORK, M, N, L, NB, LDT
15 * .. Return values ..
16 * REAL RESULT(6)
17 *
18 *
19 *> \par Purpose:
20 * =============
21 *>
22 *> \verbatim
23 *>
24 *> CQRT05 tests CTPQRT and CTPMQRT.
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 REAL 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 *> \ingroup complex_lin
77 *
78 * =====================================================================
79  SUBROUTINE cqrt05(M,N,L,NB,RESULT)
80  IMPLICIT NONE
81 *
82 * -- LAPACK test routine --
83 * -- LAPACK is a software package provided by Univ. of Tennessee, --
84 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
85 *
86 * .. Scalar Arguments ..
87  INTEGER LWORK, M, N, L, NB, LDT
88 * .. Return values ..
89  REAL RESULT(6)
90 *
91 * =====================================================================
92 *
93 * ..
94 * .. Local allocatable arrays
95  COMPLEX, ALLOCATABLE :: AF(:,:), Q(:,:),
96  $ R(:,:), WORK( : ), T(:,:),
97  $ CF(:,:), DF(:,:), A(:,:), C(:,:), D(:,:)
98  REAL, ALLOCATABLE :: RWORK(:)
99 *
100 * .. Parameters ..
101  REAL ZERO
102  COMPLEX ONE, CZERO
103  parameter( zero = 0.0, one = (1.0,0.0), czero=(0.0,0.0) )
104 * ..
105 * .. Local Scalars ..
106  INTEGER INFO, J, K, M2, NP1
107  REAL ANORM, EPS, RESID, CNORM, DNORM
108 * ..
109 * .. Local Arrays ..
110  INTEGER ISEED( 4 )
111 * ..
112 * .. External Functions ..
113  REAL SLAMCH
114  REAL CLANGE, CLANSY
115  LOGICAL LSAME
116  EXTERNAL slamch, clange, clansy, lsame
117 * ..
118 * .. Data statements ..
119  DATA iseed / 1988, 1989, 1990, 1991 /
120 *
121  eps = slamch( 'Epsilon' )
122  k = n
123  m2 = m+n
124  IF( m.GT.0 ) THEN
125  np1 = n+1
126  ELSE
127  np1 = 1
128  END IF
129  lwork = m2*m2*nb
130 *
131 * Dynamically allocate all arrays
132 *
133  ALLOCATE(a(m2,n),af(m2,n),q(m2,m2),r(m2,m2),rwork(m2),
134  $ work(lwork),t(nb,n),c(m2,n),cf(m2,n),
135  $ d(n,m2),df(n,m2) )
136 *
137 * Put random stuff into A
138 *
139  ldt=nb
140  CALL claset( 'Full', m2, n, czero, czero, a, m2 )
141  CALL claset( 'Full', nb, n, czero, czero, t, nb )
142  DO j=1,n
143  CALL clarnv( 2, iseed, j, a( 1, j ) )
144  END DO
145  IF( m.GT.0 ) THEN
146  DO j=1,n
147  CALL clarnv( 2, iseed, m-l, a( min(n+m,n+1), j ) )
148  END DO
149  END IF
150  IF( l.GT.0 ) THEN
151  DO j=1,n
152  CALL clarnv( 2, iseed, min(j,l), a( min(n+m,n+m-l+1), j ) )
153  END DO
154  END IF
155 *
156 * Copy the matrix A to the array AF.
157 *
158  CALL clacpy( 'Full', m2, n, a, m2, af, m2 )
159 *
160 * Factor the matrix A in the array AF.
161 *
162  CALL ctpqrt( m,n,l,nb,af,m2,af(np1,1),m2,t,ldt,work,info)
163 *
164 * Generate the (M+N)-by-(M+N) matrix Q by applying H to I
165 *
166  CALL claset( 'Full', m2, m2, czero, one, q, m2 )
167  CALL cgemqrt( 'R', 'N', m2, m2, k, nb, af, m2, t, ldt, q, m2,
168  $ work, info )
169 *
170 * Copy R
171 *
172  CALL claset( 'Full', m2, n, czero, czero, r, m2 )
173  CALL clacpy( 'Upper', m2, n, af, m2, r, m2 )
174 *
175 * Compute |R - Q'*A| / |A| and store in RESULT(1)
176 *
177  CALL cgemm( 'C', 'N', m2, n, m2, -one, q, m2, a, m2, one, r, m2 )
178  anorm = clange( '1', m2, n, a, m2, rwork )
179  resid = clange( '1', m2, n, r, m2, rwork )
180  IF( anorm.GT.zero ) THEN
181  result( 1 ) = resid / (eps*anorm*max(1,m2))
182  ELSE
183  result( 1 ) = zero
184  END IF
185 *
186 * Compute |I - Q'*Q| and store in RESULT(2)
187 *
188  CALL claset( 'Full', m2, m2, czero, one, r, m2 )
189  CALL cherk( 'U', 'C', m2, m2, real(-one), q, m2, real(one),
190  $ r, m2 )
191  resid = clansy( '1', 'Upper', m2, r, m2, rwork )
192  result( 2 ) = resid / (eps*max(1,m2))
193 *
194 * Generate random m-by-n matrix C and a copy CF
195 *
196  DO j=1,n
197  CALL clarnv( 2, iseed, m2, c( 1, j ) )
198  END DO
199  cnorm = clange( '1', m2, n, c, m2, rwork)
200  CALL clacpy( 'Full', m2, n, c, m2, cf, m2 )
201 *
202 * Apply Q to C as Q*C
203 *
204  CALL ctpmqrt( 'L','N', m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,m2,
205  $ cf(np1,1),m2,work,info)
206 *
207 * Compute |Q*C - Q*C| / |C|
208 *
209  CALL cgemm( 'N', 'N', m2, n, m2, -one, q, m2, c, m2, one, cf, m2 )
210  resid = clange( '1', m2, n, cf, m2, rwork )
211  IF( cnorm.GT.zero ) THEN
212  result( 3 ) = resid / (eps*max(1,m2)*cnorm)
213  ELSE
214  result( 3 ) = zero
215  END IF
216 *
217 * Copy C into CF again
218 *
219  CALL clacpy( 'Full', m2, n, c, m2, cf, m2 )
220 *
221 * Apply Q to C as QT*C
222 *
223  CALL ctpmqrt( 'L','C',m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,m2,
224  $ cf(np1,1),m2,work,info)
225 *
226 * Compute |QT*C - QT*C| / |C|
227 *
228  CALL cgemm('C','N',m2,n,m2,-one,q,m2,c,m2,one,cf,m2)
229  resid = clange( '1', m2, n, cf, m2, rwork )
230  IF( cnorm.GT.zero ) THEN
231  result( 4 ) = resid / (eps*max(1,m2)*cnorm)
232  ELSE
233  result( 4 ) = zero
234  END IF
235 *
236 * Generate random n-by-m matrix D and a copy DF
237 *
238  DO j=1,m2
239  CALL clarnv( 2, iseed, n, d( 1, j ) )
240  END DO
241  dnorm = clange( '1', n, m2, d, n, rwork)
242  CALL clacpy( 'Full', n, m2, d, n, df, n )
243 *
244 * Apply Q to D as D*Q
245 *
246  CALL ctpmqrt('R','N',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
247  $ df(1,np1),n,work,info)
248 *
249 * Compute |D*Q - D*Q| / |D|
250 *
251  CALL cgemm('N','N',n,m2,m2,-one,d,n,q,m2,one,df,n)
252  resid = clange('1',n, m2,df,n,rwork )
253  IF( cnorm.GT.zero ) THEN
254  result( 5 ) = resid / (eps*max(1,m2)*dnorm)
255  ELSE
256  result( 5 ) = zero
257  END IF
258 *
259 * Copy D into DF again
260 *
261  CALL clacpy('Full',n,m2,d,n,df,n )
262 *
263 * Apply Q to D as D*QT
264 *
265  CALL ctpmqrt('R','C',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
266  $ df(1,np1),n,work,info)
267 
268 *
269 * Compute |D*QT - D*QT| / |D|
270 *
271  CALL cgemm( 'N', 'C', n, m2, m2, -one, d, n, q, m2, one, df, n )
272  resid = clange( '1', n, m2, df, n, rwork )
273  IF( cnorm.GT.zero ) THEN
274  result( 6 ) = resid / (eps*max(1,m2)*dnorm)
275  ELSE
276  result( 6 ) = zero
277  END IF
278 *
279 * Deallocate all arrays
280 *
281  DEALLOCATE ( a, af, q, r, rwork, work, t, c, d, cf, df)
282  RETURN
283  END
284 
subroutine cgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
CGEMM
Definition: cgemm.f:187
subroutine cherk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
CHERK
Definition: cherk.f:173
subroutine cqrt05(M, N, L, NB, RESULT)
CQRT05
Definition: cqrt05.f:80
subroutine cgemqrt(SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, C, LDC, WORK, INFO)
CGEMQRT
Definition: cgemqrt.f:168
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: claset.f:106
subroutine clarnv(IDIST, ISEED, N, X)
CLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: clarnv.f:99
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:103
subroutine ctpmqrt(SIDE, TRANS, M, N, K, L, NB, V, LDV, T, LDT, A, LDA, B, LDB, WORK, INFO)
CTPMQRT
Definition: ctpmqrt.f:216
subroutine ctpqrt(M, N, L, NB, A, LDA, B, LDB, T, LDT, WORK, INFO)
CTPQRT
Definition: ctpqrt.f:189