概要
本サンプルはFortran言語によりLAPACKルーチンZHPGSTを利用するサンプルプログラムです。
入力データ
(本ルーチンの詳細はZHPGST のマニュアルページを参照)| このデータをダウンロード |
ZHPGST Example Program Data 4 :Value of N 'L' :Value of UPLO (-7.36, 0.00) ( 0.77, 0.43) ( 3.49, 0.00) (-0.64, 0.92) ( 2.19,-4.45) ( 0.12, 0.00) ( 3.01, 6.97) ( 1.90,-3.73) ( 2.88, 3.17) (-2.54, 0.00) :End of matrix A ( 3.23, 0.00) ( 1.51, 1.92) ( 3.58, 0.00) ( 1.90,-0.84) (-0.23,-1.11) ( 4.09, 0.00) ( 0.42,-2.50) (-1.18,-1.37) ( 2.33, 0.14) ( 4.29, 0.00) :End of matrix B
出力結果
(本ルーチンの詳細はZHPGST のマニュアルページを参照)ソースコード
(本ルーチンの詳細はZHPGST のマニュアルページを参照)※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。
| このソースコードをダウンロード |
Program zhpgst_example
! ZHPGST Example Program Text
! Copyright 2017, Numerical Algorithms Group Ltd. http://www.nag.com
! .. Use Statements ..
Use lapack_interfaces, Only: dsterf, zhpgst, zhptrd, zpptrf
Use lapack_precision, Only: dp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, info, j, n
Character (1) :: uplo
! .. Local Arrays ..
Complex (Kind=dp), Allocatable :: ap(:), bp(:), tau(:)
Real (Kind=dp), Allocatable :: d(:), e(:)
! .. Executable Statements ..
Write (nout, *) 'ZHPGST Example Program Results'
! Skip heading in data file
Read (nin, *)
Read (nin, *) n
Allocate (ap(n*(n+1)/2), bp(n*(n+1)/2), tau(n), d(n), e(n-1))
! Read A and B from data file
Read (nin, *) uplo
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
! Compute the Cholesky factorization of B
Call zpptrf(uplo, n, bp, info)
Write (nout, *)
If (info>0) Then
Write (nout, *) 'B is not positive definite.'
Else
! Reduce the problem to standard form C*y = lambda*y, storing
! the result in A
Call zhpgst(1, uplo, n, ap, bp, info)
! Reduce C to tridiagonal form T = (Q**H)*C*Q
Call zhptrd(uplo, n, ap, d, e, tau, info)
! Calculate the eigenvalues of T (same as C)
Call dsterf(n, d, e, info)
If (info>0) Then
Write (nout, *) 'Failure to converge.'
Else
! Print eigenvalues
Write (nout, *) 'Eigenvalues'
Write (nout, 100) d(1:n)
End If
End If
100 Format (3X, (9F8.4))
End Program
