1 SUBROUTINE DPBT01( UPLO, N, KD, A, LDA, AFAC, LDAFAC, RWORK,
2 $ RESID )
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 CHARACTER UPLO
10 INTEGER KD, LDA, LDAFAC, N
11 DOUBLE PRECISION RESID
12 * ..
13 * .. Array Arguments ..
14 DOUBLE PRECISION A( LDA, * ), AFAC( LDAFAC, * ), RWORK( * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * DPBT01 reconstructs a symmetric positive definite band matrix A from
21 * its L*L' or U'*U factorization and computes the residual
22 * norm( L*L' - A ) / ( N * norm(A) * EPS ) or
23 * norm( U'*U - A ) / ( N * norm(A) * EPS ),
24 * where EPS is the machine epsilon, L' is the conjugate transpose of
25 * L, and U' is the conjugate transpose of U.
26 *
27 * Arguments
28 * =========
29 *
30 * UPLO (input) CHARACTER*1
31 * Specifies whether the upper or lower triangular part of the
32 * symmetric matrix A is stored:
33 * = 'U': Upper triangular
34 * = 'L': Lower triangular
35 *
36 * N (input) INTEGER
37 * The number of rows and columns of the matrix A. N >= 0.
38 *
39 * KD (input) INTEGER
40 * The number of super-diagonals of the matrix A if UPLO = 'U',
41 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
42 *
43 * A (input) DOUBLE PRECISION array, dimension (LDA,N)
44 * The original symmetric band matrix A. If UPLO = 'U', the
45 * upper triangular part of A is stored as a band matrix; if
46 * UPLO = 'L', the lower triangular part of A is stored. The
47 * columns of the appropriate triangle are stored in the columns
48 * of A and the diagonals of the triangle are stored in the rows
49 * of A. See DPBTRF for further details.
50 *
51 * LDA (input) INTEGER.
52 * The leading dimension of the array A. LDA >= max(1,KD+1).
53 *
54 * AFAC (input) DOUBLE PRECISION array, dimension (LDAFAC,N)
55 * The factored form of the matrix A. AFAC contains the factor
56 * L or U from the L*L' or U'*U factorization in band storage
57 * format, as computed by DPBTRF.
58 *
59 * LDAFAC (input) INTEGER
60 * The leading dimension of the array AFAC.
61 * LDAFAC >= max(1,KD+1).
62 *
63 * RWORK (workspace) DOUBLE PRECISION array, dimension (N)
64 *
65 * RESID (output) DOUBLE PRECISION
66 * If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS )
67 * If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS )
68 *
69 * =====================================================================
70 *
71 *
72 * .. Parameters ..
73 DOUBLE PRECISION ZERO, ONE
74 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
75 * ..
76 * .. Local Scalars ..
77 INTEGER I, J, K, KC, KLEN, ML, MU
78 DOUBLE PRECISION ANORM, EPS, T
79 * ..
80 * .. External Functions ..
81 LOGICAL LSAME
82 DOUBLE PRECISION DDOT, DLAMCH, DLANSB
83 EXTERNAL LSAME, DDOT, DLAMCH, DLANSB
84 * ..
85 * .. External Subroutines ..
86 EXTERNAL DSCAL, DSYR, DTRMV
87 * ..
88 * .. Intrinsic Functions ..
89 INTRINSIC DBLE, MAX, MIN
90 * ..
91 * .. Executable Statements ..
92 *
93 * Quick exit if N = 0.
94 *
95 IF( N.LE.0 ) THEN
96 RESID = ZERO
97 RETURN
98 END IF
99 *
100 * Exit with RESID = 1/EPS if ANORM = 0.
101 *
102 EPS = DLAMCH( 'Epsilon' )
103 ANORM = DLANSB( '1', UPLO, N, KD, A, LDA, RWORK )
104 IF( ANORM.LE.ZERO ) THEN
105 RESID = ONE / EPS
106 RETURN
107 END IF
108 *
109 * Compute the product U'*U, overwriting U.
110 *
111 IF( LSAME( UPLO, 'U' ) ) THEN
112 DO 10 K = N, 1, -1
113 KC = MAX( 1, KD+2-K )
114 KLEN = KD + 1 - KC
115 *
116 * Compute the (K,K) element of the result.
117 *
118 T = DDOT( KLEN+1, AFAC( KC, K ), 1, AFAC( KC, K ), 1 )
119 AFAC( KD+1, K ) = T
120 *
121 * Compute the rest of column K.
122 *
123 IF( KLEN.GT.0 )
124 $ CALL DTRMV( 'Upper', 'Transpose', 'Non-unit', KLEN,
125 $ AFAC( KD+1, K-KLEN ), LDAFAC-1,
126 $ AFAC( KC, K ), 1 )
127 *
128 10 CONTINUE
129 *
130 * UPLO = 'L': Compute the product L*L', overwriting L.
131 *
132 ELSE
133 DO 20 K = N, 1, -1
134 KLEN = MIN( KD, N-K )
135 *
136 * Add a multiple of column K of the factor L to each of
137 * columns K+1 through N.
138 *
139 IF( KLEN.GT.0 )
140 $ CALL DSYR( 'Lower', KLEN, ONE, AFAC( 2, K ), 1,
141 $ AFAC( 1, K+1 ), LDAFAC-1 )
142 *
143 * Scale column K by the diagonal element.
144 *
145 T = AFAC( 1, K )
146 CALL DSCAL( KLEN+1, T, AFAC( 1, K ), 1 )
147 *
148 20 CONTINUE
149 END IF
150 *
151 * Compute the difference L*L' - A or U'*U - A.
152 *
153 IF( LSAME( UPLO, 'U' ) ) THEN
154 DO 40 J = 1, N
155 MU = MAX( 1, KD+2-J )
156 DO 30 I = MU, KD + 1
157 AFAC( I, J ) = AFAC( I, J ) - A( I, J )
158 30 CONTINUE
159 40 CONTINUE
160 ELSE
161 DO 60 J = 1, N
162 ML = MIN( KD+1, N-J+1 )
163 DO 50 I = 1, ML
164 AFAC( I, J ) = AFAC( I, J ) - A( I, J )
165 50 CONTINUE
166 60 CONTINUE
167 END IF
168 *
169 * Compute norm( L*L' - A ) / ( N * norm(A) * EPS )
170 *
171 RESID = DLANSB( 'I', UPLO, N, KD, AFAC, LDAFAC, RWORK )
172 *
173 RESID = ( ( RESID / DBLE( N ) ) / ANORM ) / EPS
174 *
175 RETURN
176 *
177 * End of DPBT01
178 *
179 END
2 $ RESID )
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 CHARACTER UPLO
10 INTEGER KD, LDA, LDAFAC, N
11 DOUBLE PRECISION RESID
12 * ..
13 * .. Array Arguments ..
14 DOUBLE PRECISION A( LDA, * ), AFAC( LDAFAC, * ), RWORK( * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * DPBT01 reconstructs a symmetric positive definite band matrix A from
21 * its L*L' or U'*U factorization and computes the residual
22 * norm( L*L' - A ) / ( N * norm(A) * EPS ) or
23 * norm( U'*U - A ) / ( N * norm(A) * EPS ),
24 * where EPS is the machine epsilon, L' is the conjugate transpose of
25 * L, and U' is the conjugate transpose of U.
26 *
27 * Arguments
28 * =========
29 *
30 * UPLO (input) CHARACTER*1
31 * Specifies whether the upper or lower triangular part of the
32 * symmetric matrix A is stored:
33 * = 'U': Upper triangular
34 * = 'L': Lower triangular
35 *
36 * N (input) INTEGER
37 * The number of rows and columns of the matrix A. N >= 0.
38 *
39 * KD (input) INTEGER
40 * The number of super-diagonals of the matrix A if UPLO = 'U',
41 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
42 *
43 * A (input) DOUBLE PRECISION array, dimension (LDA,N)
44 * The original symmetric band matrix A. If UPLO = 'U', the
45 * upper triangular part of A is stored as a band matrix; if
46 * UPLO = 'L', the lower triangular part of A is stored. The
47 * columns of the appropriate triangle are stored in the columns
48 * of A and the diagonals of the triangle are stored in the rows
49 * of A. See DPBTRF for further details.
50 *
51 * LDA (input) INTEGER.
52 * The leading dimension of the array A. LDA >= max(1,KD+1).
53 *
54 * AFAC (input) DOUBLE PRECISION array, dimension (LDAFAC,N)
55 * The factored form of the matrix A. AFAC contains the factor
56 * L or U from the L*L' or U'*U factorization in band storage
57 * format, as computed by DPBTRF.
58 *
59 * LDAFAC (input) INTEGER
60 * The leading dimension of the array AFAC.
61 * LDAFAC >= max(1,KD+1).
62 *
63 * RWORK (workspace) DOUBLE PRECISION array, dimension (N)
64 *
65 * RESID (output) DOUBLE PRECISION
66 * If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS )
67 * If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS )
68 *
69 * =====================================================================
70 *
71 *
72 * .. Parameters ..
73 DOUBLE PRECISION ZERO, ONE
74 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
75 * ..
76 * .. Local Scalars ..
77 INTEGER I, J, K, KC, KLEN, ML, MU
78 DOUBLE PRECISION ANORM, EPS, T
79 * ..
80 * .. External Functions ..
81 LOGICAL LSAME
82 DOUBLE PRECISION DDOT, DLAMCH, DLANSB
83 EXTERNAL LSAME, DDOT, DLAMCH, DLANSB
84 * ..
85 * .. External Subroutines ..
86 EXTERNAL DSCAL, DSYR, DTRMV
87 * ..
88 * .. Intrinsic Functions ..
89 INTRINSIC DBLE, MAX, MIN
90 * ..
91 * .. Executable Statements ..
92 *
93 * Quick exit if N = 0.
94 *
95 IF( N.LE.0 ) THEN
96 RESID = ZERO
97 RETURN
98 END IF
99 *
100 * Exit with RESID = 1/EPS if ANORM = 0.
101 *
102 EPS = DLAMCH( 'Epsilon' )
103 ANORM = DLANSB( '1', UPLO, N, KD, A, LDA, RWORK )
104 IF( ANORM.LE.ZERO ) THEN
105 RESID = ONE / EPS
106 RETURN
107 END IF
108 *
109 * Compute the product U'*U, overwriting U.
110 *
111 IF( LSAME( UPLO, 'U' ) ) THEN
112 DO 10 K = N, 1, -1
113 KC = MAX( 1, KD+2-K )
114 KLEN = KD + 1 - KC
115 *
116 * Compute the (K,K) element of the result.
117 *
118 T = DDOT( KLEN+1, AFAC( KC, K ), 1, AFAC( KC, K ), 1 )
119 AFAC( KD+1, K ) = T
120 *
121 * Compute the rest of column K.
122 *
123 IF( KLEN.GT.0 )
124 $ CALL DTRMV( 'Upper', 'Transpose', 'Non-unit', KLEN,
125 $ AFAC( KD+1, K-KLEN ), LDAFAC-1,
126 $ AFAC( KC, K ), 1 )
127 *
128 10 CONTINUE
129 *
130 * UPLO = 'L': Compute the product L*L', overwriting L.
131 *
132 ELSE
133 DO 20 K = N, 1, -1
134 KLEN = MIN( KD, N-K )
135 *
136 * Add a multiple of column K of the factor L to each of
137 * columns K+1 through N.
138 *
139 IF( KLEN.GT.0 )
140 $ CALL DSYR( 'Lower', KLEN, ONE, AFAC( 2, K ), 1,
141 $ AFAC( 1, K+1 ), LDAFAC-1 )
142 *
143 * Scale column K by the diagonal element.
144 *
145 T = AFAC( 1, K )
146 CALL DSCAL( KLEN+1, T, AFAC( 1, K ), 1 )
147 *
148 20 CONTINUE
149 END IF
150 *
151 * Compute the difference L*L' - A or U'*U - A.
152 *
153 IF( LSAME( UPLO, 'U' ) ) THEN
154 DO 40 J = 1, N
155 MU = MAX( 1, KD+2-J )
156 DO 30 I = MU, KD + 1
157 AFAC( I, J ) = AFAC( I, J ) - A( I, J )
158 30 CONTINUE
159 40 CONTINUE
160 ELSE
161 DO 60 J = 1, N
162 ML = MIN( KD+1, N-J+1 )
163 DO 50 I = 1, ML
164 AFAC( I, J ) = AFAC( I, J ) - A( I, J )
165 50 CONTINUE
166 60 CONTINUE
167 END IF
168 *
169 * Compute norm( L*L' - A ) / ( N * norm(A) * EPS )
170 *
171 RESID = DLANSB( 'I', UPLO, N, KD, AFAC, LDAFAC, RWORK )
172 *
173 RESID = ( ( RESID / DBLE( N ) ) / ANORM ) / EPS
174 *
175 RETURN
176 *
177 * End of DPBT01
178 *
179 END