計算ルーチン: 実対称三重対角行列もしくはこの形式の複素エルミート行列の全ての固有値 : (そしてオプショナルで固有ベクトル(Relatively Robust Representations))

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

ホーム > LAPACKサンプルプログラム目次 > 計算ルーチン > 実対称三重対角行列もしくはこの形式の複素エルミート行列の全ての固有値

概要

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

入力データ

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

このデータをダウンロード
ZSTEGR Example Program Data

  4                    :Value of N

  1.0  4.0  9.0  16.0  :End of D
  1.0  2.0  3.0        :End of E

  'V'                  :Value of JOBZ

出力結果

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

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

 Eigenvalues
     0.6476  3.5470  8.6578 17.1477

Warning: Floating invalid operation occurred
Warning: Floating divide by zero occurred
Warning: Floating underflow occurred
 Eigenvectors
          1       2       3       4
 1   0.9396  0.3388  0.0494  0.0034
     0.0000  0.0000  0.0000  0.0000
 
 2  -0.3311  0.8628  0.3781  0.0545
    -0.0000  0.0000  0.0000  0.0000
 
 3   0.0853 -0.3648  0.8558  0.3568
     0.0000 -0.0000  0.0000  0.0000
 
 4  -0.0167  0.0879 -0.3497  0.9326
    -0.0000  0.0000 -0.0000  0.0000

ソースコード

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

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


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

!     ZSTEGR Example Program Text

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

!     .. Use Statements ..
      Use lapack_example_aux, Only: nagf_file_print_matrix_complex_gen
      Use lapack_interfaces, Only: zstegr
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Real (Kind=dp), Parameter :: vl = 0.0E0_dp
      Real (Kind=dp), Parameter :: vu = 0.0E0_dp
      Integer, Parameter :: il = 0, iu = 0, nin = 5, nout = 6
      Character (1), Parameter :: range = 'A'
!     .. Local Scalars ..
      Real (Kind=dp) :: abstol
      Integer :: i, ifail, info, ldz, liwork, lwork, m, n
      Character (1) :: jobz
!     .. Local Arrays ..
      Complex (Kind=dp), Allocatable :: z(:, :)
      Real (Kind=dp), Allocatable :: d(:), e(:), w(:), work(:)
      Integer, Allocatable :: isuppz(:), iwork(:)
!     .. Intrinsic Procedures ..
      Intrinsic :: real
!     .. Executable Statements ..
      Write (nout, *) 'ZSTEGR Example Program Results'
      Write (nout, *)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n
      ldz = n
      liwork = 10*n
      lwork = 18*n
      Allocate (z(ldz,n), d(n), e(n), w(n), work(lwork), isuppz(2*n), &
        iwork(liwork))

!     Read the symmetric tridiagonal matrix T from data file, first
!     the diagonal elements, then the off diagonal elements and then
!     JOBV ('N' - eigenvalues only, 'V' - vectors as well)

      Read (nin, *) d(1:n)
      Read (nin, *) e(1:n-1)
      Read (nin, *) jobz

!     Calculate all the eigenvalues of T. Set ABSTOL to zero so that
!     the default value is used.

      abstol = 0.0E0_dp
      Call zstegr(jobz, range, n, d, e, vl, vu, il, iu, abstol, m, w, z, ldz, &
        isuppz, work, lwork, iwork, liwork, info)

      If (info==0) Then

!       Print eigenvalues and eigenvectors

        Write (nout, *) 'Eigenvalues'
        Write (nout, 100) w(1:m)

        Write (nout, *)
        Flush (nout)

!       Standardize the eigenvectors so that first elements are non-negative.
        Do i = 1, m
          If (real(z(1,i))<0.0_dp) Then
            z(1:n, i) = -z(1:n, i)
          End If
        End Do

!       ifail: behaviour on error exit
!              =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
        ifail = 0
        Call nagf_file_print_matrix_complex_gen('General', ' ', n, m, z, ldz, &
          'Eigenvectors', ifail)

      Else
        Write (nout, 110) 'Failure to compute an eigenvalue, INFO = ', info
      End If

100   Format ((3X,8F8.4))
110   Format (1X, A, I10)
    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks