概要
本サンプルはFortran言語によりLAPACKルーチンZTRSYLを利用するサンプルプログラムです。
入力データ
(本ルーチンの詳細はZTRSYL のマニュアルページを参照)| このデータをダウンロード |
ZTRSYL Example Program Data 4 4 :Values of M and N (-6.00,-7.00) ( 0.36,-0.36) (-0.19, 0.48) ( 0.88,-0.25) ( 0.00, 0.00) (-5.00, 2.00) (-0.03,-0.72) (-0.23, 0.13) ( 0.00, 0.00) ( 0.00, 0.00) ( 8.00,-1.00) ( 0.94, 0.53) ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00) ( 3.00,-4.00) :End of matrix A ( 0.50,-0.20) (-0.29,-0.16) (-0.37, 0.84) (-0.55, 0.73) ( 0.00, 0.00) (-0.40, 0.90) ( 0.06, 0.22) (-0.43, 0.17) ( 0.00, 0.00) ( 0.00, 0.00) (-0.90,-0.10) (-0.89,-0.42) ( 0.00, 0.00) ( 0.00, 0.00) ( 0.00, 0.00) ( 0.30,-0.70) :End of matrix B ( 0.63, 0.35) ( 0.45,-0.56) ( 0.08,-0.14) (-0.17,-0.23) (-0.17, 0.09) (-0.07,-0.31) ( 0.27,-0.54) ( 0.35, 1.21) (-0.93,-0.44) (-0.33,-0.35) ( 0.41,-0.03) ( 0.57, 0.84) ( 0.54, 0.25) (-0.62,-0.05) (-0.52,-0.13) ( 0.11,-0.08) :End of matrix C
出力結果
(本ルーチンの詳細はZTRSYL のマニュアルページを参照)| この出力例をダウンロード |
ZTRSYL Example Program Results
Solution Matrix
1 2 3
1 ( -0.0611, 0.0249) ( -0.0031, 0.0798) ( -0.0062, 0.0165)
2 ( 0.0215, -0.0003) ( -0.0155, 0.0570) ( -0.0665, 0.0718)
3 ( -0.0949, -0.0785) ( -0.0415, -0.0298) ( 0.0357, 0.0244)
4 ( 0.0281, 0.1052) ( -0.0970, -0.1214) ( -0.0271, -0.0940)
4
1 ( 0.0054, -0.0063)
2 ( 0.0290, -0.2636)
3 ( 0.0284, 0.1108)
4 ( 0.0402, 0.0048)
ソースコード
(本ルーチンの詳細はZTRSYL のマニュアルページを参照)※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。
| このソースコードをダウンロード |
Program ztrsyl_example
! ZTRSYL 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_comp
Use lapack_interfaces, Only: ztrsyl
Use lapack_precision, Only: dp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=dp) :: scale
Integer :: i, ifail, info, lda, ldb, ldc, m, n
! .. Local Arrays ..
Complex (Kind=dp), Allocatable :: a(:, :), b(:, :), c(:, :)
Character (1) :: clabs(1), rlabs(1)
! .. Executable Statements ..
Write (nout, *) 'ZTRSYL Example Program Results'
Write (nout, *)
Flush (nout)
! Skip heading in data file
Read (nin, *)
Read (nin, *) m, n
lda = m
ldb = n
ldc = m
Allocate (a(lda,m), b(ldb,n), c(ldc,n))
! Read A, B and C from data file
Read (nin, *)(a(i,1:m), i=1, m)
Read (nin, *)(b(i,1:n), i=1, n)
Read (nin, *)(c(i,1:n), i=1, m)
! Solve the Sylvester equation A*X + X*B = C for X
Call ztrsyl('No transpose', 'No transpose', 1, m, n, a, lda, b, ldb, c, &
ldc, scale, info)
If (info>=1) Then
Write (nout, 100)
Write (nout, *)
Flush (nout)
End If
! Print X
! 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_comp('General', ' ', m, n, c, &
ldc, 'Bracketed', 'F8.4', 'Solution Matrix', 'I', rlabs, 'I', clabs, &
80, 0, ifail)
100 Format (/, ' A and B have common or very close eigenvalues.', /, ' Pe', &
'rturbed values were used to solve the equations')
End Program
