LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ spot01()

subroutine spot01 ( character  uplo,
integer  n,
real, dimension( lda, * )  a,
integer  lda,
real, dimension( ldafac, * )  afac,
integer  ldafac,
real, dimension( * )  rwork,
real  resid 
)

SPOT01

Purpose:
 SPOT01 reconstructs a symmetric positive definite matrix  A  from
 its L*L' or U'*U factorization and computes the residual
    norm( L*L' - A ) / ( N * norm(A) * EPS ) or
    norm( U'*U - A ) / ( N * norm(A) * EPS ),
 where EPS is the machine epsilon.
Parameters
[in]UPLO
          UPLO is CHARACTER*1
          Specifies whether the upper or lower triangular part of the
          symmetric matrix A is stored:
          = 'U':  Upper triangular
          = 'L':  Lower triangular
[in]N
          N is INTEGER
          The number of rows and columns of the matrix A.  N >= 0.
[in]A
          A is REAL array, dimension (LDA,N)
          The original symmetric matrix A.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N)
[in,out]AFAC
          AFAC is REAL array, dimension (LDAFAC,N)
          On entry, the factor L or U from the L * L**T or U**T * U
          factorization of A.
          Overwritten with the reconstructed matrix, and then with
          the difference L * L**T - A (or U**T * U - A).
[in]LDAFAC
          LDAFAC is INTEGER
          The leading dimension of the array AFAC.  LDAFAC >= max(1,N).
[out]RWORK
          RWORK is REAL array, dimension (N)
[out]RESID
          RESID is REAL
          If UPLO = 'L', norm(L * L**T - A) / ( N * norm(A) * EPS )
          If UPLO = 'U', norm(U**T * U - A) / ( N * norm(A) * EPS )
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 103 of file spot01.f.

104*
105* -- LAPACK test routine --
106* -- LAPACK is a software package provided by Univ. of Tennessee, --
107* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
108*
109* .. Scalar Arguments ..
110 CHARACTER UPLO
111 INTEGER LDA, LDAFAC, N
112 REAL RESID
113* ..
114* .. Array Arguments ..
115 REAL A( LDA, * ), AFAC( LDAFAC, * ), RWORK( * )
116* ..
117*
118* =====================================================================
119*
120* .. Parameters ..
121 REAL ZERO, ONE
122 parameter( zero = 0.0e+0, one = 1.0e+0 )
123* ..
124* .. Local Scalars ..
125 INTEGER I, J, K
126 REAL ANORM, EPS, T
127* ..
128* .. External Functions ..
129 LOGICAL LSAME
130 REAL SDOT, SLAMCH, SLANSY
131 EXTERNAL lsame, sdot, slamch, slansy
132* ..
133* .. External Subroutines ..
134 EXTERNAL sscal, ssyr, strmv
135* ..
136* .. Intrinsic Functions ..
137 INTRINSIC real
138* ..
139* .. Executable Statements ..
140*
141* Quick exit if N = 0.
142*
143 IF( n.LE.0 ) THEN
144 resid = zero
145 RETURN
146 END IF
147*
148* Exit with RESID = 1/EPS if ANORM = 0.
149*
150 eps = slamch( 'Epsilon' )
151 anorm = slansy( '1', uplo, n, a, lda, rwork )
152 IF( anorm.LE.zero ) THEN
153 resid = one / eps
154 RETURN
155 END IF
156*
157* Compute the product U**T * U, overwriting U.
158*
159 IF( lsame( uplo, 'U' ) ) THEN
160 DO 10 k = n, 1, -1
161*
162* Compute the (K,K) element of the result.
163*
164 t = sdot( k, afac( 1, k ), 1, afac( 1, k ), 1 )
165 afac( k, k ) = t
166*
167* Compute the rest of column K.
168*
169 CALL strmv( 'Upper', 'Transpose', 'Non-unit', k-1, afac,
170 $ ldafac, afac( 1, k ), 1 )
171*
172 10 CONTINUE
173*
174* Compute the product L * L**T, overwriting L.
175*
176 ELSE
177 DO 20 k = n, 1, -1
178*
179* Add a multiple of column K of the factor L to each of
180* columns K+1 through N.
181*
182 IF( k+1.LE.n )
183 $ CALL ssyr( 'Lower', n-k, one, afac( k+1, k ), 1,
184 $ afac( k+1, k+1 ), ldafac )
185*
186* Scale column K by the diagonal element.
187*
188 t = afac( k, k )
189 CALL sscal( n-k+1, t, afac( k, k ), 1 )
190*
191 20 CONTINUE
192 END IF
193*
194* Compute the difference L * L**T - A (or U**T * U - A).
195*
196 IF( lsame( uplo, 'U' ) ) THEN
197 DO 40 j = 1, n
198 DO 30 i = 1, j
199 afac( i, j ) = afac( i, j ) - a( i, j )
200 30 CONTINUE
201 40 CONTINUE
202 ELSE
203 DO 60 j = 1, n
204 DO 50 i = j, n
205 afac( i, j ) = afac( i, j ) - a( i, j )
206 50 CONTINUE
207 60 CONTINUE
208 END IF
209*
210* Compute norm(L*U - A) / ( N * norm(A) * EPS )
211*
212 resid = slansy( '1', uplo, n, afac, ldafac, rwork )
213*
214 resid = ( ( resid / real( n ) ) / anorm ) / eps
215*
216 RETURN
217*
218* End of SPOT01
219*
real function sdot(n, sx, incx, sy, incy)
SDOT
Definition sdot.f:82
subroutine ssyr(uplo, n, alpha, x, incx, a, lda)
SSYR
Definition ssyr.f:132
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
real function slansy(norm, uplo, n, a, lda, work)
SLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition slansy.f:122
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine strmv(uplo, trans, diag, n, a, lda, x, incx)
STRMV
Definition strmv.f:147
Here is the call graph for this function:
Here is the caller graph for this function: