複素一般化エルミート固有値問題: パック形式のエルミート定値一般化行列 : (選択された固有値およびオプショナルで固有ベクトル)

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

ホーム > LAPACKサンプルプログラム目次 > 複素一般化エルミート固有値問題 > パック形式のエルミート定値一般化行列

概要

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

一般化エルミート固有値問題 $ A x = \lambda B x$の半開区間 $ (-3, 3]$の全ての固有値と対応する固有ベクトルを求めます。

\begin{displaymath}
A = \left(
\begin{array}{cccc}
-7.36 & 0.77 - 0.43i & -0....
...97i & 1.90 - 3.73i & 2.88 + 3.17i & -2.54
\end{array} \right)
\end{displaymath}

及び

\begin{displaymath}
B = \left(
\begin{array}{cccc}
3.23 & 1.51 - 1.92i & 1.90...
...0i & -1.18 - 1.37i & 2.33 + 0.14i & 4.29
\end{array} \right).
\end{displaymath}

ZHPGVDの例題プログラムは一般化対称固有値問題 $ A B x = \lambda x$の解き方を示します。

入力データ

(本ルーチンの詳細はZHPGVX のマニュアルページを参照)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

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

   4                                                        :Value of N

  -3.0           3.0                                        :Values of VL and VU

 (-7.36, 0.00) ( 0.77, -0.43) (-0.64, -0.92) ( 3.01, -6.97)
               ( 3.49,  0.00) ( 2.19,  4.45) ( 1.90,  3.73)
                              ( 0.12,  0.00) ( 2.88, -3.17)
                                             (-2.54,  0.00) :End of matrix A

 ( 3.23, 0.00) ( 1.51, -1.92) ( 1.90,  0.84) ( 0.42,  2.50)
               ( 3.58,  0.00) (-0.23,  1.11) (-1.18,  1.37)
                              ( 4.09,  0.00) ( 2.33, -0.14)
                                             ( 4.29,  0.00) :End of matrix B

出力結果

(本ルーチンの詳細はZHPGVX のマニュアルページを参照)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

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

 Number of eigenvalues found =    2

 Eigenvalues
    -2.9936  0.5047
 Selected eigenvectors
          1       2
 1  -0.6626  0.2835
     0.2258 -0.5806
 
 2  -0.1164 -0.3769
    -0.0178 -0.3194
 
 3   0.9098 -0.3338
    -0.0000 -0.0134
 
 4  -0.6120  0.6663
    -0.5348  0.0000

ソースコード

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

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

!     ZHPGVX 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: zhpgvx
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Real (Kind=dp), Parameter :: zero = 0.0E+0_dp
      Integer, Parameter :: nin = 5, nout = 6
      Character (1), Parameter :: uplo = 'U'
!     .. Local Scalars ..
      Complex (Kind=dp) :: scal
      Real (Kind=dp) :: abstol, vl, vu
      Integer :: i, ifail, il, info, iu, j, k, ldz, m, n
!     .. Local Arrays ..
      Complex (Kind=dp), Allocatable :: ap(:), bp(:), work(:), z(:, :)
      Real (Kind=dp), Allocatable :: rwork(:), w(:)
      Integer, Allocatable :: iwork(:), jfail(:)
!     .. Intrinsic Procedures ..
      Intrinsic :: abs, conjg, maxloc
!     .. Executable Statements ..
      Write (nout, *) 'ZHPGVX Example Program Results'
      Write (nout, *)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n
      ldz = n
      m = n
      Allocate (ap((n*(n+1))/2), bp((n*(n+1))/2), work(2*n), z(ldz,m), rwork(7 &
        *n), w(n), iwork(5*n), jfail(n))

!     Read the lower and upper bounds of the interval to be searched,
!     and read the upper or lower triangular parts of the matrices A
!     and B from data file

      Read (nin, *) vl, vu
      If (uplo=='U') Then
        Read (nin, *)((ap(i+(j*(j-1))/2),j=i,n), i=1, n)
        Read (nin, *)((bp(i+(j*(j-1))/2),j=i,n), i=1, n)
      Else If (uplo=='L') Then
        Read (nin, *)((ap(i+((2*n-j)*(j-1))/2),j=1,i), i=1, n)
        Read (nin, *)((bp(i+((2*n-j)*(j-1))/2),j=1,i), i=1, n)
      End If

!     Set the absolute error tolerance for eigenvalues. With abstol
!     set to zero, the default value is used instead

      abstol = zero

!     Solve the generalized Hermitian eigenvalue problem
!     A*x = lambda*B*x (itype = 1)

      Call zhpgvx(1, 'Vectors', 'Values in range', uplo, n, ap, bp, vl, vu, &
        il, iu, abstol, m, w, z, ldz, work, rwork, iwork, jfail, info)

      If (info>=0 .And. info<=n) Then

!       Print solution

        Write (nout, 100) 'Number of eigenvalues found =', m
        Write (nout, *)
        Write (nout, *) 'Eigenvalues'
        Write (nout, 110) w(1:m)
        Flush (nout)

!       Normalize the eigenvectors, largest element real
        Do i = 1, m
          rwork(1:n) = abs(z(1:n,i))
          k = maxloc(rwork(1:n), 1)
          scal = conjg(z(k,i))/abs(z(k,i))
          z(1:n, i) = z(1:n, i)*scal
        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, &
          'Selected eigenvectors', ifail)

        If (info>0) Then
          Write (nout, 100) 'INFO eigenvectors failed to converge, INFO =', &
            info
          Write (nout, *) 'Indices of eigenvectors that did not converge'
          Write (nout, 120) jfail(1:m)
        End If
      Else If (info>n .And. info<=2*n) Then
        i = info - n
        Write (nout, 130) 'The leading minor of order ', i, &
          ' of B is not positive definite'
      Else
        Write (nout, 100) 'Failure in ZHPGVX. INFO =', info
      End If

100   Format (1X, A, I5)
110   Format (3X, (8F8.4))
120   Format (3X, (8I8))
130   Format (1X, A, I4, A)
    End Program


ご案内
関連情報
© 日本ニューメリカルアルゴリズムズグループ株式会社 2025
Privacy Policy  /  Trademarks