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