LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ dorhr_col01()

subroutine dorhr_col01 ( integer  M,
integer  N,
integer  MB1,
integer  NB1,
integer  NB2,
double precision, dimension(6)  RESULT 
)

DORHR_COL01

Purpose:
 DORHR_COL01 tests DORHR_COL using DLATSQR, DGEMQRT and DORGTSQR.
 Therefore, DLATSQR (part of DGEQR), DGEMQRT (part DGEMQR), DORGTSQR
 have to be tested before this test.
Parameters
[in]M
          M is INTEGER
          Number of rows in test matrix.
[in]N
          N is INTEGER
          Number of columns in test matrix.
[in]MB1
          MB1 is INTEGER
          Number of row in row block in an input test matrix.
[in]NB1
          NB1 is INTEGER
          Number of columns in column block an input test matrix.
[in]NB2
          NB2 is INTEGER
          Number of columns in column block in an output test matrix.
[out]RESULT
          RESULT is DOUBLE PRECISION array, dimension (6)
          Results of each of the six tests below.
          ( C is a M-by-N random matrix, D is a N-by-M random matrix )

          RESULT(1) = | A - Q * R | / (eps * m * |A|)
          RESULT(2) = | I - (Q**H) * Q | / (eps * m )
          RESULT(3) = | Q * C - Q * C | / (eps * m * |C|)
          RESULT(4) = | (Q**H) * C - (Q**H) * C | / (eps * m * |C|)
          RESULT(5) = | (D * Q) - D * Q | / (eps * m * |D|)
          RESULT(6) = | D * (Q**H) - D * (Q**H) | / (eps * m * |D|)
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2019

Definition at line 89 of file dorhr_col01.f.

89  IMPLICIT NONE
90 *
91 * -- LAPACK test routine (version 3.9.0) --
92 * -- LAPACK is a software package provided by Univ. of Tennessee, --
93 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
94 * November 2019
95 *
96 * .. Scalar Arguments ..
97  INTEGER M, N, MB1, NB1, NB2
98 * .. Return values ..
99  DOUBLE PRECISION RESULT(6)
100 *
101 * =====================================================================
102 *
103 * ..
104 * .. Local allocatable arrays
105  DOUBLE PRECISION, ALLOCATABLE :: A(:,:), AF(:,:), Q(:,:), R(:,:),
106  $ RWORK(:), WORK( : ), T1(:,:), T2(:,:), DIAG(:),
107  $ C(:,:), CF(:,:), D(:,:), DF(:,:)
108 *
109 * .. Parameters ..
110  DOUBLE PRECISION ONE, ZERO
111  parameter( zero = 0.0d+0, one = 1.0d+0 )
112 * ..
113 * .. Local Scalars ..
114  LOGICAL TESTZEROS
115  INTEGER INFO, I, J, K, L, LWORK, NB1_UB, NB2_UB, NRB
116  DOUBLE PRECISION ANORM, EPS, RESID, CNORM, DNORM
117 * ..
118 * .. Local Arrays ..
119  INTEGER ISEED( 4 )
120  DOUBLE PRECISION WORKQUERY( 1 )
121 * ..
122 * .. External Functions ..
123  DOUBLE PRECISION DLAMCH, DLANGE, DLANSY
124  EXTERNAL dlamch, dlange, dlansy
125 * ..
126 * .. External Subroutines ..
127  EXTERNAL dlacpy, dlarnv, dlaset, dlatsqr, dorhr_col,
129 * ..
130 * .. Intrinsic Functions ..
131  INTRINSIC ceiling, dble, max, min
132 * ..
133 * .. Scalars in Common ..
134  CHARACTER(LEN=32) SRNAMT
135 * ..
136 * .. Common blocks ..
137  COMMON / srmnamc / srnamt
138 * ..
139 * .. Data statements ..
140  DATA iseed / 1988, 1989, 1990, 1991 /
141 *
142 * TEST MATRICES WITH HALF OF MATRIX BEING ZEROS
143 *
144  testzeros = .false.
145 *
146  eps = dlamch( 'Epsilon' )
147  k = min( m, n )
148  l = max( m, n, 1)
149 *
150 * Dynamically allocate local arrays
151 *
152  ALLOCATE ( a(m,n), af(m,n), q(l,l), r(m,l), rwork(l),
153  $ c(m,n), cf(m,n),
154  $ d(n,m), df(n,m) )
155 *
156 * Put random numbers into A and copy to AF
157 *
158  DO j = 1, n
159  CALL dlarnv( 2, iseed, m, a( 1, j ) )
160  END DO
161  IF( testzeros ) THEN
162  IF( m.GE.4 ) THEN
163  DO j = 1, n
164  CALL dlarnv( 2, iseed, m/2, a( m/4, j ) )
165  END DO
166  END IF
167  END IF
168  CALL dlacpy( 'Full', m, n, a, m, af, m )
169 *
170 * Number of row blocks in DLATSQR
171 *
172  nrb = max( 1, ceiling( dble( m - n ) / dble( mb1 - n ) ) )
173 *
174  ALLOCATE ( t1( nb1, n * nrb ) )
175  ALLOCATE ( t2( nb2, n ) )
176  ALLOCATE ( diag( n ) )
177 *
178 * Begin determine LWORK for the array WORK and allocate memory.
179 *
180 * DLATSQR requires NB1 to be bounded by N.
181 *
182  nb1_ub = min( nb1, n)
183 *
184 * DGEMQRT requires NB2 to be bounded by N.
185 *
186  nb2_ub = min( nb2, n)
187 *
188  CALL dlatsqr( m, n, mb1, nb1_ub, af, m, t1, nb1,
189  $ workquery, -1, info )
190  lwork = int( workquery( 1 ) )
191  CALL dorgtsqr( m, n, mb1, nb1, af, m, t1, nb1, workquery, -1,
192  $ info )
193 
194  lwork = max( lwork, int( workquery( 1 ) ) )
195 *
196 * In DGEMQRT, WORK is N*NB2_UB if SIDE = 'L',
197 * or M*NB2_UB if SIDE = 'R'.
198 *
199  lwork = max( lwork, nb2_ub * n, nb2_ub * m )
200 *
201  ALLOCATE ( work( lwork ) )
202 *
203 * End allocate memory for WORK.
204 *
205 *
206 * Begin Householder reconstruction routines
207 *
208 * Factor the matrix A in the array AF.
209 *
210  srnamt = 'DLATSQR'
211  CALL dlatsqr( m, n, mb1, nb1_ub, af, m, t1, nb1, work, lwork,
212  $ info )
213 *
214 * Copy the factor R into the array R.
215 *
216  srnamt = 'DLACPY'
217  CALL dlacpy( 'U', n, n, af, m, r, m )
218 *
219 * Reconstruct the orthogonal matrix Q.
220 *
221  srnamt = 'DORGTSQR'
222  CALL dorgtsqr( m, n, mb1, nb1, af, m, t1, nb1, work, lwork,
223  $ info )
224 *
225 * Perform the Householder reconstruction, the result is stored
226 * the arrays AF and T2.
227 *
228  srnamt = 'DORHR_COL'
229  CALL dorhr_col( m, n, nb2, af, m, t2, nb2, diag, info )
230 *
231 * Compute the factor R_hr corresponding to the Householder
232 * reconstructed Q_hr and place it in the upper triangle of AF to
233 * match the Q storage format in DGEQRT. R_hr = R_tsqr * S,
234 * this means changing the sign of I-th row of the matrix R_tsqr
235 * according to sign of of I-th diagonal element DIAG(I) of the
236 * matrix S.
237 *
238  srnamt = 'DLACPY'
239  CALL dlacpy( 'U', n, n, r, m, af, m )
240 *
241  DO i = 1, n
242  IF( diag( i ).EQ.-one ) THEN
243  CALL dscal( n+1-i, -one, af( i, i ), m )
244  END IF
245  END DO
246 *
247 * End Householder reconstruction routines.
248 *
249 *
250 * Generate the m-by-m matrix Q
251 *
252  CALL dlaset( 'Full', m, m, zero, one, q, m )
253 *
254  srnamt = 'DGEMQRT'
255  CALL dgemqrt( 'L', 'N', m, m, k, nb2_ub, af, m, t2, nb2, q, m,
256  $ work, info )
257 *
258 * Copy R
259 *
260  CALL dlaset( 'Full', m, n, zero, zero, r, m )
261 *
262  CALL dlacpy( 'Upper', m, n, af, m, r, m )
263 *
264 * TEST 1
265 * Compute |R - (Q**T)*A| / ( eps * m * |A| ) and store in RESULT(1)
266 *
267  CALL dgemm( 'T', 'N', m, n, m, -one, q, m, a, m, one, r, m )
268 *
269  anorm = dlange( '1', m, n, a, m, rwork )
270  resid = dlange( '1', m, n, r, m, rwork )
271  IF( anorm.GT.zero ) THEN
272  result( 1 ) = resid / ( eps * max( 1, m ) * anorm )
273  ELSE
274  result( 1 ) = zero
275  END IF
276 *
277 * TEST 2
278 * Compute |I - (Q**T)*Q| / ( eps * m ) and store in RESULT(2)
279 *
280  CALL dlaset( 'Full', m, m, zero, one, r, m )
281  CALL dsyrk( 'U', 'T', m, m, -one, q, m, one, r, m )
282  resid = dlansy( '1', 'Upper', m, r, m, rwork )
283  result( 2 ) = resid / ( eps * max( 1, m ) )
284 *
285 * Generate random m-by-n matrix C
286 *
287  DO j = 1, n
288  CALL dlarnv( 2, iseed, m, c( 1, j ) )
289  END DO
290  cnorm = dlange( '1', m, n, c, m, rwork )
291  CALL dlacpy( 'Full', m, n, c, m, cf, m )
292 *
293 * Apply Q to C as Q*C = CF
294 *
295  srnamt = 'DGEMQRT'
296  CALL dgemqrt( 'L', 'N', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
297  $ work, info )
298 *
299 * TEST 3
300 * Compute |CF - Q*C| / ( eps * m * |C| )
301 *
302  CALL dgemm( 'N', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
303  resid = dlange( '1', m, n, cf, m, rwork )
304  IF( cnorm.GT.zero ) THEN
305  result( 3 ) = resid / ( eps * max( 1, m ) * cnorm )
306  ELSE
307  result( 3 ) = zero
308  END IF
309 *
310 * Copy C into CF again
311 *
312  CALL dlacpy( 'Full', m, n, c, m, cf, m )
313 *
314 * Apply Q to C as (Q**T)*C = CF
315 *
316  srnamt = 'DGEMQRT'
317  CALL dgemqrt( 'L', 'T', m, n, k, nb2_ub, af, m, t2, nb2, cf, m,
318  $ work, info )
319 *
320 * TEST 4
321 * Compute |CF - (Q**T)*C| / ( eps * m * |C|)
322 *
323  CALL dgemm( 'T', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
324  resid = dlange( '1', m, n, cf, m, rwork )
325  IF( cnorm.GT.zero ) THEN
326  result( 4 ) = resid / ( eps * max( 1, m ) * cnorm )
327  ELSE
328  result( 4 ) = zero
329  END IF
330 *
331 * Generate random n-by-m matrix D and a copy DF
332 *
333  DO j = 1, m
334  CALL dlarnv( 2, iseed, n, d( 1, j ) )
335  END DO
336  dnorm = dlange( '1', n, m, d, n, rwork )
337  CALL dlacpy( 'Full', n, m, d, n, df, n )
338 *
339 * Apply Q to D as D*Q = DF
340 *
341  srnamt = 'DGEMQRT'
342  CALL dgemqrt( 'R', 'N', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
343  $ work, info )
344 *
345 * TEST 5
346 * Compute |DF - D*Q| / ( eps * m * |D| )
347 *
348  CALL dgemm( 'N', 'N', n, m, m, -one, d, n, q, m, one, df, n )
349  resid = dlange( '1', n, m, df, n, rwork )
350  IF( dnorm.GT.zero ) THEN
351  result( 5 ) = resid / ( eps * max( 1, m ) * dnorm )
352  ELSE
353  result( 5 ) = zero
354  END IF
355 *
356 * Copy D into DF again
357 *
358  CALL dlacpy( 'Full', n, m, d, n, df, n )
359 *
360 * Apply Q to D as D*QT = DF
361 *
362  srnamt = 'DGEMQRT'
363  CALL dgemqrt( 'R', 'T', n, m, k, nb2_ub, af, m, t2, nb2, df, n,
364  $ work, info )
365 *
366 * TEST 6
367 * Compute |DF - D*(Q**T)| / ( eps * m * |D| )
368 *
369  CALL dgemm( 'N', 'T', n, m, m, -one, d, n, q, m, one, df, n )
370  resid = dlange( '1', n, m, df, n, rwork )
371  IF( dnorm.GT.zero ) THEN
372  result( 6 ) = resid / ( eps * max( 1, m ) * dnorm )
373  ELSE
374  result( 6 ) = zero
375  END IF
376 *
377 * Deallocate all arrays
378 *
379  DEALLOCATE ( a, af, q, r, rwork, work, t1, t2, diag,
380  $ c, d, cf, df )
381 *
382  RETURN
383 *
384 * End of DORHR_COL01
385 *
Here is the call graph for this function:
Here is the caller graph for this function:
dsyrk
subroutine dsyrk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
DSYRK
Definition: dsyrk.f:171
dlansy
double precision function dlansy(NORM, UPLO, N, A, LDA, WORK)
DLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: dlansy.f:124
dgemqrt
subroutine dgemqrt(SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, C, LDC, WORK, INFO)
DGEMQRT
Definition: dgemqrt.f:170
dlange
double precision function dlange(NORM, M, N, A, LDA, WORK)
DLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: dlange.f:116
dlatsqr
subroutine dlatsqr(M, N, MB, NB, A, LDA, T, LDT, WORK, LWORK, INFO)
DLATSQR
Definition: dlatsqr.f:166
dorgtsqr
subroutine dorgtsqr(M, N, MB, NB, A, LDA, T, LDT, WORK, LWORK, INFO)
DORGTSQR
Definition: dorgtsqr.f:176
dlarnv
subroutine dlarnv(IDIST, ISEED, N, X)
DLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: dlarnv.f:99
dorhr_col
subroutine dorhr_col(M, N, NB, A, LDA, T, LDT, D, INFO)
DORHR_COL
Definition: dorhr_col.f:260
dgemm
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:189
dlaset
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:112
dscal
subroutine dscal(N, DA, DX, INCX)
DSCAL
Definition: dscal.f:81
dlamch
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:70
dlacpy
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:105