1 SUBROUTINE STRT01( UPLO, DIAG, N, A, LDA, AINV, LDAINV, RCOND,
2 $ WORK, 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 DIAG, UPLO
10 INTEGER LDA, LDAINV, N
11 REAL RCOND, RESID
12 * ..
13 * .. Array Arguments ..
14 REAL A( LDA, * ), AINV( LDAINV, * ), WORK( * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * STRT01 computes the residual for a triangular matrix A times its
21 * inverse:
22 * RESID = norm( A*AINV - I ) / ( N * norm(A) * norm(AINV) * EPS ),
23 * where EPS is the machine epsilon.
24 *
25 * Arguments
26 * ==========
27 *
28 * UPLO (input) CHARACTER*1
29 * Specifies whether the matrix A is upper or lower triangular.
30 * = 'U': Upper triangular
31 * = 'L': Lower triangular
32 *
33 * DIAG (input) CHARACTER*1
34 * Specifies whether or not the matrix A is unit triangular.
35 * = 'N': Non-unit triangular
36 * = 'U': Unit triangular
37 *
38 * N (input) INTEGER
39 * The order of the matrix A. N >= 0.
40 *
41 * A (input) REAL array, dimension (LDA,N)
42 * The triangular matrix A. If UPLO = 'U', the leading n by n
43 * upper triangular part of the array A contains the upper
44 * triangular matrix, and the strictly lower triangular part of
45 * A is not referenced. If UPLO = 'L', the leading n by n lower
46 * triangular part of the array A contains the lower triangular
47 * matrix, and the strictly upper triangular part of A is not
48 * referenced. If DIAG = 'U', the diagonal elements of A are
49 * also not referenced and are assumed to be 1.
50 *
51 * LDA (input) INTEGER
52 * The leading dimension of the array A. LDA >= max(1,N).
53 *
54 * AINV (input/output) REAL array, dimension (LDAINV,N)
55 * On entry, the (triangular) inverse of the matrix A, in the
56 * same storage format as A.
57 * On exit, the contents of AINV are destroyed.
58 *
59 * LDAINV (input) INTEGER
60 * The leading dimension of the array AINV. LDAINV >= max(1,N).
61 *
62 * RCOND (output) REAL
63 * The reciprocal condition number of A, computed as
64 * 1/(norm(A) * norm(AINV)).
65 *
66 * WORK (workspace) REAL array, dimension (N)
67 *
68 * RESID (output) REAL
69 * norm(A*AINV - I) / ( N * norm(A) * norm(AINV) * EPS )
70 *
71 * =====================================================================
72 *
73 * .. Parameters ..
74 REAL ZERO, ONE
75 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
76 * ..
77 * .. Local Scalars ..
78 INTEGER J
79 REAL AINVNM, ANORM, EPS
80 * ..
81 * .. External Functions ..
82 LOGICAL LSAME
83 REAL SLAMCH, SLANTR
84 EXTERNAL LSAME, SLAMCH, SLANTR
85 * ..
86 * .. External Subroutines ..
87 EXTERNAL STRMV
88 * ..
89 * .. Intrinsic Functions ..
90 INTRINSIC REAL
91 * ..
92 * .. Executable Statements ..
93 *
94 * Quick exit if N = 0
95 *
96 IF( N.LE.0 ) THEN
97 RCOND = ONE
98 RESID = ZERO
99 RETURN
100 END IF
101 *
102 * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0.
103 *
104 EPS = SLAMCH( 'Epsilon' )
105 ANORM = SLANTR( '1', UPLO, DIAG, N, N, A, LDA, WORK )
106 AINVNM = SLANTR( '1', UPLO, DIAG, N, N, AINV, LDAINV, WORK )
107 IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
108 RCOND = ZERO
109 RESID = ONE / EPS
110 RETURN
111 END IF
112 RCOND = ( ONE / ANORM ) / AINVNM
113 *
114 * Set the diagonal of AINV to 1 if AINV has unit diagonal.
115 *
116 IF( LSAME( DIAG, 'U' ) ) THEN
117 DO 10 J = 1, N
118 AINV( J, J ) = ONE
119 10 CONTINUE
120 END IF
121 *
122 * Compute A * AINV, overwriting AINV.
123 *
124 IF( LSAME( UPLO, 'U' ) ) THEN
125 DO 20 J = 1, N
126 CALL STRMV( 'Upper', 'No transpose', DIAG, J, A, LDA,
127 $ AINV( 1, J ), 1 )
128 20 CONTINUE
129 ELSE
130 DO 30 J = 1, N
131 CALL STRMV( 'Lower', 'No transpose', DIAG, N-J+1, A( J, J ),
132 $ LDA, AINV( J, J ), 1 )
133 30 CONTINUE
134 END IF
135 *
136 * Subtract 1 from each diagonal element to form A*AINV - I.
137 *
138 DO 40 J = 1, N
139 AINV( J, J ) = AINV( J, J ) - ONE
140 40 CONTINUE
141 *
142 * Compute norm(A*AINV - I) / (N * norm(A) * norm(AINV) * EPS)
143 *
144 RESID = SLANTR( '1', UPLO, 'Non-unit', N, N, AINV, LDAINV, WORK )
145 *
146 RESID = ( ( RESID*RCOND ) / REAL( N ) ) / EPS
147 *
148 RETURN
149 *
150 * End of STRT01
151 *
152 END
2 $ WORK, 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 DIAG, UPLO
10 INTEGER LDA, LDAINV, N
11 REAL RCOND, RESID
12 * ..
13 * .. Array Arguments ..
14 REAL A( LDA, * ), AINV( LDAINV, * ), WORK( * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * STRT01 computes the residual for a triangular matrix A times its
21 * inverse:
22 * RESID = norm( A*AINV - I ) / ( N * norm(A) * norm(AINV) * EPS ),
23 * where EPS is the machine epsilon.
24 *
25 * Arguments
26 * ==========
27 *
28 * UPLO (input) CHARACTER*1
29 * Specifies whether the matrix A is upper or lower triangular.
30 * = 'U': Upper triangular
31 * = 'L': Lower triangular
32 *
33 * DIAG (input) CHARACTER*1
34 * Specifies whether or not the matrix A is unit triangular.
35 * = 'N': Non-unit triangular
36 * = 'U': Unit triangular
37 *
38 * N (input) INTEGER
39 * The order of the matrix A. N >= 0.
40 *
41 * A (input) REAL array, dimension (LDA,N)
42 * The triangular matrix A. If UPLO = 'U', the leading n by n
43 * upper triangular part of the array A contains the upper
44 * triangular matrix, and the strictly lower triangular part of
45 * A is not referenced. If UPLO = 'L', the leading n by n lower
46 * triangular part of the array A contains the lower triangular
47 * matrix, and the strictly upper triangular part of A is not
48 * referenced. If DIAG = 'U', the diagonal elements of A are
49 * also not referenced and are assumed to be 1.
50 *
51 * LDA (input) INTEGER
52 * The leading dimension of the array A. LDA >= max(1,N).
53 *
54 * AINV (input/output) REAL array, dimension (LDAINV,N)
55 * On entry, the (triangular) inverse of the matrix A, in the
56 * same storage format as A.
57 * On exit, the contents of AINV are destroyed.
58 *
59 * LDAINV (input) INTEGER
60 * The leading dimension of the array AINV. LDAINV >= max(1,N).
61 *
62 * RCOND (output) REAL
63 * The reciprocal condition number of A, computed as
64 * 1/(norm(A) * norm(AINV)).
65 *
66 * WORK (workspace) REAL array, dimension (N)
67 *
68 * RESID (output) REAL
69 * norm(A*AINV - I) / ( N * norm(A) * norm(AINV) * EPS )
70 *
71 * =====================================================================
72 *
73 * .. Parameters ..
74 REAL ZERO, ONE
75 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
76 * ..
77 * .. Local Scalars ..
78 INTEGER J
79 REAL AINVNM, ANORM, EPS
80 * ..
81 * .. External Functions ..
82 LOGICAL LSAME
83 REAL SLAMCH, SLANTR
84 EXTERNAL LSAME, SLAMCH, SLANTR
85 * ..
86 * .. External Subroutines ..
87 EXTERNAL STRMV
88 * ..
89 * .. Intrinsic Functions ..
90 INTRINSIC REAL
91 * ..
92 * .. Executable Statements ..
93 *
94 * Quick exit if N = 0
95 *
96 IF( N.LE.0 ) THEN
97 RCOND = ONE
98 RESID = ZERO
99 RETURN
100 END IF
101 *
102 * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0.
103 *
104 EPS = SLAMCH( 'Epsilon' )
105 ANORM = SLANTR( '1', UPLO, DIAG, N, N, A, LDA, WORK )
106 AINVNM = SLANTR( '1', UPLO, DIAG, N, N, AINV, LDAINV, WORK )
107 IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
108 RCOND = ZERO
109 RESID = ONE / EPS
110 RETURN
111 END IF
112 RCOND = ( ONE / ANORM ) / AINVNM
113 *
114 * Set the diagonal of AINV to 1 if AINV has unit diagonal.
115 *
116 IF( LSAME( DIAG, 'U' ) ) THEN
117 DO 10 J = 1, N
118 AINV( J, J ) = ONE
119 10 CONTINUE
120 END IF
121 *
122 * Compute A * AINV, overwriting AINV.
123 *
124 IF( LSAME( UPLO, 'U' ) ) THEN
125 DO 20 J = 1, N
126 CALL STRMV( 'Upper', 'No transpose', DIAG, J, A, LDA,
127 $ AINV( 1, J ), 1 )
128 20 CONTINUE
129 ELSE
130 DO 30 J = 1, N
131 CALL STRMV( 'Lower', 'No transpose', DIAG, N-J+1, A( J, J ),
132 $ LDA, AINV( J, J ), 1 )
133 30 CONTINUE
134 END IF
135 *
136 * Subtract 1 from each diagonal element to form A*AINV - I.
137 *
138 DO 40 J = 1, N
139 AINV( J, J ) = AINV( J, J ) - ONE
140 40 CONTINUE
141 *
142 * Compute norm(A*AINV - I) / (N * norm(A) * norm(AINV) * EPS)
143 *
144 RESID = SLANTR( '1', UPLO, 'Non-unit', N, N, AINV, LDAINV, WORK )
145 *
146 RESID = ( ( RESID*RCOND ) / REAL( N ) ) / EPS
147 *
148 RETURN
149 *
150 * End of STRT01
151 *
152 END