MAGMA  1.2.0 MatrixAlgebraonGPUandMulticoreArchitectures
dpot03.f
Go to the documentation of this file.
1  SUBROUTINE dpot03( UPLO, N, A, LDA, AINV, LDAINV, WORK, LDWORK,
2  \$ rwork, rcond, 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 uplo
10  INTEGER lda, ldainv, ldwork, n
11  DOUBLE PRECISION rcond, resid
12 * ..
13 * .. Array Arguments ..
14  DOUBLE PRECISION a( lda, * ), ainv( ldainv, * ), rwork( * ),
15  \$ work( ldwork, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * DPOT03 computes the residual for a symmetric matrix times its
22 * inverse:
23 * norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ),
24 * where EPS is the machine epsilon.
25 *
26 * Arguments
27 * ==========
28 *
29 * UPLO (input) CHARACTER*1
30 * Specifies whether the upper or lower triangular part of the
31 * symmetric matrix A is stored:
32 * = 'U': Upper triangular
33 * = 'L': Lower triangular
34 *
35 * N (input) INTEGER
36 * The number of rows and columns of the matrix A. N >= 0.
37 *
38 * A (input) DOUBLE PRECISION array, dimension (LDA,N)
39 * The original symmetric matrix A.
40 *
41 * LDA (input) INTEGER
42 * The leading dimension of the array A. LDA >= max(1,N)
43 *
44 * AINV (input/output) DOUBLE PRECISION array, dimension (LDAINV,N)
45 * On entry, the inverse of the matrix A, stored as a symmetric
46 * matrix in the same format as A.
47 * In this version, AINV is expanded into a full matrix and
48 * multiplied by A, so the opposing triangle of AINV will be
49 * changed; i.e., if the upper triangular part of AINV is
50 * stored, the lower triangular part will be used as work space.
51 *
52 * LDAINV (input) INTEGER
53 * The leading dimension of the array AINV. LDAINV >= max(1,N).
54 *
55 * WORK (workspace) DOUBLE PRECISION array, dimension (LDWORK,N)
56 *
57 * LDWORK (input) INTEGER
58 * The leading dimension of the array WORK. LDWORK >= max(1,N).
59 *
60 * RWORK (workspace) DOUBLE PRECISION array, dimension (N)
61 *
62 * RCOND (output) DOUBLE PRECISION
63 * The reciprocal of the condition number of A, computed as
64 * ( 1/norm(A) ) / norm(AINV).
65 *
66 * RESID (output) DOUBLE PRECISION
67 * norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS )
68 *
69 * =====================================================================
70 *
71 * .. Parameters ..
72  DOUBLE PRECISION zero, one
73  parameter( zero = 0.0d+0, one = 1.0d+0 )
74 * ..
75 * .. Local Scalars ..
76  INTEGER i, j
77  DOUBLE PRECISION ainvnm, anorm, eps
78 * ..
79 * .. External Functions ..
80  LOGICAL lsame
81  DOUBLE PRECISION dlamch, dlange, dlansy
82  EXTERNAL lsame, dlamch, dlange, dlansy
83 * ..
84 * .. External Subroutines ..
85  EXTERNAL dsymm
86 * ..
87 * .. Intrinsic Functions ..
88  INTRINSIC dble
89 * ..
90 * .. Executable Statements ..
91 *
92 * Quick exit if N = 0.
93 *
94  IF( n.LE.0 ) THEN
95  rcond = one
96  resid = zero
97  return
98  END IF
99 *
100 * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0.
101 *
102  eps = dlamch( 'Epsilon' )
103  anorm = dlansy( '1', uplo, n, a, lda, rwork )
104  ainvnm = dlansy( '1', uplo, n, ainv, ldainv, rwork )
105  IF( anorm.LE.zero .OR. ainvnm.LE.zero ) THEN
106  rcond = zero
107  resid = one / eps
108  return
109  END IF
110  rcond = ( one / anorm ) / ainvnm
111 *
112 * Expand AINV into a full matrix and call DSYMM to multiply
113 * AINV on the left by A.
114 *
115  IF( lsame( uplo, 'U' ) ) THEN
116  DO 20 j = 1, n
117  DO 10 i = 1, j - 1
118  ainv( j, i ) = ainv( i, j )
119  10 continue
120  20 continue
121  ELSE
122  DO 40 j = 1, n
123  DO 30 i = j + 1, n
124  ainv( j, i ) = ainv( i, j )
125  30 continue
126  40 continue
127  END IF
128  CALL dsymm( 'Left', uplo, n, n, -one, a, lda, ainv, ldainv, zero,
129  \$ work, ldwork )
130 *
131 * Add the identity matrix to WORK .
132 *
133  DO 50 i = 1, n
134  work( i, i ) = work( i, i ) + one
135  50 continue
136 *
137 * Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS)
138 *
139  resid = dlange( '1', n, n, work, ldwork, rwork )
140 *
141  resid = ( ( resid*rcond ) / eps ) / dble( n )
142 *
143  return
144 *
145 * End of DPOT03
146 *
147  END