計算ルーチン: 実上準三角行列の選択された固有値と固有ベクトルの感度の評価

LAPACKサンプルソースコード : 使用ルーチン名:DTRSNA

ホーム > LAPACKサンプルプログラム目次 > 計算ルーチン > 実上準三角行列の選択された固有値と固有ベクトルの感度の評価

概要

本サンプルはFortran言語によりLAPACKルーチンDTRSNAを利用するサンプルプログラムです。

入力データ

(本ルーチンの詳細はDTRSNA のマニュアルページを参照)

このデータをダウンロード
DTRSNA Example Program Data
  4                                   :Value of N
  0.7995  -0.1144   0.0060   0.0336
  0.0000  -0.0994   0.2478   0.3474
  0.0000  -0.6483  -0.0994   0.2026
  0.0000   0.0000   0.0000  -0.1007   :End of matrix T

出力結果

(本ルーチンの詳細はDTRSNA のマニュアルページを参照)

この出力例をダウンロード
 DTRSNA Example Program Results

 S
       9.9E-01    7.0E-01    7.0E-01    5.7E-01

 SEP
       6.3E-01    3.7E-01    3.7E-01    3.1E-01

 Approximate error estimates for eigenvalues of T (machine-dependent)
       1.9E-16    2.7E-16    2.7E-16    3.4E-16

 Approximate error estimates for right eigenvectors of T (machine-dependent)
       3.1E-16    5.1E-16    5.1E-16    6.1E-16

ソースコード

(本ルーチンの詳細はDTRSNA のマニュアルページを参照)

※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。


このソースコードをダウンロード
    Program dtrsna_example

!     DTRSNA Example Program Text

!     Copyright 2017, Numerical Algorithms Group Ltd. http://www.nag.com

!     .. Use Statements ..
      Use lapack_interfaces, Only: dlange, dtrevc, dtrsna
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=dp) :: eps, tnorm
      Integer :: i, info, ldt, ldvl, ldvr, ldwork, m, n
!     .. Local Arrays ..
      Real (Kind=dp), Allocatable :: s(:), sep(:), t(:, :), vl(:, :), &
        vr(:, :), work(:, :)
      Integer, Allocatable :: iwork(:)
      Logical :: select(1)
!     .. Intrinsic Procedures ..
      Intrinsic :: epsilon
!     .. Executable Statements ..
      Write (nout, *) 'DTRSNA Example Program Results'
      Write (nout, *)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n
      ldt = n
      ldvl = n
      ldvr = n
      ldwork = n
      Allocate (s(n), sep(n), t(ldt,n), vl(ldvl,n), vr(ldvr,n), &
        work(ldwork,n+6), iwork(2*n-1))

!     Read T from data file

      Read (nin, *)(t(i,1:n), i=1, n)

!     Calculate the left and right eigenvectors of T

      Call dtrevc('Both', 'All', select, n, t, ldt, vl, ldvl, vr, ldvr, n, m, &
        work, info)

!     Estimate condition numbers for all the eigenvalues and right
!     eigenvectors of T

      Call dtrsna('Both', 'All', select, n, t, ldt, vl, ldvl, vr, ldvr, s, &
        sep, n, m, work, ldwork, iwork, info)

!     Print condition numbers of eigenvalues and right eigenvectors

      Write (nout, *) 'S'
      Write (nout, 100) s(1:m)
      Write (nout, *)
      Write (nout, *) 'SEP'
      Write (nout, 100) sep(1:m)

!     Calculate approximate error estimates (using the 1-norm)

      eps = epsilon(1.0E0_dp)
      tnorm = dlange('1-norm', n, n, t, ldt, work)
      Write (nout, *)
      Write (nout, *) 'Approximate error estimates for eigenvalues ', &
        'of T (machine-dependent)'
      Write (nout, 100)(eps*tnorm/s(i), i=1, m)
      Write (nout, *)
      Write (nout, *) 'Approximate error estimates for right ', &
        'eigenvectors of T (machine-dependent)'
      Write (nout, 100)(eps*tnorm/sep(i), i=1, m)

100   Format ((3X,1P,7E11.1))
    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks