1 SUBROUTINE ZQRT01P( M, N, A, AF, Q, R, LDA, TAU, WORK, LWORK,
2 $ RWORK, RESULT )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * June 2010
7 *
8 * .. Scalar Arguments ..
9 INTEGER LDA, LWORK, M, N
10 * ..
11 * .. Array Arguments ..
12 DOUBLE PRECISION RESULT( * ), RWORK( * )
13 COMPLEX*16 A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
14 $ R( LDA, * ), TAU( * ), WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * ZQRT01P tests ZGEQRFP, which computes the QR factorization of an m-by-n
21 * matrix A, and partially tests ZUNGQR which forms the m-by-m
22 * orthogonal matrix Q.
23 *
24 * ZQRT01P compares R with Q'*A, and checks that Q is orthogonal.
25 *
26 * Arguments
27 * =========
28 *
29 * M (input) INTEGER
30 * The number of rows of the matrix A. M >= 0.
31 *
32 * N (input) INTEGER
33 * The number of columns of the matrix A. N >= 0.
34 *
35 * A (input) COMPLEX*16 array, dimension (LDA,N)
36 * The m-by-n matrix A.
37 *
38 * AF (output) COMPLEX*16 array, dimension (LDA,N)
39 * Details of the QR factorization of A, as returned by ZGEQRFP.
40 * See ZGEQRFP for further details.
41 *
42 * Q (output) COMPLEX*16 array, dimension (LDA,M)
43 * The m-by-m orthogonal matrix Q.
44 *
45 * R (workspace) COMPLEX*16 array, dimension (LDA,max(M,N))
46 *
47 * LDA (input) INTEGER
48 * The leading dimension of the arrays A, AF, Q and R.
49 * LDA >= max(M,N).
50 *
51 * TAU (output) COMPLEX*16 array, dimension (min(M,N))
52 * The scalar factors of the elementary reflectors, as returned
53 * by ZGEQRFP.
54 *
55 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
56 *
57 * LWORK (input) INTEGER
58 * The dimension of the array WORK.
59 *
60 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
61 *
62 * RESULT (output) DOUBLE PRECISION array, dimension (2)
63 * The test ratios:
64 * RESULT(1) = norm( R - Q'*A ) / ( M * norm(A) * EPS )
65 * RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
66 *
67 * =====================================================================
68 *
69 * .. Parameters ..
70 DOUBLE PRECISION ZERO, ONE
71 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
72 COMPLEX*16 ROGUE
73 PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
74 * ..
75 * .. Local Scalars ..
76 INTEGER INFO, MINMN
77 DOUBLE PRECISION ANORM, EPS, RESID
78 * ..
79 * .. External Functions ..
80 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANSY
81 EXTERNAL DLAMCH, ZLANGE, ZLANSY
82 * ..
83 * .. External Subroutines ..
84 EXTERNAL ZGEMM, ZGEQRFP, ZHERK, ZLACPY, ZLASET, ZUNGQR
85 * ..
86 * .. Intrinsic Functions ..
87 INTRINSIC DBLE, DCMPLX, MAX, MIN
88 * ..
89 * .. Scalars in Common ..
90 CHARACTER*32 SRNAMT
91 * ..
92 * .. Common blocks ..
93 COMMON / SRNAMC / SRNAMT
94 * ..
95 * .. Executable Statements ..
96 *
97 MINMN = MIN( M, N )
98 EPS = DLAMCH( 'Epsilon' )
99 *
100 * Copy the matrix A to the array AF.
101 *
102 CALL ZLACPY( 'Full', M, N, A, LDA, AF, LDA )
103 *
104 * Factorize the matrix A in the array AF.
105 *
106 SRNAMT = 'ZGEQRFP'
107 CALL ZGEQRFP( M, N, AF, LDA, TAU, WORK, LWORK, INFO )
108 *
109 * Copy details of Q
110 *
111 CALL ZLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
112 CALL ZLACPY( 'Lower', M-1, N, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA )
113 *
114 * Generate the m-by-m matrix Q
115 *
116 SRNAMT = 'ZUNGQR'
117 CALL ZUNGQR( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO )
118 *
119 * Copy R
120 *
121 CALL ZLASET( 'Full', M, N, DCMPLX( ZERO ), DCMPLX( ZERO ), R,
122 $ LDA )
123 CALL ZLACPY( 'Upper', M, N, AF, LDA, R, LDA )
124 *
125 * Compute R - Q'*A
126 *
127 CALL ZGEMM( 'Conjugate transpose', 'No transpose', M, N, M,
128 $ DCMPLX( -ONE ), Q, LDA, A, LDA, DCMPLX( ONE ), R,
129 $ LDA )
130 *
131 * Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
132 *
133 ANORM = ZLANGE( '1', M, N, A, LDA, RWORK )
134 RESID = ZLANGE( '1', M, N, R, LDA, RWORK )
135 IF( ANORM.GT.ZERO ) THEN
136 RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, M ) ) ) / ANORM ) / EPS
137 ELSE
138 RESULT( 1 ) = ZERO
139 END IF
140 *
141 * Compute I - Q'*Q
142 *
143 CALL ZLASET( 'Full', M, M, DCMPLX( ZERO ), DCMPLX( ONE ), R, LDA )
144 CALL ZHERK( 'Upper', 'Conjugate transpose', M, M, -ONE, Q, LDA,
145 $ ONE, R, LDA )
146 *
147 * Compute norm( I - Q'*Q ) / ( M * EPS ) .
148 *
149 RESID = ZLANSY( '1', 'Upper', M, R, LDA, RWORK )
150 *
151 RESULT( 2 ) = ( RESID / DBLE( MAX( 1, M ) ) ) / EPS
152 *
153 RETURN
154 *
155 * End of ZQRT01P
156 *
157 END
2 $ RWORK, RESULT )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * June 2010
7 *
8 * .. Scalar Arguments ..
9 INTEGER LDA, LWORK, M, N
10 * ..
11 * .. Array Arguments ..
12 DOUBLE PRECISION RESULT( * ), RWORK( * )
13 COMPLEX*16 A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
14 $ R( LDA, * ), TAU( * ), WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * ZQRT01P tests ZGEQRFP, which computes the QR factorization of an m-by-n
21 * matrix A, and partially tests ZUNGQR which forms the m-by-m
22 * orthogonal matrix Q.
23 *
24 * ZQRT01P compares R with Q'*A, and checks that Q is orthogonal.
25 *
26 * Arguments
27 * =========
28 *
29 * M (input) INTEGER
30 * The number of rows of the matrix A. M >= 0.
31 *
32 * N (input) INTEGER
33 * The number of columns of the matrix A. N >= 0.
34 *
35 * A (input) COMPLEX*16 array, dimension (LDA,N)
36 * The m-by-n matrix A.
37 *
38 * AF (output) COMPLEX*16 array, dimension (LDA,N)
39 * Details of the QR factorization of A, as returned by ZGEQRFP.
40 * See ZGEQRFP for further details.
41 *
42 * Q (output) COMPLEX*16 array, dimension (LDA,M)
43 * The m-by-m orthogonal matrix Q.
44 *
45 * R (workspace) COMPLEX*16 array, dimension (LDA,max(M,N))
46 *
47 * LDA (input) INTEGER
48 * The leading dimension of the arrays A, AF, Q and R.
49 * LDA >= max(M,N).
50 *
51 * TAU (output) COMPLEX*16 array, dimension (min(M,N))
52 * The scalar factors of the elementary reflectors, as returned
53 * by ZGEQRFP.
54 *
55 * WORK (workspace) COMPLEX*16 array, dimension (LWORK)
56 *
57 * LWORK (input) INTEGER
58 * The dimension of the array WORK.
59 *
60 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
61 *
62 * RESULT (output) DOUBLE PRECISION array, dimension (2)
63 * The test ratios:
64 * RESULT(1) = norm( R - Q'*A ) / ( M * norm(A) * EPS )
65 * RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
66 *
67 * =====================================================================
68 *
69 * .. Parameters ..
70 DOUBLE PRECISION ZERO, ONE
71 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
72 COMPLEX*16 ROGUE
73 PARAMETER ( ROGUE = ( -1.0D+10, -1.0D+10 ) )
74 * ..
75 * .. Local Scalars ..
76 INTEGER INFO, MINMN
77 DOUBLE PRECISION ANORM, EPS, RESID
78 * ..
79 * .. External Functions ..
80 DOUBLE PRECISION DLAMCH, ZLANGE, ZLANSY
81 EXTERNAL DLAMCH, ZLANGE, ZLANSY
82 * ..
83 * .. External Subroutines ..
84 EXTERNAL ZGEMM, ZGEQRFP, ZHERK, ZLACPY, ZLASET, ZUNGQR
85 * ..
86 * .. Intrinsic Functions ..
87 INTRINSIC DBLE, DCMPLX, MAX, MIN
88 * ..
89 * .. Scalars in Common ..
90 CHARACTER*32 SRNAMT
91 * ..
92 * .. Common blocks ..
93 COMMON / SRNAMC / SRNAMT
94 * ..
95 * .. Executable Statements ..
96 *
97 MINMN = MIN( M, N )
98 EPS = DLAMCH( 'Epsilon' )
99 *
100 * Copy the matrix A to the array AF.
101 *
102 CALL ZLACPY( 'Full', M, N, A, LDA, AF, LDA )
103 *
104 * Factorize the matrix A in the array AF.
105 *
106 SRNAMT = 'ZGEQRFP'
107 CALL ZGEQRFP( M, N, AF, LDA, TAU, WORK, LWORK, INFO )
108 *
109 * Copy details of Q
110 *
111 CALL ZLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
112 CALL ZLACPY( 'Lower', M-1, N, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA )
113 *
114 * Generate the m-by-m matrix Q
115 *
116 SRNAMT = 'ZUNGQR'
117 CALL ZUNGQR( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO )
118 *
119 * Copy R
120 *
121 CALL ZLASET( 'Full', M, N, DCMPLX( ZERO ), DCMPLX( ZERO ), R,
122 $ LDA )
123 CALL ZLACPY( 'Upper', M, N, AF, LDA, R, LDA )
124 *
125 * Compute R - Q'*A
126 *
127 CALL ZGEMM( 'Conjugate transpose', 'No transpose', M, N, M,
128 $ DCMPLX( -ONE ), Q, LDA, A, LDA, DCMPLX( ONE ), R,
129 $ LDA )
130 *
131 * Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
132 *
133 ANORM = ZLANGE( '1', M, N, A, LDA, RWORK )
134 RESID = ZLANGE( '1', M, N, R, LDA, RWORK )
135 IF( ANORM.GT.ZERO ) THEN
136 RESULT( 1 ) = ( ( RESID / DBLE( MAX( 1, M ) ) ) / ANORM ) / EPS
137 ELSE
138 RESULT( 1 ) = ZERO
139 END IF
140 *
141 * Compute I - Q'*Q
142 *
143 CALL ZLASET( 'Full', M, M, DCMPLX( ZERO ), DCMPLX( ONE ), R, LDA )
144 CALL ZHERK( 'Upper', 'Conjugate transpose', M, M, -ONE, Q, LDA,
145 $ ONE, R, LDA )
146 *
147 * Compute norm( I - Q'*Q ) / ( M * EPS ) .
148 *
149 RESID = ZLANSY( '1', 'Upper', M, R, LDA, RWORK )
150 *
151 RESULT( 2 ) = ( RESID / DBLE( MAX( 1, M ) ) ) / EPS
152 *
153 RETURN
154 *
155 * End of ZQRT01P
156 *
157 END