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
zlqt02.f
Go to the documentation of this file.
1  SUBROUTINE zlqt02( M, N, K, A, AF, Q, L, 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 result( * ), rwork( * )
16  COMPLEX*16 a( lda, * ), af( lda, * ), l( lda, * ),
17  $ q( lda, * ), work( lwork )
18 * ..
19 *
20 * Purpose
21 * =======
22 *
23 * ZLQT02 tests ZUNGLQ, which generates an m-by-n matrix Q with
24 * orthonornmal rows that is defined as the product of k elementary
25 * reflectors.
26 *
27 * Given the LQ factorization of an m-by-n matrix A, ZLQT02 generates
28 * the orthogonal matrix Q defined by the factorization of the first k
29 * rows of A; it compares L(1:k,1:m) with A(1:k,1:n)*Q(1:m,1:n)', and
30 * checks that the rows of Q are orthonormal.
31 *
32 * Arguments
33 * =========
34 *
35 * M (input) INTEGER
36 * The number of rows of the matrix Q to be generated. M >= 0.
37 *
38 * N (input) INTEGER
39 * The number of columns of the matrix Q to be generated.
40 * N >= M >= 0.
41 *
42 * K (input) INTEGER
43 * The number of elementary reflectors whose product defines the
44 * matrix Q. M >= K >= 0.
45 *
46 * A (input) COMPLEX*16 array, dimension (LDA,N)
47 * The m-by-n matrix A which was factorized by ZLQT01.
48 *
49 * AF (input) COMPLEX*16 array, dimension (LDA,N)
50 * Details of the LQ factorization of A, as returned by ZGELQF.
51 * See ZGELQF for further details.
52 *
53 * Q (workspace) COMPLEX*16 array, dimension (LDA,N)
54 *
55 * L (workspace) COMPLEX*16 array, dimension (LDA,M)
56 *
57 * LDA (input) INTEGER
58 * The leading dimension of the arrays A, AF, Q and L. LDA >= N.
59 *
60 * TAU (input) COMPLEX*16 array, dimension (M)
61 * The scalar factors of the elementary reflectors corresponding
62 * to the LQ factorization in AF.
63 *
64 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
65 *
66 * LWORK (input) INTEGER
67 * The dimension of the array WORK.
68 *
69 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
70 *
71 * RESULT (output) DOUBLE PRECISION array, dimension (2)
72 * The test ratios:
73 * RESULT(1) = norm( L - A*Q' ) / ( N * norm(A) * EPS )
74 * RESULT(2) = norm( I - Q*Q' ) / ( N * EPS )
75 *
76 * =====================================================================
77 *
78 * .. Parameters ..
79  DOUBLE PRECISION zero, one
80  parameter( zero = 0.0d+0, one = 1.0d+0 )
81  COMPLEX*16 rogue
82  parameter( rogue = ( -1.0d+10, -1.0d+10 ) )
83 * ..
84 * .. Local Scalars ..
85  INTEGER info
86  DOUBLE PRECISION anorm, eps, resid
87 * ..
88 * .. External Functions ..
89  DOUBLE PRECISION dlamch, zlange, zlansy
90  EXTERNAL dlamch, zlange, zlansy
91 * ..
92 * .. External Subroutines ..
93  EXTERNAL zgemm, zherk, zlacpy, zlaset, zunglq
94 * ..
95 * .. Intrinsic Functions ..
96  INTRINSIC dble, dcmplx, max
97 * ..
98 * .. Scalars in Common ..
99  CHARACTER*32 srnamt
100 * ..
101 * .. Common blocks ..
102  common / srnamc / srnamt
103 * ..
104 * .. Executable Statements ..
105 *
106  eps = dlamch( 'Epsilon' )
107 *
108 * Copy the first k rows of the factorization to the array Q
109 *
110  CALL zlaset( 'Full', m, n, dcmplx( zero ), dcmplx( one ), q, lda )
111 *
112 * Generate the first n columns of the matrix Q
113 *
114  srnamt = 'ZUNGLQ'
115  CALL plasma_zunglq( m, n, k, af, lda, t, q, lda, info )
116 *
117 * Copy L(1:k,1:m)
118 *
119  CALL zlaset( 'Full', k, m, dcmplx( zero ), dcmplx( zero ), l,
120  $ lda )
121  CALL zlacpy( 'Lower', k, m, af, lda, l, lda )
122 *
123 * Compute L(1:k,1:m) - A(1:k,1:n) * Q(1:m,1:n)'
124 *
125  CALL zgemm( 'No transpose', 'Conjugate transpose', k, m, n,
126  $ dcmplx( -one ), a, lda, q, lda, dcmplx( one ), l,
127  $ lda )
128 *
129 * Compute norm( L - A*Q' ) / ( N * norm(A) * EPS ) .
130 *
131  anorm = zlange( '1', k, n, a, lda, rwork )
132  resid = zlange( '1', k, m, l, lda, rwork )
133  IF( anorm.GT.zero ) THEN
134  result( 1 ) = ( ( resid / dble( max( 1, n ) ) ) / anorm ) / eps
135  ELSE
136  result( 1 ) = zero
137  END IF
138 *
139 * Compute I - Q*Q'
140 *
141  CALL zlaset( 'Full', m, m, dcmplx( zero ), dcmplx( one ), l, lda )
142  CALL zherk( 'Upper', 'No transpose', m, n, -one, q, lda, one, l,
143  $ lda )
144 *
145 * Compute norm( I - Q*Q' ) / ( N * EPS ) .
146 *
147  resid = zlansy( '1', 'Upper', m, l, lda, rwork )
148 *
149  result( 2 ) = ( resid / dble( max( 1, n ) ) ) / eps
150 *
151  return
152 *
153 * End of ZLQT02
154 *
155  END