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

◆ ctrsna()

subroutine ctrsna ( character  job,
character  howmny,
logical, dimension( * )  select,
integer  n,
complex, dimension( ldt, * )  t,
integer  ldt,
complex, dimension( ldvl, * )  vl,
integer  ldvl,
complex, dimension( ldvr, * )  vr,
integer  ldvr,
real, dimension( * )  s,
real, dimension( * )  sep,
integer  mm,
integer  m,
complex, dimension( ldwork, * )  work,
integer  ldwork,
real, dimension( * )  rwork,
integer  info 
)

CTRSNA

Download CTRSNA + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 CTRSNA estimates reciprocal condition numbers for specified
 eigenvalues and/or right eigenvectors of a complex upper triangular
 matrix T (or of any matrix Q*T*Q**H with Q unitary).
Parameters
[in]JOB
          JOB is CHARACTER*1
          Specifies whether condition numbers are required for
          eigenvalues (S) or eigenvectors (SEP):
          = 'E': for eigenvalues only (S);
          = 'V': for eigenvectors only (SEP);
          = 'B': for both eigenvalues and eigenvectors (S and SEP).
[in]HOWMNY
          HOWMNY is CHARACTER*1
          = 'A': compute condition numbers for all eigenpairs;
          = 'S': compute condition numbers for selected eigenpairs
                 specified by the array SELECT.
[in]SELECT
          SELECT is LOGICAL array, dimension (N)
          If HOWMNY = 'S', SELECT specifies the eigenpairs for which
          condition numbers are required. To select condition numbers
          for the j-th eigenpair, SELECT(j) must be set to .TRUE..
          If HOWMNY = 'A', SELECT is not referenced.
[in]N
          N is INTEGER
          The order of the matrix T. N >= 0.
[in]T
          T is COMPLEX array, dimension (LDT,N)
          The upper triangular matrix T.
[in]LDT
          LDT is INTEGER
          The leading dimension of the array T. LDT >= max(1,N).
[in]VL
          VL is COMPLEX array, dimension (LDVL,M)
          If JOB = 'E' or 'B', VL must contain left eigenvectors of T
          (or of any Q*T*Q**H with Q unitary), corresponding to the
          eigenpairs specified by HOWMNY and SELECT. The eigenvectors
          must be stored in consecutive columns of VL, as returned by
          CHSEIN or CTREVC.
          If JOB = 'V', VL is not referenced.
[in]LDVL
          LDVL is INTEGER
          The leading dimension of the array VL.
          LDVL >= 1; and if JOB = 'E' or 'B', LDVL >= N.
[in]VR
          VR is COMPLEX array, dimension (LDVR,M)
          If JOB = 'E' or 'B', VR must contain right eigenvectors of T
          (or of any Q*T*Q**H with Q unitary), corresponding to the
          eigenpairs specified by HOWMNY and SELECT. The eigenvectors
          must be stored in consecutive columns of VR, as returned by
          CHSEIN or CTREVC.
          If JOB = 'V', VR is not referenced.
[in]LDVR
          LDVR is INTEGER
          The leading dimension of the array VR.
          LDVR >= 1; and if JOB = 'E' or 'B', LDVR >= N.
[out]S
          S is REAL array, dimension (MM)
          If JOB = 'E' or 'B', the reciprocal condition numbers of the
          selected eigenvalues, stored in consecutive elements of the
          array. Thus S(j), SEP(j), and the j-th columns of VL and VR
          all correspond to the same eigenpair (but not in general the
          j-th eigenpair, unless all eigenpairs are selected).
          If JOB = 'V', S is not referenced.
[out]SEP
          SEP is REAL array, dimension (MM)
          If JOB = 'V' or 'B', the estimated reciprocal condition
          numbers of the selected eigenvectors, stored in consecutive
          elements of the array.
          If JOB = 'E', SEP is not referenced.
[in]MM
          MM is INTEGER
          The number of elements in the arrays S (if JOB = 'E' or 'B')
           and/or SEP (if JOB = 'V' or 'B'). MM >= M.
[out]M
          M is INTEGER
          The number of elements of the arrays S and/or SEP actually
          used to store the estimated condition numbers.
          If HOWMNY = 'A', M is set to N.
[out]WORK
          WORK is COMPLEX array, dimension (LDWORK,N+6)
          If JOB = 'E', WORK is not referenced.
[in]LDWORK
          LDWORK is INTEGER
          The leading dimension of the array WORK.
          LDWORK >= 1; and if JOB = 'V' or 'B', LDWORK >= N.
[out]RWORK
          RWORK is REAL array, dimension (N)
          If JOB = 'E', RWORK is not referenced.
[out]INFO
          INFO is INTEGER
          = 0: successful exit
          < 0: if INFO = -i, the i-th argument had an illegal value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
  The reciprocal of the condition number of an eigenvalue lambda is
  defined as

          S(lambda) = |v**H*u| / (norm(u)*norm(v))

  where u and v are the right and left eigenvectors of T corresponding
  to lambda; v**H denotes the conjugate transpose of v, and norm(u)
  denotes the Euclidean norm. These reciprocal condition numbers always
  lie between zero (very badly conditioned) and one (very well
  conditioned). If n = 1, S(lambda) is defined to be 1.

  An approximate error bound for a computed eigenvalue W(i) is given by

                      EPS * norm(T) / S(i)

  where EPS is the machine precision.

  The reciprocal of the condition number of the right eigenvector u
  corresponding to lambda is defined as follows. Suppose

              T = ( lambda  c  )
                  (   0    T22 )

  Then the reciprocal condition number is

          SEP( lambda, T22 ) = sigma-min( T22 - lambda*I )

  where sigma-min denotes the smallest singular value. We approximate
  the smallest singular value by the reciprocal of an estimate of the
  one-norm of the inverse of T22 - lambda*I. If n = 1, SEP(1) is
  defined to be abs(T(1,1)).

  An approximate error bound for a computed right eigenvector VR(i)
  is given by

                      EPS * norm(T) / SEP(i)

Definition at line 246 of file ctrsna.f.

249*
250* -- LAPACK computational routine --
251* -- LAPACK is a software package provided by Univ. of Tennessee, --
252* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
253*
254* .. Scalar Arguments ..
255 CHARACTER HOWMNY, JOB
256 INTEGER INFO, LDT, LDVL, LDVR, LDWORK, M, MM, N
257* ..
258* .. Array Arguments ..
259 LOGICAL SELECT( * )
260 REAL RWORK( * ), S( * ), SEP( * )
261 COMPLEX T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),
262 $ WORK( LDWORK, * )
263* ..
264*
265* =====================================================================
266*
267* .. Parameters ..
268 REAL ZERO, ONE
269 parameter( zero = 0.0e+0, one = 1.0+0 )
270* ..
271* .. Local Scalars ..
272 LOGICAL SOMCON, WANTBH, WANTS, WANTSP
273 CHARACTER NORMIN
274 INTEGER I, IERR, IX, J, K, KASE, KS
275 REAL BIGNUM, EPS, EST, LNRM, RNRM, SCALE, SMLNUM,
276 $ XNORM
277 COMPLEX CDUM, PROD
278* ..
279* .. Local Arrays ..
280 INTEGER ISAVE( 3 )
281 COMPLEX DUMMY( 1 )
282* ..
283* .. External Functions ..
284 LOGICAL LSAME
285 INTEGER ICAMAX
286 REAL SCNRM2, SLAMCH
287 COMPLEX CDOTC
288 EXTERNAL lsame, icamax, scnrm2, slamch, cdotc
289* ..
290* .. External Subroutines ..
291 EXTERNAL clacn2, clacpy, clatrs, csrscl, ctrexc, xerbla
292* ..
293* .. Intrinsic Functions ..
294 INTRINSIC abs, aimag, max, real
295* ..
296* .. Statement Functions ..
297 REAL CABS1
298* ..
299* .. Statement Function definitions ..
300 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
301* ..
302* .. Executable Statements ..
303*
304* Decode and test the input parameters
305*
306 wantbh = lsame( job, 'B' )
307 wants = lsame( job, 'E' ) .OR. wantbh
308 wantsp = lsame( job, 'V' ) .OR. wantbh
309*
310 somcon = lsame( howmny, 'S' )
311*
312* Set M to the number of eigenpairs for which condition numbers are
313* to be computed.
314*
315 IF( somcon ) THEN
316 m = 0
317 DO 10 j = 1, n
318 IF( SELECT( j ) )
319 $ m = m + 1
320 10 CONTINUE
321 ELSE
322 m = n
323 END IF
324*
325 info = 0
326 IF( .NOT.wants .AND. .NOT.wantsp ) THEN
327 info = -1
328 ELSE IF( .NOT.lsame( howmny, 'A' ) .AND. .NOT.somcon ) THEN
329 info = -2
330 ELSE IF( n.LT.0 ) THEN
331 info = -4
332 ELSE IF( ldt.LT.max( 1, n ) ) THEN
333 info = -6
334 ELSE IF( ldvl.LT.1 .OR. ( wants .AND. ldvl.LT.n ) ) THEN
335 info = -8
336 ELSE IF( ldvr.LT.1 .OR. ( wants .AND. ldvr.LT.n ) ) THEN
337 info = -10
338 ELSE IF( mm.LT.m ) THEN
339 info = -13
340 ELSE IF( ldwork.LT.1 .OR. ( wantsp .AND. ldwork.LT.n ) ) THEN
341 info = -16
342 END IF
343 IF( info.NE.0 ) THEN
344 CALL xerbla( 'CTRSNA', -info )
345 RETURN
346 END IF
347*
348* Quick return if possible
349*
350 IF( n.EQ.0 )
351 $ RETURN
352*
353 IF( n.EQ.1 ) THEN
354 IF( somcon ) THEN
355 IF( .NOT.SELECT( 1 ) )
356 $ RETURN
357 END IF
358 IF( wants )
359 $ s( 1 ) = one
360 IF( wantsp )
361 $ sep( 1 ) = abs( t( 1, 1 ) )
362 RETURN
363 END IF
364*
365* Get machine constants
366*
367 eps = slamch( 'P' )
368 smlnum = slamch( 'S' ) / eps
369 bignum = one / smlnum
370*
371 ks = 1
372 DO 50 k = 1, n
373*
374 IF( somcon ) THEN
375 IF( .NOT.SELECT( k ) )
376 $ GO TO 50
377 END IF
378*
379 IF( wants ) THEN
380*
381* Compute the reciprocal condition number of the k-th
382* eigenvalue.
383*
384 prod = cdotc( n, vr( 1, ks ), 1, vl( 1, ks ), 1 )
385 rnrm = scnrm2( n, vr( 1, ks ), 1 )
386 lnrm = scnrm2( n, vl( 1, ks ), 1 )
387 s( ks ) = abs( prod ) / ( rnrm*lnrm )
388*
389 END IF
390*
391 IF( wantsp ) THEN
392*
393* Estimate the reciprocal condition number of the k-th
394* eigenvector.
395*
396* Copy the matrix T to the array WORK and swap the k-th
397* diagonal element to the (1,1) position.
398*
399 CALL clacpy( 'Full', n, n, t, ldt, work, ldwork )
400 CALL ctrexc( 'No Q', n, work, ldwork, dummy, 1, k, 1, ierr )
401*
402* Form C = T22 - lambda*I in WORK(2:N,2:N).
403*
404 DO 20 i = 2, n
405 work( i, i ) = work( i, i ) - work( 1, 1 )
406 20 CONTINUE
407*
408* Estimate a lower bound for the 1-norm of inv(C**H). The 1st
409* and (N+1)th columns of WORK are used to store work vectors.
410*
411 sep( ks ) = zero
412 est = zero
413 kase = 0
414 normin = 'N'
415 30 CONTINUE
416 CALL clacn2( n-1, work( 1, n+1 ), work, est, kase, isave )
417*
418 IF( kase.NE.0 ) THEN
419 IF( kase.EQ.1 ) THEN
420*
421* Solve C**H*x = scale*b
422*
423 CALL clatrs( 'Upper', 'Conjugate transpose',
424 $ 'Nonunit', normin, n-1, work( 2, 2 ),
425 $ ldwork, work, scale, rwork, ierr )
426 ELSE
427*
428* Solve C*x = scale*b
429*
430 CALL clatrs( 'Upper', 'No transpose', 'Nonunit',
431 $ normin, n-1, work( 2, 2 ), ldwork, work,
432 $ scale, rwork, ierr )
433 END IF
434 normin = 'Y'
435 IF( scale.NE.one ) THEN
436*
437* Multiply by 1/SCALE if doing so will not cause
438* overflow.
439*
440 ix = icamax( n-1, work, 1 )
441 xnorm = cabs1( work( ix, 1 ) )
442 IF( scale.LT.xnorm*smlnum .OR. scale.EQ.zero )
443 $ GO TO 40
444 CALL csrscl( n, scale, work, 1 )
445 END IF
446 GO TO 30
447 END IF
448*
449 sep( ks ) = one / max( est, smlnum )
450 END IF
451*
452 40 CONTINUE
453 ks = ks + 1
454 50 CONTINUE
455 RETURN
456*
457* End of CTRSNA
458*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
complex function cdotc(n, cx, incx, cy, incy)
CDOTC
Definition cdotc.f:83
integer function icamax(n, cx, incx)
ICAMAX
Definition icamax.f:71
subroutine clacn2(n, v, x, est, kase, isave)
CLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition clacn2.f:133
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
Definition clacpy.f:103
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
subroutine clatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
CLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
Definition clatrs.f:239
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
real(wp) function scnrm2(n, x, incx)
SCNRM2
Definition scnrm2.f90:90
subroutine csrscl(n, sa, sx, incx)
CSRSCL multiplies a vector by the reciprocal of a real scalar.
Definition csrscl.f:84
subroutine ctrexc(compq, n, t, ldt, q, ldq, ifst, ilst, info)
CTREXC
Definition ctrexc.f:126
Here is the call graph for this function:
Here is the caller graph for this function: