MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
dppt03.f
Go to the documentation of this file.
1  SUBROUTINE dppt03( UPLO, N, A, AINV, WORK, LDWORK, RWORK, RCOND,
2  $ 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 ldwork, n
11  DOUBLE PRECISION rcond, resid
12 * ..
13 * .. Array Arguments ..
14  DOUBLE PRECISION a( * ), ainv( * ), rwork( * ),
15  $ work( ldwork, * )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * DPPT03 computes the residual for a symmetric packed 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 (N*(N+1)/2)
39 * The original symmetric matrix A, stored as a packed
40 * triangular matrix.
41 *
42 * AINV (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
43 * The (symmetric) inverse of the matrix A, stored as a packed
44 * triangular matrix.
45 *
46 * WORK (workspace) DOUBLE PRECISION array, dimension (LDWORK,N)
47 *
48 * LDWORK (input) INTEGER
49 * The leading dimension of the array WORK. LDWORK >= max(1,N).
50 *
51 * RWORK (workspace) DOUBLE PRECISION array, dimension (N)
52 *
53 * RCOND (output) DOUBLE PRECISION
54 * The reciprocal of the condition number of A, computed as
55 * ( 1/norm(A) ) / norm(AINV).
56 *
57 * RESID (output) DOUBLE PRECISION
58 * norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS )
59 *
60 * =====================================================================
61 *
62 * .. Parameters ..
63  DOUBLE PRECISION zero, one
64  parameter( zero = 0.0d+0, one = 1.0d+0 )
65 * ..
66 * .. Local Scalars ..
67  INTEGER i, j, jj
68  DOUBLE PRECISION ainvnm, anorm, eps
69 * ..
70 * .. External Functions ..
71  LOGICAL lsame
72  DOUBLE PRECISION dlamch, dlange, dlansp
73  EXTERNAL lsame, dlamch, dlange, dlansp
74 * ..
75 * .. Intrinsic Functions ..
76  INTRINSIC dble
77 * ..
78 * .. External Subroutines ..
79  EXTERNAL dcopy, dspmv
80 * ..
81 * .. Executable Statements ..
82 *
83 * Quick exit if N = 0.
84 *
85  IF( n.LE.0 ) THEN
86  rcond = one
87  resid = zero
88  return
89  END IF
90 *
91 * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0.
92 *
93  eps = dlamch( 'Epsilon' )
94  anorm = dlansp( '1', uplo, n, a, rwork )
95  ainvnm = dlansp( '1', uplo, n, ainv, rwork )
96  IF( anorm.LE.zero .OR. ainvnm.EQ.zero ) THEN
97  rcond = zero
98  resid = one / eps
99  return
100  END IF
101  rcond = ( one / anorm ) / ainvnm
102 *
103 * UPLO = 'U':
104 * Copy the leading N-1 x N-1 submatrix of AINV to WORK(1:N,2:N) and
105 * expand it to a full matrix, then multiply by A one column at a
106 * time, moving the result one column to the left.
107 *
108  IF( lsame( uplo, 'U' ) ) THEN
109 *
110 * Copy AINV
111 *
112  jj = 1
113  DO 10 j = 1, n - 1
114  CALL dcopy( j, ainv( jj ), 1, work( 1, j+1 ), 1 )
115  CALL dcopy( j-1, ainv( jj ), 1, work( j, 2 ), ldwork )
116  jj = jj + j
117  10 continue
118  jj = ( ( n-1 )*n ) / 2 + 1
119  CALL dcopy( n-1, ainv( jj ), 1, work( n, 2 ), ldwork )
120 *
121 * Multiply by A
122 *
123  DO 20 j = 1, n - 1
124  CALL dspmv( 'Upper', n, -one, a, work( 1, j+1 ), 1, zero,
125  $ work( 1, j ), 1 )
126  20 continue
127  CALL dspmv( 'Upper', n, -one, a, ainv( jj ), 1, zero,
128  $ work( 1, n ), 1 )
129 *
130 * UPLO = 'L':
131 * Copy the trailing N-1 x N-1 submatrix of AINV to WORK(1:N,1:N-1)
132 * and multiply by A, moving each column to the right.
133 *
134  ELSE
135 *
136 * Copy AINV
137 *
138  CALL dcopy( n-1, ainv( 2 ), 1, work( 1, 1 ), ldwork )
139  jj = n + 1
140  DO 30 j = 2, n
141  CALL dcopy( n-j+1, ainv( jj ), 1, work( j, j-1 ), 1 )
142  CALL dcopy( n-j, ainv( jj+1 ), 1, work( j, j ), ldwork )
143  jj = jj + n - j + 1
144  30 continue
145 *
146 * Multiply by A
147 *
148  DO 40 j = n, 2, -1
149  CALL dspmv( 'Lower', n, -one, a, work( 1, j-1 ), 1, zero,
150  $ work( 1, j ), 1 )
151  40 continue
152  CALL dspmv( 'Lower', n, -one, a, ainv( 1 ), 1, zero,
153  $ work( 1, 1 ), 1 )
154 *
155  END IF
156 *
157 * Add the identity matrix to WORK .
158 *
159  DO 50 i = 1, n
160  work( i, i ) = work( i, i ) + one
161  50 continue
162 *
163 * Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS)
164 *
165  resid = dlange( '1', n, n, work, ldwork, rwork )
166 *
167  resid = ( ( resid*rcond ) / eps ) / dble( n )
168 *
169  return
170 *
171 * End of DPPT03
172 *
173  END