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