LAPACK  3.8.0 LAPACK: Linear Algebra PACKage
slqt05.f
Go to the documentation of this file.
1 * Definition:
2 * ===========
3 *
4 * SUBROUTINE SLQT05(M,N,L,NB,RESULT)
5 *
6 * .. Scalar Arguments ..
7 * INTEGER LWORK, M, N, L, NB, LDT
8 * .. Return values ..
9 * REAL RESULT(6)
10 *
11 *
12 *> \par Purpose:
13 * =============
14 *>
15 *> \verbatim
16 *>
17 *> SQRT05 tests STPLQT and STPMLQT.
18 *> \endverbatim
19 *
20 * Arguments:
21 * ==========
22 *
23 *> \param[in] M
24 *> \verbatim
25 *> M is INTEGER
26 *> Number of rows in lower part of the test matrix.
27 *> \endverbatim
28 *>
29 *> \param[in] N
30 *> \verbatim
31 *> N is INTEGER
32 *> Number of columns in test matrix.
33 *> \endverbatim
34 *>
35 *> \param[in] L
36 *> \verbatim
37 *> L is INTEGER
38 *> The number of rows of the upper trapezoidal part the
39 *> lower test matrix. 0 <= L <= M.
40 *> \endverbatim
41 *>
42 *> \param[in] NB
43 *> \verbatim
44 *> NB is INTEGER
45 *> Block size of test matrix. NB <= 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 double_lin
72 *
73 * =====================================================================
74  SUBROUTINE slqt05(M,N,L,NB,RESULT)
75  IMPLICIT NONE
76 *
77 * -- LAPACK test routine (version 3.7.0) --
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 LWORK, M, N, L, NB, LDT
84 * .. Return values ..
85  REAL RESULT(6)
86 *
87 * =====================================================================
88 *
89 * ..
90 * .. Local allocatable arrays
91  REAL, ALLOCATABLE :: AF(:,:), Q(:,:),
92  \$ r(:,:), rwork(:), work( : ), t(:,:),
93  \$ cf(:,:), df(:,:), a(:,:), c(:,:), d(:,:)
94 *
95 * .. Parameters ..
96  REAL ONE, ZERO
97  parameter( zero = 0.0, one = 1.0 )
98 * ..
99 * .. Local Scalars ..
100  INTEGER INFO, J, K, N2, NP1,i
101  REAL ANORM, EPS, RESID, CNORM, DNORM
102 * ..
103 * .. Local Arrays ..
104  INTEGER ISEED( 4 )
105 * ..
106 * .. External Functions ..
107  REAL SLAMCH, SLANGE, SLANSY
108  LOGICAL LSAME
109  EXTERNAL slamch, slange, slansy, lsame
110 * ..
111 * .. Data statements ..
112  DATA iseed / 1988, 1989, 1990, 1991 /
113 *
114  eps = slamch( 'Epsilon' )
115  k = m
116  n2 = m+n
117  IF( n.GT.0 ) THEN
118  np1 = m+1
119  ELSE
120  np1 = 1
121  END IF
122  lwork = n2*n2*nb
123 *
124 * Dynamically allocate all arrays
125 *
126  ALLOCATE(a(m,n2),af(m,n2),q(n2,n2),r(n2,n2),rwork(n2),
127  \$ work(lwork),t(nb,m),c(n2,m),cf(n2,m),
128  \$ d(m,n2),df(m,n2) )
129 *
130 * Put random stuff into A
131 *
132  ldt=nb
133  CALL slaset( 'Full', m, n2, zero, zero, a, m )
134  CALL slaset( 'Full', nb, m, zero, zero, t, nb )
135  DO j=1,m
136  CALL slarnv( 2, iseed, m-j+1, a( j, j ) )
137  END DO
138  IF( n.GT.0 ) THEN
139  DO j=1,n-l
140  CALL slarnv( 2, iseed, m, a( 1, min(n+m,m+1) + j - 1 ) )
141  END DO
142  END IF
143  IF( l.GT.0 ) THEN
144  DO j=1,l
145  CALL slarnv( 2, iseed, m-j+1, a( j, min(n+m,n+m-l+1)
146  \$ + j - 1 ) )
147  END DO
148  END IF
149 *
150 * Copy the matrix A to the array AF.
151 *
152  CALL slacpy( 'Full', m, n2, a, m, af, m )
153 *
154 * Factor the matrix A in the array AF.
155 *
156  CALL stplqt( m,n,l,nb,af,m,af(1,np1),m,t,ldt,work,info)
157 *
158 * Generate the (M+N)-by-(M+N) matrix Q by applying H to I
159 *
160  CALL slaset( 'Full', n2, n2, zero, one, q, n2 )
161  CALL sgemlqt( 'L', 'N', n2, n2, k, nb, af, m, t, ldt, q, n2,
162  \$ work, info )
163 *
164 * Copy L
165 *
166  CALL slaset( 'Full', n2, n2, zero, zero, r, n2 )
167  CALL slacpy( 'Lower', m, n2, af, m, r, n2 )
168 *
169 * Compute |L - A*Q*T| / |A| and store in RESULT(1)
170 *
171  CALL sgemm( 'N', 'T', m, n2, n2, -one, a, m, q, n2, one, r, n2)
172  anorm = slange( '1', m, n2, a, m, rwork )
173  resid = slange( '1', m, n2, r, n2, rwork )
174  IF( anorm.GT.zero ) THEN
175  result( 1 ) = resid / (eps*anorm*max(1,n2))
176  ELSE
177  result( 1 ) = zero
178  END IF
179 *
180 * Compute |I - Q*Q'| and store in RESULT(2)
181 *
182  CALL slaset( 'Full', n2, n2, zero, one, r, n2 )
183  CALL ssyrk( 'U', 'N', n2, n2, -one, q, n2, one, r, n2 )
184  resid = slansy( '1', 'Upper', n2, r, n2, rwork )
185  result( 2 ) = resid / (eps*max(1,n2))
186 *
187 * Generate random m-by-n matrix C and a copy CF
188 *
189  CALL slaset( 'Full', n2, m, zero, one, c, n2 )
190  DO j=1,m
191  CALL slarnv( 2, iseed, n2, c( 1, j ) )
192  END DO
193  cnorm = slange( '1', n2, m, c, n2, rwork)
194  CALL slacpy( 'Full', n2, m, c, n2, cf, n2 )
195 *
196 * Apply Q to C as Q*C
197 *
198  CALL stpmlqt( 'L','N', n,m,k,l,nb,af(1, np1),m,t,ldt,cf,n2,
199  \$ cf(np1,1),n2,work,info)
200 *
201 * Compute |Q*C - Q*C| / |C|
202 *
203  CALL sgemm( 'N', 'N', n2, m, n2, -one, q, n2, c, n2, one, cf, n2 )
204  resid = slange( '1', n2, m, cf, n2, rwork )
205  IF( cnorm.GT.zero ) THEN
206  result( 3 ) = resid / (eps*max(1,n2)*cnorm)
207  ELSE
208  result( 3 ) = zero
209  END IF
210
211 *
212 * Copy C into CF again
213 *
214  CALL slacpy( 'Full', n2, m, c, n2, cf, n2 )
215 *
216 * Apply Q to C as QT*C
217 *
218  CALL stpmlqt( 'L','T',n,m,k,l,nb,af(1,np1),m,t,ldt,cf,n2,
219  \$ cf(np1,1),n2,work,info)
220 *
221 * Compute |QT*C - QT*C| / |C|
222 *
223  CALL sgemm('T','N',n2,m,n2,-one,q,n2,c,n2,one,cf,n2)
224  resid = slange( '1', n2, m, cf, n2, rwork )
225
226  IF( cnorm.GT.zero ) THEN
227  result( 4 ) = resid / (eps*max(1,n2)*cnorm)
228  ELSE
229  result( 4 ) = zero
230  END IF
231 *
232 * Generate random m-by-n matrix D and a copy DF
233 *
234  DO j=1,n2
235  CALL slarnv( 2, iseed, m, d( 1, j ) )
236  END DO
237  dnorm = slange( '1', m, n2, d, m, rwork)
238  CALL slacpy( 'Full', m, n2, d, m, df, m )
239 *
240 * Apply Q to D as D*Q
241 *
242  CALL stpmlqt('R','N',m,n,k,l,nb,af(1,np1),m,t,ldt,df,m,
243  \$ df(1,np1),m,work,info)
244 *
245 * Compute |D*Q - D*Q| / |D|
246 *
247  CALL sgemm('N','N',m,n2,n2,-one,d,m,q,n2,one,df,m)
248  resid = slange('1',m, n2,df,m,rwork )
249  IF( cnorm.GT.zero ) THEN
250  result( 5 ) = resid / (eps*max(1,n2)*dnorm)
251  ELSE
252  result( 5 ) = zero
253  END IF
254 *
255 * Copy D into DF again
256 *
257  CALL slacpy('Full',m,n2,d,m,df,m )
258 *
259 * Apply Q to D as D*QT
260 *
261  CALL stpmlqt('R','T',m,n,k,l,nb,af(1,np1),m,t,ldt,df,m,
262  \$ df(1,np1),m,work,info)
263
264 *
265 * Compute |D*QT - D*QT| / |D|
266 *
267  CALL sgemm( 'N', 'T', m, n2, n2, -one, d, m, q, n2, one, df, m )
268  resid = slange( '1', m, n2, df, m, rwork )
269  IF( cnorm.GT.zero ) THEN
270  result( 6 ) = resid / (eps*max(1,n2)*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
subroutine sgemlqt(SIDE, TRANS, M, N, K, MB, V, LDV, T, LDT, C, LDC, WORK, INFO)
Definition: sgemlqt.f:153
subroutine stplqt(M, N, L, MB, A, LDA, B, LDB, T, LDT, WORK, INFO)
STPLQT
Definition: stplqt.f:191
subroutine ssyrk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
SSYRK
Definition: ssyrk.f:171
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:189
subroutine stpmlqt(SIDE, TRANS, M, N, K, L, MB, V, LDV, T, LDT, A, LDA, B, LDB, WORK, INFO)
DTPMLQT
Definition: stpmlqt.f:218
subroutine slaset(UPLO, M, N, ALPHA, BETA, A, LDA)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: slaset.f:112
subroutine slarnv(IDIST, ISEED, N, X)
SLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: slarnv.f:99
subroutine slqt05(M, N, L, NB, RESULT)
Definition: slqt05.f:75
subroutine slacpy(UPLO, M, N, A, LDA, B, LDB)
SLACPY copies all or part of one two-dimensional array to another.
Definition: slacpy.f:105