LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
sqrt04.f
Go to the documentation of this file.
1 *> \brief \b SQRT04
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 SQRT04(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 *> SQRT04 tests SGEQRT and SGEMQRT.
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 single_lin
72 *
73 * =====================================================================
74  SUBROUTINE sqrt04(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  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, l, lwork
101  REAL anorm, eps, resid, cnorm, dnorm
102 * ..
103 * .. Local Arrays ..
104  INTEGER iseed( 4 )
105 * ..
106 * .. External Functions ..
107  REAL slamch
108  REAL slange, slansy
109  LOGICAL lsame
110  EXTERNAL slamch, slange, slansy, lsame
111 * ..
112 * .. Intrinsic Functions ..
113  INTRINSIC max, min
114 * ..
115 * .. Data statements ..
116  DATA iseed / 1988, 1989, 1990, 1991 /
117 *
118  eps = slamch( 'Epsilon' )
119  k = min(m,n)
120  l = max(m,n)
121  lwork = max(2,l)*max(2,l)*nb
122 *
123 * Dynamically allocate local arrays
124 *
125  ALLOCATE ( a(m,n), af(m,n), q(m,m), r(m,l), rwork(l),
126  $ work(lwork), t(nb,n), c(m,n), cf(m,n),
127  $ d(n,m), df(n,m) )
128 *
129 * Put random numbers into A and copy to AF
130 *
131  ldt=nb
132  DO j=1,n
133  CALL slarnv( 2, iseed, m, a( 1, j ) )
134  END DO
135  CALL slacpy( 'Full', m, n, a, m, af, m )
136 *
137 * Factor the matrix A in the array AF.
138 *
139  CALL sgeqrt( m, n, nb, af, m, t, ldt, work, info )
140 *
141 * Generate the m-by-m matrix Q
142 *
143  CALL slaset( 'Full', m, m, zero, one, q, m )
144  CALL sgemqrt( 'R', 'N', m, m, k, nb, af, m, t, ldt, q, m,
145  $ work, info )
146 *
147 * Copy R
148 *
149  CALL slaset( 'Full', m, n, zero, zero, r, m )
150  CALL slacpy( 'Upper', m, n, af, m, r, m )
151 *
152 * Compute |R - Q'*A| / |A| and store in RESULT(1)
153 *
154  CALL sgemm( 'T', 'N', m, n, m, -one, q, m, a, m, one, r, m )
155  anorm = slange( '1', m, n, a, m, rwork )
156  resid = slange( '1', m, n, r, m, rwork )
157  IF( anorm.GT.zero ) THEN
158  result( 1 ) = resid / (eps*max(1,m)*anorm)
159  ELSE
160  result( 1 ) = zero
161  END IF
162 *
163 * Compute |I - Q'*Q| and store in RESULT(2)
164 *
165  CALL slaset( 'Full', m, m, zero, one, r, m )
166  CALL ssyrk( 'U', 'C', m, m, -one, q, m, one, r, m )
167  resid = slansy( '1', 'Upper', m, r, m, rwork )
168  result( 2 ) = resid / (eps*max(1,m))
169 *
170 * Generate random m-by-n matrix C and a copy CF
171 *
172  DO j=1,n
173  CALL slarnv( 2, iseed, m, c( 1, j ) )
174  END DO
175  cnorm = slange( '1', m, n, c, m, rwork)
176  CALL slacpy( 'Full', m, n, c, m, cf, m )
177 *
178 * Apply Q to C as Q*C
179 *
180  CALL sgemqrt( 'L', 'N', m, n, k, nb, af, m, t, nb, cf, m,
181  $ work, info)
182 *
183 * Compute |Q*C - Q*C| / |C|
184 *
185  CALL sgemm( 'N', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
186  resid = slange( '1', m, n, cf, m, rwork )
187  IF( cnorm.GT.zero ) THEN
188  result( 3 ) = resid / (eps*max(1,m)*cnorm)
189  ELSE
190  result( 3 ) = zero
191  END IF
192 *
193 * Copy C into CF again
194 *
195  CALL slacpy( 'Full', m, n, c, m, cf, m )
196 *
197 * Apply Q to C as QT*C
198 *
199  CALL sgemqrt( 'L', 'T', m, n, k, nb, af, m, t, nb, cf, m,
200  $ work, info)
201 *
202 * Compute |QT*C - QT*C| / |C|
203 *
204  CALL sgemm( 'T', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
205  resid = slange( '1', m, n, cf, m, rwork )
206  IF( cnorm.GT.zero ) THEN
207  result( 4 ) = resid / (eps*max(1,m)*cnorm)
208  ELSE
209  result( 4 ) = zero
210  END IF
211 *
212 * Generate random n-by-m matrix D and a copy DF
213 *
214  DO j=1,m
215  CALL slarnv( 2, iseed, n, d( 1, j ) )
216  END DO
217  dnorm = slange( '1', n, m, d, n, rwork)
218  CALL slacpy( 'Full', n, m, d, n, df, n )
219 *
220 * Apply Q to D as D*Q
221 *
222  CALL sgemqrt( 'R', 'N', n, m, k, nb, af, m, t, nb, df, n,
223  $ work, info)
224 *
225 * Compute |D*Q - D*Q| / |D|
226 *
227  CALL sgemm( 'N', 'N', n, m, m, -one, d, n, q, m, one, df, n )
228  resid = slange( '1', n, m, df, n, rwork )
229  IF( cnorm.GT.zero ) THEN
230  result( 5 ) = resid / (eps*max(1,m)*dnorm)
231  ELSE
232  result( 5 ) = zero
233  END IF
234 *
235 * Copy D into DF again
236 *
237  CALL slacpy( 'Full', n, m, d, n, df, n )
238 *
239 * Apply Q to D as D*QT
240 *
241  CALL sgemqrt( 'R', 'T', n, m, k, nb, af, m, t, nb, df, n,
242  $ work, info)
243 *
244 * Compute |D*QT - D*QT| / |D|
245 *
246  CALL sgemm( 'N', 'T', n, m, m, -one, d, n, q, m, one, df, n )
247  resid = slange( '1', n, m, df, n, rwork )
248  IF( cnorm.GT.zero ) THEN
249  result( 6 ) = resid / (eps*max(1,m)*dnorm)
250  ELSE
251  result( 6 ) = zero
252  END IF
253 *
254 * Deallocate all arrays
255 *
256  DEALLOCATE ( a, af, q, r, rwork, work, t, c, d, cf, df)
257 *
258  return
259  END
260