LAPACK  3.10.1
LAPACK: Linear Algebra PACKage
dqrt05.f
Go to the documentation of this file.
1 *> \brief \b DQRT05
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 DQRT05(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 *> DQRT05 tests DTPQRT and DTPMQRT.
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 *> \ingroup double_lin
77 *
78 * =====================================================================
79  SUBROUTINE dqrt05(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  DOUBLE PRECISION RESULT(6)
90 *
91 * =====================================================================
92 *
93 * ..
94 * .. Local allocatable arrays
95  DOUBLE PRECISION, ALLOCATABLE :: AF(:,:), Q(:,:),
96  $ R(:,:), RWORK(:), WORK( : ), T(:,:),
97  $ CF(:,:), DF(:,:), A(:,:), C(:,:), D(:,:)
98 *
99 * .. Parameters ..
100  DOUBLE PRECISION ONE, ZERO
101  parameter( zero = 0.0, one = 1.0 )
102 * ..
103 * .. Local Scalars ..
104  INTEGER INFO, J, K, M2, NP1
105  DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
106 * ..
107 * .. Local Arrays ..
108  INTEGER ISEED( 4 )
109 * ..
110 * .. External Functions ..
111  DOUBLE PRECISION DLAMCH, DLANGE, DLANSY
112  LOGICAL LSAME
113  EXTERNAL dlamch, dlange, dlansy, lsame
114 * ..
115 * .. Data statements ..
116  DATA iseed / 1988, 1989, 1990, 1991 /
117 *
118  eps = dlamch( 'Epsilon' )
119  k = n
120  m2 = m+n
121  IF( m.GT.0 ) THEN
122  np1 = n+1
123  ELSE
124  np1 = 1
125  END IF
126  lwork = m2*m2*nb
127 *
128 * Dynamically allocate all arrays
129 *
130  ALLOCATE(a(m2,n),af(m2,n),q(m2,m2),r(m2,m2),rwork(m2),
131  $ work(lwork),t(nb,n),c(m2,n),cf(m2,n),
132  $ d(n,m2),df(n,m2) )
133 *
134 * Put random stuff into A
135 *
136  ldt=nb
137  CALL dlaset( 'Full', m2, n, zero, zero, a, m2 )
138  CALL dlaset( 'Full', nb, n, zero, zero, t, nb )
139  DO j=1,n
140  CALL dlarnv( 2, iseed, j, a( 1, j ) )
141  END DO
142  IF( m.GT.0 ) THEN
143  DO j=1,n
144  CALL dlarnv( 2, iseed, m-l, a( min(n+m,n+1), j ) )
145  END DO
146  END IF
147  IF( l.GT.0 ) THEN
148  DO j=1,n
149  CALL dlarnv( 2, iseed, min(j,l), a( min(n+m,n+m-l+1), j ) )
150  END DO
151  END IF
152 *
153 * Copy the matrix A to the array AF.
154 *
155  CALL dlacpy( 'Full', m2, n, a, m2, af, m2 )
156 *
157 * Factor the matrix A in the array AF.
158 *
159  CALL dtpqrt( m,n,l,nb,af,m2,af(np1,1),m2,t,ldt,work,info)
160 *
161 * Generate the (M+N)-by-(M+N) matrix Q by applying H to I
162 *
163  CALL dlaset( 'Full', m2, m2, zero, one, q, m2 )
164  CALL dgemqrt( 'R', 'N', m2, m2, k, nb, af, m2, t, ldt, q, m2,
165  $ work, info )
166 *
167 * Copy R
168 *
169  CALL dlaset( 'Full', m2, n, zero, zero, r, m2 )
170  CALL dlacpy( 'Upper', m2, n, af, m2, r, m2 )
171 *
172 * Compute |R - Q'*A| / |A| and store in RESULT(1)
173 *
174  CALL dgemm( 'T', 'N', m2, n, m2, -one, q, m2, a, m2, one, r, m2 )
175  anorm = dlange( '1', m2, n, a, m2, rwork )
176  resid = dlange( '1', m2, n, r, m2, rwork )
177  IF( anorm.GT.zero ) THEN
178  result( 1 ) = resid / (eps*anorm*max(1,m2))
179  ELSE
180  result( 1 ) = zero
181  END IF
182 *
183 * Compute |I - Q'*Q| and store in RESULT(2)
184 *
185  CALL dlaset( 'Full', m2, m2, zero, one, r, m2 )
186  CALL dsyrk( 'U', 'C', m2, m2, -one, q, m2, one, r, m2 )
187  resid = dlansy( '1', 'Upper', m2, r, m2, rwork )
188  result( 2 ) = resid / (eps*max(1,m2))
189 *
190 * Generate random m-by-n matrix C and a copy CF
191 *
192  DO j=1,n
193  CALL dlarnv( 2, iseed, m2, c( 1, j ) )
194  END DO
195  cnorm = dlange( '1', m2, n, c, m2, rwork)
196  CALL dlacpy( 'Full', m2, n, c, m2, cf, m2 )
197 *
198 * Apply Q to C as Q*C
199 *
200  CALL dtpmqrt( 'L','N', m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,m2,
201  $ cf(np1,1),m2,work,info)
202 *
203 * Compute |Q*C - Q*C| / |C|
204 *
205  CALL dgemm( 'N', 'N', m2, n, m2, -one, q, m2, c, m2, one, cf, m2 )
206  resid = dlange( '1', m2, n, cf, m2, rwork )
207  IF( cnorm.GT.zero ) THEN
208  result( 3 ) = resid / (eps*max(1,m2)*cnorm)
209  ELSE
210  result( 3 ) = zero
211  END IF
212 *
213 * Copy C into CF again
214 *
215  CALL dlacpy( 'Full', m2, n, c, m2, cf, m2 )
216 *
217 * Apply Q to C as QT*C
218 *
219  CALL dtpmqrt( 'L','T',m,n,k,l,nb,af(np1,1),m2,t,ldt,cf,m2,
220  $ cf(np1,1),m2,work,info)
221 *
222 * Compute |QT*C - QT*C| / |C|
223 *
224  CALL dgemm('T','N',m2,n,m2,-one,q,m2,c,m2,one,cf,m2)
225  resid = dlange( '1', m2, n, cf, m2, rwork )
226  IF( cnorm.GT.zero ) THEN
227  result( 4 ) = resid / (eps*max(1,m2)*cnorm)
228  ELSE
229  result( 4 ) = zero
230  END IF
231 *
232 * Generate random n-by-m matrix D and a copy DF
233 *
234  DO j=1,m2
235  CALL dlarnv( 2, iseed, n, d( 1, j ) )
236  END DO
237  dnorm = dlange( '1', n, m2, d, n, rwork)
238  CALL dlacpy( 'Full', n, m2, d, n, df, n )
239 *
240 * Apply Q to D as D*Q
241 *
242  CALL dtpmqrt('R','N',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
243  $ df(1,np1),n,work,info)
244 *
245 * Compute |D*Q - D*Q| / |D|
246 *
247  CALL dgemm('N','N',n,m2,m2,-one,d,n,q,m2,one,df,n)
248  resid = dlange('1',n, m2,df,n,rwork )
249  IF( cnorm.GT.zero ) THEN
250  result( 5 ) = resid / (eps*max(1,m2)*dnorm)
251  ELSE
252  result( 5 ) = zero
253  END IF
254 *
255 * Copy D into DF again
256 *
257  CALL dlacpy('Full',n,m2,d,n,df,n )
258 *
259 * Apply Q to D as D*QT
260 *
261  CALL dtpmqrt('R','T',n,m,n,l,nb,af(np1,1),m2,t,ldt,df,n,
262  $ df(1,np1),n,work,info)
263 
264 *
265 * Compute |D*QT - D*QT| / |D|
266 *
267  CALL dgemm( 'N', 'T', n, m2, m2, -one, d, n, q, m2, one, df, n )
268  resid = dlange( '1', n, m2, df, n, rwork )
269  IF( cnorm.GT.zero ) THEN
270  result( 6 ) = resid / (eps*max(1,m2)*dnorm)
271  ELSE
272  result( 6 ) = zero
273  END IF
274 *
275 * Deallocate all arrays
276 *
277  DEALLOCATE ( a, af, q, r, rwork, work, t, c, d, cf, df)
278  RETURN
279  END
280 
subroutine dlarnv(IDIST, ISEED, N, X)
DLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: dlarnv.f:97
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:103
subroutine dlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: dlaset.f:110
subroutine dsyrk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
DSYRK
Definition: dsyrk.f:169
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:187
subroutine dqrt05(M, N, L, NB, RESULT)
DQRT05
Definition: dqrt05.f:80
subroutine dgemqrt(SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, C, LDC, WORK, INFO)
DGEMQRT
Definition: dgemqrt.f:168
subroutine dtpqrt(M, N, L, NB, A, LDA, B, LDB, T, LDT, WORK, INFO)
DTPQRT
Definition: dtpqrt.f:189
subroutine dtpmqrt(SIDE, TRANS, M, N, K, L, NB, V, LDV, T, LDT, A, LDA, B, LDB, WORK, INFO)
DTPMQRT
Definition: dtpmqrt.f:216