1 SUBROUTINE SPBT02( UPLO, N, KD, NRHS, A, LDA, X, LDX, B, LDB,
2 $ RWORK, 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, LDB, LDX, N, NRHS
11 REAL RESID
12 * ..
13 * .. Array Arguments ..
14 REAL A( LDA, * ), B( LDB, * ), RWORK( * ),
15 $ X( LDX, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * SPBT02 computes the residual for a solution of a symmetric banded
22 * system of equations A*x = b:
23 * RESID = norm( B - A*X ) / ( norm(A) * norm(X) * EPS)
24 * where EPS is the machine precision.
25 *
26 * Arguments
27 * =========
28 *
29 * UPLO (input) CHARACTER*1
30 * Specifies whether the upper or lower triangular part of the
31 * symmetric matrix A is stored:
32 * = 'U': Upper triangular
33 * = 'L': Lower triangular
34 *
35 * N (input) INTEGER
36 * The number of rows and columns of the matrix A. N >= 0.
37 *
38 * KD (input) INTEGER
39 * The number of super-diagonals of the matrix A if UPLO = 'U',
40 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
41 *
42 * A (input) REAL array, dimension (LDA,N)
43 * The original symmetric band matrix A. If UPLO = 'U', the
44 * upper triangular part of A is stored as a band matrix; if
45 * UPLO = 'L', the lower triangular part of A is stored. The
46 * columns of the appropriate triangle are stored in the columns
47 * of A and the diagonals of the triangle are stored in the rows
48 * of A. See SPBTRF for further details.
49 *
50 * LDA (input) INTEGER.
51 * The leading dimension of the array A. LDA >= max(1,KD+1).
52 *
53 * X (input) REAL array, dimension (LDX,NRHS)
54 * The computed solution vectors for the system of linear
55 * equations.
56 *
57 * LDX (input) INTEGER
58 * The leading dimension of the array X. LDX >= max(1,N).
59 *
60 * B (input/output) REAL array, dimension (LDB,NRHS)
61 * On entry, the right hand side vectors for the system of
62 * linear equations.
63 * On exit, B is overwritten with the difference B - A*X.
64 *
65 * LDB (input) INTEGER
66 * The leading dimension of the array B. LDB >= max(1,N).
67 *
68 * RWORK (workspace) REAL array, dimension (N)
69 *
70 * RESID (output) REAL
71 * The maximum over the number of right hand sides of
72 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77 REAL ZERO, ONE
78 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
79 * ..
80 * .. Local Scalars ..
81 INTEGER J
82 REAL ANORM, BNORM, EPS, XNORM
83 * ..
84 * .. External Functions ..
85 REAL SASUM, SLAMCH, SLANSB
86 EXTERNAL SASUM, SLAMCH, SLANSB
87 * ..
88 * .. External Subroutines ..
89 EXTERNAL SSBMV
90 * ..
91 * .. Intrinsic Functions ..
92 INTRINSIC MAX
93 * ..
94 * .. Executable Statements ..
95 *
96 * Quick exit if N = 0 or NRHS = 0.
97 *
98 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
99 RESID = ZERO
100 RETURN
101 END IF
102 *
103 * Exit with RESID = 1/EPS if ANORM = 0.
104 *
105 EPS = SLAMCH( 'Epsilon' )
106 ANORM = SLANSB( '1', UPLO, N, KD, A, LDA, RWORK )
107 IF( ANORM.LE.ZERO ) THEN
108 RESID = ONE / EPS
109 RETURN
110 END IF
111 *
112 * Compute B - A*X
113 *
114 DO 10 J = 1, NRHS
115 CALL SSBMV( UPLO, N, KD, -ONE, A, LDA, X( 1, J ), 1, ONE,
116 $ B( 1, J ), 1 )
117 10 CONTINUE
118 *
119 * Compute the maximum over the number of right hand sides of
120 * norm( B - A*X ) / ( norm(A) * norm(X) * EPS )
121 *
122 RESID = ZERO
123 DO 20 J = 1, NRHS
124 BNORM = SASUM( N, B( 1, J ), 1 )
125 XNORM = SASUM( N, X( 1, J ), 1 )
126 IF( XNORM.LE.ZERO ) THEN
127 RESID = ONE / EPS
128 ELSE
129 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
130 END IF
131 20 CONTINUE
132 *
133 RETURN
134 *
135 * End of SPBT02
136 *
137 END
2 $ RWORK, 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, LDB, LDX, N, NRHS
11 REAL RESID
12 * ..
13 * .. Array Arguments ..
14 REAL A( LDA, * ), B( LDB, * ), RWORK( * ),
15 $ X( LDX, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * SPBT02 computes the residual for a solution of a symmetric banded
22 * system of equations A*x = b:
23 * RESID = norm( B - A*X ) / ( norm(A) * norm(X) * EPS)
24 * where EPS is the machine precision.
25 *
26 * Arguments
27 * =========
28 *
29 * UPLO (input) CHARACTER*1
30 * Specifies whether the upper or lower triangular part of the
31 * symmetric matrix A is stored:
32 * = 'U': Upper triangular
33 * = 'L': Lower triangular
34 *
35 * N (input) INTEGER
36 * The number of rows and columns of the matrix A. N >= 0.
37 *
38 * KD (input) INTEGER
39 * The number of super-diagonals of the matrix A if UPLO = 'U',
40 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
41 *
42 * A (input) REAL array, dimension (LDA,N)
43 * The original symmetric band matrix A. If UPLO = 'U', the
44 * upper triangular part of A is stored as a band matrix; if
45 * UPLO = 'L', the lower triangular part of A is stored. The
46 * columns of the appropriate triangle are stored in the columns
47 * of A and the diagonals of the triangle are stored in the rows
48 * of A. See SPBTRF for further details.
49 *
50 * LDA (input) INTEGER.
51 * The leading dimension of the array A. LDA >= max(1,KD+1).
52 *
53 * X (input) REAL array, dimension (LDX,NRHS)
54 * The computed solution vectors for the system of linear
55 * equations.
56 *
57 * LDX (input) INTEGER
58 * The leading dimension of the array X. LDX >= max(1,N).
59 *
60 * B (input/output) REAL array, dimension (LDB,NRHS)
61 * On entry, the right hand side vectors for the system of
62 * linear equations.
63 * On exit, B is overwritten with the difference B - A*X.
64 *
65 * LDB (input) INTEGER
66 * The leading dimension of the array B. LDB >= max(1,N).
67 *
68 * RWORK (workspace) REAL array, dimension (N)
69 *
70 * RESID (output) REAL
71 * The maximum over the number of right hand sides of
72 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
73 *
74 * =====================================================================
75 *
76 * .. Parameters ..
77 REAL ZERO, ONE
78 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
79 * ..
80 * .. Local Scalars ..
81 INTEGER J
82 REAL ANORM, BNORM, EPS, XNORM
83 * ..
84 * .. External Functions ..
85 REAL SASUM, SLAMCH, SLANSB
86 EXTERNAL SASUM, SLAMCH, SLANSB
87 * ..
88 * .. External Subroutines ..
89 EXTERNAL SSBMV
90 * ..
91 * .. Intrinsic Functions ..
92 INTRINSIC MAX
93 * ..
94 * .. Executable Statements ..
95 *
96 * Quick exit if N = 0 or NRHS = 0.
97 *
98 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
99 RESID = ZERO
100 RETURN
101 END IF
102 *
103 * Exit with RESID = 1/EPS if ANORM = 0.
104 *
105 EPS = SLAMCH( 'Epsilon' )
106 ANORM = SLANSB( '1', UPLO, N, KD, A, LDA, RWORK )
107 IF( ANORM.LE.ZERO ) THEN
108 RESID = ONE / EPS
109 RETURN
110 END IF
111 *
112 * Compute B - A*X
113 *
114 DO 10 J = 1, NRHS
115 CALL SSBMV( UPLO, N, KD, -ONE, A, LDA, X( 1, J ), 1, ONE,
116 $ B( 1, J ), 1 )
117 10 CONTINUE
118 *
119 * Compute the maximum over the number of right hand sides of
120 * norm( B - A*X ) / ( norm(A) * norm(X) * EPS )
121 *
122 RESID = ZERO
123 DO 20 J = 1, NRHS
124 BNORM = SASUM( N, B( 1, J ), 1 )
125 XNORM = SASUM( N, X( 1, J ), 1 )
126 IF( XNORM.LE.ZERO ) THEN
127 RESID = ONE / EPS
128 ELSE
129 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
130 END IF
131 20 CONTINUE
132 *
133 RETURN
134 *
135 * End of SPBT02
136 *
137 END