LAPACK  3.9.1
LAPACK: Linear Algebra PACKage
sget22.f
Go to the documentation of this file.
1 *> \brief \b SGET22
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 SGET22( TRANSA, TRANSE, TRANSW, N, A, LDA, E, LDE, WR,
12 * WI, WORK, RESULT )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER TRANSA, TRANSE, TRANSW
16 * INTEGER LDA, LDE, N
17 * ..
18 * .. Array Arguments ..
19 * REAL A( LDA, * ), E( LDE, * ), RESULT( 2 ), WI( * ),
20 * $ WORK( * ), WR( * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> SGET22 does an eigenvector check.
30 *>
31 *> The basic test is:
32 *>
33 *> RESULT(1) = | A E - E W | / ( |A| |E| ulp )
34 *>
35 *> using the 1-norm. It also tests the normalization of E:
36 *>
37 *> RESULT(2) = max | m-norm(E(j)) - 1 | / ( n ulp )
38 *> j
39 *>
40 *> where E(j) is the j-th eigenvector, and m-norm is the max-norm of a
41 *> vector. If an eigenvector is complex, as determined from WI(j)
42 *> nonzero, then the max-norm of the vector ( er + i*ei ) is the maximum
43 *> of
44 *> |er(1)| + |ei(1)|, ... , |er(n)| + |ei(n)|
45 *>
46 *> W is a block diagonal matrix, with a 1 by 1 block for each real
47 *> eigenvalue and a 2 by 2 block for each complex conjugate pair.
48 *> If eigenvalues j and j+1 are a complex conjugate pair, so that
49 *> WR(j) = WR(j+1) = wr and WI(j) = - WI(j+1) = wi, then the 2 by 2
50 *> block corresponding to the pair will be:
51 *>
52 *> ( wr wi )
53 *> ( -wi wr )
54 *>
55 *> Such a block multiplying an n by 2 matrix ( ur ui ) on the right
56 *> will be the same as multiplying ur + i*ui by wr + i*wi.
57 *>
58 *> To handle various schemes for storage of left eigenvectors, there are
59 *> options to use A-transpose instead of A, E-transpose instead of E,
60 *> and/or W-transpose instead of W.
61 *> \endverbatim
62 *
63 * Arguments:
64 * ==========
65 *
66 *> \param[in] TRANSA
67 *> \verbatim
68 *> TRANSA is CHARACTER*1
69 *> Specifies whether or not A is transposed.
70 *> = 'N': No transpose
71 *> = 'T': Transpose
72 *> = 'C': Conjugate transpose (= Transpose)
73 *> \endverbatim
74 *>
75 *> \param[in] TRANSE
76 *> \verbatim
77 *> TRANSE is CHARACTER*1
78 *> Specifies whether or not E is transposed.
79 *> = 'N': No transpose, eigenvectors are in columns of E
80 *> = 'T': Transpose, eigenvectors are in rows of E
81 *> = 'C': Conjugate transpose (= Transpose)
82 *> \endverbatim
83 *>
84 *> \param[in] TRANSW
85 *> \verbatim
86 *> TRANSW is CHARACTER*1
87 *> Specifies whether or not W is transposed.
88 *> = 'N': No transpose
89 *> = 'T': Transpose, use -WI(j) instead of WI(j)
90 *> = 'C': Conjugate transpose, use -WI(j) instead of WI(j)
91 *> \endverbatim
92 *>
93 *> \param[in] N
94 *> \verbatim
95 *> N is INTEGER
96 *> The order of the matrix A. N >= 0.
97 *> \endverbatim
98 *>
99 *> \param[in] A
100 *> \verbatim
101 *> A is REAL array, dimension (LDA,N)
102 *> The matrix whose eigenvectors are in E.
103 *> \endverbatim
104 *>
105 *> \param[in] LDA
106 *> \verbatim
107 *> LDA is INTEGER
108 *> The leading dimension of the array A. LDA >= max(1,N).
109 *> \endverbatim
110 *>
111 *> \param[in] E
112 *> \verbatim
113 *> E is REAL array, dimension (LDE,N)
114 *> The matrix of eigenvectors. If TRANSE = 'N', the eigenvectors
115 *> are stored in the columns of E, if TRANSE = 'T' or 'C', the
116 *> eigenvectors are stored in the rows of E.
117 *> \endverbatim
118 *>
119 *> \param[in] LDE
120 *> \verbatim
121 *> LDE is INTEGER
122 *> The leading dimension of the array E. LDE >= max(1,N).
123 *> \endverbatim
124 *>
125 *> \param[in] WR
126 *> \verbatim
127 *> WR is REAL array, dimension (N)
128 *> \endverbatim
129 *>
130 *> \param[in] WI
131 *> \verbatim
132 *> WI is REAL array, dimension (N)
133 *>
134 *> The real and imaginary parts of the eigenvalues of A.
135 *> Purely real eigenvalues are indicated by WI(j) = 0.
136 *> Complex conjugate pairs are indicated by WR(j)=WR(j+1) and
137 *> WI(j) = - WI(j+1) non-zero; the real part is assumed to be
138 *> stored in the j-th row/column and the imaginary part in
139 *> the (j+1)-th row/column.
140 *> \endverbatim
141 *>
142 *> \param[out] WORK
143 *> \verbatim
144 *> WORK is REAL array, dimension (N*(N+1))
145 *> \endverbatim
146 *>
147 *> \param[out] RESULT
148 *> \verbatim
149 *> RESULT is REAL array, dimension (2)
150 *> RESULT(1) = | A E - E W | / ( |A| |E| ulp )
151 *> RESULT(2) = max | m-norm(E(j)) - 1 | / ( n ulp )
152 *> \endverbatim
153 *
154 * Authors:
155 * ========
156 *
157 *> \author Univ. of Tennessee
158 *> \author Univ. of California Berkeley
159 *> \author Univ. of Colorado Denver
160 *> \author NAG Ltd.
161 *
162 *> \ingroup single_eig
163 *
164 * =====================================================================
165  SUBROUTINE sget22( TRANSA, TRANSE, TRANSW, N, A, LDA, E, LDE, WR,
166  $ WI, WORK, RESULT )
167 *
168 * -- LAPACK test routine --
169 * -- LAPACK is a software package provided by Univ. of Tennessee, --
170 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
171 *
172 * .. Scalar Arguments ..
173  CHARACTER TRANSA, TRANSE, TRANSW
174  INTEGER LDA, LDE, N
175 * ..
176 * .. Array Arguments ..
177  REAL A( LDA, * ), E( LDE, * ), RESULT( 2 ), WI( * ),
178  $ work( * ), wr( * )
179 * ..
180 *
181 * =====================================================================
182 *
183 * .. Parameters ..
184  REAL ZERO, ONE
185  parameter( zero = 0.0, one = 1.0 )
186 * ..
187 * .. Local Scalars ..
188  CHARACTER NORMA, NORME
189  INTEGER IECOL, IEROW, INCE, IPAIR, ITRNSE, J, JCOL,
190  $ jvec
191  REAL ANORM, ENORM, ENRMAX, ENRMIN, ERRNRM, TEMP1,
192  $ ulp, unfl
193 * ..
194 * .. Local Arrays ..
195  REAL WMAT( 2, 2 )
196 * ..
197 * .. External Functions ..
198  LOGICAL LSAME
199  REAL SLAMCH, SLANGE
200  EXTERNAL lsame, slamch, slange
201 * ..
202 * .. External Subroutines ..
203  EXTERNAL saxpy, sgemm, slaset
204 * ..
205 * .. Intrinsic Functions ..
206  INTRINSIC abs, max, min, real
207 * ..
208 * .. Executable Statements ..
209 *
210 * Initialize RESULT (in case N=0)
211 *
212  result( 1 ) = zero
213  result( 2 ) = zero
214  IF( n.LE.0 )
215  $ RETURN
216 *
217  unfl = slamch( 'Safe minimum' )
218  ulp = slamch( 'Precision' )
219 *
220  itrnse = 0
221  ince = 1
222  norma = 'O'
223  norme = 'O'
224 *
225  IF( lsame( transa, 'T' ) .OR. lsame( transa, 'C' ) ) THEN
226  norma = 'I'
227  END IF
228  IF( lsame( transe, 'T' ) .OR. lsame( transe, 'C' ) ) THEN
229  norme = 'I'
230  itrnse = 1
231  ince = lde
232  END IF
233 *
234 * Check normalization of E
235 *
236  enrmin = one / ulp
237  enrmax = zero
238  IF( itrnse.EQ.0 ) THEN
239 *
240 * Eigenvectors are column vectors.
241 *
242  ipair = 0
243  DO 30 jvec = 1, n
244  temp1 = zero
245  IF( ipair.EQ.0 .AND. jvec.LT.n .AND. wi( jvec ).NE.zero )
246  $ ipair = 1
247  IF( ipair.EQ.1 ) THEN
248 *
249 * Complex eigenvector
250 *
251  DO 10 j = 1, n
252  temp1 = max( temp1, abs( e( j, jvec ) )+
253  $ abs( e( j, jvec+1 ) ) )
254  10 CONTINUE
255  enrmin = min( enrmin, temp1 )
256  enrmax = max( enrmax, temp1 )
257  ipair = 2
258  ELSE IF( ipair.EQ.2 ) THEN
259  ipair = 0
260  ELSE
261 *
262 * Real eigenvector
263 *
264  DO 20 j = 1, n
265  temp1 = max( temp1, abs( e( j, jvec ) ) )
266  20 CONTINUE
267  enrmin = min( enrmin, temp1 )
268  enrmax = max( enrmax, temp1 )
269  ipair = 0
270  END IF
271  30 CONTINUE
272 *
273  ELSE
274 *
275 * Eigenvectors are row vectors.
276 *
277  DO 40 jvec = 1, n
278  work( jvec ) = zero
279  40 CONTINUE
280 *
281  DO 60 j = 1, n
282  ipair = 0
283  DO 50 jvec = 1, n
284  IF( ipair.EQ.0 .AND. jvec.LT.n .AND. wi( jvec ).NE.zero )
285  $ ipair = 1
286  IF( ipair.EQ.1 ) THEN
287  work( jvec ) = max( work( jvec ),
288  $ abs( e( j, jvec ) )+abs( e( j,
289  $ jvec+1 ) ) )
290  work( jvec+1 ) = work( jvec )
291  ELSE IF( ipair.EQ.2 ) THEN
292  ipair = 0
293  ELSE
294  work( jvec ) = max( work( jvec ),
295  $ abs( e( j, jvec ) ) )
296  ipair = 0
297  END IF
298  50 CONTINUE
299  60 CONTINUE
300 *
301  DO 70 jvec = 1, n
302  enrmin = min( enrmin, work( jvec ) )
303  enrmax = max( enrmax, work( jvec ) )
304  70 CONTINUE
305  END IF
306 *
307 * Norm of A:
308 *
309  anorm = max( slange( norma, n, n, a, lda, work ), unfl )
310 *
311 * Norm of E:
312 *
313  enorm = max( slange( norme, n, n, e, lde, work ), ulp )
314 *
315 * Norm of error:
316 *
317 * Error = AE - EW
318 *
319  CALL slaset( 'Full', n, n, zero, zero, work, n )
320 *
321  ipair = 0
322  ierow = 1
323  iecol = 1
324 *
325  DO 80 jcol = 1, n
326  IF( itrnse.EQ.1 ) THEN
327  ierow = jcol
328  ELSE
329  iecol = jcol
330  END IF
331 *
332  IF( ipair.EQ.0 .AND. wi( jcol ).NE.zero )
333  $ ipair = 1
334 *
335  IF( ipair.EQ.1 ) THEN
336  wmat( 1, 1 ) = wr( jcol )
337  wmat( 2, 1 ) = -wi( jcol )
338  wmat( 1, 2 ) = wi( jcol )
339  wmat( 2, 2 ) = wr( jcol )
340  CALL sgemm( transe, transw, n, 2, 2, one, e( ierow, iecol ),
341  $ lde, wmat, 2, zero, work( n*( jcol-1 )+1 ), n )
342  ipair = 2
343  ELSE IF( ipair.EQ.2 ) THEN
344  ipair = 0
345 *
346  ELSE
347 *
348  CALL saxpy( n, wr( jcol ), e( ierow, iecol ), ince,
349  $ work( n*( jcol-1 )+1 ), 1 )
350  ipair = 0
351  END IF
352 *
353  80 CONTINUE
354 *
355  CALL sgemm( transa, transe, n, n, n, one, a, lda, e, lde, -one,
356  $ work, n )
357 *
358  errnrm = slange( 'One', n, n, work, n, work( n*n+1 ) ) / enorm
359 *
360 * Compute RESULT(1) (avoiding under/overflow)
361 *
362  IF( anorm.GT.errnrm ) THEN
363  result( 1 ) = ( errnrm / anorm ) / ulp
364  ELSE
365  IF( anorm.LT.one ) THEN
366  result( 1 ) = ( min( errnrm, anorm ) / anorm ) / ulp
367  ELSE
368  result( 1 ) = min( errnrm / anorm, one ) / ulp
369  END IF
370  END IF
371 *
372 * Compute RESULT(2) : the normalization error in E.
373 *
374  result( 2 ) = max( abs( enrmax-one ), abs( enrmin-one ) ) /
375  $ ( real( n )*ulp )
376 *
377  RETURN
378 *
379 * End of SGET22
380 *
381  END
subroutine slaset(UPLO, M, N, ALPHA, BETA, A, LDA)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: slaset.f:110
subroutine saxpy(N, SA, SX, INCX, SY, INCY)
SAXPY
Definition: saxpy.f:89
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:187
subroutine sget22(TRANSA, TRANSE, TRANSW, N, A, LDA, E, LDE, WR, WI, WORK, RESULT)
SGET22
Definition: sget22.f:167