LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
dsyt01_aa.f
Go to the documentation of this file.
1 *> \brief \b DSYT01
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 DSYT01_AA( UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC,
12 * RWORK, RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER UPLO
16 * INTEGER LDA, LDAFAC, LDC, N
17 * DOUBLE PRECISION RESID
18 * ..
19 * .. Array Arguments ..
20 * INTEGER IPIV( * )
21 * DOUBLE PRECISION A( LDA, * ), AFAC( LDAFAC, * ), C( LDC, * ),
22 * $ RWORK( * )
23 * ..
24 *
25 *
26 *> \par Purpose:
27 * =============
28 *>
29 *> \verbatim
30 *>
31 *> DSYT01 reconstructs a symmetric indefinite matrix A from its
32 *> block L*D*L' or U*D*U' factorization and computes the residual
33 *> norm( C - A ) / ( N * norm(A) * EPS ),
34 *> where C is the reconstructed matrix and EPS is the machine epsilon.
35 *> \endverbatim
36 *
37 * Arguments:
38 * ==========
39 *
40 *> \param[in] UPLO
41 *> \verbatim
42 *> UPLO is CHARACTER*1
43 *> Specifies whether the upper or lower triangular part of the
44 *> symmetric matrix A is stored:
45 *> = 'U': Upper triangular
46 *> = 'L': Lower triangular
47 *> \endverbatim
48 *>
49 *> \param[in] N
50 *> \verbatim
51 *> N is INTEGER
52 *> The number of rows and columns of the matrix A. N >= 0.
53 *> \endverbatim
54 *>
55 *> \param[in] A
56 *> \verbatim
57 *> A is DOUBLE PRECISION array, dimension (LDA,N)
58 *> The original symmetric matrix A.
59 *> \endverbatim
60 *>
61 *> \param[in] LDA
62 *> \verbatim
63 *> LDA is INTEGER
64 *> The leading dimension of the array A. LDA >= max(1,N)
65 *> \endverbatim
66 *>
67 *> \param[in] AFAC
68 *> \verbatim
69 *> AFAC is DOUBLE PRECISION array, dimension (LDAFAC,N)
70 *> The factored form of the matrix A. AFAC contains the block
71 *> diagonal matrix D and the multipliers used to obtain the
72 *> factor L or U from the block L*D*L' or U*D*U' factorization
73 *> as computed by DSYTRF.
74 *> \endverbatim
75 *>
76 *> \param[in] LDAFAC
77 *> \verbatim
78 *> LDAFAC is INTEGER
79 *> The leading dimension of the array AFAC. LDAFAC >= max(1,N).
80 *> \endverbatim
81 *>
82 *> \param[in] IPIV
83 *> \verbatim
84 *> IPIV is INTEGER array, dimension (N)
85 *> The pivot indices from DSYTRF.
86 *> \endverbatim
87 *>
88 *> \param[out] C
89 *> \verbatim
90 *> C is DOUBLE PRECISION array, dimension (LDC,N)
91 *> \endverbatim
92 *>
93 *> \param[in] LDC
94 *> \verbatim
95 *> LDC is INTEGER
96 *> The leading dimension of the array C. LDC >= max(1,N).
97 *> \endverbatim
98 *>
99 *> \param[out] RWORK
100 *> \verbatim
101 *> RWORK is DOUBLE PRECISION array, dimension (N)
102 *> \endverbatim
103 *>
104 *> \param[out] RESID
105 *> \verbatim
106 *> RESID is DOUBLE PRECISION
107 *> If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS )
108 *> If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * 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 December 2016
120 *
121 * @precisions fortran d -> z c
122 *
123 *> \ingroup double_lin
124 *
125 * =====================================================================
126  SUBROUTINE dsyt01_aa( UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C,
127  $ LDC, RWORK, RESID )
128 *
129 * -- LAPACK test routine (version 3.7.0) --
130 * -- LAPACK is a software package provided by Univ. of Tennessee, --
131 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
132 * December 2016
133 *
134 * .. Scalar Arguments ..
135  CHARACTER UPLO
136  INTEGER LDA, LDAFAC, LDC, N
137  DOUBLE PRECISION RESID
138 * ..
139 * .. Array Arguments ..
140  INTEGER IPIV( * )
141  DOUBLE PRECISION A( lda, * ), AFAC( ldafac, * ), C( ldc, * ),
142  $ rwork( * )
143 * ..
144 *
145 * =====================================================================
146 *
147 * .. Parameters ..
148  DOUBLE PRECISION ZERO, ONE
149  parameter( zero = 0.0d+0, one = 1.0d+0 )
150 * ..
151 * .. Local Scalars ..
152  INTEGER I, J
153  DOUBLE PRECISION ANORM, EPS
154 * ..
155 * .. External Functions ..
156  LOGICAL LSAME
157  DOUBLE PRECISION DLAMCH, DLANSY
158  EXTERNAL lsame, dlamch, dlansy
159 * ..
160 * .. External Subroutines ..
161  EXTERNAL dlaset, dlavsy
162 * ..
163 * .. Intrinsic Functions ..
164  INTRINSIC dble
165 * ..
166 * .. Executable Statements ..
167 *
168 * Quick exit if N = 0.
169 *
170  IF( n.LE.0 ) THEN
171  resid = zero
172  RETURN
173  END IF
174 *
175 * Determine EPS and the norm of A.
176 *
177  eps = dlamch( 'Epsilon' )
178  anorm = dlansy( '1', uplo, n, a, lda, rwork )
179 *
180 * Initialize C to the tridiagonal matrix T.
181 *
182  CALL dlaset( 'Full', n, n, zero, zero, c, ldc )
183  CALL dlacpy( 'F', 1, n, afac( 1, 1 ), ldafac+1, c( 1, 1 ), ldc+1 )
184  IF( n.GT.1 ) THEN
185  IF( lsame( uplo, 'U' ) ) THEN
186  CALL dlacpy( 'F', 1, n-1, afac( 1, 2 ), ldafac+1, c( 1, 2 ),
187  $ ldc+1 )
188  CALL dlacpy( 'F', 1, n-1, afac( 1, 2 ), ldafac+1, c( 2, 1 ),
189  $ ldc+1 )
190  ELSE
191  CALL dlacpy( 'F', 1, n-1, afac( 2, 1 ), ldafac+1, c( 1, 2 ),
192  $ ldc+1 )
193  CALL dlacpy( 'F', 1, n-1, afac( 2, 1 ), ldafac+1, c( 2, 1 ),
194  $ ldc+1 )
195  ENDIF
196 *
197 * Call DTRMM to form the product U' * D (or L * D ).
198 *
199  IF( lsame( uplo, 'U' ) ) THEN
200  CALL dtrmm( 'Left', uplo, 'Transpose', 'Unit', n-1, n,
201  $ one, afac( 1, 2 ), ldafac, c( 2, 1 ), ldc )
202  ELSE
203  CALL dtrmm( 'Left', uplo, 'No transpose', 'Unit', n-1, n,
204  $ one, afac( 2, 1 ), ldafac, c( 2, 1 ), ldc )
205  END IF
206 *
207 * Call DTRMM again to multiply by U (or L ).
208 *
209  IF( lsame( uplo, 'U' ) ) THEN
210  CALL dtrmm( 'Right', uplo, 'No transpose', 'Unit', n, n-1,
211  $ one, afac( 1, 2 ), ldafac, c( 1, 2 ), ldc )
212  ELSE
213  CALL dtrmm( 'Right', uplo, 'Transpose', 'Unit', n, n-1,
214  $ one, afac( 2, 1 ), ldafac, c( 1, 2 ), ldc )
215  END IF
216  ENDIF
217 *
218 * Apply symmetric pivots
219 *
220  DO j = n, 1, -1
221  i = ipiv( j )
222  IF( i.NE.j )
223  $ CALL dswap( n, c( j, 1 ), ldc, c( i, 1 ), ldc )
224  END DO
225  DO j = n, 1, -1
226  i = ipiv( j )
227  IF( i.NE.j )
228  $ CALL dswap( n, c( 1, j ), 1, c( 1, i ), 1 )
229  END DO
230 *
231 *
232 * Compute the difference C - A .
233 *
234  IF( lsame( uplo, 'U' ) ) THEN
235  DO j = 1, n
236  DO i = 1, j
237  c( i, j ) = c( i, j ) - a( i, j )
238  END DO
239  END DO
240  ELSE
241  DO j = 1, n
242  DO i = j, n
243  c( i, j ) = c( i, j ) - a( i, j )
244  END DO
245  END DO
246  END IF
247 *
248 * Compute norm( C - A ) / ( N * norm(A) * EPS )
249 *
250  resid = dlansy( '1', uplo, n, c, ldc, rwork )
251 *
252  IF( anorm.LE.zero ) THEN
253  IF( resid.NE.zero )
254  $ resid = one / eps
255  ELSE
256  resid = ( ( resid / dble( n ) ) / anorm ) / eps
257  END IF
258 *
259  RETURN
260 *
261 * End of DSYT01
262 *
263  END
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:105
subroutine dtrmm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
DTRMM
Definition: dtrmm.f:179
subroutine dlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: dlaset.f:112
subroutine dswap(N, DX, INCX, DY, INCY)
DSWAP
Definition: dswap.f:84
subroutine dlavsy(UPLO, TRANS, DIAG, N, NRHS, A, LDA, IPIV, B, LDB, INFO)
DLAVSY
Definition: dlavsy.f:157
subroutine dsyt01_aa(UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC, RWORK, RESID)
DSYT01
Definition: dsyt01_aa.f:128