PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
dpot01.f
Go to the documentation of this file.
1  SUBROUTINE dpot01( UPLO, N, A, LDA, AFAC, LDAFAC, RWORK, RESID )
2 *
3 * -- LAPACK test routine (version 3.1) --
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  CHARACTER uplo
9  INTEGER lda, ldafac, n
10  DOUBLE PRECISION resid
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION a( lda, * ), afac( ldafac, * ), rwork( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DPOT01 reconstructs a symmetric positive definite matrix A from
20 * its L*L' or U'*U factorization and computes the residual
21 * norm( L*L' - A ) / ( N * norm(A) * EPS ) or
22 * norm( U'*U - A ) / ( N * norm(A) * EPS ),
23 * where EPS is the machine epsilon.
24 *
25 * Arguments
26 * ==========
27 *
28 * UPLO (input) CHARACTER*1
29 * Specifies whether the upper or lower triangular part of the
30 * symmetric matrix A is stored:
31 * = 'U': Upper triangular
32 * = 'L': Lower triangular
33 *
34 * N (input) INTEGER
35 * The number of rows and columns of the matrix A. N >= 0.
36 *
37 * A (input) DOUBLE PRECISION array, dimension (LDA,N)
38 * The original symmetric matrix A.
39 *
40 * LDA (input) INTEGER
41 * The leading dimension of the array A. LDA >= max(1,N)
42 *
43 * AFAC (input/output) DOUBLE PRECISION array, dimension (LDAFAC,N)
44 * On entry, the factor L or U from the L*L' or U'*U
45 * factorization of A.
46 * Overwritten with the reconstructed matrix, and then with the
47 * difference L*L' - A (or U'*U - A).
48 *
49 * LDAFAC (input) INTEGER
50 * The leading dimension of the array AFAC. LDAFAC >= max(1,N).
51 *
52 * RWORK (workspace) DOUBLE PRECISION array, dimension (N)
53 *
54 * RESID (output) DOUBLE PRECISION
55 * If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS )
56 * If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS )
57 *
58 * =====================================================================
59 *
60 * .. Parameters ..
61  DOUBLE PRECISION zero, one
62  parameter( zero = 0.0d+0, one = 1.0d+0 )
63 * ..
64 * .. Local Scalars ..
65  INTEGER i, j, k
66  DOUBLE PRECISION anorm, eps, t
67 * ..
68 * .. External Functions ..
69  LOGICAL lsame
70  DOUBLE PRECISION ddot, dlamch, dlansy
71  EXTERNAL lsame, ddot, dlamch, dlansy
72 * ..
73 * .. External Subroutines ..
74  EXTERNAL dscal, dsyr, dtrmv
75 * ..
76 * .. Intrinsic Functions ..
77  INTRINSIC dble
78 * ..
79 * .. Executable Statements ..
80 *
81 * Quick exit if N = 0.
82 *
83  IF( n.LE.0 ) THEN
84  resid = zero
85  return
86  END IF
87 *
88 * Exit with RESID = 1/EPS if ANORM = 0.
89 *
90  eps = dlamch( 'Epsilon' )
91  anorm = dlansy( '1', uplo, n, a, lda, rwork )
92  IF( anorm.LE.zero ) THEN
93  resid = one / eps
94  return
95  END IF
96 *
97 * Compute the product U'*U, overwriting U.
98 *
99  IF( lsame( uplo, 'U' ) ) THEN
100  DO 10 k = n, 1, -1
101 *
102 * Compute the (K,K) element of the result.
103 *
104  t = ddot( k, afac( 1, k ), 1, afac( 1, k ), 1 )
105  afac( k, k ) = t
106 *
107 * Compute the rest of column K.
108 *
109  CALL dtrmv( 'Upper', 'Transpose', 'Non-unit', k-1, afac,
110  $ ldafac, afac( 1, k ), 1 )
111 *
112  10 continue
113 *
114 * Compute the product L*L', overwriting L.
115 *
116  ELSE
117  DO 20 k = n, 1, -1
118 *
119 * Add a multiple of column K of the factor L to each of
120 * columns K+1 through N.
121 *
122  IF( k+1.LE.n )
123  $ CALL dsyr( 'Lower', n-k, one, afac( k+1, k ), 1,
124  $ afac( k+1, k+1 ), ldafac )
125 *
126 * Scale column K by the diagonal element.
127 *
128  t = afac( k, k )
129  CALL dscal( n-k+1, t, afac( k, k ), 1 )
130 *
131  20 continue
132  END IF
133 *
134 * Compute the difference L*L' - A (or U'*U - A).
135 *
136  IF( lsame( uplo, 'U' ) ) THEN
137  DO 40 j = 1, n
138  DO 30 i = 1, j
139  afac( i, j ) = afac( i, j ) - a( i, j )
140  30 continue
141  40 continue
142  ELSE
143  DO 60 j = 1, n
144  DO 50 i = j, n
145  afac( i, j ) = afac( i, j ) - a( i, j )
146  50 continue
147  60 continue
148  END IF
149 *
150 * Compute norm( L*U - A ) / ( N * norm(A) * EPS )
151 *
152  resid = dlansy( '1', uplo, n, afac, ldafac, rwork )
153 *
154  resid = ( ( resid / dble( n ) ) / anorm ) / eps
155 *
156  return
157 *
158 * End of DPOT01
159 *
160  END