PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
dlqt03.f
Go to the documentation of this file.
1  SUBROUTINE dlqt03( M, N, K, AF, C, CC, Q, LDA, T, WORK, LWORK,
2  $ rwork, result )
3 *
4  include 'plasmaf.h'
5 *
6 * -- LAPACK test routine (version 3.1) --
7 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
8 * November 2006
9 *
10 * .. Scalar Arguments ..
11  INTEGER k, lda, lwork, m, n
12  INTEGER t( 2 )
13 * ..
14 * .. Array Arguments ..
15  DOUBLE PRECISION af( lda, * ), c( lda, * ), cc( lda, * ),
16  $ q( lda, * ), result( * ), rwork( * ),
17  $ work( lwork )
18 * ..
19 *
20 * Purpose
21 * =======
22 *
23 * DLQT03 tests DORMLQ, which computes Q*C, Q'*C, C*Q or C*Q'.
24 *
25 * DLQT03 compares the results of a call to DORMLQ with the results of
26 * forming Q explicitly by a call to DORGLQ and then performing matrix
27 * multiplication by a call to DGEMM.
28 *
29 * Arguments
30 * =========
31 *
32 * M (input) INTEGER
33 * The number of rows or columns of the matrix C; C is n-by-m if
34 * Q is applied from the left, or m-by-n if Q is applied from
35 * the right. M >= 0.
36 *
37 * N (input) INTEGER
38 * The order of the orthogonal matrix Q. N >= 0.
39 *
40 * K (input) INTEGER
41 * The number of elementary reflectors whose product defines the
42 * orthogonal matrix Q. N >= K >= 0.
43 *
44 * AF (input) DOUBLE PRECISION array, dimension (LDA,N)
45 * Details of the LQ factorization of an m-by-n matrix, as
46 * returned by DGELQF. See SGELQF for further details.
47 *
48 * C (workspace) DOUBLE PRECISION array, dimension (LDA,N)
49 *
50 * CC (workspace) DOUBLE PRECISION array, dimension (LDA,N)
51 *
52 * Q (workspace) DOUBLE PRECISION array, dimension (LDA,N)
53 *
54 * LDA (input) INTEGER
55 * The leading dimension of the arrays AF, C, CC, and Q.
56 *
57 * TAU (input) DOUBLE PRECISION array, dimension (min(M,N))
58 * The scalar factors of the elementary reflectors corresponding
59 * to the LQ factorization in AF.
60 *
61 * WORK (workspace) DOUBLE PRECISION array, dimension (LWORK)
62 *
63 * LWORK (input) INTEGER
64 * The length of WORK. LWORK must be at least M, and should be
65 * M*NB, where NB is the blocksize for this environment.
66 *
67 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
68 *
69 * RESULT (output) DOUBLE PRECISION array, dimension (4)
70 * The test ratios compare two techniques for multiplying a
71 * random matrix C by an n-by-n orthogonal matrix Q.
72 * RESULT(1) = norm( Q*C - Q*C ) / ( N * norm(C) * EPS )
73 * RESULT(2) = norm( C*Q - C*Q ) / ( N * norm(C) * EPS )
74 * RESULT(3) = norm( Q'*C - Q'*C )/ ( N * norm(C) * EPS )
75 * RESULT(4) = norm( C*Q' - C*Q' )/ ( N * norm(C) * EPS )
76 *
77 * =====================================================================
78 *
79 * .. Parameters ..
80  DOUBLE PRECISION one, zero
81  parameter( one = 1.0d0 )
82  parameter( zero = 0.0d+0 )
83  DOUBLE PRECISION rogue
84  parameter( rogue = -1.0d+10 )
85 * ..
86 * .. Local Scalars ..
87  CHARACTER side, trans
88  INTEGER info, iside, itrans, j, mc, nc
89  INTEGER plasma_side, plasma_trans
90  DOUBLE PRECISION cnorm, eps, resid
91 * ..
92 * .. External Functions ..
93  LOGICAL lsame
94  DOUBLE PRECISION dlamch, dlange
95  EXTERNAL lsame, dlamch, dlange
96 * ..
97 * .. External Subroutines ..
98  EXTERNAL dgemm, dlacpy, dlarnv, dlaset, dorglq, dormlq
99 * ..
100 * .. Local Arrays ..
101  INTEGER iseed( 4 )
102 * ..
103 * .. Intrinsic Functions ..
104  INTRINSIC dble, max
105 * ..
106 * .. Scalars in Common ..
107  CHARACTER*32 srnamt
108 * ..
109 * .. Common blocks ..
110  common / srnamc / srnamt
111 * ..
112 * .. Data statements ..
113  DATA iseed / 1988, 1989, 1990, 1991 /
114 * ..
115 * .. Executable Statements ..
116 *
117  eps = dlamch( 'Epsilon' )
118 *
119 * Copy the first k rows of the factorization to the array Q
120 *
121  IF ( k.EQ.0 ) THEN
122  CALL dlaset( 'Full', n, n, rogue, rogue, q, lda )
123  ELSE
124  CALL dlaset( 'Full', n, n, zero, one, q, lda )
125  ENDIF
126 *
127 * Generate the n-by-n matrix Q
128 *
129  srnamt = 'DORGLQ'
130  CALL plasma_dorglq( n, n, k, af, lda, t, q, lda, info )
131 *
132  DO 30 iside = 1, 2
133  IF( iside.EQ.1 ) THEN
134  side = 'L'
135  plasma_side = plasmaleft
136  mc = n
137  nc = m
138  ELSE
139  side = 'R'
140  plasma_side = plasmaright
141  mc = m
142  nc = n
143  END IF
144 *
145 * Generate MC by NC matrix C
146 *
147  DO 10 j = 1, nc
148  CALL dlarnv( 2, iseed, mc, c( 1, j ) )
149  10 continue
150  cnorm = dlange( '1', mc, nc, c, lda, rwork )
151  IF( cnorm.EQ.0.0d0 )
152  $ cnorm = one
153 *
154  DO 20 itrans = 1, 2
155  IF( itrans.EQ.1 ) THEN
156  trans = 'N'
157  plasma_trans = plasmanotrans
158  ELSE
159  trans = 'T'
160  plasma_trans = plasmatrans
161  END IF
162 *
163 * Copy C
164 *
165  CALL dlacpy( 'Full', mc, nc, c, lda, cc, lda )
166 *
167 * Apply Q or Q' to C
168 *
169  srnamt = 'DORMLQ'
170  CALL plasma_dormlq( plasma_side, plasma_trans, mc, nc, k,
171  $ af, lda, t, cc, lda, info )
172 *
173 * Form explicit product and subtract
174 *
175  IF ( k.EQ.0 ) THEN
176  CALL dlaset( 'Full', n, n, zero, one, q, lda )
177  ENDIF
178  IF( lsame( side, 'L' ) ) THEN
179  CALL dgemm( trans, 'No transpose', mc, nc, mc, -one, q,
180  $ lda, c, lda, one, cc, lda )
181  ELSE
182  CALL dgemm( 'No transpose', trans, mc, nc, nc, -one, c,
183  $ lda, q, lda, one, cc, lda )
184  END IF
185 *
186 * Compute error in the difference
187 *
188  resid = dlange( '1', mc, nc, cc, lda, rwork )
189  result( ( iside-1 )*2+itrans ) = resid /
190  $ ( dble( max( 1, n ) )*cnorm*eps )
191 *
192  20 continue
193  30 continue
194 *
195  return
196 *
197 * End of DLQT03
198 *
199  END