実一般化対称固有値問題: 帯対称定値一般化行列 : (分割統治法)

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

概要

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

一般化帯対称固有値問題$ A x = \lambda B x$のすべての固有値を求めます。

\begin{displaymath}
A = \left(
\begin{array}{rrrr}
0.24 & 0.39 & 0.42 & 0  ...
...& 0.65 & -0.33 \\
0 & 0 & -0.33 & 1.17
\end{array} \right).
\end{displaymath}

入力データ

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

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

  4      2      1            :Values of N, KA and KB

  0.24   0.39   0.42
        -0.11   0.79   0.63
               -0.25   0.48
                      -0.03  :End of matrix A
  2.07   0.95
         1.69  -0.29
                0.65  -0.33
                       1.17  :End of matrix B

出力結果

(本ルーチンの詳細はDSBGVD のマニュアルページを参照)
1
2
3
4

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

 Eigenvalues
       -0.8305    -0.6401     0.0992     1.8525

ソースコード

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

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

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

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

!     DSBGVD Example Program Text

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

!     .. Use Statements ..
      Use lapack_interfaces, Only: dsbgvd
      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, lwork, n
!     .. Local Arrays ..
      Real (Kind=dp), Allocatable :: ab(:, :), bb(:, :), w(:), work(:)
      Real (Kind=dp) :: dummy(1, 1)
      Integer, Allocatable :: iwork(:)
!     .. Intrinsic Procedures ..
      Intrinsic :: max, min
!     .. Executable Statements ..
      Write (nout, *) 'DSBGVD Example Program Results'
      Write (nout, *)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n, ka, kb
      ldab = ka + 1
      ldbb = kb + 1
      liwork = 1
      lwork = 3*n
      Allocate (ab(ldab,n), bb(ldbb,n), w(n), work(lwork), 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 symmetric band eigenvalue problem
!     A*x = lambda*B*x

      Call dsbgvd('No vectors', uplo, n, ka, kb, ab, ldab, bb, ldbb, w, dummy, &
        1, work, lwork, 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 DSBGVD. INFO =', info
      End If

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


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