LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
strt01.f
Go to the documentation of this file.
1 *> \brief \b STRT01
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE STRT01( UPLO, DIAG, N, A, LDA, AINV, LDAINV, RCOND,
12 * WORK, RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER DIAG, UPLO
16 * INTEGER LDA, LDAINV, N
17 * REAL RCOND, RESID
18 * ..
19 * .. Array Arguments ..
20 * REAL A( LDA, * ), AINV( LDAINV, * ), WORK( * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> STRT01 computes the residual for a triangular matrix A times its
30 *> inverse:
31 *> RESID = norm( A*AINV - I ) / ( N * norm(A) * norm(AINV) * EPS ),
32 *> where EPS is the machine epsilon.
33 *> \endverbatim
34 *
35 * Arguments:
36 * ==========
37 *
38 *> \param[in] UPLO
39 *> \verbatim
40 *> UPLO is CHARACTER*1
41 *> Specifies whether the matrix A is upper or lower triangular.
42 *> = 'U': Upper triangular
43 *> = 'L': Lower triangular
44 *> \endverbatim
45 *>
46 *> \param[in] DIAG
47 *> \verbatim
48 *> DIAG is CHARACTER*1
49 *> Specifies whether or not the matrix A is unit triangular.
50 *> = 'N': Non-unit triangular
51 *> = 'U': Unit triangular
52 *> \endverbatim
53 *>
54 *> \param[in] N
55 *> \verbatim
56 *> N is INTEGER
57 *> The order of the matrix A. N >= 0.
58 *> \endverbatim
59 *>
60 *> \param[in] A
61 *> \verbatim
62 *> A is REAL array, dimension (LDA,N)
63 *> The triangular matrix A. If UPLO = 'U', the leading n by n
64 *> upper triangular part of the array A contains the upper
65 *> triangular matrix, and the strictly lower triangular part of
66 *> A is not referenced. If UPLO = 'L', the leading n by n lower
67 *> triangular part of the array A contains the lower triangular
68 *> matrix, and the strictly upper triangular part of A is not
69 *> referenced. If DIAG = 'U', the diagonal elements of A are
70 *> also not referenced and are assumed to be 1.
71 *> \endverbatim
72 *>
73 *> \param[in] LDA
74 *> \verbatim
75 *> LDA is INTEGER
76 *> The leading dimension of the array A. LDA >= max(1,N).
77 *> \endverbatim
78 *>
79 *> \param[in,out] AINV
80 *> \verbatim
81 *> AINV is REAL array, dimension (LDAINV,N)
82 *> On entry, the (triangular) inverse of the matrix A, in the
83 *> same storage format as A.
84 *> On exit, the contents of AINV are destroyed.
85 *> \endverbatim
86 *>
87 *> \param[in] LDAINV
88 *> \verbatim
89 *> LDAINV is INTEGER
90 *> The leading dimension of the array AINV. LDAINV >= max(1,N).
91 *> \endverbatim
92 *>
93 *> \param[out] RCOND
94 *> \verbatim
95 *> RCOND is REAL
96 *> The reciprocal condition number of A, computed as
97 *> 1/(norm(A) * norm(AINV)).
98 *> \endverbatim
99 *>
100 *> \param[out] WORK
101 *> \verbatim
102 *> WORK is REAL array, dimension (N)
103 *> \endverbatim
104 *>
105 *> \param[out] RESID
106 *> \verbatim
107 *> RESID is REAL
108 *> norm(A*AINV - I) / ( N * norm(A) * norm(AINV) * EPS )
109 *> \endverbatim
110 *
111 * Authors:
112 * ========
113 *
114 *> \author Univ. of Tennessee
115 *> \author Univ. of California Berkeley
116 *> \author Univ. of Colorado Denver
117 *> \author NAG Ltd.
118 *
119 *> \date November 2011
120 *
121 *> \ingroup single_lin
122 *
123 * =====================================================================
124  SUBROUTINE strt01( UPLO, DIAG, N, A, LDA, AINV, LDAINV, RCOND,
125  $ work, resid )
126 *
127 * -- LAPACK test routine (version 3.4.0) --
128 * -- LAPACK is a software package provided by Univ. of Tennessee, --
129 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
130 * November 2011
131 *
132 * .. Scalar Arguments ..
133  CHARACTER diag, uplo
134  INTEGER lda, ldainv, n
135  REAL rcond, resid
136 * ..
137 * .. Array Arguments ..
138  REAL a( lda, * ), ainv( ldainv, * ), work( * )
139 * ..
140 *
141 * =====================================================================
142 *
143 * .. Parameters ..
144  REAL zero, one
145  parameter( zero = 0.0e+0, one = 1.0e+0 )
146 * ..
147 * .. Local Scalars ..
148  INTEGER j
149  REAL ainvnm, anorm, eps
150 * ..
151 * .. External Functions ..
152  LOGICAL lsame
153  REAL slamch, slantr
154  EXTERNAL lsame, slamch, slantr
155 * ..
156 * .. External Subroutines ..
157  EXTERNAL strmv
158 * ..
159 * .. Intrinsic Functions ..
160  INTRINSIC real
161 * ..
162 * .. Executable Statements ..
163 *
164 * Quick exit if N = 0
165 *
166  IF( n.LE.0 ) THEN
167  rcond = one
168  resid = zero
169  return
170  END IF
171 *
172 * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0.
173 *
174  eps = slamch( 'Epsilon' )
175  anorm = slantr( '1', uplo, diag, n, n, a, lda, work )
176  ainvnm = slantr( '1', uplo, diag, n, n, ainv, ldainv, work )
177  IF( anorm.LE.zero .OR. ainvnm.LE.zero ) THEN
178  rcond = zero
179  resid = one / eps
180  return
181  END IF
182  rcond = ( one / anorm ) / ainvnm
183 *
184 * Set the diagonal of AINV to 1 if AINV has unit diagonal.
185 *
186  IF( lsame( diag, 'U' ) ) THEN
187  DO 10 j = 1, n
188  ainv( j, j ) = one
189  10 continue
190  END IF
191 *
192 * Compute A * AINV, overwriting AINV.
193 *
194  IF( lsame( uplo, 'U' ) ) THEN
195  DO 20 j = 1, n
196  CALL strmv( 'Upper', 'No transpose', diag, j, a, lda,
197  $ ainv( 1, j ), 1 )
198  20 continue
199  ELSE
200  DO 30 j = 1, n
201  CALL strmv( 'Lower', 'No transpose', diag, n-j+1, a( j, j ),
202  $ lda, ainv( j, j ), 1 )
203  30 continue
204  END IF
205 *
206 * Subtract 1 from each diagonal element to form A*AINV - I.
207 *
208  DO 40 j = 1, n
209  ainv( j, j ) = ainv( j, j ) - one
210  40 continue
211 *
212 * Compute norm(A*AINV - I) / (N * norm(A) * norm(AINV) * EPS)
213 *
214  resid = slantr( '1', uplo, 'Non-unit', n, n, ainv, ldainv, work )
215 *
216  resid = ( ( resid*rcond ) / REAL( N ) ) / eps
217 *
218  return
219 *
220 * End of STRT01
221 *
222  END