1 SUBROUTINE SQLT01( M, N, A, AF, Q, L, 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 * November 2006
7 *
8 * .. Scalar Arguments ..
9 INTEGER LDA, LWORK, M, N
10 * ..
11 * .. Array Arguments ..
12 REAL A( LDA, * ), AF( LDA, * ), L( LDA, * ),
13 $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
14 $ WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * SQLT01 tests SGEQLF, which computes the QL factorization of an m-by-n
21 * matrix A, and partially tests SORGQL which forms the m-by-m
22 * orthogonal matrix Q.
23 *
24 * SQLT01 compares L 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) REAL array, dimension (LDA,N)
36 * The m-by-n matrix A.
37 *
38 * AF (output) REAL array, dimension (LDA,N)
39 * Details of the QL factorization of A, as returned by SGEQLF.
40 * See SGEQLF for further details.
41 *
42 * Q (output) REAL array, dimension (LDA,M)
43 * The m-by-m orthogonal matrix Q.
44 *
45 * L (workspace) REAL 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) REAL array, dimension (min(M,N))
52 * The scalar factors of the elementary reflectors, as returned
53 * by SGEQLF.
54 *
55 * WORK (workspace) REAL array, dimension (LWORK)
56 *
57 * LWORK (input) INTEGER
58 * The dimension of the array WORK.
59 *
60 * RWORK (workspace) REAL array, dimension (M)
61 *
62 * RESULT (output) REAL array, dimension (2)
63 * The test ratios:
64 * RESULT(1) = norm( L - Q'*A ) / ( M * norm(A) * EPS )
65 * RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
66 *
67 * =====================================================================
68 *
69 * .. Parameters ..
70 REAL ZERO, ONE
71 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
72 REAL ROGUE
73 PARAMETER ( ROGUE = -1.0E+10 )
74 * ..
75 * .. Local Scalars ..
76 INTEGER INFO, MINMN
77 REAL ANORM, EPS, RESID
78 * ..
79 * .. External Functions ..
80 REAL SLAMCH, SLANGE, SLANSY
81 EXTERNAL SLAMCH, SLANGE, SLANSY
82 * ..
83 * .. External Subroutines ..
84 EXTERNAL SGEMM, SGEQLF, SLACPY, SLASET, SORGQL, SSYRK
85 * ..
86 * .. Intrinsic Functions ..
87 INTRINSIC MAX, MIN, REAL
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 = SLAMCH( 'Epsilon' )
99 *
100 * Copy the matrix A to the array AF.
101 *
102 CALL SLACPY( 'Full', M, N, A, LDA, AF, LDA )
103 *
104 * Factorize the matrix A in the array AF.
105 *
106 SRNAMT = 'SGEQLF'
107 CALL SGEQLF( M, N, AF, LDA, TAU, WORK, LWORK, INFO )
108 *
109 * Copy details of Q
110 *
111 CALL SLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
112 IF( M.GE.N ) THEN
113 IF( N.LT.M .AND. N.GT.0 )
114 $ CALL SLACPY( 'Full', M-N, N, AF, LDA, Q( 1, M-N+1 ), LDA )
115 IF( N.GT.1 )
116 $ CALL SLACPY( 'Upper', N-1, N-1, AF( M-N+1, 2 ), LDA,
117 $ Q( M-N+1, M-N+2 ), LDA )
118 ELSE
119 IF( M.GT.1 )
120 $ CALL SLACPY( 'Upper', M-1, M-1, AF( 1, N-M+2 ), LDA,
121 $ Q( 1, 2 ), LDA )
122 END IF
123 *
124 * Generate the m-by-m matrix Q
125 *
126 SRNAMT = 'SORGQL'
127 CALL SORGQL( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO )
128 *
129 * Copy L
130 *
131 CALL SLASET( 'Full', M, N, ZERO, ZERO, L, LDA )
132 IF( M.GE.N ) THEN
133 IF( N.GT.0 )
134 $ CALL SLACPY( 'Lower', N, N, AF( M-N+1, 1 ), LDA,
135 $ L( M-N+1, 1 ), LDA )
136 ELSE
137 IF( N.GT.M .AND. M.GT.0 )
138 $ CALL SLACPY( 'Full', M, N-M, AF, LDA, L, LDA )
139 IF( M.GT.0 )
140 $ CALL SLACPY( 'Lower', M, M, AF( 1, N-M+1 ), LDA,
141 $ L( 1, N-M+1 ), LDA )
142 END IF
143 *
144 * Compute L - Q'*A
145 *
146 CALL SGEMM( 'Transpose', 'No transpose', M, N, M, -ONE, Q, LDA, A,
147 $ LDA, ONE, L, LDA )
148 *
149 * Compute norm( L - Q'*A ) / ( M * norm(A) * EPS ) .
150 *
151 ANORM = SLANGE( '1', M, N, A, LDA, RWORK )
152 RESID = SLANGE( '1', M, N, L, LDA, RWORK )
153 IF( ANORM.GT.ZERO ) THEN
154 RESULT( 1 ) = ( ( RESID / REAL( MAX( 1, M ) ) ) / ANORM ) / EPS
155 ELSE
156 RESULT( 1 ) = ZERO
157 END IF
158 *
159 * Compute I - Q'*Q
160 *
161 CALL SLASET( 'Full', M, M, ZERO, ONE, L, LDA )
162 CALL SSYRK( 'Upper', 'Transpose', M, M, -ONE, Q, LDA, ONE, L,
163 $ LDA )
164 *
165 * Compute norm( I - Q'*Q ) / ( M * EPS ) .
166 *
167 RESID = SLANSY( '1', 'Upper', M, L, LDA, RWORK )
168 *
169 RESULT( 2 ) = ( RESID / REAL( MAX( 1, M ) ) ) / EPS
170 *
171 RETURN
172 *
173 * End of SQLT01
174 *
175 END
2 $ RWORK, RESULT )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9 INTEGER LDA, LWORK, M, N
10 * ..
11 * .. Array Arguments ..
12 REAL A( LDA, * ), AF( LDA, * ), L( LDA, * ),
13 $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
14 $ WORK( LWORK )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * SQLT01 tests SGEQLF, which computes the QL factorization of an m-by-n
21 * matrix A, and partially tests SORGQL which forms the m-by-m
22 * orthogonal matrix Q.
23 *
24 * SQLT01 compares L 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) REAL array, dimension (LDA,N)
36 * The m-by-n matrix A.
37 *
38 * AF (output) REAL array, dimension (LDA,N)
39 * Details of the QL factorization of A, as returned by SGEQLF.
40 * See SGEQLF for further details.
41 *
42 * Q (output) REAL array, dimension (LDA,M)
43 * The m-by-m orthogonal matrix Q.
44 *
45 * L (workspace) REAL 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) REAL array, dimension (min(M,N))
52 * The scalar factors of the elementary reflectors, as returned
53 * by SGEQLF.
54 *
55 * WORK (workspace) REAL array, dimension (LWORK)
56 *
57 * LWORK (input) INTEGER
58 * The dimension of the array WORK.
59 *
60 * RWORK (workspace) REAL array, dimension (M)
61 *
62 * RESULT (output) REAL array, dimension (2)
63 * The test ratios:
64 * RESULT(1) = norm( L - Q'*A ) / ( M * norm(A) * EPS )
65 * RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
66 *
67 * =====================================================================
68 *
69 * .. Parameters ..
70 REAL ZERO, ONE
71 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
72 REAL ROGUE
73 PARAMETER ( ROGUE = -1.0E+10 )
74 * ..
75 * .. Local Scalars ..
76 INTEGER INFO, MINMN
77 REAL ANORM, EPS, RESID
78 * ..
79 * .. External Functions ..
80 REAL SLAMCH, SLANGE, SLANSY
81 EXTERNAL SLAMCH, SLANGE, SLANSY
82 * ..
83 * .. External Subroutines ..
84 EXTERNAL SGEMM, SGEQLF, SLACPY, SLASET, SORGQL, SSYRK
85 * ..
86 * .. Intrinsic Functions ..
87 INTRINSIC MAX, MIN, REAL
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 = SLAMCH( 'Epsilon' )
99 *
100 * Copy the matrix A to the array AF.
101 *
102 CALL SLACPY( 'Full', M, N, A, LDA, AF, LDA )
103 *
104 * Factorize the matrix A in the array AF.
105 *
106 SRNAMT = 'SGEQLF'
107 CALL SGEQLF( M, N, AF, LDA, TAU, WORK, LWORK, INFO )
108 *
109 * Copy details of Q
110 *
111 CALL SLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA )
112 IF( M.GE.N ) THEN
113 IF( N.LT.M .AND. N.GT.0 )
114 $ CALL SLACPY( 'Full', M-N, N, AF, LDA, Q( 1, M-N+1 ), LDA )
115 IF( N.GT.1 )
116 $ CALL SLACPY( 'Upper', N-1, N-1, AF( M-N+1, 2 ), LDA,
117 $ Q( M-N+1, M-N+2 ), LDA )
118 ELSE
119 IF( M.GT.1 )
120 $ CALL SLACPY( 'Upper', M-1, M-1, AF( 1, N-M+2 ), LDA,
121 $ Q( 1, 2 ), LDA )
122 END IF
123 *
124 * Generate the m-by-m matrix Q
125 *
126 SRNAMT = 'SORGQL'
127 CALL SORGQL( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO )
128 *
129 * Copy L
130 *
131 CALL SLASET( 'Full', M, N, ZERO, ZERO, L, LDA )
132 IF( M.GE.N ) THEN
133 IF( N.GT.0 )
134 $ CALL SLACPY( 'Lower', N, N, AF( M-N+1, 1 ), LDA,
135 $ L( M-N+1, 1 ), LDA )
136 ELSE
137 IF( N.GT.M .AND. M.GT.0 )
138 $ CALL SLACPY( 'Full', M, N-M, AF, LDA, L, LDA )
139 IF( M.GT.0 )
140 $ CALL SLACPY( 'Lower', M, M, AF( 1, N-M+1 ), LDA,
141 $ L( 1, N-M+1 ), LDA )
142 END IF
143 *
144 * Compute L - Q'*A
145 *
146 CALL SGEMM( 'Transpose', 'No transpose', M, N, M, -ONE, Q, LDA, A,
147 $ LDA, ONE, L, LDA )
148 *
149 * Compute norm( L - Q'*A ) / ( M * norm(A) * EPS ) .
150 *
151 ANORM = SLANGE( '1', M, N, A, LDA, RWORK )
152 RESID = SLANGE( '1', M, N, L, LDA, RWORK )
153 IF( ANORM.GT.ZERO ) THEN
154 RESULT( 1 ) = ( ( RESID / REAL( MAX( 1, M ) ) ) / ANORM ) / EPS
155 ELSE
156 RESULT( 1 ) = ZERO
157 END IF
158 *
159 * Compute I - Q'*Q
160 *
161 CALL SLASET( 'Full', M, M, ZERO, ONE, L, LDA )
162 CALL SSYRK( 'Upper', 'Transpose', M, M, -ONE, Q, LDA, ONE, L,
163 $ LDA )
164 *
165 * Compute norm( I - Q'*Q ) / ( M * EPS ) .
166 *
167 RESID = SLANSY( '1', 'Upper', M, L, LDA, RWORK )
168 *
169 RESULT( 2 ) = ( RESID / REAL( MAX( 1, M ) ) ) / EPS
170 *
171 RETURN
172 *
173 * End of SQLT01
174 *
175 END