複素一般化エルミート固有値問題: 帯エルミート定値一般化行列 : (分割統治法)

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

概要

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

一般化帯エルミート固有値問題 $ A x = \lambda B x$の全ての固有値を求めます。

\begin{displaymath}
A = \left(
\begin{array}{cccc}
-1.13 & 1.94 - 2.10 i & -1...
... & -0.67 - 0.34 i & -1.10 + 0.16 i & 0.50
\end{array} \right)
\end{displaymath}

及び

\begin{displaymath}
B = \left(
\begin{array}{cccc}
9.89 & 1.08 - 1.73 i & 0 &...
....24 i \\
0 & 0 & -0.33 - 2.24 i & 2.17
\end{array} \right).
\end{displaymath}

入力データ

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

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

   4             2             1                         :Values of N, KA and KB

 (-1.13, 0.00) ( 1.94,-2.10) (-1.40, 0.25)
               (-1.91, 0.00) (-0.82,-0.89) (-0.67, 0.34)
                             (-1.87, 0.00) (-1.10,-0.16)
                                           ( 0.50, 0.00) :End of matrix A

 ( 9.89, 0.00) ( 1.08,-1.73)
               ( 1.69, 0.00) (-0.04, 0.29)
                             ( 2.65, 0.00) (-0.33, 2.24)
                                           ( 2.17, 0.00) :End of matrix B

出力結果

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

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

 Eigenvalues
       -6.6089    -2.0416     0.1603     1.7712

ソースコード

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

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


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

!     ZHBGVD Example Program Text

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

!     .. Use Statements ..
      Use lapack_interfaces, Only: zhbgvd
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter :: nin = 5, nout = 6
      Character (1), Parameter :: uplo = 'U'
!     .. Local Scalars ..
      Integer :: i, info, j, ka, kb, ldab, ldbb, liwork, lrwork, lwork, n
!     .. Local Arrays ..
      Complex (Kind=dp), Allocatable :: ab(:, :), bb(:, :), work(:)
      Complex (Kind=dp) :: dummy(1, 1)
      Real (Kind=dp), Allocatable :: rwork(:), w(:)
      Integer, Allocatable :: iwork(:)
!     .. Intrinsic Procedures ..
      Intrinsic :: max, min
!     .. Executable Statements ..
      Write (nout, *) 'ZHBGVD Example Program Results'
      Write (nout, *)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n, ka, kb
      ldab = ka + 1
      ldbb = kb + 1
      lrwork = n
      lwork = n
      liwork = 1
      Allocate (ab(ldab,n), bb(ldbb,n), work(lwork), rwork(lrwork), w(n), &
        iwork(liwork))

!     Read the upper or lower triangular parts of the matrices A and
!     B from data file

      If (uplo=='U') Then
        Read (nin, *)((ab(ka+1+i-j,j),j=i,min(n,i+ka)), i=1, n)
        Read (nin, *)((bb(kb+1+i-j,j),j=i,min(n,i+kb)), i=1, n)
      Else If (uplo=='L') Then
        Read (nin, *)((ab(1+i-j,j),j=max(1,i-ka),i), i=1, n)
        Read (nin, *)((bb(1+i-j,j),j=max(1,i-kb),i), i=1, n)
      End If

!     Solve the generalized Hermitian band eigenvalue problem
!     A*x = lambda*B*x

      Call zhbgvd('No vectors', uplo, n, ka, kb, ab, ldab, bb, ldbb, w, dummy, &
        1, work, lwork, rwork, lrwork, iwork, liwork, info)

      If (info==0) Then

!       Print solution

        Write (nout, *) 'Eigenvalues'
        Write (nout, 100) w(1:n)
      Else If (info>n .And. info<=2*n) Then
        i = info - n
        Write (nout, 110) 'The leading minor of order ', i, &
          ' of B is not positive definite'
      Else
        Write (nout, 120) 'Failure in ZHBGVD. INFO =', info
      End If

100   Format (3X, (6F11.4))
110   Format (1X, A, I4, A)
120   Format (1X, A, I4)
    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks